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 292E0C19F2D for ; Sun, 7 Aug 2022 01:42:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05D3C8E0002; Sat, 6 Aug 2022 21:42:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00D7A8E0001; Sat, 6 Aug 2022 21:42:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E16D68E0002; Sat, 6 Aug 2022 21:42:18 -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 CFED18E0001 for ; Sat, 6 Aug 2022 21:42:18 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A5C9B40567 for ; Sun, 7 Aug 2022 01:42:18 +0000 (UTC) X-FDA: 79771096356.22.380D855 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 91C37100152 for ; Sun, 7 Aug 2022 01:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659836537; 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=RzrwrZZlAdAxg74pcF45oBLCZITEOpP3GprO6bJ7DKPiS6vyJZq2EXlzIVIa3zNr2JVj+w M3slPY82UNYbKcwaAeQdhub/nCSuYDdRrbxTCLEWMOJyB1t8WH74rvwl+p+AI5HCPf4K2R DfpDVGEPYcDfv5Vqx7+ey+dX8lLmOo0= 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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659836538; a=rsa-sha256; cv=none; b=TGcc1iHeNNHF6BauY9uu4IlrtEg2Lj+selm0hNRiDP1kuQ7dsDUvBv2OY4ALRotzKJq4qb BhdTdj0Z01DuMOSVffW0Rja/TpaGLQ01Gq6hcM9wslP8Nr6mYuGOlIEx6cOhn22SwlXsvV EZDEoJrh8p6MCF8uQfEJUnGI4PJ6rT0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RzrwrZZl; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659836538; 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:dkim-signature; bh=yRa3p/29F3baYB0BuqQ0MuKQVUhJE1CPCIoS8bSSmmI=; b=i5FPQePxkjnENRiTRjtRpfhck9raFP12SjmSr3p4snzfWsAFlEFYprs3asLcU/a6u/ftjA 3/QFAhtVpV4SCVcmTyZA9EpDd2cu3c+aQBtyKySqF+f9J9FZ0GcW83k1qknXO48uWZokjT A0zhfz+CUmj9F2a+1wfC6vQGhGZz8UA= X-Stat-Signature: x3xxdamagm6yrobn9kkwfu7i8xbgc1mo X-Rspamd-Queue-Id: 91C37100152 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RzrwrZZl; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1659836537-569232 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/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 = 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. > > 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 = (void *)((unsigned long)addr & PAGE_MASK); > > > > + void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_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()  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.