[{"id":3669041,"web_url":"http://patchwork.ozlabs.org/comment/3669041/","msgid":"<3a51ad39-558f-860d-4920-9f757b7d5131@linux.intel.com>","date":"2026-03-25T12:04:03","subject":"Re: [PATCH 09/10] PCI: Align head space better","submitter":{"id":83553,"url":"http://patchwork.ozlabs.org/api/people/83553/","name":"Ilpo Järvinen","email":"ilpo.jarvinen@linux.intel.com"},"content":"On Tue, 24 Mar 2026, Ilpo Järvinen wrote:\n\n> When a bridge window contains big and small resource(s), the small\n> resource(s) may not amount to the half of the size of the big resource\n> which would allow calculate_head_align() to shrink the head alignment.\n> This results in always placing the small resource(s) after the big\n> resource.\n> \n> In general, it would be good to be able to place the small resource(s)\n> before the big resource to achieve better utilization of the address\n> space. In the cases where the large resource can only fit at the end\n> of the window, it is even required.\n> \n> However, carrying the information over from pbus_size_mem() and\n> calculate_head_align() to __pci_assign_resource() and\n> pcibios_align_resource() is not easy with the current data structures.\n> \n> A somewhat hacky way to move the non-aligning tail part to the head is\n> possible within pcibios_align_resource(). The free space between the\n> start of the free space span and the aligned start address can be\n> compared with the non-aligning remainder of the size. If the free space\n> is larger than the remainder, placing the remainder before the start\n> address is possible. This relocation should generally work, because PCI\n> resources consist only power-of-2 atoms.\n> \n> Various arch requirements may still need to override the relocation, so\n> the relocation is only applied selectively in such cases.\n> \n> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221205\n> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>\n> ---\n>  arch/arm/kernel/bios32.c         |  3 +++\n>  arch/m68k/kernel/pcibios.c       |  4 ++++\n>  arch/mips/pci/pci-generic.c      |  3 +++\n>  arch/mips/pci/pci-legacy.c       |  2 ++\n>  arch/parisc/kernel/pci.c         |  3 +++\n>  arch/powerpc/kernel/pci-common.c |  2 ++\n>  arch/sh/drivers/pci/pci.c        |  2 ++\n>  arch/x86/pci/i386.c              |  2 ++\n>  arch/xtensa/kernel/pci.c         |  2 ++\n>  drivers/pci/setup-res.c          | 39 +++++++++++++++++++++++++++++++-\n>  include/linux/pci.h              |  5 ++++\n>  kernel/resource.c                |  2 +-\n>  12 files changed, 67 insertions(+), 2 deletions(-)\n\n> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c\n> index 7a0522316ee3..994c3bd36ef2 100644\n> --- a/arch/sh/drivers/pci/pci.c\n> +++ b/arch/sh/drivers/pci/pci.c\n> @@ -185,6 +185,8 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,\n>  \t\t */\n>  \t\tif (start & 0x300)\n>  \t\t\tstart = (start + 0x3ff) & ~0x3ff;\n> +\t} else (res->flags & IORESOURCE_MEM) {\n\nI'll be adding the missing if into this in v2 (found by sashiko). It seems \nlkp didn't test this so it was not caught earlier.\n\n> +\t\tstart = pci_align_resource(dev, res, empty_res, size, align);\n>  \t}\n>  \n>  \treturn start;","headers":{"Return-Path":"\n <linuxppc-dev+bounces-18773-incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linuxppc-dev@lists.ozlabs.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=O/v7lq0B;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-18773-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n arc=none smtp.remote-ip=192.198.163.12","lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.intel.com","lists.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=O/v7lq0B;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=linux.intel.com\n (client-ip=192.198.163.12; helo=mgamail.intel.com;\n envelope-from=ilpo.jarvinen@linux.intel.com; receiver=lists.ozlabs.org)"],"Received":["from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\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 4fglvB2Vrlz1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 23:04:22 +1100 (AEDT)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fglvB1YrZz2xmX;\n\tWed, 25 Mar 2026 23:04:22 +1100 (AEDT)","from mgamail.intel.com (mgamail.intel.com [192.198.163.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fglv75235z2xcB\n\tfor <linuxppc-dev@lists.ozlabs.org>; Wed, 25 Mar 2026 23:04:18 +1100 (AEDT)","from orviesa002.jf.intel.com ([10.64.159.142])\n  by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 25 Mar 2026 05:04:16 -0700","from ijarvine-mobl1.ger.corp.intel.com (HELO localhost)\n ([10.245.245.125])\n  by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 25 Mar 2026 05:04:07 -0700"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1774440262;\n\tcv=none;\n b=R4ieYfj13+f/OvCvRrRyWASYon9gf4XV0aBKsWpBQqiMP0bdB5fUwV7IkcjRVWBdjiB4eCBvHtW1e5iRWAp+bKUr6QhfrAnuFfHu6DSsu+OZ73xygPRTU1fNwnEZxGmMp04HnO6qcKoHqLVyl78k0yLhuMWyZ8C/r3LYjmG6rbFsX1f2Xw9RRA0kvoXmHIOPLOkXsLrnHDjdEt5fcLMTThJ8vBmgsuE2KlKtmG1/MVL7BYmbgLdkcVDTpoWRJbCooL1wqUtiFqjTf2aItcfrMfxGU71J29EeWGcYCl3y3khtikaSgeamB/HFWM35nYUxYfQB7BcRyndu7bfRV/AhCQ==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1774440262; c=relaxed/relaxed;\n\tbh=cUg0TZE02i0OBp5PS3uAaiZ2fcbewL1haWJ/BT+KAlo=;\n\th=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References:\n\t MIME-Version:Content-Type;\n b=A+mh8IfyJz90yupRBofXbexXjmVF3cO7ypBI5QRHRqfy3gY1fvJB/PLEk55oSJ6C3QNG70YbriRjJekAjhV+uXTXSuNWH16QZHJgbATzQvxGxnh7fUiMMlMcS5w1OsCG20n+y2SyOR9jOBc1fUsQ7l3weWkFTJ48261xEwaMv1jUNhmQ9yxUphw3LooblHUt3OwV4DnFcvKX9LQ5Wd13hX3GHRp8IPvJUIhrR7/tujxJCjb/XC/8A/Vkoo33v80bENA/f5nGo3Yvyh0ZW7+2WR9wjD6c2nRJlArLldDIv4ZU/RPPBui7xO0wY/+ySIydTcznjmExEPQygwJhZkW4hA==","ARC-Authentication-Results":"i=1; lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.intel.com;\n dkim=pass (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=O/v7lq0B; dkim-atps=neutral;\n spf=pass (client-ip=192.198.163.12; helo=mgamail.intel.com;\n envelope-from=ilpo.jarvinen@linux.intel.com;\n receiver=lists.ozlabs.org) smtp.mailfrom=linux.intel.com","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n  t=1774440260; x=1805976260;\n  h=from:date:to:cc:subject:in-reply-to:message-id:\n   references:mime-version;\n  bh=pthnvpb4bRgKrgjRM/7gqeUF0giUw3hMBAx3mtd0Tfk=;\n  b=O/v7lq0BkpL/9inHRU+zpx0ck0NkBuVkPeIZl47Xwjbo6Ss0WyNOIkZT\n   m3/eQu24mNDdU5zYVKbd3PXf8u0+Kk3qPe+JlTRLrOoJyqiEl96I2GFDb\n   AaoQHxFF2aUc7UzZs4FJy3xqSGB9eAA0+ob6oyQfAHeV6M79CKn63OeUt\n   SMnSXQApS3qVr29Q2Jw6jmew3/0ZfWTXYEMe7CRKAS7GC7bbacT8soVhe\n   5ZHmPA97U3C2oL8TDLsDhat2NMgey6UhX+EI82ZRaayWH80PCsv4mZtk2\n   yZ5bnQAfInlGX9SsTBMK1S1eZFu41Cd7pXg6A6qF44fGiH11VPmRuXQtP\n   w==;","X-CSE-ConnectionGUID":["b9vVka/8QWWS846xRH6udA==","GDVCGG5yQPG4XMQBFBjvAw=="],"X-CSE-MsgGUID":["dWOrvaVdSRaqrnFoSQKNwg==","2mzDZ70tTHGJhYkLqZAkRA=="],"X-IronPort-AV":["E=McAfee;i=\"6800,10657,11739\"; a=\"79381343\"","E=Sophos;i=\"6.23,140,1770624000\";\n   d=\"scan'208\";a=\"79381343\"","E=Sophos;i=\"6.23,140,1770624000\";\n   d=\"scan'208\";a=\"255160046\""],"X-ExtLoop1":"1","From":"=?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>","Date":"Wed, 25 Mar 2026 14:04:03 +0200 (EET)","To":"linux-pci@vger.kernel.org","cc":"Bjorn Helgaas <bhelgaas@google.com>, Guenter Roeck <linux@roeck-us.net>,\n    linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org,\n    linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org,\n    linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,\n    linux-s390@vger.kernel.org, linux-sh@vger.kernel.org,\n    Russell King <linux@armlinux.org.uk>,\n    Geert Uytterhoeven <geert@linux-m68k.org>,\n    Thomas Bogendoerfer <tsbogend@alpha.franken.de>,\n    \"James E.J. Bottomley\" <James.Bottomley@HansenPartnership.com>,\n    Helge Deller <deller@gmx.de>, Michael Ellerman <mpe@ellerman.id.au>,\n    Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,\n    Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>,\n    \"H. Peter Anvin\" <hpa@zytor.com>, Chris Zankel <chris@zankel.net>,\n    Max Filippov <jcmvbkbc@gmail.com>,\n    Madhavan Srinivasan <maddy@linux.ibm.com>,\n    Yoshinori Sato <ysato@users.sourceforge.jp>,\n Rich Felker <dalias@libc.org>,\n    John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,\n    Nicholas Piggin <npiggin@gmail.com>,\n    \"Christophe Leroy (CS GROUP)\" <chleroy@kernel.org>, x86@kernel.org,\n    LKML <linux-kernel@vger.kernel.org>","Subject":"Re: [PATCH 09/10] PCI: Align head space better","In-Reply-To":"<20260324165633.4583-10-ilpo.jarvinen@linux.intel.com>","Message-ID":"<3a51ad39-558f-860d-4920-9f757b7d5131@linux.intel.com>","References":"<20260324165633.4583-1-ilpo.jarvinen@linux.intel.com>\n <20260324165633.4583-10-ilpo.jarvinen@linux.intel.com>","X-Mailing-List":"linuxppc-dev@lists.ozlabs.org","List-Id":"<linuxppc-dev.lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev+help@lists.ozlabs.org>","List-Owner":"<mailto:linuxppc-dev+owner@lists.ozlabs.org>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Archive":"<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Subscribe":"<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>","List-Unsubscribe":"<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>","Precedence":"list","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"8323328-1062646629-1774440243=:976\"","X-Spam-Status":"No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,\n\tDKIM_VALID,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled\n\tversion=4.0.1 OzLabs 8","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"}}]