public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	Shawn Jin <shawn.jin@asteralabs.com>,
	linuxppc-dev@lists.ozlabs.org,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH 00/11] PCI: pci_resource_alignment() improvement + cleanups
Date: Wed, 29 Apr 2026 15:26:06 +0300	[thread overview]
Message-ID: <20260429122617.7324-1-ilpo.jarvinen@linux.intel.com> (raw)

pci_resource_alignment() returns 0 when resource is already assigned
and in case of disabled bridge windows. This has caused problems to
calculations relying on pci_resource_alignment():

https://lore.kernel.org/linux-pci/LV8P221MB1472A24B9975F7C8E8D6BF929947A@LV8P221MB1472.NAMP221.PROD.OUTLOOK.COM/

This series reworks pci_resource_alignment() interface to return always
non-zero alignment if the resource exists. For assigned bridge windows,
the calculation is using heuristic based on size and start address
alignment as calculating the alignment again is costly (would require
sizing the entire sub-hierarchy).

As pci_resource_alignment() is becoming more complicated, it's also
moved to setup-res.c. While moving pci_resource_alignment()'s arguments
are converted into const to tell compiler it can rely on resource
remaining the same across the call.

This was intended to be part of a larger series that addresses some
shortcomings in pci=realloc. The pci=realloc changes will recalculate
bridge window sizes considering also assigned resources which required
making these changes to pci_resource_alignment().

As this also relates to the issue linked above, I'm sending it already
now without pci=realloc changes that are still incomplete. The first
patches originate from the large pci=realloc work but seem generally
useful even if independent of the alignment improvements so I've
included them here without reorganizing the series to contain only
alignment related changes.

Ilpo Järvinen (11):
  PCI: Log all resource claims
  PCI: Rename added to add_list
  PCI: Consolidate add_list (aka realloc_head) empty sanity checks
  PCI: Remove const removal cast
  resource: Make resource_alignment() input const resource
  powerpc/pseries: Make pseries_get_iov_fw_value() & pnv_iov_get()
    pci_dev const
  PCI: Make pci_sriov_resource_alignment() pci_dev const
  PCI: Convert pci_resource_alignment() input parameters to const
  PCI: Move pci_resource_alignment() to setup-res.c file
  PCI: Lower bound bridge windown alignment
  PCI: Return valid alignment for assigned resources

 arch/powerpc/include/asm/machdep.h         |  2 +-
 arch/powerpc/kernel/pci-common.c           |  2 +-
 arch/powerpc/platforms/powernv/pci-sriov.c |  4 +-
 arch/powerpc/platforms/powernv/pci.h       |  5 ++-
 arch/powerpc/platforms/pseries/setup.c     |  5 ++-
 drivers/pci/iov.c                          |  7 +--
 drivers/pci/pci.h                          | 24 ++++-------
 drivers/pci/setup-bus.c                    | 50 ++++++++++++----------
 drivers/pci/setup-cardbus.c                |  2 +-
 drivers/pci/setup-res.c                    | 37 ++++++++++++++++
 include/linux/ioport.h                     |  2 +-
 include/linux/pci.h                        |  8 ++--
 kernel/resource.c                          |  2 +-
 13 files changed, 94 insertions(+), 56 deletions(-)


base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
-- 
2.39.5


             reply	other threads:[~2026-04-29 12:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 12:26 Ilpo Järvinen [this message]
2026-04-29 12:26 ` [PATCH 01/11] PCI: Log all resource claims Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 02/11] PCI: Rename added to add_list Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 03/11] PCI: Consolidate add_list (aka realloc_head) empty sanity checks Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 04/11] PCI: Remove const removal cast Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 05/11] resource: Make resource_alignment() input const resource Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 06/11] powerpc/pseries: Make pseries_get_iov_fw_value() & pnv_iov_get() pci_dev const Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 07/11] PCI: Make pci_sriov_resource_alignment() " Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 08/11] PCI: Convert pci_resource_alignment() input parameters to const Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 09/11] PCI: Move pci_resource_alignment() to setup-res.c file Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 10/11] PCI: Lower bound bridge window alignment Ilpo Järvinen
2026-04-29 12:26 ` [PATCH 11/11] PCI: Return valid alignment for assigned resources Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260429122617.7324-1-ilpo.jarvinen@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=shawn.jin@asteralabs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox