{"id":2215474,"url":"http://patchwork.ozlabs.org/api/patches/2215474/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260324165633.4583-2-ilpo.jarvinen@linux.intel.com/","project":{"id":28,"url":"http://patchwork.ozlabs.org/api/projects/28/?format=json","name":"Linux PCI development","link_name":"linux-pci","list_id":"linux-pci.vger.kernel.org","list_email":"linux-pci@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260324165633.4583-2-ilpo.jarvinen@linux.intel.com>","list_archive_url":null,"date":"2026-03-24T16:56:24","name":"[01/10] resource: Add __resource_contains_unbound() for internal contains checks","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"126ce096f6773287bf75a9f91bd2f4c29506bcd5","submitter":{"id":83553,"url":"http://patchwork.ozlabs.org/api/people/83553/?format=json","name":"Ilpo Järvinen","email":"ilpo.jarvinen@linux.intel.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260324165633.4583-2-ilpo.jarvinen@linux.intel.com/mbox/","series":[{"id":497318,"url":"http://patchwork.ozlabs.org/api/series/497318/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=497318","date":"2026-03-24T16:56:23","name":"PCI: Improve head free space usage","version":1,"mbox":"http://patchwork.ozlabs.org/series/497318/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2215474/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2215474/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-pci+bounces-50930-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=c/Cx3dv3;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-50930-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com\n header.b=\"c/Cx3dv3\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=198.175.65.13","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.intel.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.intel.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgGZT758Kz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 04:03:13 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 1DC9C30A8AFE\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 24 Mar 2026 16:58:44 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id B084238BF97;\n\tTue, 24 Mar 2026 16:58:42 +0000 (UTC)","from mgamail.intel.com (mgamail.intel.com [198.175.65.13])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A6E003FE643;\n\tTue, 24 Mar 2026 16:58:40 +0000 (UTC)","from orviesa008.jf.intel.com ([10.64.159.148])\n  by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 24 Mar 2026 09:58:40 -0700","from ijarvine-mobl1.ger.corp.intel.com (HELO localhost)\n ([10.245.244.217])\n  by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 24 Mar 2026 09:58:30 -0700"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774371522; cv=none;\n b=TM34RP+d0mYZAjsjyDUKhcRdN5jiVxyc8Xc/nVwMmtC/8aHwxQoGxWY3Xo6J8Kz5LhsQHvMgK2gdWuofEKpEeOP6lIv1lUMtT4ywgEmK+ADvZ7gHYNzn0WNLz4D7wfLraTyKGnPE+2jr/SdUeOqqladl9BQgJMbGi62xow8KcC8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774371522; c=relaxed/simple;\n\tbh=rU3n+FhgkyydByVdKs0lqSkLocKXu14IaAOX593F5w8=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=QwTakeoK7U0YdOh4yFHH4cAHLGM69xpLBO4HphGtXwOZAQrBCLOuC27JPBXlFRJZFAt3FYeOKDCOwGg8Mk91RsRP72nrRuMUXKVcQmd/RjYadrdE7GnmEmXfeA4BB9+ekX9E6kTcS6t0V9gB70yerlhzCqwoYJYyBfmpLPu9q8w=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.intel.com;\n spf=pass smtp.mailfrom=linux.intel.com;\n dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com\n header.b=c/Cx3dv3; arc=none smtp.client-ip=198.175.65.13","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n  t=1774371521; x=1805907521;\n  h=from:to:cc:subject:date:message-id:in-reply-to:\n   references:mime-version:content-transfer-encoding;\n  bh=rU3n+FhgkyydByVdKs0lqSkLocKXu14IaAOX593F5w8=;\n  b=c/Cx3dv3Vz2/YJbekHvh+gD+WIP1CwyNuQ3q0MlWTGImDZiT1q5uRbVc\n   8bALhv9WRH2YI6Npjox5VxweEtizr6VeUqSCQGPI9tV9WRwXrQ1zza/8/\n   DZD+qQ8HedqBh24LsNLDc44P9DDOd2eFzXOFXpQlU3wRet3dnQGImnx/A\n   QWjN1f6hkstl6XO4sFD0Hn0WMcpJ4Qk9XRk4id57U2nGqI0lvMsw+aS6k\n   ZdkDBuammcrUGgQ50INjc/9hFh8UCB4L+koUWz1oInxxf1kGgNqKYoAfm\n   DyAb/ZzbHxMOjwNlPDxK5ULEw2j5/9lg8vkem+s1IqsMlZipeNnSYQpNs\n   A==;","X-CSE-ConnectionGUID":["uNh4kUZ4SX+tjgPF/ZVCZg==","cUSLjl01TreRSEfKEtoT3A=="],"X-CSE-MsgGUID":["8vPySxbkRhqdU//0wy+muQ==","UG9hoz2GT3+u65rMjcqTqQ=="],"X-IronPort-AV":["E=McAfee;i=\"6800,10657,11739\"; a=\"86471560\"","E=Sophos;i=\"6.23,138,1770624000\";\n   d=\"scan'208\";a=\"86471560\"","E=Sophos;i=\"6.23,138,1770624000\";\n   d=\"scan'208\";a=\"224421884\""],"X-ExtLoop1":"1","From":"=?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>","To":"linux-pci@vger.kernel.org,\n\tBjorn Helgaas <bhelgaas@google.com>,\n\tGuenter Roeck <linux@roeck-us.net>,\n\tlinux-alpha@vger.kernel.org,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinux-m68k@lists.linux-m68k.org,\n\tlinux-mips@vger.kernel.org,\n\tlinux-parisc@vger.kernel.org,\n\tlinuxppc-dev@lists.ozlabs.org,\n\tlinux-s390@vger.kernel.org,\n\tlinux-sh@vger.kernel.org,\n\tRussell King <linux@armlinux.org.uk>,\n\tGeert Uytterhoeven <geert@linux-m68k.org>,\n\tThomas Bogendoerfer <tsbogend@alpha.franken.de>,\n\t\"James E.J. Bottomley\" <James.Bottomley@HansenPartnership.com>,\n\tHelge Deller <deller@gmx.de>,\n\tMichael Ellerman <mpe@ellerman.id.au>,\n\tThomas Gleixner <tglx@kernel.org>,\n\tIngo Molnar <mingo@redhat.com>,\n\tBorislav Petkov <bp@alien8.de>,\n\tDave Hansen <dave.hansen@linux.intel.com>,\n\t\"H. Peter Anvin\" <hpa@zytor.com>,\n\tChris Zankel <chris@zankel.net>,\n\tMax Filippov <jcmvbkbc@gmail.com>,\n\tMadhavan Srinivasan <maddy@linux.ibm.com>,\n\tYoshinori Sato <ysato@users.sourceforge.jp>,\n\tRich Felker <dalias@libc.org>,\n\tJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,\n\tlinux-kernel@vger.kernel.org","Cc":"=?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>","Subject":"[PATCH 01/10] resource: Add __resource_contains_unbound() for\n internal contains checks","Date":"Tue, 24 Mar 2026 18:56:24 +0200","Message-Id":"<20260324165633.4583-2-ilpo.jarvinen@linux.intel.com>","X-Mailer":"git-send-email 2.39.5","In-Reply-To":"<20260324165633.4583-1-ilpo.jarvinen@linux.intel.com>","References":"<20260324165633.4583-1-ilpo.jarvinen@linux.intel.com>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit"},"content":"__find_resource_space() currently uses resource_contains() but for\ntentative resources that are not yet crafted into the resource tree. As\nresource_contains() checks that IORESOURCE_UNSET is not set for either\nof the resources, the caller has to hack around this problem by\nclearing the IORESOURCE_UNSET flag (essentially lying to\nresource_contains()).\n\nInstead of the hack, introduce __resource_contains_unbound() for cases\nlike this.\n\nSigned-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>\n---\n include/linux/ioport.h | 20 +++++++++++++++++---\n kernel/resource.c      |  4 ++--\n 2 files changed, 19 insertions(+), 5 deletions(-)","diff":"diff --git a/include/linux/ioport.h b/include/linux/ioport.h\nindex 5533a5debf3f..19d5e04564d9 100644\n--- a/include/linux/ioport.h\n+++ b/include/linux/ioport.h\n@@ -304,14 +304,28 @@ static inline unsigned long resource_ext_type(const struct resource *res)\n {\n \treturn res->flags & IORESOURCE_EXT_TYPE_BITS;\n }\n-/* True iff r1 completely contains r2 */\n-static inline bool resource_contains(const struct resource *r1, const struct resource *r2)\n+\n+/*\n+ * For checking if @r1 completely contains @r2 for resources that have real\n+ * addresses but are not yet crafted into the resource tree. Normally\n+ * resource_contains() should be used instead of this function as it checks\n+ * also IORESOURCE_UNSET flag.\n+ */\n+static inline bool __resource_contains_unbound(const struct resource *r1,\n+\t\t\t\t\t       const struct resource *r2)\n {\n \tif (resource_type(r1) != resource_type(r2))\n \t\treturn false;\n+\n+\treturn r1->start <= r2->start && r1->end >= r2->end;\n+}\n+/* True iff r1 completely contains r2 */\n+static inline bool resource_contains(const struct resource *r1, const struct resource *r2)\n+{\n \tif (r1->flags & IORESOURCE_UNSET || r2->flags & IORESOURCE_UNSET)\n \t\treturn false;\n-\treturn r1->start <= r2->start && r1->end >= r2->end;\n+\n+\treturn __resource_contains_unbound(r1, r2);\n }\n \n /* True if any part of r1 overlaps r2 */\ndiff --git a/kernel/resource.c b/kernel/resource.c\nindex bb966699da31..1e2f1dfc0edd 100644\n--- a/kernel/resource.c\n+++ b/kernel/resource.c\n@@ -754,7 +754,7 @@ static int __find_resource_space(struct resource *root, struct resource *old,\n \t\t/* Check for overflow after ALIGN() */\n \t\tavail.start = ALIGN(tmp.start, constraint->align);\n \t\tavail.end = tmp.end;\n-\t\tavail.flags = new->flags & ~IORESOURCE_UNSET;\n+\t\tavail.flags = new->flags;\n \t\tif (avail.start >= tmp.start) {\n \t\t\talloc.flags = avail.flags;\n \t\t\tif (alignf) {\n@@ -765,7 +765,7 @@ static int __find_resource_space(struct resource *root, struct resource *old,\n \t\t\t}\n \t\t\talloc.end = alloc.start + size - 1;\n \t\t\tif (alloc.start <= alloc.end &&\n-\t\t\t    resource_contains(&avail, &alloc)) {\n+\t\t\t    __resource_contains_unbound(&avail, &alloc)) {\n \t\t\t\tnew->start = alloc.start;\n \t\t\t\tnew->end = alloc.end;\n \t\t\t\treturn 0;\n","prefixes":["01/10"]}