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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 367F3C19F2D for ; Sun, 7 Aug 2022 01:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xjrg45aif/3CG6HA0VnS9HsQtOiyI+uoyKg7YyygRTs=; b=gSduC0r2t+J7Nb yEGipy/HffOSQHyTLtUhgtMEwXzIeb97iX9XUPiTOHHiTAqt4KzfTf0HHQ+eunGskTK02xQtbgEtl ehlyN9stSVovdGT7lly6dlbS8iobBMsqWjnuJbsm/YgYjVjyy/XWheFRhNZwAoBcZSl7MYl0CZaN/ Q/3GS32dqj4Gh9Nfq+KR6f/MoK4rglAXURxnfIeADUy1IWlfOyMwXhPRrCMPXSkVPi3MrD1FlbQdk xTURkDcKIC8WpWfwv46OPN+q8UaFztTBuSD1+SEtjlzAZDp/9fAd8/kqSU1r419Q/J2iiRwOZtbZh UtaDsWSCnWGG+4LVk3Ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKVJ7-004D0F-Na; Sun, 07 Aug 2022 01:42:21 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKVJ3-004CsP-Pw for linux-arm-kernel@lists.infradead.org; Sun, 07 Aug 2022 01:42:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659836535; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yRa3p/29F3baYB0BuqQ0MuKQVUhJE1CPCIoS8bSSmmI=; b=IxGzKtGSeycoi+9Lt4eNMcmz8+E1jlHy5HDXIG0Vu5tqWdBnQ6z5MojshV58vGDTT6OJug oySAMTM0IMmCpaGsG7id4rWjD1tabKQ5oL/Lff+XSkmKXdq41hWomHbkieMlPeX7qXic5m 1LrlorzP0VxOYCCIJ5jnZdpFmlYdNas= 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-146-oSUK6zFtMjOJwmjt0oW7HA-1; Sat, 06 Aug 2022 21:42:11 -0400 X-MC-Unique: oSUK6zFtMjOJwmjt0oW7HA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4097D3C025C2; Sun, 7 Aug 2022 01:42:11 +0000 (UTC) Received: from localhost (ovpn-12-55.pek2.redhat.com [10.72.12.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5290F403167; Sun, 7 Aug 2022 01:42:09 +0000 (UTC) Date: Sun, 7 Aug 2022 09:42:06 +0800 From: Baoquan He To: Alexander Gordeev , Kefeng Wang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, hch@infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 01/11] mm/ioremap: change the return value of io[re|un]map_allowed Message-ID: <20220807014206.GA416711@MiWiFi-R3L-srv> References: <20220801144029.57829-1-bhe@redhat.com> <20220801144029.57829-2-bhe@redhat.com> <832b38ca-064e-0ab8-cd62-337d0d83d471@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220806_184217_934176_F0B5A675 X-CRM114-Status: GOOD ( 34.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 08/06/22 at 10:29am, Alexander Gordeev wrote: > On Sat, Aug 06, 2022 at 10:29:03AM +0800, Kefeng Wang wrote: > > = > > 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 =3D phys_addr + size - 1; > > > > + int ret =3D -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 __io= mem *addr) > > > > /* > > > > * Arch code can implement the following two hooks when using GEN= ERIC_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 -=3D offset; > > > > size =3D PAGE_ALIGN(size + offset); > > > > - if (!ioremap_allowed(phys_addr, size, prot)) > > > > + base =3D 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. > = > vaddr name is wrong AFAICT. ioremap_allowed() returns __iomem address, > not the virtual one. Thanks a lot for reviewing, both. Here, I tend to agree with Alexander. ioremap_allowed() returns __iomem*. How about naming it io_addr here. While I don't have strong opinion about it, reusing vaddr and casting it to (__iomem*) when return is also OK to me. > = > > > = > > > > @@ -50,9 +54,9 @@ EXPORT_SYMBOL(ioremap_prot); > > > > void iounmap(volatile void __iomem *addr) > > > > { > > > > - void *vaddr =3D (void *)((unsigned long)addr & PAGE_MASK); > > > > + void __iomem *vaddr =3D (void __iomem *)((unsigned long)addr & PA= GE_MASK); > = > Same here. > = > > > > - 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()=A0 and vunmap() in iounmap() use void *, > > = > > so we could simply use void* for iounmap_allowed(). > = > iounmap_allowed() accepts void __iomem * and I that looks correct to me. > = > Passing void * on the other hand means you pass a pointer that > in theory differs from what architecture previously returned > with ioremap_allowed() and "knows" nothing about. > = > I think you need to pass addr to iounmap_allowed() as is. OK, I will change to pass (__iomem*) to iounmap_allowed() directly. Thanks. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel