From patchwork Fri Sep 6 03:07:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13793168 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 BFEA1CE7AA5 for ; Fri, 6 Sep 2024 03:09:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4AD9B6B008A; Thu, 5 Sep 2024 23:09:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45CBC6B0092; Thu, 5 Sep 2024 23:09:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E1D56B0093; Thu, 5 Sep 2024 23:09:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0F4796B008A for ; Thu, 5 Sep 2024 23:09:29 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B7EFE40D4B for ; Fri, 6 Sep 2024 03:09:28 +0000 (UTC) X-FDA: 82532832816.14.CDBCFFD Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by imf21.hostedemail.com (Postfix) with ESMTP id 935DB1C000C for ; Fri, 6 Sep 2024 03:09:26 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=l+3wBS7B; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of ying.huang@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725592094; a=rsa-sha256; cv=none; b=z6d0Ywx4nfTSr8cefNihJCbLG4GYEzExxjiHmbfLBpolCXAOqT4tAFw+iPan2Wut6U7ljP friBr4oPube7CmtZCpJhuFfJ/2vmYLpBZCWTGLTLyEO/MHTYxK4sDxwn6a3oCLqBfKihHw 9cljB5oXORS6Xhcnz62rq9zQkKfogBw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=l+3wBS7B; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of ying.huang@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725592094; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=z+EHTFnjwcKj608X0cDnnlPS8vNfF3r+0nwUHhMlex4=; b=ZBlBRwSzAXiWuKSCeITaTXz6IbIs9MXwad4JfDKyJrcDGXIGYHRmHnYNxSsPHNf2he1MTX MIUagCueIwEDbP7IxsrdYpKAPTdS8syY2smadplUJRBZqb4Stix3BZPUitkmVzF6/qgdp4 gdFGGNwZAMy4UEk3LVa+8krCfXMD1TA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725592166; x=1757128166; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3Ij6u3xpNnYxJGL++yR1zK7P57z01gPw8JrpH/RINL8=; b=l+3wBS7BTVWD1jLQiKPgjPRUR36yDLfLkASuPUn3dN2YM50UszGXU3wb SdZudGjwbnZ7NL2PKUQjABem5b7J632wF8R90j4Wq8OklUXxPHQ2vuX10 hJzum5v27aIdRKgJdGsRn5D6N2xSp3n5FtrxGIbMofgxESHUg0vpDv75A JwRe2Dpnv+j1s4IDD6W0uP7Pbcy3jEgH9OEi4mC+/oQKxCxP80Aou6aur 4LFBnUnmqcAfYP8h08KTrEQ6FesqbrB0NERYsfCADmI1BpEWccDMZ2ozh apFvOLeWruXGlXWN7HyISk+vB9buZxbLu1n+5IpEI5L+brZiHw6smbti8 A==; X-CSE-ConnectionGUID: X5QO7GkfQmuMD79Wi54EHA== X-CSE-MsgGUID: u3gt3v4cSVuQcjBSLZo24Q== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="28089475" X-IronPort-AV: E=Sophos;i="6.10,206,1719903600"; d="scan'208";a="28089475" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 20:09:25 -0700 X-CSE-ConnectionGUID: nKPr5kD7TPSkUShYudxjNw== X-CSE-MsgGUID: zSY50cl/Tb2/KgutidFYzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,206,1719903600"; d="scan'208";a="66364396" Received: from unknown (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.245.242.189]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 20:09:22 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, Huang Ying , Dan Williams , David Hildenbrand , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Alistair Popple , Andy Shevchenko , Bjorn Helgaas , Baoquan He Subject: [PATCH -v3 2/3] resource: Make alloc_free_mem_region() works for iomem_resource Date: Fri, 6 Sep 2024 11:07:12 +0800 Message-Id: <20240906030713.204292-3-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240906030713.204292-1-ying.huang@intel.com> References: <20240906030713.204292-1-ying.huang@intel.com> MIME-Version: 1.0 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huvfpoEVTtWUMHu+c s0yFJK1I NiwTkHoT2z9E1KM2X2R4gU0azbfqyhnd1II9FF3bDfhzz1Tz8N508KDRTrLzukxal79p8idyKXluQZ3IvjOeK8PdS/Zs5cynB4570CP05FQMABPnjrD9KsHPwCzBcqZRIgrRZPOMHOJjrr6fmrnPCqmj9Q3o1sY+4i/vzd48ii+4EUK6hF5njfz1Vf/Pu0sirGaq/4pn2hWusv1JMiLk4jltt3b523j88Hkg5/iVh8QUzK1oM3omfFa7byglJhMZ41RzDV/oszl4cz8bJq8seuhPKE3dk+Ohlqx2H+nTo1FeLI99APQjmWQcgPbPQmyQW9MiyQR2nWKr/Y6lz2L0xvElFZHBvsxt2b7aJcOzexW9VTwSk7EFeVhPigA== 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: List-Subscribe: List-Unsubscribe: During developing a kunit test case for region_intersects(), some fake resources need to be inserted into iomem_resource. To do that, a resource hole needs to be found first in iomem_resource. However, alloc_free_mem_region() cannot work for iomem_resource now. Because the start address to check cannot be 0 to detect address wrapping 0 in gfr_continue(), while iomem_resource.start == 0. To make alloc_free_mem_region() works for iomem_resource, gfr_start() is changed to avoid to return 0 even if base->start == 0. We don't need to check 0 as start address. Signed-off-by: "Huang, Ying" Cc: Dan Williams Cc: David Hildenbrand Cc: Davidlohr Bueso Cc: Jonathan Cameron Cc: Dave Jiang Cc: Alison Schofield Cc: Vishal Verma Cc: Ira Weiny Cc: Alistair Popple Cc: Andy Shevchenko Cc: Bjorn Helgaas Cc: Baoquan He --- kernel/resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/resource.c b/kernel/resource.c index 235dc77f8add..035ef16c1a66 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -1873,7 +1873,7 @@ static resource_size_t gfr_start(struct resource *base, resource_size_t size, return end - size + 1; } - return ALIGN(base->start, align); + return ALIGN(max(base->start, align), align); } static bool gfr_continue(struct resource *base, resource_size_t addr,