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 93A9CC4332F for ; Sun, 16 Oct 2022 08:15:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4E538E0002; Sun, 16 Oct 2022 04:15:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFC208E0001; Sun, 16 Oct 2022 04:15:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9D1F8E0002; Sun, 16 Oct 2022 04:15:19 -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 94C798E0001 for ; Sun, 16 Oct 2022 04:15:19 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 59C63120ABD for ; Sun, 16 Oct 2022 08:15:19 +0000 (UTC) X-FDA: 80026102758.08.6C4D4F9 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf21.hostedemail.com (Postfix) with ESMTP id DB44E1C0020 for ; Sun, 16 Oct 2022 08:15:18 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29G3wxUw032333; Sun, 16 Oct 2022 08:14:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=hMozpMwg+vZnUk1wC1EQIabeNAUmNvS/E5iI/01UZHU=; b=KDoOnXfRMJz3cUc7B79z9yw8KStrFIzwJBmhtyFhn5/O2AEXWmIylIQv6HU5ttKb4Ijg 876VNGIYgG8P9OIbZ2ox5RQ+PmwtglxLZrOFu5Gq86h9EuqnIEvVLBkunbGalu8wC3vB SA19IzqdxHxXs0JM6j2HxT8vY9vPXy85t/pOfD8oCAeykIxNxDh3Yc2mtfmoS0HO6Xsq 9zZz6Ag1PXmvW9fKvh9S4qetJkqaNiLLQUj4qRToN/QuuoqUtfzTomy8qDhYsbKXkD87 19SX/TLy4forcuPlIUbvv49R2MGtusMWffSqAr0Gj8Lh9aYoaexQkxtaTZhcH6FMl0IE gg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k866art41-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 16 Oct 2022 08:14:57 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29G8Eujq012129; Sun, 16 Oct 2022 08:14:56 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k866art3a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 16 Oct 2022 08:14:56 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29G85b5O007953; Sun, 16 Oct 2022 08:14:53 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 3k7mg8s2b4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 16 Oct 2022 08:14:53 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29G8EpBx50594108 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 16 Oct 2022 08:14:51 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7FA914203F; Sun, 16 Oct 2022 08:14:51 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E79014204B; Sun, 16 Oct 2022 08:14:50 +0000 (GMT) Received: from li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com (unknown [9.145.58.10]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sun, 16 Oct 2022 08:14:50 +0000 (GMT) Date: Sun, 16 Oct 2022 10:14:49 +0200 From: Alexander Gordeev To: Christophe Leroy Cc: Baoquan He , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, akpm@linux-foundation.org, hch@infradead.org, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@aculab.com, shorne@gmail.com Subject: Re: [RFC PATCH 3/8] mm/ioremap: Define generic_ioremap_prot() and generic_iounmap() Message-ID: References: <32dedfbe00c1da0114f66d6a43c56f4a16a85b64.1665568707.git.christophe.leroy@csgroup.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <32dedfbe00c1da0114f66d6a43c56f4a16a85b64.1665568707.git.christophe.leroy@csgroup.eu> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jBURfmDGT6azRIRzYI1iuxxRjRloJWlc X-Proofpoint-ORIG-GUID: 6KdXepSdsv_24mTO-01aIVOQKmd5G-rM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-16_03,2022-10-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 mlxscore=0 adultscore=0 mlxlogscore=819 lowpriorityscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 clxscore=1015 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210160049 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665908119; a=rsa-sha256; cv=none; b=AsqnRQqcPsDcrWFNPVaFCjisIDaOmVpDrMI0NYPSWjdH0VXT/tocBXbPFYugun3y5AIv77 Xf4/bWmPbTccCoFa/YVkWu2f2sWaLzqKBBWdC53EiJp4w4cuqH/Rvk6IEGmAIYVHs77klP XfXkcTOgfITXHL1RCmJkrR/6A0+rY/8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=KDoOnXfR; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf21.hostedemail.com: domain of agordeev@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=agordeev@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665908119; 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=hMozpMwg+vZnUk1wC1EQIabeNAUmNvS/E5iI/01UZHU=; b=vtcPnJd6UH35TsHlH3YEpdUcTe14hPh3Zm8e0afkqattDeqAQvT00YMZKZ7a3hN2B7IhJH bV0CxpspFMgnDq1ZqqtLhQtn1foj1JunSGU1gQ2XfdrUzwwxgVmZBphcDajVI9whX1+uHb 97HLoTbOixzBCpFZaooATjr58XhimPQ= X-Rspamd-Server: rspam05 X-Rspam-User: X-Rspamd-Queue-Id: DB44E1C0020 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=KDoOnXfR; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf21.hostedemail.com: domain of agordeev@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=agordeev@linux.ibm.com X-Stat-Signature: oiptp4tp44kuxt1u4nhi8d85qsrij5h7 X-HE-Tag: 1665908118-360259 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 Wed, Oct 12, 2022 at 12:09:39PM +0200, Christophe Leroy wrote: > Define a generic version of ioremap_prot() and iounmap() that > architectures can call after they have performed the necessary > alteration to parameters and/or necessary verifications. > > Signed-off-by: Christophe Leroy [...] > diff --git a/mm/ioremap.c b/mm/ioremap.c > index 8652426282cc..9f34a8f90b58 100644 > --- a/mm/ioremap.c > +++ b/mm/ioremap.c > @@ -11,8 +11,8 @@ > #include > #include > > -void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > - unsigned long prot) > +void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, > + pgprot_t prot) > { > unsigned long offset, vaddr; > phys_addr_t last_addr; > @@ -28,7 +28,7 @@ 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)) > + if (!ioremap_allowed(phys_addr, size, pgprot_val(prot))) > return NULL; It seems to me ioremap_allowed() is not needed anymore. Whatever is checked here would move to architecture- specific implementation. > area = get_vm_area_caller(size, VM_IOREMAP, > @@ -38,17 +38,24 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > vaddr = (unsigned long)area->addr; > area->phys_addr = phys_addr; > > - if (ioremap_page_range(vaddr, vaddr + size, phys_addr, > - __pgprot(prot))) { > + if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) { > free_vm_area(area); > return NULL; > } > > return (void __iomem *)(vaddr + offset); > } > + > +#ifndef ioremap_prot I guess, this is also needed: #define ioremap_prot ioremap_prot > +void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > + unsigned long prot) > +{ > + return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); > +} > EXPORT_SYMBOL(ioremap_prot); > +#endif > > -void iounmap(volatile void __iomem *addr) > +void generic_iounmap(volatile void __iomem *addr) > { > void *vaddr = (void *)((unsigned long)addr & PAGE_MASK); > > @@ -58,4 +65,11 @@ void iounmap(volatile void __iomem *addr) > if (is_vmalloc_addr(vaddr)) > vunmap(vaddr); > } > + > +#ifndef iounmap Same here. > +void iounmap(volatile void __iomem *addr) > +{ > + generic_iounmap(addr); > +} > EXPORT_SYMBOL(iounmap); > +#endif