From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0DA9C433FE for ; Mon, 10 Oct 2022 00:25:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DD986B0071; Sun, 9 Oct 2022 20:25:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 18E5A6B0073; Sun, 9 Oct 2022 20:25:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07CC26B0074; Sun, 9 Oct 2022 20:25:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E9A7B6B0071 for ; Sun, 9 Oct 2022 20:25:32 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B90C7160A6C for ; Mon, 10 Oct 2022 00:25:32 +0000 (UTC) X-FDA: 80003146104.19.FCDE300 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 43E6F4001A for ; Mon, 10 Oct 2022 00:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665361531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2Wlgr5678H60NOl4njbwYLitT+ttN6vPLcrFmUMxdHw=; b=RKnyXThVroXHeEtd+7Ik3ez59h2nucCSKY9a03BaWavfeT/1ZRcMkxO5Yhn4sBqtE+6IV5 Qe5rMmEoZGhq14dZp4hRi0NDmk3U6GX6yEnFad8si+uOaJo4QwJykVMO+KB7YwcYHmzZUe hRnxj45cfEuX6EBNwYBAPCb5ktL1dm4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-yxRvlpj5P7axHHUHhconUQ-1; Sun, 09 Oct 2022 20:25:28 -0400 X-MC-Unique: yxRvlpj5P7axHHUHhconUQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B071B29AB406; Mon, 10 Oct 2022 00:25:27 +0000 (UTC) Received: from localhost (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70EE5145D825; Mon, 10 Oct 2022 00:25:26 +0000 (UTC) Date: Mon, 10 Oct 2022 08:25:22 +0800 From: Baoquan He To: Kefeng Wang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, hch@infradead.org, agordeev@linux.ibm.com, christophe.leroy@csgroup.eu, schnelle@linux.ibm.com, David.Laight@aculab.com, shorne@gmail.com, Arnd Bergmann , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 03/11] mm/ioremap: change the return value of io[re|un]map_allowed and rename Message-ID: References: <20221009103114.149036-1-bhe@redhat.com> <20221009103114.149036-4-bhe@redhat.com> <10ada8f0-0931-b6a6-e240-fc8b500e578d@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10ada8f0-0931-b6a6-e240-fc8b500e578d@huawei.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665361532; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2Wlgr5678H60NOl4njbwYLitT+ttN6vPLcrFmUMxdHw=; b=keTr+hFLvU2ia6qdyFjlhIEZVTMQSliLgn8ZE/x6nEKH2y5tgh/1tmlPjLSBIMi4OxVrTf c/CkvvTQ1XqUTukdhjN753UCSLZIr9Iazk42wXZdlAOTIlSSDuOq3loMyGGMeGuNB44mvU gqAWGABS/02KWLY0vG/a/fqAuEvIl4c= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RKnyXThV; spf=pass (imf11.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665361532; a=rsa-sha256; cv=none; b=nLy27e+7duE7DiCY2MdHon+wt0SJ7N+4TGK6v4ZcltkAkhJPQEdxY6kWOMcDvVMjX8VB7f KHEDyGgALvq6dMteQQ32vWgxtNowfI5FQkUl4qjUYFgnWEvVOrxyt0OeG93P2Za0GhcNfk bNumxoKSXPW3dZ/uaM01UWeWzn1x+mI= X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 43E6F4001A X-Stat-Signature: wrd77qeh51c84udbto1ddju6z5tyq57o Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RKnyXThV; spf=pass (imf11.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1665361532-975605 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 10/09/22 at 07:13pm, Kefeng Wang wrote: > > On 2022/10/9 18:31, Baoquan He wrote: > > Currently, hooks ioremap_allowed() and iounmap_allowed() are used to > > check if it's qualified to do ioremap, and now this is done on ARM64. > > However, in oder to convert more architectures to take GENERIC_IOREMAP > > method, several more things need be done in those two hooks: > > 1) The io address mapping need be handled specifically on architectures, > > e.g arc, ia64, s390; > > 2) The original physical address passed into ioremap_prot() need be > > fixed up, e.g arc; > > 3) The 'prot' passed into ioremap_prot() need be adjusted, e.g on arc > > and xtensa. > > > > To handle these three issues, > > > > 1) Rename ioremap_allowed() and iounmap_allowed() to arch_ioremap() > > and arch_iounmap() since the old name can't reflect their > > functionality after change; > > 2) Change the return value of arch_ioremap() so that arch can add > > specifical io address mapping handling inside and return the maped > > address. Now their returned value means: > > === > > arch_ioremap() return a bool, > pointer? Right, I forgot fixing it again. Thanks. > > - IS_ERR means return an error > > - 0 means continue to remap > > - a non-zero, non-IS_ERR pointer is returned directly > > arch_iounmap() return a bool, > > - true means continue to vunmap > > - false means skip vunmap and return directly > ... > > /* > > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h > > index a68f8fbf423b..2ae16906f3be 100644 > > --- a/include/asm-generic/io.h > > +++ b/include/asm-generic/io.h > > @@ -1049,25 +1049,26 @@ static inline void iounmap(volatile void __iomem *addr) > > /* > > * Arch code can implement the following two hooks when using GENERIC_IOREMAP > > - * ioremap_allowed() return a bool, > > - * - true means continue to remap > > - * - false means skip remap and return directly > > - * iounmap_allowed() return a bool, > > + * arch_ioremap() return a bool, > ditto... Will change. > > area = get_vm_area_caller(size, VM_IOREMAP, > > __builtin_return_address(0)); > > if (!area) > > @@ -52,7 +57,7 @@ void iounmap(volatile void __iomem *addr) > > { > > void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); > > - if (!iounmap_allowed(vaddr)) > > + if (!arch_iounmap((void __iomem *)addr)) > vaddr? No, it's intentional. Alexander suggested this, both of you discussed this in v1, see below thread. https://lore.kernel.org/all/Yu4mYxpV0GWRTjQp@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com/T/#u > > return; > > if (is_vmalloc_addr(vaddr)) >