Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp2357764rwb; Fri, 5 Aug 2022 19:42:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR6xzqV5VCJkcxFyL218AbYYZyyHc5PrA9I2670b5OKk8n2DBxh3Y61rXC/yETVEBmd14GW6 X-Received: by 2002:a17:907:6e19:b0:730:a680:7b68 with SMTP id sd25-20020a1709076e1900b00730a6807b68mr6836639ejc.581.1659753755641; Fri, 05 Aug 2022 19:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659753755; cv=none; d=google.com; s=arc-20160816; b=XLraYa7nkqd5TKmmE7i9ZViYmm8ucPlXf9FSs3lT42MbPfVYflf3kUmE/lUG93eZSp moCSFNhlsiKTARzHTgBcJj9PBHgvgIrhwHJGAaEWBFVSrxk00cMC5maTW1ktwxD3CVoi RtXEuSvIckZTuA50FwxgafX7PWlCaJLH5H4uWKS9jVfH/YpW+IfQzus22ELAGiZpFMXT Yde6tHiMas9pQNFO9FYfMr76ZIZT5bicEbeFCPQKaR/B0FRZs+pg19czsb2jK1AZ6vgu GSq1tVAdCeTr2y4SxvhgOM1aJmJkl1xd4jcLcsBk66TCe6bylessli6Tuwm9IiXkpNw8 7UWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=qBRWNCUaShedJcoUdWAf6fbh4/HecQrBFqR9JhCeEfU=; b=rhAM3eUpmJ82NzFhDpgSSRP18w1NbGcdMlytNfnNz48vemhsxHglvFtQpnEqiGmpge J6fB+t3IX+XS427zuVa5V6FM8c3+KJn0r8hZk/SLqgi+LuTris6WLZ+ivYR7783nJOE5 DFSwcsl4IOPulLf0nprADjW/cmTeeR8mL8QTqKWs4ieyC8l+jUHXFNhMgpKQRmJrzh+x +mTXFQRAyqBykHdQ4BNI1KIU2zptKYzT2og6mzp9asmFvSNrH6oBV6uoMu2nVa94MPG1 qYRD9O6N5l+k9qUADpi18Jlo6gj4Q5rbIfhOsavj+Mjb9ILrgIJ6qKdCPg4rvAgP1WKp 9Kyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw9-20020a170906478900b0072b6a009383si5637263ejc.826.2022.08.05.19.42.10; Fri, 05 Aug 2022 19:42:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241653AbiHFC3L (ORCPT + 99 others); Fri, 5 Aug 2022 22:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237982AbiHFC3J (ORCPT ); Fri, 5 Aug 2022 22:29:09 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EA02286F9 for ; Fri, 5 Aug 2022 19:29:07 -0700 (PDT) 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > .