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 ECD7CECAAD2 for ; Sun, 28 Aug 2022 09:56:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D657940008; Sun, 28 Aug 2022 05:56:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 086B8940007; Sun, 28 Aug 2022 05:56:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9047940008; Sun, 28 Aug 2022 05:56:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D70E5940007 for ; Sun, 28 Aug 2022 05:56:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 60D008073F for ; Sun, 28 Aug 2022 09:56:05 +0000 (UTC) X-FDA: 79848545490.26.C6E61D8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 4BB23140044 for ; Sun, 28 Aug 2022 09:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661680563; 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=KmoVkJKn7sDlJ8XCXp6Z2DlsC39Vq8jBiod6jjguAyk=; b=O5W3Ci2MA2SYCwZVukQMUPDUCNttoDLxUZrUeK2zwtcCUHD15XOhewCggEfq3ZJGxC9ZYR fUw1G++2YspqJju9YMoj/ZuMtq8FYLejTNvjCj4SByuLIZy/3LnWTVYuaLA9rFg5uvyI8b t1cKYSW9JwARagcpLDGBMygJWiL9F4w= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-378--Y5_IFOCNa6f2P_lc1v6tA-1; Sun, 28 Aug 2022 05:55:57 -0400 X-MC-Unique: -Y5_IFOCNa6f2P_lc1v6tA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EB3780029D; Sun, 28 Aug 2022 09:55:57 +0000 (UTC) Received: from localhost (ovpn-12-25.pek2.redhat.com [10.72.12.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F5794010D43; Sun, 28 Aug 2022 09:55:55 +0000 (UTC) Date: Sun, 28 Aug 2022 17:55:52 +0800 From: Baoquan He To: Alexander Gordeev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, hch@infradead.org, wangkefeng.wang@huawei.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 01/11] mm/ioremap: change the return value of io[re|un]map_allowed and rename Message-ID: References: <20220820003125.353570-1-bhe@redhat.com> <20220820003125.353570-2-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661680565; a=rsa-sha256; cv=none; b=y6AlAWvKmSjgTNbe2U8cc0wMWfbSKwi63gL6EiNgPslgX4Y7MzaMyhC35T/kI/d3HLAtnP r5wSOu8OeLLKx2Em31S4SQTdJGyXepnErN0kBiPhM5VP//ENVt81dg5B8+dw3f37olpUTW buNrAlKms1ymN7jog8KxiG+74/1sBxo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O5W3Ci2M; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661680565; 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=KmoVkJKn7sDlJ8XCXp6Z2DlsC39Vq8jBiod6jjguAyk=; b=TsPneiHmf4xtAGwNMtowefQ+4yDK3gssdypaxXflPbKlew8TXHvXdyQfN+6BS2FTNbR3qC tRGjdxu5jBLpTLYG5wvBADNde9p2/+eIDN8ld7EVw7AqFcf3N6ZzvMHftezaCA7wzhhgO8 qbWgH+kf2UYw/m/93l3OBGmkjPohnyU= X-Rspamd-Queue-Id: 4BB23140044 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O5W3Ci2M; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: j8cynux6jbe7eiant9f7iaw4re95jaya X-HE-Tag: 1661680564-456361 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 08/28/22 at 10:36am, Alexander Gordeev wrote: > On Sat, Aug 20, 2022 at 08:31:15AM +0800, Baoquan He wrote: > > Hi Baoquan, > > > arch_ioremap() return a bool, > > - IS_ERR means return an error > > - NULL means continue to remap > > - a non-NULL, non-IS_ERR pointer is returned directly > > arch_iounmap() return a bool, > > - 0 means continue to vunmap > > - error code means skip vunmap and return directly > > It would make more sense if the return values were described > from the prospective of an architecture, not the caller. > I.e true - unmapped, false - not supported, etc. Yes, sounds reasonable to me, thanks. While ChristopheL suggested to take another way. Please see below link. I will reply to Christophe to discuss that. https://lore.kernel.org/all/8df89136-a7f2-9b66-d522-a4fb9860bf22@csgroup.eu/T/#u If the current arch_ioremap() way is taken, I will change the description as you said. > > > diff --git a/mm/ioremap.c b/mm/ioremap.c > > index 8652426282cc..99fde69becc7 100644 > > --- a/mm/ioremap.c > > +++ b/mm/ioremap.c > > @@ -17,6 +17,13 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > unsigned long offset, vaddr; > > phys_addr_t last_addr; > > struct vm_struct *area; > > + void __iomem *ioaddr; > > + > > + ioaddr = arch_ioremap(phys_addr, size, prot); > > + if (IS_ERR(ioaddr)) > > + return NULL; > > + else if (ioaddr) > > + return ioaddr; > > It seems to me arch_ioremap() could simply return an address > or an error. Then IOMEM_ERR_PTR(-ENOSYS) if the architecture > does not support it reads much better than the cryptic NULL. I may not follow. Returning NULL means arch_ioremap() doesn't give out a mapped address and doesn't encounter wrong thing. NULL is a little twisting, maybe '0' is better? > > Probably arch_iounmap() returning error would look better too, > though not sure about that. Don't follow either. arch_iounmap() is returning error now.