mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 00/17] PCI: Serialize bridge window sizing and resource assignment
@ 2026-11-25 23:08 Ilpo Järvinen
  2026-11-25 23:09 ` [PATCH v3 01/17] PCI: Add pci_bus_size_and_assign_resources() Ilpo Järvinen
                   ` (16 more replies)
  0 siblings, 17 replies; 19+ messages in thread
From: Ilpo Järvinen @ 2026-11-25 23:08 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi, Rob Herring,
	Krzysztof Wilczyński, David Matlack, Rafael J . Wysocki
  Cc: linux-kernel, Ilpo Järvinen

Hi all,

Bridge window sizing and resource assignment can be started from
multiple entrypoints: rescan and hotplug under pci_rescan_remove_lock,
and BAR resize from sysfs or driver probe under device_lock() only. As
the entrypoints hold pci_bus_sem at most for read, nothing prevents two
sizing and assignment passes from running concurrently on the same
bridge windows and BARs.

Multiple issues due to these races could be reproduced some on a real
host and more in QEMU with a synthetic PCI host bridge (not part of
this series) by looping BAR resize against a rescan through sysfs. The
failures include spurious BAR resize failures, a WARN in
pci_dev_res_restore(), a NULL pointer dereference in
__release_resource(), and a bridge window programmed over RAM. None of
them occurred with this series applied.

The series adds pci_bus_size_and_assign_resources() and
pci_assign_unassigned_slot_resources() so that PCI core can hold the
locks across both phases. It converts the callers (alpha nautilus
retains an extra sizing call to avoid complex refactoring). The
entrypoints are made to consistently hold pci_bus_sem for read and
use guard(). A per host bridge pci_res_setup_lock is added to
serialize the sizing and assignment passes. Last, the series converts
the remaining pci_bus_assign_resources() users and removes it.

Drivers that call pci_assign_resource() or pci_release_resource()
directly are not covered by this series.

I've another series coming up which will add struct pci_setup_data that
is to be held across the entire sizing and assignment algorithm, which
is another reason why those actions have to be kept together going
forward. The goal of that upcoming series is to size also assigned
bridge windows properly and we need a place to keep the alignment
because STARTALIGN is lost when a resource gets assigned.

v3:
- Move the new lock under pci_host_bridge
- Make pci_find_host_bridge() input const bus
- Reduce number of lockdep asserts as finding the lock is more costly now

v2:
- Expand BAR Resize lock coverage to include the parent window acquire
  (sashiko)
- Add pci_assign_unassigned_slot_resources()
- Refactor acpiphp, replaces sizing call in the loop with one
  pci_assign_unassigned_slot_resources() after the loop to not hold
  locks across scan
- Keep pci_res_setup_lock local to setup-bus.c (drops setup-cardbus.c
  assert that was of minor importance anyway)
- Minor language tweaks to changelogs


Ilpo Järvinen (17):
  PCI: Add pci_bus_size_and_assign_resources()
  alpha/PCI: Convert to pci_bus_size_and_assign_resources()
  PCI: Use guard() for pci_bus_sem in
    pci_do_resource_release_and_resize()
  PCI: Add pci_assign_unassigned_slot_resources()
  PCI: acpiphp: Use pci_assign_unassigned_slot_resources()
  PCI: Hold pci_bus_sem across sizing and assignment entrypoints
  PCI: Make pci_find_host_bridge() take a const bus
  PCI: Serialize bridge window sizing and resource assignment
  PCI: Make internal sizing and assignment functions static
  EDAC/i82875p: Convert to pci_assign_unassigned_bus_resources()
  platform/x86: asus-wmi: Convert to
    pci_assign_unassigned_bus_resources()
  platform/x86: eeepc-laptop: Convert to
    pci_assign_unassigned_bus_resources()
  parisc/PCI: Convert to pci_assign_unassigned_bus_resources()
  PCI: octep_hp: Convert to pci_assign_unassigned_bus_resources()
  PCI: ftpci100: Convert to pci_assign_unassigned_bus_resources()
  PCI: hv: Convert to pci_assign_unassigned_bus_resources()
  PCI: Remove pci_bus_assign_resources()

 arch/alpha/kernel/sys_nautilus.c      |   2 +-
 arch/arm/kernel/bios32.c              |   5 +-
 arch/m68k/coldfire/pci.c              |   3 +-
 arch/mips/pci/pci-legacy.c            |   5 +-
 arch/sh/drivers/pci/pci.c             |   3 +-
 drivers/edac/i82875p_edac.c           |   2 +-
 drivers/parisc/dino.c                 |   2 +-
 drivers/parisc/lba_pci.c              |   7 +-
 drivers/pci/controller/pci-ftpci100.c |   2 +-
 drivers/pci/controller/pci-hyperv.c   |   2 +-
 drivers/pci/host-bridge.c             |   8 +-
 drivers/pci/hotplug/acpiphp_glue.c    |   8 +-
 drivers/pci/hotplug/octep_hp.c        |   2 +-
 drivers/pci/pci.h                     |   6 +-
 drivers/pci/probe.c                   |   2 +
 drivers/pci/setup-bus.c               | 108 ++++++++++++++++++++------
 drivers/pcmcia/cardbus.c              |   3 +-
 drivers/platform/x86/asus-wmi.c       |   2 +-
 drivers/platform/x86/eeepc-laptop.c   |   2 +-
 include/linux/pci.h                   |  16 +++-
 20 files changed, 125 insertions(+), 65 deletions(-)


base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.47.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-11-26  0:33 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 23:08 [PATCH v3 00/17] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 01/17] PCI: Add pci_bus_size_and_assign_resources() Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 02/17] alpha/PCI: Convert to pci_bus_size_and_assign_resources() Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 03/17] PCI: Use guard() for pci_bus_sem in pci_do_resource_release_and_resize() Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 04/17] PCI: Add pci_assign_unassigned_slot_resources() Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 05/17] PCI: acpiphp: Use pci_assign_unassigned_slot_resources() Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 06/17] PCI: Hold pci_bus_sem across sizing and assignment entrypoints Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 07/17] PCI: Make pci_find_host_bridge() take a const bus Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 08/17] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 09/17] PCI: Make internal sizing and assignment functions static Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 10/17] EDAC/i82875p: Convert to pci_assign_unassigned_bus_resources() Ilpo Järvinen
2026-11-26  0:32   ` Borislav Petkov
2026-11-25 23:09 ` [PATCH v3 11/17] platform/x86: asus-wmi: " Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 12/17] platform/x86: eeepc-laptop: " Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 13/17] parisc/PCI: " Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 14/17] PCI: octep_hp: " Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 15/17] PCI: ftpci100: " Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 16/17] PCI: hv: " Ilpo Järvinen
2026-11-25 23:09 ` [PATCH v3 17/17] PCI: Remove pci_bus_assign_resources() Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®