From patchwork Wed Jul 29 03:34:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 11690277 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E9C1722 for ; Wed, 29 Jul 2020 03:35:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 01E062075F for ; Wed, 29 Jul 2020 03:35:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01E062075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 50C988D000B; Tue, 28 Jul 2020 23:35:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4E22A6B002D; Tue, 28 Jul 2020 23:35:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D1968D000B; Tue, 28 Jul 2020 23:35:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 278066B002C for ; Tue, 28 Jul 2020 23:35:30 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DF3631F212 for ; Wed, 29 Jul 2020 03:35:29 +0000 (UTC) X-FDA: 77089698378.15.pail23_5003e2526f6f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id B5B621814B0C8 for ; Wed, 29 Jul 2020 03:35:29 +0000 (UTC) X-Spam-Summary: 1,0,0,530101b07ad2d87c,d41d8cd98f00b204,justin.he@arm.com,,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1261:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3871:3872:3874:4321:4605:5007:6120:6261:6742:6743:7904:8634:10004:11026:11233:11473:11658:11914:12043:12048:12114:12297:12438:12555:12895:13069:13161:13229:13311:13357:14096:14181:14384:14721:21080:21324:21451:21627:21987:21990:30054:30070,0,RBL:217.140.110.172:@arm.com:.lbl8.mailshell.net-64.100.201.201 62.2.0.100;04yr6cej4ug7zbnzdsctqhbwxbpf5op43p3ozaucxxpbrdurgkdsu78t16nbxm1.89g6j6yju6xjrkcgckxnew8i3bk68am8kjyb4fueu3kgkz6fh4k6gdybctowm6b.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: pail23_5003e2526f6f X-Filterd-Recvd-Size: 3844 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 29 Jul 2020 03:35:29 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 22CD631B; Tue, 28 Jul 2020 20:35:28 -0700 (PDT) Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com [10.169.212.213]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A76983F66E; Tue, 28 Jul 2020 20:35:20 -0700 (PDT) From: Jia He To: Dan Williams , Vishal Verma , Mike Rapoport , David Hildenbrand Cc: Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Dave Jiang , Andrew Morton , Steve Capper , Mark Rutland , Logan Gunthorpe , Anshuman Khandual , Hsin-Yi Wang , Jason Gunthorpe , Dave Hansen , Kees Cook , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org, Wei Yang , Pankaj Gupta , Ira Weiny , Kaly Xin , Jia He Subject: [RFC PATCH 2/6] resource: export find_next_iomem_res() helper Date: Wed, 29 Jul 2020 11:34:20 +0800 Message-Id: <20200729033424.2629-3-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200729033424.2629-1-justin.he@arm.com> References: <20200729033424.2629-1-justin.he@arm.com> X-Rspamd-Queue-Id: B5B621814B0C8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: The helper is to find the lowest iomem resource that covers part of [@start..@end] It is useful when relaxing the alignment check for dax pmem kmem. Signed-off-by: Jia He --- include/linux/ioport.h | 3 +++ kernel/resource.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 6c2b06fe8beb..203fd16c9f45 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -247,6 +247,9 @@ extern struct resource * __request_region(struct resource *, extern void __release_region(struct resource *, resource_size_t, resource_size_t); +extern int find_next_iomem_res(resource_size_t start, resource_size_t end, + unsigned long flags, unsigned long desc, + bool first_lvl, struct resource *res); #ifdef CONFIG_MEMORY_HOTREMOVE extern int release_mem_region_adjustable(struct resource *, resource_size_t, resource_size_t); diff --git a/kernel/resource.c b/kernel/resource.c index 841737bbda9e..57e6a6802a3d 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -338,7 +338,7 @@ EXPORT_SYMBOL(release_resource); * @first_lvl: walk only the first level children, if set * @res: return ptr, if resource found */ -static int find_next_iomem_res(resource_size_t start, resource_size_t end, +int find_next_iomem_res(resource_size_t start, resource_size_t end, unsigned long flags, unsigned long desc, bool first_lvl, struct resource *res) { @@ -391,6 +391,7 @@ static int find_next_iomem_res(resource_size_t start, resource_size_t end, read_unlock(&resource_lock); return p ? 0 : -ENODEV; } +EXPORT_SYMBOL(find_next_iomem_res); static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end, unsigned long flags, unsigned long desc,