Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] PCI: Convert bitfield flags to atomic accessors
@ 2026-07-11 15:21 Maurice Hieronymus
  2026-07-11 15:21 ` [PATCH 1/2] PCI: Replace pci_dev->is_busmaster with accessors Maurice Hieronymus
  2026-07-11 15:21 ` [PATCH 2/2] PCI: Replace pci_dev->broken_parity_status " Maurice Hieronymus
  0 siblings, 2 replies; 7+ messages in thread
From: Maurice Hieronymus @ 2026-07-11 15:21 UTC (permalink / raw)
  To: Edward Cree, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Bjorn Helgaas, Justin Tee, Paul Ely,
	James E.J. Bottomley, Martin K. Petersen, Juergen Gross,
	Stefano Stabellini, Oleksandr Tyshchenko, Miguel Ojeda,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan,
	Borislav Petkov, Tony Luck
  Cc: Danilo Krummrich, rust-for-linux, netdev, linux-net-drivers,
	linux-kernel, linux-pci, linux-scsi, xen-devel, linux-edac,
	Maurice Hieronymus

`struct pci_dev` keeps ~60 flags in one C bitfield. Bits sharing a
word must not be modified concurrently, but several writers take no
common lock: `pci_set_master()` writes `is_busmaster` and can run
without the device lock (e.g. runtime PM resume paths),
`pci_disable_device()` clears it, and `broken_parity_status_store()`
writes the same word from sysfs at any time without any lock.

Convert these two bits to a new public `flags` bitmap accessed with
atomic bitops, mirroring how the driver core replaced its
`offline`/`offline_disabled` bitfield in commit a7cc262a1135 ("driver
core: Replace dev->offline + ->offline_disabled with accessors").
More bits can follow the same pattern later.

An alternative would be to reuse `priv_flags`, but its bit definitions
and accessors are deliberately private to drivers/pci, while
`is_busmaster` is accessed by xen-pciback, lpfc and sfc. Happy to
respin that way if preferred.

This is also a prerequisite for the Rust device enabling API rework
[1]: the guard object planned there calls `pci_disable_device()` from
contexts that may run concurrently with `pci_set_master()`, which
requires `is_busmaster` to not be part of a shared bitfield word.

Link: https://lore.kernel.org/rust-for-linux/DJOEYVBS17MJ.1YD3TNGQBWHNK@kernel.org/ [1]
Signed-off-by: Maurice Hieronymus <mhi@mailbox.org>
---
Maurice Hieronymus (2):
      PCI: Replace pci_dev->is_busmaster with accessors
      PCI: Replace pci_dev->broken_parity_status with accessors

 drivers/edac/edac_pci_sysfs.c               |  4 +--
 drivers/net/ethernet/sfc/falcon/farch.c     |  2 +-
 drivers/net/ethernet/sfc/siena/farch.c      |  2 +-
 drivers/pci/pci-driver.c                    |  2 +-
 drivers/pci/pci-sysfs.c                     |  4 +--
 drivers/pci/pci.c                           |  6 ++---
 drivers/scsi/lpfc/lpfc_init.c               |  4 +--
 drivers/xen/xen-pciback/conf_space_header.c |  4 +--
 drivers/xen/xen-pciback/pciback_ops.c       |  4 +--
 include/linux/pci.h                         | 42 +++++++++++++++++++++++++++--
 10 files changed, 56 insertions(+), 18 deletions(-)
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260711-pci-dev-flags-fbbcf4ff9031

Best regards,
-- 
Maurice Hieronymus <mhi@mailbox.org>


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

end of thread, other threads:[~2026-07-12 15:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-11 15:21 [PATCH 0/2] PCI: Convert bitfield flags to atomic accessors Maurice Hieronymus
2026-07-11 15:21 ` [PATCH 1/2] PCI: Replace pci_dev->is_busmaster with accessors Maurice Hieronymus
2026-07-12 14:28   ` Lukas Wunner
2026-07-12 15:21   ` sashiko-bot
2026-07-11 15:21 ` [PATCH 2/2] PCI: Replace pci_dev->broken_parity_status " Maurice Hieronymus
2026-07-12 14:55   ` Lukas Wunner
2026-07-12 15:21   ` sashiko-bot

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