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 0EFC2C433FE for ; Sun, 9 Oct 2022 11:14:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B1B86B0071; Sun, 9 Oct 2022 07:14:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 460AC6B0073; Sun, 9 Oct 2022 07:14:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34F916B0074; Sun, 9 Oct 2022 07:14:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 22ADE6B0071 for ; Sun, 9 Oct 2022 07:14:01 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EDB9512022C for ; Sun, 9 Oct 2022 11:14:00 +0000 (UTC) X-FDA: 80001151440.01.DF71AF6 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf25.hostedemail.com (Postfix) with ESMTP id 300A3A001A for ; Sun, 9 Oct 2022 11:13:58 +0000 (UTC) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MlfSg0MX3z1P75B; Sun, 9 Oct 2022 19:09:23 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sun, 9 Oct 2022 19:13:53 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sun, 9 Oct 2022 19:13:52 +0800 Message-ID: <10ada8f0-0931-b6a6-e240-fc8b500e578d@huawei.com> Date: Sun, 9 Oct 2022 19:13:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v3 03/11] mm/ioremap: change the return value of io[re|un]map_allowed and rename Content-Language: en-US To: Baoquan He , CC: , , , , , , , , "Arnd Bergmann" , , References: <20221009103114.149036-1-bhe@redhat.com> <20221009103114.149036-4-bhe@redhat.com> From: Kefeng Wang In-Reply-To: <20221009103114.149036-4-bhe@redhat.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665314040; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y+fipt7pAL4xyvg62rBUesGauyy577KLbfBxKK5R1Ec=; b=BKKCh/FrSIcVk7QYEqKX/N0zuBh7b2z39EVjQlkRo6AJXL9+1mhq6clhwo5pppOSbsqpHz IFBMKpzGPQOzzJPx1cwfSZi4c8DqDeY+OGLWeQAgmQc1TRpwf9tLr865iIW3olbrIryoXG 7WIzk4NE1xcF67U/Bos7SIyRWGFDKm0= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665314040; a=rsa-sha256; cv=none; b=VwU4jHoUN//HbGm5vn+yz4ec+fbw65ZU+qtSmd31efdjKA2qiUHL2Vz2HCTCzo+c15kreL Pp0YzEDyv2+LEctTB7jQBHmUqaZUiy8UNsdtdE51GrTFsDuKQnUarINFyFeUiyadrVVjyo I6egMJkbIOVsgLNM8yNT5RjvXdwUevM= Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: ao8yckruo9zqu9cgokfeuhc8b6tsdgcu X-Rspamd-Queue-Id: 300A3A001A X-Rspamd-Server: rspam01 X-HE-Tag: 1665314038-943999 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 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? > - 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... > 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? > return; > > if (is_vmalloc_addr(vaddr))