Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp801835ybg; Tue, 28 Jul 2020 20:36:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrpELhvifvX1dD0GR+WnSB8bBh2Qu61coH3179OcruV7bvNBO6qVs5DcKnKvIyjhZTsgiG X-Received: by 2002:a17:906:e2d6:: with SMTP id gr22mr17561407ejb.455.1595993784103; Tue, 28 Jul 2020 20:36:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595993784; cv=none; d=google.com; s=arc-20160816; b=vQPauA75DTI6vLoqrOagz0I4A8m7qLIKczHCbeKBwcUBazwa+ziM2vd/VTbPRsn9m0 U5m8zDproJ74FTKNassAljHP3NFB7OScS7TmSJ4lVb4MrfwZpPZiuTPfLyB7UzsG64Wk d1GaKyd4I7eEmHCS/ilcqOA7t6uzW8WCUtiPD0yz9YZepQDgvy9wY0EVQ0x0/o/YMx+g mcmVb4BJ3PPW2lFoTWE5kIxxTvf5YK6Lc5U4cdK1sIO32BRXMo8zsrthng2zno0LDUm7 3Fyj1pRCUwekGnrzMSAb3AFl1jdl5j2PvzXHsn/TWu0TEcn13BX5a/fZ1Ny86wPWvFeb auSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=W5mUhpLDcVQb3hZwQEyQt3pq7c7JclYJ1ezKgYiW+qo=; b=p4pMgYG2gIzZsSOgad+EpPMqB9Sc+FiteIFXx7gsj5iOnzre7EA9++z8BY+5scBLhV 315uI3+YJxgFEoVDAzd5IOAQ1Svpz8UUTVgfd8jHZddTdVf5VYhvrzxOVGq4LKS/BM5O BUMo95X93VzXelHl9OdDdkL1V+/iZ75tk9qt/kWQhLHoV539vGOWUHIhtuVZdjvXjRph zAOs9ItKjtzv7pIdfYj2knuHUS2uxWoCtytxZpItYsU/wPMZ/xlF8jV3T8v7BvVXDjr1 zE8GMp0ItSx152m3Wrkg1l+gWqkNf7NA1x1WuDdYDskZVO/kjqJAtXwUKM/TpcoIBHQ5 +Yng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si459408eds.283.2020.07.28.20.36.02; Tue, 28 Jul 2020 20:36:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726847AbgG2Df3 (ORCPT + 99 others); Tue, 28 Jul 2020 23:35:29 -0400 Received: from foss.arm.com ([217.140.110.172]:44566 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgG2Df2 (ORCPT ); Tue, 28 Jul 2020 23:35:28 -0400 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 2.17.1