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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F45CC433EF for ; Wed, 8 Jun 2022 07:57:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232504AbiFHH5v (ORCPT ); Wed, 8 Jun 2022 03:57:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232952AbiFHH4n (ORCPT ); Wed, 8 Jun 2022 03:56:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7AE5F1DFC55 for ; Wed, 8 Jun 2022 00:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654672981; 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=o1idPqOloA86p2fVQONMUWnq8T0JoB50Wldq7zBiLdw=; b=H1NgbUEVAB+/5tUk5OQ+UC4gYaFS6cdhdwGQBDhnSFJvDoTchQP5DZXPu7Nbo0LbKHgyWU +Wt9PsLmetMvs0geuvPkCyppzgH+e4lEpuzxn2TDwy3NHt6QLczoVsqp7veWkDwnAcdQDp Jpmer6XkSxAsHFVBceRCupAHOalozx4= 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-618-uObRR-dCP9i-_Pw1WR2-Dw-1; Wed, 08 Jun 2022 03:22:58 -0400 X-MC-Unique: uObRR-dCP9i-_Pw1WR2-Dw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B5F480B712; Wed, 8 Jun 2022 07:22:58 +0000 (UTC) Received: from localhost (ovpn-12-81.pek2.redhat.com [10.72.12.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 339C11121314; Wed, 8 Jun 2022 07:22:56 +0000 (UTC) Date: Wed, 8 Jun 2022 15:22:53 +0800 From: Baoquan He To: Kefeng Wang Cc: catalin.marinas@arm.com, will@kernel.org, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, hch@infradead.org, arnd@arndb.de, anshuman.khandual@arm.com Subject: Re: [PATCH v5 2/6] mm: ioremap: Use more sensibly name in ioremap_prot() Message-ID: References: <20220607125027.44946-1-wangkefeng.wang@huawei.com> <20220607125027.44946-3-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/08/22 at 12:16pm, Baoquan He wrote: > On 06/07/22 at 08:50pm, Kefeng Wang wrote: > > Use more meaningful and sensibly naming phys_addr > > instead addr in ioremap_prot(). > > > > Suggested-by: Andrew Morton > > Reviewed-by: Anshuman Khandual > > Signed-off-by: Kefeng Wang > > --- > > include/asm-generic/io.h | 3 ++- > > mm/ioremap.c | 14 ++++++++------ > > 2 files changed, 10 insertions(+), 7 deletions(-) > > > > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h > > index 7ce93aaf69f8..b76379628a02 100644 > > --- a/include/asm-generic/io.h > > +++ b/include/asm-generic/io.h > > @@ -964,7 +964,8 @@ static inline void iounmap(volatile void __iomem *addr) > > #elif defined(CONFIG_GENERIC_IOREMAP) > > #include > > > > -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); > > +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > + unsigned long prot); > > void iounmap(volatile void __iomem *addr); > > > > static inline void __iomem *ioremap(phys_addr_t addr, size_t size) > > diff --git a/mm/ioremap.c b/mm/ioremap.c > > index 5fe598ecd9b7..2d754b48d230 100644 > > --- a/mm/ioremap.c > > +++ b/mm/ioremap.c > > @@ -11,20 +11,21 @@ > > #include > > #include > > > > -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) > > +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > + unsigned long prot) > > { > > unsigned long offset, vaddr; > > phys_addr_t last_addr; > > struct vm_struct *area; > > > > /* Disallow wrap-around or zero size */ > > - last_addr = addr + size - 1; > > - if (!size || last_addr < addr) > > + last_addr = phys_addr + size - 1; > > + if (!size || last_addr < phys_addr) > > return NULL; > > > > /* Page-align mappings */ > > - offset = addr & (~PAGE_MASK); > > - addr -= offset; > > + offset = phys_addr & (~PAGE_MASK); > ~~~ use offset_in_page() instead? Sorry, this patch only does s/addr/phys_addr/, please ignore this comment. > > Other than this nitpick, this looks good to me. > > Reviewed-by: Baoquan He > > > + phys_addr -= offset; > > size = PAGE_ALIGN(size + offset); > > > > area = get_vm_area_caller(size, VM_IOREMAP, > > @@ -33,7 +34,8 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) > > return NULL; > > vaddr = (unsigned long)area->addr; > > > > - if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) { > > + if (ioremap_page_range(vaddr, vaddr + size, phys_addr, > > + __pgprot(prot))) { > > free_vm_area(area); > > return NULL; > > } > > -- > > 2.35.3 > > > > > 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 C27A8C43334 for ; Wed, 8 Jun 2022 07:24:09 +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=cNg0uvNmqku52TZn7PZkfmOb1AlpQMzljPNLwONqSto=; b=xXSpxWAgX+ihP8 JkvM1t01dkiuyTdjT05Xbvj6x1kPzRzcM0Ice6JKpFihGwK9aPAYpOvJh2qRyawpGsQ9tqa/9wl4k nhjYmxy7/iuiOEgCxE/3dK28C0jBnNX9+tL/AWz9K2raB2O3SeTegs3C8hwJLOf/HUiYShmYjM6pE SHVCpq/cAVA1wDPwnSPNwdsZ7wl/i51zaoDjCy2BYwaa6OXwwAZvh3kdtvujY/+GU0eNyDROP86uC VDNLVXPn3kQIiEYww0IiyEvqToEZOi0lG1+Bl/0NELFBlI7zS19Ue+/ShnaFMyGc5M3jT/Luu9eHv +vhqTVLRKuS5IUZ4KwFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyq1x-00BaWK-RT; Wed, 08 Jun 2022 07:23:05 +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 1nyq1v-00BaVI-2i for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2022 07:23:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654672981; 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=o1idPqOloA86p2fVQONMUWnq8T0JoB50Wldq7zBiLdw=; b=H1NgbUEVAB+/5tUk5OQ+UC4gYaFS6cdhdwGQBDhnSFJvDoTchQP5DZXPu7Nbo0LbKHgyWU +Wt9PsLmetMvs0geuvPkCyppzgH+e4lEpuzxn2TDwy3NHt6QLczoVsqp7veWkDwnAcdQDp Jpmer6XkSxAsHFVBceRCupAHOalozx4= 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-618-uObRR-dCP9i-_Pw1WR2-Dw-1; Wed, 08 Jun 2022 03:22:58 -0400 X-MC-Unique: uObRR-dCP9i-_Pw1WR2-Dw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B5F480B712; Wed, 8 Jun 2022 07:22:58 +0000 (UTC) Received: from localhost (ovpn-12-81.pek2.redhat.com [10.72.12.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 339C11121314; Wed, 8 Jun 2022 07:22:56 +0000 (UTC) Date: Wed, 8 Jun 2022 15:22:53 +0800 From: Baoquan He To: Kefeng Wang Cc: catalin.marinas@arm.com, will@kernel.org, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, hch@infradead.org, arnd@arndb.de, anshuman.khandual@arm.com Subject: Re: [PATCH v5 2/6] mm: ioremap: Use more sensibly name in ioremap_prot() Message-ID: References: <20220607125027.44946-1-wangkefeng.wang@huawei.com> <20220607125027.44946-3-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220608_002303_273172_037673D0 X-CRM114-Status: GOOD ( 22.03 ) 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 06/08/22 at 12:16pm, Baoquan He wrote: > On 06/07/22 at 08:50pm, Kefeng Wang wrote: > > Use more meaningful and sensibly naming phys_addr > > instead addr in ioremap_prot(). > > > > Suggested-by: Andrew Morton > > Reviewed-by: Anshuman Khandual > > Signed-off-by: Kefeng Wang > > --- > > include/asm-generic/io.h | 3 ++- > > mm/ioremap.c | 14 ++++++++------ > > 2 files changed, 10 insertions(+), 7 deletions(-) > > > > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h > > index 7ce93aaf69f8..b76379628a02 100644 > > --- a/include/asm-generic/io.h > > +++ b/include/asm-generic/io.h > > @@ -964,7 +964,8 @@ static inline void iounmap(volatile void __iomem *addr) > > #elif defined(CONFIG_GENERIC_IOREMAP) > > #include > > > > -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot); > > +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > + unsigned long prot); > > void iounmap(volatile void __iomem *addr); > > > > static inline void __iomem *ioremap(phys_addr_t addr, size_t size) > > diff --git a/mm/ioremap.c b/mm/ioremap.c > > index 5fe598ecd9b7..2d754b48d230 100644 > > --- a/mm/ioremap.c > > +++ b/mm/ioremap.c > > @@ -11,20 +11,21 @@ > > #include > > #include > > > > -void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) > > +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > + unsigned long prot) > > { > > unsigned long offset, vaddr; > > phys_addr_t last_addr; > > struct vm_struct *area; > > > > /* Disallow wrap-around or zero size */ > > - last_addr = addr + size - 1; > > - if (!size || last_addr < addr) > > + last_addr = phys_addr + size - 1; > > + if (!size || last_addr < phys_addr) > > return NULL; > > > > /* Page-align mappings */ > > - offset = addr & (~PAGE_MASK); > > - addr -= offset; > > + offset = phys_addr & (~PAGE_MASK); > ~~~ use offset_in_page() instead? Sorry, this patch only does s/addr/phys_addr/, please ignore this comment. > > Other than this nitpick, this looks good to me. > > Reviewed-by: Baoquan He > > > + phys_addr -= offset; > > size = PAGE_ALIGN(size + offset); > > > > area = get_vm_area_caller(size, VM_IOREMAP, > > @@ -33,7 +34,8 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot) > > return NULL; > > vaddr = (unsigned long)area->addr; > > > > - if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) { > > + if (ioremap_page_range(vaddr, vaddr + size, phys_addr, > > + __pgprot(prot))) { > > free_vm_area(area); > > return NULL; > > } > > -- > > 2.35.3 > > > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel