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 65AC4C00140 for ; Sat, 6 Aug 2022 02:29:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 817F86B0071; Fri, 5 Aug 2022 22:29:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C7478E0002; Fri, 5 Aug 2022 22:29:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B5E28E0001; Fri, 5 Aug 2022 22:29:11 -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 5DCC66B0071 for ; Fri, 5 Aug 2022 22:29:11 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2A4A01606CC for ; Sat, 6 Aug 2022 02:29:11 +0000 (UTC) X-FDA: 79767585702.04.A3F0601 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf27.hostedemail.com (Postfix) with ESMTP id AF6AB4013D for ; Sat, 6 Aug 2022 02:29:09 +0000 (UTC) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M05vX5qM9zmVJS; Sat, 6 Aug 2022 10:27:04 +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.24; Sat, 6 Aug 2022 10:29:04 +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.24; Sat, 6 Aug 2022 10:29:04 +0800 Message-ID: <832b38ca-064e-0ab8-cd62-337d0d83d471@huawei.com> Date: Sat, 6 Aug 2022 10:29:03 +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 01/11] mm/ioremap: change the return value of io[re|un]map_allowed Content-Language: en-US To: Alexander Gordeev , Baoquan He CC: , , , , References: <20220801144029.57829-1-bhe@redhat.com> <20220801144029.57829-2-bhe@redhat.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659752950; a=rsa-sha256; cv=none; b=r9I4k+NR1Oeqm+FOTyUEw19MfPS0YW5tKJo8nAu6aLBJXbHeClJBOq6Ci+LnW9sZ8DOttZ XZ2iPAzlhWWAxfkr8Tb4Co96hXY+iEMKroA0cTME6l8SVUc3lVNOHCpeYwqNc5dPP5Ijqm 7Wp+qX5tkRBPVsqEfwaaen5xaCp5W1g= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659752950; 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=qBRWNCUaShedJcoUdWAf6fbh4/HecQrBFqR9JhCeEfU=; b=1fJ5rOGMwGdTg2gwm3GrNt0bwABDtaWpDzMa7BmW4xEAq6CmUftd9tJ7kFHoN1cuYu45qg /1X/M2h/WHeF/pmNgeCBmRMcia842F0xWqbgHPe57vEPeCvHKVHIE9g6cH2UPW5WuGRk+K Tj8Zemy/fouD8MrLm1Y4SjL8QfgUvBU= X-Rspam-User: X-Stat-Signature: 4oenoadd1qthpz6fteonuhexaetdwb6a X-Rspamd-Queue-Id: AF6AB4013D Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-Rspamd-Server: rspam02 X-HE-Tag: 1659752949-459149 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/8/4 23:42, Alexander Gordeev wrote: > On Mon, Aug 01, 2022 at 10:40:19PM +0800, Baoquan He wrote: > > Hi Baoquan, > >> --- a/arch/arm64/mm/ioremap.c >> +++ b/arch/arm64/mm/ioremap.c >> @@ -3,19 +3,20 @@ >> #include >> #include >> >> -bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot) >> +void __iomem *ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot) >> { >> unsigned long last_addr = phys_addr + size - 1; >> + int ret = -EINVAL; > If ret variable is really needed? > >> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h >> index 72974cb81343..d72eb310fb3c 100644 >> --- a/include/asm-generic/io.h >> +++ b/include/asm-generic/io.h >> @@ -967,26 +967,27 @@ 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 >> + * - IS_ERR means return an error >> + * - NULL means continue to remap >> + * - a non-NULL, non-IS_ERR pointer is returned directly > If ioremap_allowed() returns a valid pointer, then the function name > is not as precise anymore. Maybe use arch_ioremap/unmap as before, or some better name. > >> @@ -28,8 +29,11 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, >> phys_addr -= offset; >> size = PAGE_ALIGN(size + offset); >> >> - if (!ioremap_allowed(phys_addr, size, prot)) >> + base = ioremap_allowed(phys_addr, size, prot); >> + if (IS_ERR(base)) >> return NULL; >> + else if (base) >> + return base; > It is probably just me, but the base name bit misleading here. We could reuse vaddr, not add new base. > >> @@ -50,9 +54,9 @@ EXPORT_SYMBOL(ioremap_prot); >> >> void iounmap(volatile void __iomem *addr) >> { >> - void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); >> + void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK); >> >> - if (!iounmap_allowed(vaddr)) >> + if (iounmap_allowed(vaddr)) > I guess, iounmap_allowed() should accept void __iomem *, not void *. > Then addr needs to be passed to iounmap_allowed() not vaddr. The following is_vmalloc_addr()  and vunmap() in iounmap() use void *, so we could simply use void* for iounmap_allowed(). > >> return; > .