From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6E003FE643; Tue, 24 Mar 2026 16:58:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371522; cv=none; b=TM34RP+d0mYZAjsjyDUKhcRdN5jiVxyc8Xc/nVwMmtC/8aHwxQoGxWY3Xo6J8Kz5LhsQHvMgK2gdWuofEKpEeOP6lIv1lUMtT4ywgEmK+ADvZ7gHYNzn0WNLz4D7wfLraTyKGnPE+2jr/SdUeOqqladl9BQgJMbGi62xow8KcC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371522; c=relaxed/simple; bh=rU3n+FhgkyydByVdKs0lqSkLocKXu14IaAOX593F5w8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=QwTakeoK7U0YdOh4yFHH4cAHLGM69xpLBO4HphGtXwOZAQrBCLOuC27JPBXlFRJZFAt3FYeOKDCOwGg8Mk91RsRP72nrRuMUXKVcQmd/RjYadrdE7GnmEmXfeA4BB9+ekX9E6kTcS6t0V9gB70yerlhzCqwoYJYyBfmpLPu9q8w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=c/Cx3dv3; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="c/Cx3dv3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371521; x=1805907521; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rU3n+FhgkyydByVdKs0lqSkLocKXu14IaAOX593F5w8=; b=c/Cx3dv3Vz2/YJbekHvh+gD+WIP1CwyNuQ3q0MlWTGImDZiT1q5uRbVc 8bALhv9WRH2YI6Npjox5VxweEtizr6VeUqSCQGPI9tV9WRwXrQ1zza/8/ DZD+qQ8HedqBh24LsNLDc44P9DDOd2eFzXOFXpQlU3wRet3dnQGImnx/A QWjN1f6hkstl6XO4sFD0Hn0WMcpJ4Qk9XRk4id57U2nGqI0lvMsw+aS6k ZdkDBuammcrUGgQ50INjc/9hFh8UCB4L+koUWz1oInxxf1kGgNqKYoAfm DyAb/ZzbHxMOjwNlPDxK5ULEw2j5/9lg8vkem+s1IqsMlZipeNnSYQpNs A==; X-CSE-ConnectionGUID: uNh4kUZ4SX+tjgPF/ZVCZg== X-CSE-MsgGUID: 8vPySxbkRhqdU//0wy+muQ== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="86471560" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="86471560" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:58:40 -0700 X-CSE-ConnectionGUID: cUSLjl01TreRSEfKEtoT3A== X-CSE-MsgGUID: UG9hoz2GT3+u65rMjcqTqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="224421884" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:58:30 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 01/10] resource: Add __resource_contains_unbound() for 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable __find_resource_space() currently uses resource_contains() but for tentative resources that are not yet crafted into the resource tree. As resource_contains() checks that IORESOURCE_UNSET is not set for either of the resources, the caller has to hack around this problem by clearing the IORESOURCE_UNSET flag (essentially lying to resource_contains()). Instead of the hack, introduce __resource_contains_unbound() for cases like this. Signed-off-by: Ilpo J=C3=A4rvinen --- include/linux/ioport.h | 20 +++++++++++++++++--- kernel/resource.c | 4 ++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 5533a5debf3f..19d5e04564d9 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -304,14 +304,28 @@ static inline unsigned long resource_ext_type(const s= truct resource *res) { return res->flags & IORESOURCE_EXT_TYPE_BITS; } -/* True iff r1 completely contains r2 */ -static inline bool resource_contains(const struct resource *r1, const stru= ct resource *r2) + +/* + * For checking if @r1 completely contains @r2 for resources that have real + * addresses but are not yet crafted into the resource tree. Normally + * resource_contains() should be used instead of this function as it checks + * also IORESOURCE_UNSET flag. + */ +static inline bool __resource_contains_unbound(const struct resource *r1, + const struct resource *r2) { if (resource_type(r1) !=3D resource_type(r2)) return false; + + return r1->start <=3D r2->start && r1->end >=3D r2->end; +} +/* True iff r1 completely contains r2 */ +static inline bool resource_contains(const struct resource *r1, const stru= ct resource *r2) +{ if (r1->flags & IORESOURCE_UNSET || r2->flags & IORESOURCE_UNSET) return false; - return r1->start <=3D r2->start && r1->end >=3D r2->end; + + return __resource_contains_unbound(r1, r2); } =20 /* True if any part of r1 overlaps r2 */ diff --git a/kernel/resource.c b/kernel/resource.c index bb966699da31..1e2f1dfc0edd 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -754,7 +754,7 @@ static int __find_resource_space(struct resource *root,= struct resource *old, /* Check for overflow after ALIGN() */ avail.start =3D ALIGN(tmp.start, constraint->align); avail.end =3D tmp.end; - avail.flags =3D new->flags & ~IORESOURCE_UNSET; + avail.flags =3D new->flags; if (avail.start >=3D tmp.start) { alloc.flags =3D avail.flags; if (alignf) { @@ -765,7 +765,7 @@ static int __find_resource_space(struct resource *root,= struct resource *old, } alloc.end =3D alloc.start + size - 1; if (alloc.start <=3D alloc.end && - resource_contains(&avail, &alloc)) { + __resource_contains_unbound(&avail, &alloc)) { new->start =3D alloc.start; new->end =3D alloc.end; return 0; --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B44F7364044; Tue, 24 Mar 2026 16:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371548; cv=none; b=ZbwBLLmbm9ZQf/7/O/NzPIpSpxvJFgiLPIMBk5PbQmTdi62jX/+ooOL8ABxC3zPd8aREM+pFOjangQhPjINxvhWtBOES8H3mVAEm4N0UBQXbAXxiTF79O8jSGWxR4I/PfzvOrILkpXCbWwfxhIsQV2DXNAX3zqm1Psphf4J1/Wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371548; c=relaxed/simple; bh=WCR3Q80GUH+QkmAMmzfR2ddGucv9DgzL69WXspRX/jg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Ty+Lsgk8bDfe38Ijm0DCW59i87eReDJ/tD+y6Kfja8J1gK/+I92si/EXEhQCkjjji6q4y/Y+3jdBai69+zDRnwIk90rh2xSbNhi+JDwsKdYbaQH8NnW54NM7lk3n+gqVF2ai0mNyaJSW1qAu+yHNdD+uL+vHlUkj/SYJ0SdURnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HQQGzlch; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HQQGzlch" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371547; x=1805907547; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WCR3Q80GUH+QkmAMmzfR2ddGucv9DgzL69WXspRX/jg=; b=HQQGzlchPcReU4bpAPfEAG9HmWlOrv2ed3s2F3drHqt7R4ux8WQjalJH 7g+a2DvovYg7NIxq+6lfeQDVit61w1J2cG1xh1e7JU1w18xSbgB/6s6oT vBMq2z5hhCeB6zkqVeABaBoegJ8Mnb0nKbADZEGVyp6EMdS3EkvX6wJCP lSFjD9Ez/C+VC1zvabqLanVpZYud9rmG2o0i2NfcN7Cw2zXUGJ0L/SxIM hqsuY6qsUPXfheqcQGA1iv1YZAI8cFrajGeU76hMaxMy7rgV51/65CPFI dyUJh0/msTAXfK6dGoVdbV5YQWvhselEAnGSxczmzNnqOpo6HPoiT7Gxt g==; X-CSE-ConnectionGUID: PtaXiS0PSIynHKh3BPkKNw== X-CSE-MsgGUID: uxU80DllS261HL+9njNKVQ== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="86471700" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="86471700" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:59:06 -0700 X-CSE-ConnectionGUID: WtnV/loaRsCO4KMKean0ww== X-CSE-MsgGUID: ZxEF/K58SR25QVPpKDYMzA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="224666153" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:58:46 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Richard Henderson , Matt Turner , Magnus Lindholm , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , x86@kernel.org, Dominik Brodowski , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 02/10] resource: Pass full extent of empty space to resource_alignf CB Date: Tue, 24 Mar 2026 18:56:25 +0200 Message-Id: <20260324165633.4583-3-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable __find_resource_space() calculates the full extent of empty space but only passes the aligned space to resource_alignf callback. In some situations, the callback may choose take advantage of the free space before the requested alignment. Pass the full extent of the calculated empty space to resource_alignf callback as an additional parameter. Signed-off-by: Ilpo J=C3=A4rvinen --- arch/alpha/kernel/pci.c | 1 + arch/arm/kernel/bios32.c | 4 +++- arch/m68k/kernel/pcibios.c | 4 +++- arch/mips/pci/pci-generic.c | 3 ++- arch/mips/pci/pci-legacy.c | 1 + arch/parisc/kernel/pci.c | 4 +++- arch/powerpc/kernel/pci-common.c | 4 +++- arch/s390/pci/pci.c | 1 + arch/sh/drivers/pci/pci.c | 4 +++- arch/x86/pci/i386.c | 3 ++- arch/xtensa/kernel/pci.c | 1 + drivers/pci/setup-res.c | 3 ++- drivers/pcmcia/rsrc_nonstatic.c | 3 ++- include/linux/ioport.h | 2 ++ include/linux/pci.h | 7 ++++--- kernel/resource.c | 3 ++- 16 files changed, 35 insertions(+), 13 deletions(-) diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index 51a8a4c4572a..11df411b1d18 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c @@ -125,6 +125,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios= _fixup_final); =20 resource_size_t pcibios_align_resource(void *data, const struct resource *res, + const struct resource *empty_res, resource_size_t size, resource_size_t align) { struct pci_dev *dev =3D data; diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index b5793e8fbdc1..5b9b4fcd0e54 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -560,7 +560,9 @@ char * __init pcibios_setup(char *str) * which might be mirrored at 0x0100-0x03ff.. */ resource_size_t pcibios_align_resource(void *data, const struct resource *= res, - resource_size_t size, resource_size_t align) + const struct resource *empty_res, + resource_size_t size, + resource_size_t align) { struct pci_dev *dev =3D data; resource_size_t start =3D res->start; diff --git a/arch/m68k/kernel/pcibios.c b/arch/m68k/kernel/pcibios.c index e6ab3f9ff5d8..1415f6e4e5ce 100644 --- a/arch/m68k/kernel/pcibios.c +++ b/arch/m68k/kernel/pcibios.c @@ -27,7 +27,9 @@ * which might be mirrored at 0x0100-0x03ff.. */ resource_size_t pcibios_align_resource(void *data, const struct resource *= res, - resource_size_t size, resource_size_t align) + const struct resource *empty_res, + resource_size_t size, + resource_size_t align) { resource_size_t start =3D res->start; =20 diff --git a/arch/mips/pci/pci-generic.c b/arch/mips/pci/pci-generic.c index d2d68bac3d25..f4957c26efc7 100644 --- a/arch/mips/pci/pci-generic.c +++ b/arch/mips/pci/pci-generic.c @@ -22,7 +22,8 @@ * which might have be mirrored at 0x0100-0x03ff.. */ resource_size_t pcibios_align_resource(void *data, const struct resource *= res, - resource_size_t size, resource_size_t align) + const struct resource *empty_res, + resource_size_t size, resource_size_t align) { struct pci_dev *dev =3D data; resource_size_t start =3D res->start; diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c index d04b7c1294b6..817e97402afe 100644 --- a/arch/mips/pci/pci-legacy.c +++ b/arch/mips/pci/pci-legacy.c @@ -52,6 +52,7 @@ unsigned long pci_address_to_pio(phys_addr_t address) */ resource_size_t pcibios_align_resource(void *data, const struct resource *res, + const struct resource *empty_res, resource_size_t size, resource_size_t align) { struct pci_dev *dev =3D data; diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c index cf285b17a5ae..f99b20795d5a 100644 --- a/arch/parisc/kernel/pci.c +++ b/arch/parisc/kernel/pci.c @@ -196,7 +196,9 @@ void __ref pcibios_init_bridge(struct pci_dev *dev) * than res->start. */ resource_size_t pcibios_align_resource(void *data, const struct resource *= res, - resource_size_t size, resource_size_t alignment) + const struct resource *empty_res, + resource_size_t size, + resource_size_t alignment) { resource_size_t mask, align, start =3D res->start; =20 diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-com= mon.c index a7a2fb605971..e7bfa15da043 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1132,7 +1132,9 @@ static int skip_isa_ioresource_align(struct pci_dev *= dev) * which might have be mirrored at 0x0100-0x03ff.. */ resource_size_t pcibios_align_resource(void *data, const struct resource *= res, - resource_size_t size, resource_size_t align) + const struct resource *empty_res, + resource_size_t size, + resource_size_t align) { struct pci_dev *dev =3D data; resource_size_t start =3D res->start; diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 2a430722cbe4..39bd2adfc240 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -266,6 +266,7 @@ static int zpci_cfg_store(struct zpci_dev *zdev, int of= fset, u32 val, u8 len) } =20 resource_size_t pcibios_align_resource(void *data, const struct resource *= res, + const struct resource *empty_res, resource_size_t size, resource_size_t align) { diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index a3903304f33f..7a0522316ee3 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c @@ -168,7 +168,9 @@ subsys_initcall(pcibios_init); * modulo 0x400. */ resource_size_t pcibios_align_resource(void *data, const struct resource *= res, - resource_size_t size, resource_size_t align) + const struct resource *empty_res, + resource_size_t size, + resource_size_t align) { struct pci_dev *dev =3D data; struct pci_channel *hose =3D dev->sysdata; diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index c4ec39ad276b..6fbd4b34c3f7 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c @@ -153,7 +153,8 @@ skip_isa_ioresource_align(struct pci_dev *dev) { */ resource_size_t pcibios_align_resource(void *data, const struct resource *res, - resource_size_t size, resource_size_t align) + const struct resource *empty_res, + resource_size_t size, resource_size_t align) { struct pci_dev *dev =3D data; resource_size_t start =3D res->start; diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index 62c900e400d6..64ccb7e0d92f 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c @@ -39,6 +39,7 @@ */ resource_size_t pcibios_align_resource(void *data, const struct resource *res, + const struct resource *empty_res, resource_size_t size, resource_size_t align) { struct pci_dev *dev =3D data; diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index bb2aef373d6f..c375e255c509 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -251,10 +251,11 @@ static int pci_revert_fw_address(struct resource *res= , struct pci_dev *dev, */ resource_size_t __weak pcibios_align_resource(void *data, const struct resource *res, + const struct resource *empty_res, resource_size_t size, resource_size_t align) { - return res->start; + return res->start; } =20 static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstati= c.c index 0679dd434719..949e69921fe9 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -602,7 +602,8 @@ static resource_size_t pcmcia_common_align(struct pcmci= a_align_data *align_data, =20 static resource_size_t pcmcia_align(void *align_data, const struct resource *res, - resource_size_t size, resource_size_t align) + const struct resource *empty_res, + resource_size_t size, resource_size_t align) { struct pcmcia_align_data *data =3D align_data; struct resource_map *m; diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 19d5e04564d9..3c73c9c0d4f7 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -202,6 +202,7 @@ enum { * typedef resource_alignf - Resource alignment callback * @data: Private data used by the callback * @res: Resource candidate range (an empty resource space) + * @empty_res: Empty resource range without alignment applied * @size: The minimum size of the empty space * @align: Alignment from the constraints * @@ -212,6 +213,7 @@ enum { */ typedef resource_size_t (*resource_alignf)(void *data, const struct resource *res, + const struct resource *empty_res, resource_size_t size, resource_size_t align); =20 diff --git a/include/linux/pci.h b/include/linux/pci.h index 1c270f1d5123..ac332ff9da9f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1206,9 +1206,10 @@ int __must_check pcibios_enable_device(struct pci_de= v *, int mask); char *pcibios_setup(char *str); =20 /* Used only when drivers/pci/setup.c is used */ -resource_size_t pcibios_align_resource(void *, const struct resource *, - resource_size_t, - resource_size_t); +resource_size_t pcibios_align_resource(void *data, const struct resource *= res, + const struct resource *empty_res, + resource_size_t size, + resource_size_t align); =20 /* Generic PCI functions used internally */ =20 diff --git a/kernel/resource.c b/kernel/resource.c index 1e2f1dfc0edd..1b8d3101bdc6 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -759,7 +759,8 @@ static int __find_resource_space(struct resource *root,= struct resource *old, alloc.flags =3D avail.flags; if (alignf) { alloc.start =3D alignf(constraint->alignf_data, - &avail, size, constraint->align); + &avail, &tmp, + size, constraint->align); } else { alloc.start =3D avail.start; } --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 806BD3CF66F; Tue, 24 Mar 2026 16:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371559; cv=none; b=R7z0RlaN4f156EJHjfeMjs8WyFjVHYYl0izmldeH0xz+h0kN2Z1a0fbQ+ib3viBaKpf4sifGu23ovU2q36y9B2lGVGZ7HfevN+NA7qGoDEOUhmis6VhGtarJZFSSvyEWAyqphy8OtG75Jmbh5NbHTft7xSdLpaNMhKVVd7yO7GM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371559; c=relaxed/simple; bh=4wZaEWcRmOK6fFyQu8mcl48M7LLtMpZtBEYXsd1Cc4E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=kt/+STf+a1WULvdnJwY03JoezaC82Jp5YIwieGmBpZihTYhoOHFCMKmB8EyU7dmBBV+gO91gmYWQQAWVmTmSTl+EoW/gfm+wAgtCIb3L/bx22JkEdPsfg/iff6+nYgGKYga5LC6RMWY1E9d1SG+qCQQT+/QZuCJhOSE+ZGx9KZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JL9j3tQe; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JL9j3tQe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371558; x=1805907558; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4wZaEWcRmOK6fFyQu8mcl48M7LLtMpZtBEYXsd1Cc4E=; b=JL9j3tQeXBYC83en/T8KiQE9JJyUH+tYKOhXXjWWAS+oIoMIcgoLgo0W PQ8J1LtlYKISV4O7YW4/ZBAJLct0KS1Z5n33+LDGxT8qTDxPJ/zK75RFD 4Q3UCd0TwlbWJ4z5Q/sUv6+VUWa3Xv8xuxHm1hnJRTlnLpcZxk0cEfAtq lkw7v9Xlcb1JWazFzTGp0KurDx2USnkngF1b1Y6DgXdvqg53lVlYPkMCS XbtxgNWWfjWW8bznrWL16ZxYU3qxLOwG9lKtqEj7ilgD/My2dEzFsCQ4y qBALtZT9j0oKqDX4EM8Vxa9VIBnen6b1lzG9qJMUFdv5DeZsNK4U7H5Nh w==; X-CSE-ConnectionGUID: Vdv1ZBH0TvqJY+mk/TDCgQ== X-CSE-MsgGUID: GwDKocO1TBCQrsFLqMxLdw== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="86471757" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="86471757" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:59:17 -0700 X-CSE-ConnectionGUID: b26LCQzsTZi2fIETMNneag== X-CSE-MsgGUID: WA0Ub946SXOBfg0OV/eeeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="224666273" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:59:07 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 03/10] resource: Rename 'tmp' variable to 'full_avail' Date: Tue, 24 Mar 2026 18:56:26 +0200 Message-Id: <20260324165633.4583-4-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable __find_resource_space() has variable called 'tmp'. Rename it to 'full_avail' to better indicate its purpose. Signed-off-by: Ilpo J=C3=A4rvinen --- kernel/resource.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 1b8d3101bdc6..8c5fcb30fc33 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -727,39 +727,39 @@ static int __find_resource_space(struct resource *roo= t, struct resource *old, struct resource_constraint *constraint) { struct resource *this =3D root->child; - struct resource tmp =3D *new, avail, alloc; + struct resource full_avail =3D *new, avail, alloc; resource_alignf alignf =3D constraint->alignf; =20 - tmp.start =3D root->start; + full_avail.start =3D root->start; /* * Skip past an allocated resource that starts at 0, since the assignment - * of this->start - 1 to tmp->end below would cause an underflow. + * of this->start - 1 to full_avail->end below would cause an underflow. */ if (this && this->start =3D=3D root->start) { - tmp.start =3D (this =3D=3D old) ? old->start : this->end + 1; + full_avail.start =3D (this =3D=3D old) ? old->start : this->end + 1; this =3D this->sibling; } for(;;) { if (this) - tmp.end =3D (this =3D=3D old) ? this->end : this->start - 1; + full_avail.end =3D (this =3D=3D old) ? this->end : this->start - 1; else - tmp.end =3D root->end; + full_avail.end =3D root->end; =20 - if (tmp.end < tmp.start) + if (full_avail.end < full_avail.start) goto next; =20 - resource_clip(&tmp, constraint->min, constraint->max); - arch_remove_reservations(&tmp); + resource_clip(&full_avail, constraint->min, constraint->max); + arch_remove_reservations(&full_avail); =20 /* Check for overflow after ALIGN() */ - avail.start =3D ALIGN(tmp.start, constraint->align); - avail.end =3D tmp.end; + avail.start =3D ALIGN(full_avail.start, constraint->align); + avail.end =3D full_avail.end; avail.flags =3D new->flags; - if (avail.start >=3D tmp.start) { + if (avail.start >=3D full_avail.start) { alloc.flags =3D avail.flags; if (alignf) { alloc.start =3D alignf(constraint->alignf_data, - &avail, &tmp, + &avail, &full_avail, size, constraint->align); } else { alloc.start =3D avail.start; @@ -777,7 +777,7 @@ next: if (!this || this->end =3D=3D root->end) break; =20 if (this !=3D old) - tmp.start =3D this->end + 1; + full_avail.start =3D this->end + 1; this =3D this->sibling; } return -EBUSY; --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCF0736C581; Tue, 24 Mar 2026 16:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371579; cv=none; b=QJd4mjOMz/qe4Eal//vGTNexXX9h808t1Tc3DJ2W2DLxK4Jc9bxFEQbuFaX3wnFCWOPqNuOxkwL6I44O55WmmHaQSHBC2/zmGOi3vzPeYVtVCP+nXKLBs5ggq39zy7dSHkff+ud4CAF4SVcEb/tHMjqWuZyTFB91TsA3qZmZHy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371579; c=relaxed/simple; bh=cQi+TnP6KS0Xel2L1NUm1zOxuJkTQw+HXZFhNST/QpA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=f8lxFMe3jbVREaKgWfxjut9dyQWbdxyS7MseLjPxbhZvlLnck9RAUwqbyIYwk0MsKfxj19/Tq4EINambXiEUtdiXm+1ehBOnxYkjTEmaevsb7Lrw2T54zlqUqFmDx4C9xRG/eeCBTKMOE2ndCx16b92JvvoQqJDsXG4KQb9Uk/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ULyMssny; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ULyMssny" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371579; x=1805907579; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cQi+TnP6KS0Xel2L1NUm1zOxuJkTQw+HXZFhNST/QpA=; b=ULyMssnyIxA+WgYz4/xyz832bS6VnKyxuvu5Ok0+dNNVjR2RfyGrtrtU ed6PE3wEPeca+UVwF7mQuddaHj2rgoKRPOAoiytSqNDW5u/ES+fA4A3fk ZQl9hxSFfCmptk0j2A8Emh4mVsfgURFzUBmHxahq4pi5lztUmRUxWddDD 6iPhr4XVrpgAF82B7FSgR+0+OktAelLlig+1XpL6sWeZaUNwgUCh/YBME FYp4or+BoTRVWJClIjsI0b5mAtZ3S8vbtFkwdgppaVwS3nGAb6Adf8rfN yEfICABoO85WKD0JDO88L5dWvF2nESWlSMQlLr5dv3WfJ4jiAKYrOJ5li w==; X-CSE-ConnectionGUID: SFhs8CXTQguTB5+gxm3jhw== X-CSE-MsgGUID: bx5lfOLMQyKYRmnFnL2VBQ== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="79252739" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="79252739" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:59:34 -0700 X-CSE-ConnectionGUID: bklkz5swSMGrpU/gEbGm9Q== X-CSE-MsgGUID: DjRzhFV5Q9qVW8oMHuNG1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="228447839" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:59:22 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 04/10] ARM/PCI: Remove unnecessary second application of align Date: Tue, 24 Mar 2026 18:56:27 +0200 Message-Id: <20260324165633.4583-5-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Aligning res->start by align inside pcibios_align_resource() is unnecessary because caller of pcibios_align_resource() is __find_resource_space() that aligns res->start with align before calling pcibios_align_resource(). Aligning by align in case of IORESOURCE_IO && start & 0x300 cannot ever result in changing start either because 0x300 bits would have not survived the earlier alignment if align was large enough to have an impact. Thus, remove the duplicated aligning from pcibios_align_resource(). Signed-off-by: Ilpo J=C3=A4rvinen --- arch/arm/kernel/bios32.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 5b9b4fcd0e54..cedb83a85dd9 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -571,8 +571,6 @@ resource_size_t pcibios_align_resource(void *data, cons= t struct resource *res, if (res->flags & IORESOURCE_IO && start & 0x300) start =3D (start + 0x3ff) & ~0x3ff; =20 - start =3D (start + align - 1) & ~(align - 1); - host_bridge =3D pci_find_host_bridge(dev->bus); =20 if (host_bridge->align_resource) --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 872BE3909B2; Tue, 24 Mar 2026 16:59:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371595; cv=none; b=QNxh3VA4ErecsGi7NPRgdaoz35FzOWW48AJ7kp2uUYKudFU93a51PIScCKxUfa/4NIfuCZ3XwBJwk+KOjgkO8tyYREOB6y4JoXPGw9qB0+cxUqzOCClkgYR37HiUMRW/vngZvM0dllwFZLxAlh+q3UbPtr6C4gF3H1p0iE9kvUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371595; c=relaxed/simple; bh=1PkvXAZOx3orpMkb8PpUbgz2WR5NIQkeHlnghDGYLjQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=G4Iy0Jx3fjjt9t82sj3ZDlr6WtqAwY6UIyPjnfDtbRjjF5ao+4gSe36hYc23gHd4zCXRcMxxp3d1TMnDbR7qq1EksTnBXbHKvRwuOx/ZUUb8ZIzmb4Rqw47p6c9fEwkym/AxZQkpkAEYRZV+B97K2imJxCYP2+cCdjgwBvE1C1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JhwM3gmN; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JhwM3gmN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371593; x=1805907593; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1PkvXAZOx3orpMkb8PpUbgz2WR5NIQkeHlnghDGYLjQ=; b=JhwM3gmN6ni1u98M9Mnz8RO93EOabSJB/hIofQDq5V2d6PzqgRI77P9P 9LSx4wH8Z+M5l/srtHgwWUf9rjAPuRCK3tFrchxFFBGJnmMYHk5AB+FI9 44GjNUGFnk8ttCdiqOitVdApAsEmdrXQEww1bNKbut1UFXSYx0fDELXm1 rwwBT8DB4Y4gurFgDzEvqgOz44cGVhxx+q8KS2/FYfghkjF0e5FdXyhpq HwhhiCK1rjDPisT8PnbT8AUr6tbLpgVTzO1/js/jMc5f8weVcF2AP7NQS r3gdqsIV6WfZMTV5DTwuCNgGGC+dd4G6NSwHvnuBCqQEubMQIcxG6bIk8 Q==; X-CSE-ConnectionGUID: 7GrSIIJ8SemxCIvk181etg== X-CSE-MsgGUID: yCHLhH+4S8GxZVDaWT15Xw== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="79252781" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="79252781" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:59:52 -0700 X-CSE-ConnectionGUID: lSvW+pYLTSuPFRVG7+1ISg== X-CSE-MsgGUID: iJA4o6fzRaW9L3ZwLnjXfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="228447959" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:59:38 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 05/10] am68k/PCI: Remove unnecessary second application of align Date: Tue, 24 Mar 2026 18:56:28 +0200 Message-Id: <20260324165633.4583-6-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Aligning res->start by align inside pcibios_align_resource() is unnecessary because caller of pcibios_align_resource() is __find_resource_space() that aligns res->start with align before calling pcibios_align_resource(). Aligning by align in case of IORESOURCE_IO && start & 0x300 cannot ever result in changing start either because 0x300 bits would have not survived the earlier alignment if align was large enough to have an impact. Thus, remove the duplicated aligning from pcibios_align_resource(). Signed-off-by: Ilpo J=C3=A4rvinen Acked-by: Greg Ungerer --- arch/m68k/kernel/pcibios.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/m68k/kernel/pcibios.c b/arch/m68k/kernel/pcibios.c index 1415f6e4e5ce..7e286ee1976b 100644 --- a/arch/m68k/kernel/pcibios.c +++ b/arch/m68k/kernel/pcibios.c @@ -36,8 +36,6 @@ resource_size_t pcibios_align_resource(void *data, const = struct resource *res, if ((res->flags & IORESOURCE_IO) && (start & 0x300)) start =3D (start + 0x3ff) & ~0x3ff; =20 - start =3D (start + align - 1) & ~(align - 1); - return start; } =20 --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD62F38911B; Tue, 24 Mar 2026 17:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371609; cv=none; b=o39a7TtOj6yNGmFrGp0BDv7MmujKcOOFjaAo3LRafuPVE6TPLEaXRWyn4A7jg+vNVz+WHVGjcOmPWp4BNwziMYqkHCjTJ3w5sgrHWZMaP/A7yJWDRSA9YS9lA2tvLDfzRjfynVRbkck/nhQf9x8PUfqNU7rwt4AJfANGAu8BNtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371609; c=relaxed/simple; bh=9hvV8PDAdyGkHU10me7VyjfjKt6p0yD22QH58KrfakU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=SWdnOF9MjhNyx/v4Vn+o8GGnuxvhCG64XirlpMWGX6sOQ0UE44yyQR5Ue2D+Yg83/jF3HydXITG2dCpN44C54GtxDfKKYuTUXGCEVhsyDNWwz05zRRu8UbRlNm/bE6saylOFJXvBbUKlN27qvCd4UCO5TGoE75mxmLb3jHGqmCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gpEHST9P; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gpEHST9P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371607; x=1805907607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9hvV8PDAdyGkHU10me7VyjfjKt6p0yD22QH58KrfakU=; b=gpEHST9P1UugeaS32z4rzTOOKQ9kQj4bIIQ7osxvVXJxWCmJ9ddnBqSp H9E8F2CV5VUEmNyesdo3O4RNI4sgeGnoI+7QP2aaJjoyPVY+We+FXuLmt 7+gLB87ce3pnwfGQ51eaBGeg1yn8j4MJS/7ruQ0Im3YaHVEA8n4ujALmD 1NS3qMdWW/H6yx9O7+Q8GIrBbhCBzqIDCRm+HDJ0J35jFdHh9Vo+IK2LI FPn0XXe/WImSbsCSIu3UtlqPMKxs2C8BEVxjEILdnAVr0DpcM3Wb5//9r sjpapG5eGao8ltTti4DPhqKFhvgV2oJzIUgwVgLFqOX182Ycx01Z31hqF g==; X-CSE-ConnectionGUID: LSgROxn/Tsi1yLyFZVyL3w== X-CSE-MsgGUID: YKVnB93wRB6HsX9nY4ouZw== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="75281401" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="75281401" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:00:06 -0700 X-CSE-ConnectionGUID: ZabKv/GtRfqHh4rMbY+IrQ== X-CSE-MsgGUID: KjVhSRgDSkWdd+eayrpYDg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="219540084" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 09:59:57 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 06/10] MIPS: PCI: Remove unnecessary second application of align Date: Tue, 24 Mar 2026 18:56:29 +0200 Message-Id: <20260324165633.4583-7-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Aligning res->start by align inside pcibios_align_resource() is unnecessary because caller of pcibios_align_resource() is __find_resource_space() that aligns res->start with align before calling pcibios_align_resource(). Aligning by align in case of IORESOURCE_IO && start & 0x300 cannot ever result in changing start either because 0x300 bits would have not survived the earlier alignment if align was large enough to have an impact. Thus, remove the duplicated aligning from pcibios_align_resource(). Signed-off-by: Ilpo J=C3=A4rvinen --- arch/mips/pci/pci-generic.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/mips/pci/pci-generic.c b/arch/mips/pci/pci-generic.c index f4957c26efc7..aaa1d6de8bef 100644 --- a/arch/mips/pci/pci-generic.c +++ b/arch/mips/pci/pci-generic.c @@ -32,8 +32,6 @@ resource_size_t pcibios_align_resource(void *data, const = struct resource *res, if (res->flags & IORESOURCE_IO && start & 0x300) start =3D (start + 0x3ff) & ~0x3ff; =20 - start =3D (start + align - 1) & ~(align - 1); - host_bridge =3D pci_find_host_bridge(dev->bus); =20 if (host_bridge->align_resource) --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 792F3391E7E; Tue, 24 Mar 2026 17:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371622; cv=none; b=DYzFqj+MiubjNr7ReBhFREq0VWFMcYtxn5FvjFmUeY1SAZvxP0j2J0Wd/TyFDE/vvuFN2d2UAsDeguQ88h6Lk01XKxH/5x5GpYE6cBpKwggLZ6bjG1A/MStuXRT46mgBoqo3lJHTaMJ5HGIIqZlydFfjiYCAY326Wf5jwyHwTdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371622; c=relaxed/simple; bh=d6KLxSDgRcKiLzDY+NMiMRY2jmIC2rw/9NmZTIuAx/o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=n3MSQxt+FutHshNqorQJz00/UHDu/9KJCTeObK3XpLts6o7QrXXERdY+Fy0nEMtPdJpecMDz/sefyzEt1AmZIL9NVOzsfOpea0jAYbzvZMBtQD4RFqQd10ZSoVE9L4E9mo7ceOvp/DG0VcY28y+uSiqjv+QNbd796Z6Zr265lXo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jBzXgPUR; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jBzXgPUR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371620; x=1805907620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d6KLxSDgRcKiLzDY+NMiMRY2jmIC2rw/9NmZTIuAx/o=; b=jBzXgPUR0QtWYycsjVLpDEUrOCItsFVArtlgUN6FA6YG2yoXW0dqxawJ jLuXUTLNI9fj21Z7kshsLHqAAmiTCq4GP+q3J5vvh809C4L8hUBa4d+Wc 0am6j7Rr8D0i/PgLOPWsnxPiQBJnyWBLBI5TXG25rs85bg6DlTW9iqE/q zhd/bHo0ZvpcWDvsFmKP5F67EkJriuJY8P/EcoQo4+7ewTFB1TawVLtNy MIlm6robS/dgLFkLWltLQh0+lk7FiXSGjMqv7PykvT4kByKnijsu66CG3 6s7KQJTN6X0Lur2H/w4M+OAtoImSHzxnNDbrBzQttbrgoKj+Tpupjz9yl Q==; X-CSE-ConnectionGUID: F1CyYZZqSC+xZFXs0ca8bg== X-CSE-MsgGUID: 9nh59SSPRESai79d3MTEMA== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="75281439" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="75281439" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:00:18 -0700 X-CSE-ConnectionGUID: ib4xzWKRSNm/cm3wyP1vbg== X-CSE-MsgGUID: WCv5QcPyT7OGGuY23A4d9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="219540242" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:00:10 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 07/10] parisc/PCI: Cleanup align handling Date: Tue, 24 Mar 2026 18:56:30 +0200 Message-Id: <20260324165633.4583-8-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Caller of pcibios_align_resource() (__find_resource_space()) already aligns the start address by 'alignment' so aligning is only necessary if align > alignment. Change also to use ALIGN() instead of open-coding. Signed-off-by: Ilpo J=C3=A4rvinen --- arch/parisc/kernel/pci.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c index f99b20795d5a..f50be1a63c4c 100644 --- a/arch/parisc/kernel/pci.c +++ b/arch/parisc/kernel/pci.c @@ -8,6 +8,7 @@ * Copyright (C) 1999-2001 Hewlett-Packard Company * Copyright (C) 1999-2001 Grant Grundler */ +#include #include #include #include @@ -200,7 +201,7 @@ resource_size_t pcibios_align_resource(void *data, cons= t struct resource *res, resource_size_t size, resource_size_t alignment) { - resource_size_t mask, align, start =3D res->start; + resource_size_t align, start =3D res->start; =20 DBG_RES("pcibios_align_resource(%s, (%p) [%lx,%lx]/%x, 0x%lx, 0x%lx)\n", pci_name(((struct pci_dev *) data)), @@ -209,11 +210,8 @@ resource_size_t pcibios_align_resource(void *data, con= st struct resource *res, =20 /* If it's not IO, then it's gotta be MEM */ align =3D (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM; - - /* Align to largest of MIN or input size */ - mask =3D max(alignment, align) - 1; - start +=3D mask; - start &=3D ~mask; + if (align > alignment) + start =3D ALIGN(start, align); =20 return start; } --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5617123C8AE; Tue, 24 Mar 2026 17:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371634; cv=none; b=Jd12nuJjdqPDvgogp59/8tBggqJMQYUv/16zN5+uNnTE80rwt56YDjpv6lQb1S2zflJukHtlErE0Vmgqn3fTZg2LxU+974dFag0iY3hnXOUN2M8/P/YWU7OiKo5Hm2yGvAyWyJggpKuA9hEuk+lmvfnu191nA81miOJ4dM2Hac0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371634; c=relaxed/simple; bh=yRiNPjyR6BmckrFz9yS55d2yQZU16Z4uT3UMgBowpHk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ejn578OaF6JP8coUZEk1Wzq1NqYhGdkRCdg5x5TmJ/vBlg/iAAL6aRUlcryEX2qUWtB0fTK+9bZppr8fE024llnfF5JrcYVk3C3p2kWpmQa15LXODaBBN/uY3KPYj/aNP9gC9EpyhB19hFcacfjyln+Cg7BdVR+aDg2EE3abmVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XVu7atom; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XVu7atom" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371632; x=1805907632; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yRiNPjyR6BmckrFz9yS55d2yQZU16Z4uT3UMgBowpHk=; b=XVu7atomGqeRQ/mCvdsKBuOQqnS1A97ZFHQ5puo3JRTcIwdzrp5Yr2Rd jj1ETPgCNbjE6BE79nJ3C7Zaa+z4mSwmDHFYxZRmzrp2mpbO4Cu3Qt/yD vJJiRCY2WGxFF2yToGAcCqMXJn0mooQi9q830Eh2W/9dyTmG97j3QNmRd mzE6F3SHc1fSTFh0U4wYdOQ1jinn5Iw0QBTFOWxePvgJJAl/rtzmYuJKM jDxSMumIEEoe+9e1PoNoEwc9Sqib5SCOCiOVH3nSToaOEA2SziPRnnnZT hG7orP7S4succId+dkQnlq9tlZ16Uzf2dP8dFFiFg03yoXx6YLJepcJZr A==; X-CSE-ConnectionGUID: 0aj1QaDoTeiUONUsc8/J8Q== X-CSE-MsgGUID: MXAYKiVpSQOuiLrr6n22vw== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="75281459" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="75281459" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:00:31 -0700 X-CSE-ConnectionGUID: NHjFhTG1RYO9C2glveQ6yA== X-CSE-MsgGUID: hhyUW1HYQmiP63jGpn9/jA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="219540299" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:00:22 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 08/10] PCI: Rename window_alignment() to pci_min_window_alignment() Date: Tue, 24 Mar 2026 18:56:31 +0200 Message-Id: <20260324165633.4583-9-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable window_alignment() lacks prefix. Rename it to pci_min_window_alignment() in order to include the prefix and also add min to indicate the returned window alignment is the minimum PCI spec and arch allows. Also make it available in drivers/pci/pci.h as upcoming changes will need to call it from outside of setup-bus.c. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/pci.h | 3 +++ drivers/pci/setup-bus.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 13d998fbacce..2edb03c1c6b9 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1053,6 +1053,9 @@ static inline resource_size_t pci_resource_alignment(= struct pci_dev *dev, return resource_alignment(res); } =20 +resource_size_t pci_min_window_alignment(struct pci_bus *bus, + unsigned long type); + void pci_acs_init(struct pci_dev *dev); void pci_enable_acs(struct pci_dev *dev); #ifdef CONFIG_PCI_QUIRKS diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 61f769aaa2f6..edc0d682dcad 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1035,7 +1035,7 @@ resource_size_t __weak pcibios_window_alignment(struc= t pci_bus *bus, #define PCI_P2P_DEFAULT_IO_ALIGN SZ_4K #define PCI_P2P_DEFAULT_IO_ALIGN_1K SZ_1K =20 -static resource_size_t window_alignment(struct pci_bus *bus, unsigned long= type) +resource_size_t pci_min_window_alignment(struct pci_bus *bus, unsigned lon= g type) { resource_size_t align =3D 1, arch_align; =20 @@ -1084,7 +1084,7 @@ static void pbus_size_io(struct pci_bus *bus, resourc= e_size_t add_size, if (resource_assigned(b_res)) return; =20 - min_align =3D window_alignment(bus, IORESOURCE_IO); + min_align =3D pci_min_window_alignment(bus, IORESOURCE_IO); list_for_each_entry(dev, &bus->devices, bus_list) { struct resource *r; =20 @@ -1339,7 +1339,7 @@ static void pbus_size_mem(struct pci_bus *bus, struct= resource *b_res, } } =20 - win_align =3D window_alignment(bus, b_res->flags); + win_align =3D pci_min_window_alignment(bus, b_res->flags); min_align =3D calculate_head_align(aligns, max_order); min_align =3D max(min_align, win_align); size0 =3D calculate_memsize(size, realloc_head ? 0 : add_size, --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74CE01EDA0F; Tue, 24 Mar 2026 17:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371648; cv=none; b=p+B9qUp1jPndyUHtnLcbKz31urNSJrCtPnAw+bJKeYf6o1KKyeqWAC53g8m6iMHpb1ybKy4MECVv11hSF/dWTRpavP5kfx5uwL63/KsBwO4sxqeDyF39qIZz+VWIbNZLQxYA2gq5beA6QTtt6jXnO5DZAXkp5LEPD68s94PbH44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371648; c=relaxed/simple; bh=vNoPxtdd4BxfeIP2GD5+Lm5ztZ/3WHvkEpVD97Kr7m4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=t2XYQbxlFjXCuh9ejitTZJiQCkNfEViZzRXPdXWP7LmAucq39jhQIg7Sndqd0LTU8OFj3BJeIIdi4MbE3EyYl6gQokKb6yLYXPq3f8n05Tl4N/rkImHYx9qzm22WvQkooi971k1vVZTtrjk2C3LA4mV0BguH/r0B2hYPrtBfIlw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PDOHWd0E; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PDOHWd0E" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371648; x=1805907648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vNoPxtdd4BxfeIP2GD5+Lm5ztZ/3WHvkEpVD97Kr7m4=; b=PDOHWd0EgL0oFptiRK/XV8jZkc8TAiQaOZH1S8jTPufKxamvqoT6QrM5 9+NNFB+xT7WQPB5lNQ7jtMK1PCeGFy5fRgAbXeAB5DTT0ytgvBomxv9DK /VDoISB/PgT2FHxDb9RMRjGI89RIJKK8HoouI95behp1KjphtqhHMHZKs NR5p+xulHPNEBVI3PEkdzodFY6VOU8Gx6Bm5rEMpuU+YeddSKAVgmFiIS 1BJg81q0YWIMB0iYZESF3K4vmHV3SdGnT4RSfdLXm1Lw7YImEO4PiTwKH ZonUQLRV6Ixjkkse2/Pxc9VdwS9Cu6NMlJ/eRhjdEpUAeVPQzYF7kpyKe A==; X-CSE-ConnectionGUID: Di+zoJbJRfKnDeeVvvMpOA== X-CSE-MsgGUID: 3J/avPsXRuux0gWRx3Qihg== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="78991782" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="78991782" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:00:46 -0700 X-CSE-ConnectionGUID: ApYT6ADHR4inoKAd9O076A== X-CSE-MsgGUID: yzqK2g13S9m6CJEqxk0sPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="254911560" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:00:37 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , x86@kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 09/10] PCI: Align head space better Date: Tue, 24 Mar 2026 18:56:32 +0200 Message-Id: <20260324165633.4583-10-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable When a bridge window contains big and small resource(s), the small resource(s) may not amount to the half of the size of the big resource which would allow calculate_head_align() to shrink the head alignment. This results in always placing the small resource(s) after the big resource. In general, it would be good to be able to place the small resource(s) before the big resource to achieve better utilization of the address space. In the cases where the large resource can only fit at the end of the window, it is even required. However, carrying the information over from pbus_size_mem() and calculate_head_align() to __pci_assign_resource() and pcibios_align_resource() is not easy with the current data structures. A somewhat hacky way to move the non-aligning tail part to the head is possible within pcibios_align_resource(). The free space between the start of the free space span and the aligned start address can be compared with the non-aligning remainder of the size. If the free space is larger than the remainder, placing the remainder before the start address is possible. This relocation should generally work, because PCI resources consist only power-of-2 atoms. Various arch requirements may still need to override the relocation, so the relocation is only applied selectively in such cases. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D221205 Signed-off-by: Ilpo J=C3=A4rvinen --- arch/arm/kernel/bios32.c | 3 +++ arch/m68k/kernel/pcibios.c | 4 ++++ arch/mips/pci/pci-generic.c | 3 +++ arch/mips/pci/pci-legacy.c | 2 ++ arch/parisc/kernel/pci.c | 3 +++ arch/powerpc/kernel/pci-common.c | 2 ++ arch/sh/drivers/pci/pci.c | 2 ++ arch/x86/pci/i386.c | 2 ++ arch/xtensa/kernel/pci.c | 2 ++ drivers/pci/setup-res.c | 39 +++++++++++++++++++++++++++++++- include/linux/pci.h | 5 ++++ kernel/resource.c | 2 +- 12 files changed, 67 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index cedb83a85dd9..ac0e890510da 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -577,6 +577,9 @@ resource_size_t pcibios_align_resource(void *data, cons= t struct resource *res, return host_bridge->align_resource(dev, res, start, size, align); =20 + if (res->flags & IORESOURCE_MEM) + return pci_align_resource(dev, res, empty_res, size, align); + return start; } =20 diff --git a/arch/m68k/kernel/pcibios.c b/arch/m68k/kernel/pcibios.c index 7e286ee1976b..7a9e60df79c5 100644 --- a/arch/m68k/kernel/pcibios.c +++ b/arch/m68k/kernel/pcibios.c @@ -31,11 +31,15 @@ resource_size_t pcibios_align_resource(void *data, cons= t struct resource *res, resource_size_t size, resource_size_t align) { + struct pci_dev *dev =3D data; resource_size_t start =3D res->start; =20 if ((res->flags & IORESOURCE_IO) && (start & 0x300)) start =3D (start + 0x3ff) & ~0x3ff; =20 + if (res->flags & IORESOURCE_MEM) + return pci_align_resource(dev, res, empty_res, size, align); + return start; } =20 diff --git a/arch/mips/pci/pci-generic.c b/arch/mips/pci/pci-generic.c index aaa1d6de8bef..c2e23d0c1d77 100644 --- a/arch/mips/pci/pci-generic.c +++ b/arch/mips/pci/pci-generic.c @@ -38,6 +38,9 @@ resource_size_t pcibios_align_resource(void *data, const = struct resource *res, return host_bridge->align_resource(dev, res, start, size, align); =20 + if (res->flags & IORESOURCE_MEM) + return pci_align_resource(dev, res, empty_res, size, align); + return start; } =20 diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c index 817e97402afe..dae6dafdd6e0 100644 --- a/arch/mips/pci/pci-legacy.c +++ b/arch/mips/pci/pci-legacy.c @@ -70,6 +70,8 @@ pcibios_align_resource(void *data, const struct resource = *res, if (start & 0x300) start =3D (start + 0x3ff) & ~0x3ff; } else if (res->flags & IORESOURCE_MEM) { + start =3D pci_align_resource(dev, res, empty_res, size, align); + /* Make sure we start at our min on all hoses */ if (start < PCIBIOS_MIN_MEM + hose->mem_resource->start) start =3D PCIBIOS_MIN_MEM + hose->mem_resource->start; diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c index f50be1a63c4c..b8007c7400d4 100644 --- a/arch/parisc/kernel/pci.c +++ b/arch/parisc/kernel/pci.c @@ -201,6 +201,7 @@ resource_size_t pcibios_align_resource(void *data, cons= t struct resource *res, resource_size_t size, resource_size_t alignment) { + struct pci_dev *dev =3D data; resource_size_t align, start =3D res->start; =20 DBG_RES("pcibios_align_resource(%s, (%p) [%lx,%lx]/%x, 0x%lx, 0x%lx)\n", @@ -212,6 +213,8 @@ resource_size_t pcibios_align_resource(void *data, cons= t struct resource *res, align =3D (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM; if (align > alignment) start =3D ALIGN(start, align); + else + start =3D pci_align_resource(dev, res, empty_res, size, alignment); =20 return start; } diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-com= mon.c index e7bfa15da043..8efe95a0c4ff 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1144,6 +1144,8 @@ resource_size_t pcibios_align_resource(void *data, co= nst struct resource *res, return start; if (start & 0x300) start =3D (start + 0x3ff) & ~0x3ff; + } else if (res->flags & IORESOURCE_MEM) { + start =3D pci_align_resource(dev, res, empty_res, size, align); } =20 return start; diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index 7a0522316ee3..994c3bd36ef2 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c @@ -185,6 +185,8 @@ resource_size_t pcibios_align_resource(void *data, cons= t struct resource *res, */ if (start & 0x300) start =3D (start + 0x3ff) & ~0x3ff; + } else (res->flags & IORESOURCE_MEM) { + start =3D pci_align_resource(dev, res, empty_res, size, align); } =20 return start; diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 6fbd4b34c3f7..e2de26b82940 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c @@ -165,6 +165,8 @@ pcibios_align_resource(void *data, const struct resourc= e *res, if (start & 0x300) start =3D (start + 0x3ff) & ~0x3ff; } else if (res->flags & IORESOURCE_MEM) { + start =3D pci_align_resource(dev, res, empty_res, size, align); + /* The low 1MB range is reserved for ISA cards */ if (start < BIOS_END) start =3D BIOS_END; diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index 64ccb7e0d92f..305031551136 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c @@ -54,6 +54,8 @@ pcibios_align_resource(void *data, const struct resource = *res, =20 if (start & 0x300) start =3D (start + 0x3ff) & ~0x3ff; + } else if (res->flags & IORESOURCE_MEM) { + start =3D pci_align_resource(dev, res, empty_res, size, align); } =20 return start; diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index c375e255c509..fbc05cda96ee 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -244,6 +244,41 @@ static int pci_revert_fw_address(struct resource *res,= struct pci_dev *dev, return 0; } =20 +/* + * For mem bridge windows, try to relocate tail remainder space to space + * before res->start if there's enough free space there. This enables + * tighter packing for resources. + */ +resource_size_t pci_align_resource(struct pci_dev *dev, + const struct resource *res, + const struct resource *empty_res, + resource_size_t size, + resource_size_t align) +{ + resource_size_t remainder, start_addr; + + if (!(res->flags & IORESOURCE_MEM)) + return res->start; + + if (IS_ALIGNED(size, align)) + return res->start; + + remainder =3D size - ALIGN_DOWN(size, align); + /* Don't mess with size that doesn't align with window size granularity */ + if (!IS_ALIGNED(remainder, pci_min_window_alignment(dev->bus, res->flags)= )) + return res->start; + /* Try to place remainder that doesn't fill align before */ + if (res->start < remainder) + return res->start; + start_addr =3D res->start - remainder; + if (empty_res->start > start_addr) + return res->start; + + pci_dbg(dev, "%pR: moving candidate start address below align to %llx\n", + res, (unsigned long long)start_addr); + return start_addr; +} + /* * We don't have to worry about legacy ISA devices, so nothing to do here. * This is marked as __weak because multiple architectures define it; it s= hould @@ -255,7 +290,9 @@ resource_size_t __weak pcibios_align_resource(void *dat= a, resource_size_t size, resource_size_t align) { - return res->start; + struct pci_dev *dev =3D data; + + return pci_align_resource(dev, res, empty_res, size, align); } =20 static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, diff --git a/include/linux/pci.h b/include/linux/pci.h index ac332ff9da9f..cedf948dc614 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1210,6 +1210,11 @@ resource_size_t pcibios_align_resource(void *data, c= onst struct resource *res, const struct resource *empty_res, resource_size_t size, resource_size_t align); +resource_size_t pci_align_resource(struct pci_dev *dev, + const struct resource *res, + const struct resource *empty_res, + resource_size_t size, + resource_size_t align); =20 /* Generic PCI functions used internally */ =20 diff --git a/kernel/resource.c b/kernel/resource.c index 8c5fcb30fc33..d02a53fb95d8 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -766,7 +766,7 @@ static int __find_resource_space(struct resource *root,= struct resource *old, } alloc.end =3D alloc.start + size - 1; if (alloc.start <=3D alloc.end && - __resource_contains_unbound(&avail, &alloc)) { + __resource_contains_unbound(&full_avail, &alloc)) { new->start =3D alloc.start; new->end =3D alloc.end; return 0; --=20 2.39.5 From nobody Sun Apr 5 13:24:04 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F23973115B8; Tue, 24 Mar 2026 17:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371662; cv=none; b=bdnoWWxeXrQzt1FN4n6Qndyco4N/QXkAQ2BP35KTCd5BBQvcbHhTvjdft59uPy42y/+55aEpXGWHe7i4nnBZjCS+cj6qViT7oAtNxZyylUszwaCM5ycpzrGNHc5A12GWIjWoLIMnMDbEhlUPxXxoK+5tjWkyMMX46tSqGZhUfQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774371662; c=relaxed/simple; bh=9odwDAEObJO7qnios8NXzgvO+dTMZAcsFe/K0R+E/MA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=dz8buy6NrMvHEuJeaMG8i6+QpWlF0/o6n8B84FoaHtEp+7dfVzE1GQ9OPZR5klMjQ0Pa9dAJDP2hANhrA8/FExiAxUy6lyIMT5vUrF4bAxeLye95fm03bNbtWLGdHMkRwP2wVxBezDJ3upc0Yzgk/c+DuSMN6YdghNt2ykUrl0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fdPQijol; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fdPQijol" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774371661; x=1805907661; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=9odwDAEObJO7qnios8NXzgvO+dTMZAcsFe/K0R+E/MA=; b=fdPQijolZkoXol/SJjY9hE/6J/JsbNRtcOlCVyTorpTSwk4ilWQf/TaX 4rD2fvqdo6LKiW1t0Ty2ARTtwmKUFFD1y9oK+dgYErHx0/omftpHJ2FBa yeAnTfR/4k0PCTtuiQyrSyECYD1njslGbXRuD+Z1mi8o52J5MQFiGbFUt +oGJGI9yreoxBbMHs2sZJQX3IS4lBsPpht/SuXgnj4otysdvjWy+9wJ/y rOKglWHDPFh0d4OQy7klkNmLT+VjCeNuP1YBnsCGGuZo8dSKDzf7HXgR4 yhhKnAi21Wt8b6VceHySmB9X0jsoCI91T4JqBQQS/cNuomStObv3HvCld Q==; X-CSE-ConnectionGUID: B8fCFw4oTI2UOKipbgp4Yg== X-CSE-MsgGUID: fq/wCFxbR5i90z+MO4XFWw== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="78991839" X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="78991839" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:01:00 -0700 X-CSE-ConnectionGUID: hHMisBSDR/+i1mWAm9Fh8g== X-CSE-MsgGUID: e4f6sgI4SzaAnXpv3WumJQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,138,1770624000"; d="scan'208";a="254912161" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.217]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2026 10:00:51 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Guenter Roeck , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, Russell King , Geert Uytterhoeven , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Chris Zankel , Max Filippov , Madhavan Srinivasan , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , linux-kernel@vger.kernel.org Subject: [PATCH 10/10] PCI: Fix alignment calculation for resource size larger than align Date: Tue, 24 Mar 2026 18:56:33 +0200 Message-Id: <20260324165633.4583-11-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The commit bc75c8e50711 ("PCI: Rewrite bridge window head alignment function") did not use if (r_size <=3D align) check from pbus_size_mem() for the new head alignment bookkeeping structure (aligns2[]). In some configurations, this can result in producing a gap into the bridge window which the resource larger than its alignment cannot fill. The old alignment calculation algorithm was removed by the subsequent commit 3958bf16e2fe ("PCI: Stop over-estimating bridge window size") which renamed the aligns2[] array leaving only aligns[] array. Add the if (r_size <=3D align) check back to avoid this problem. Fixes: bc75c8e50711 ("PCI: Rewrite bridge window head alignment function") Closes: https://lore.kernel.org/all/b05a6f14-979d-42c9-924c-d8408cb12ae7@ro= eck-us.net/ Reported-by: Guenter Roeck Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/setup-bus.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index edc0d682dcad..e5af8799c36f 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1333,7 +1333,14 @@ static void pbus_size_mem(struct pci_bus *bus, struc= t resource *b_res, r_size =3D resource_size(r); size +=3D max(r_size, align); =20 - aligns[order] +=3D align; + /* + * If resource's size is larger than its alignment, + * some configurations result in an unwanted gap in + * the head space that the larger resource cannot + * fill. + */ + if (r_size <=3D align) + aligns[order] +=3D align; if (order > max_order) max_order =3D order; } --=20 2.39.5