public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
@ 2026-02-23 15:29 Shawn Lin
  2026-02-23 15:29 ` [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation Shawn Lin
                   ` (38 more replies)
  0 siblings, 39 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:29 UTC (permalink / raw)
  To: Bjorn Helgaas, Vaibhaav Ram T . L, Kumaravel Thiagarajan, Even Xu,
	Xinpeng Sun, Srinivas Pandruvada, Jiri Kosina, Alexandre Belloni,
	Zhou Wang, Longfang Liu, Vinod Koul, Lee Jones, Jijie Shao,
	Jian Shen, Sunil Goutham, Andrew Lunn, Heiner Kallweit,
	David S . Miller, Jeff Hugo, Oded Gabbay, Maciej Falkowski,
	Karol Wachowski, Min Ma, Lizhi Hou, Andreas Noever,
	Mika Westerberg, Tomasz Jeznach, Will Deacon, Xinliang Liu,
	Tian Tao, Davidlohr Bueso, Jonathan Cameron, Srujana Challa,
	Bharat Bhushan, Antoine Tenart, Herbert Xu, Raag Jadav,
	Hans de Goede, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Manivannan Sadhasivam, Mika Westerberg, Andi Shyti,
	Robert Richter, Mark Brown, Nirmal Patel, Kurt Schwemmer,
	Logan Gunthorpe, Linus Walleij, Bartosz Golaszewski, Sakari Ailus,
	Bingbu Cao, Ulf Hansson
  Cc: Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Andy Shevchenko, Jan Dabros, linux-i2c,
	Daniel Mack, Haojian Zhuang, linux-spi, Jonathan Derrick,
	linux-pci, linux-gpio, Mauro Carvalho Chehab, linux-media,
	linux-mmc, Shawn Lin

This patch series addresses a long-standing design issue in the PCI/MSI
subsystem where the implicit, automatic management of IRQ vectors by
the devres framework conflicts with explicit driver cleanup, creating
ambiguity and potential resource management bugs.

==== The Problem: Implicit vs. Explicit Management ====
Historically, `pcim_enable_device()` not only manages standard PCI resources
(BARs) via devres but also implicitly triggers automatic IRQ vector management
by setting a flag that registers `pcim_msi_release()` as a cleanup action.

This creates an ambiguous ownership model. Many drivers follow a pattern of:
1. Calling `pci_alloc_irq_vectors()` to allocate interrupts.
2. Also calling `pci_free_irq_vectors()` in their error paths or remove routines.

When such a driver also uses `pcim_enable_device()`, the devres framework may
attempt to free the IRQ vectors a second time upon device release, leading to
a double-free. Analysis of the tree shows this hazardous pattern exists widely,
while 35 other drivers correctly rely solely on the implicit cleanup.

==== The Solution: Making Management Explicit ====
This series enforces a clear, predictable model:
1.  New Managed API (Patch 1/37): Introduces pcim_alloc_irq_vectors() and
    pcim_alloc_irq_vectors_affinity(). Drivers that desire devres-managed IRQ
    vectors should use these functions, which set the is_msi_managed flag and
    ensure automatic cleanup.
2.  Patches 2 through 36 convert each driver that uses pcim_enable_device() alongside
    pci_alloc_irq_vectors() and relies on devres for IRQ vector cleanup to instead
    make an explicit call to pcim_alloc_irq_vectors().
3.  Core Change (Patch 37/37): With the former cleanup, now modifies pcim_setup_msi_release()
    to check only the is_msi_managed flag. This decouples automatic IRQ cleanup from
    pcim_enable_device(). IRQ vectors allocated via pci_alloc_irq_vectors*()
    are now solely the driver's responsibility to free with pci_free_irq_vectors().

With these changes, we clear ownership model: Explicit resource management eliminates
ambiguity and follows the "principle of least surprise." New drivers choose one model and
be consistent.
- Use `pci_alloc_irq_vectors()` + `pci_free_irq_vectors()` for explicit control.
- Use `pcim_alloc_irq_vectors()` for devres-managed, automatic cleanup.

==== Testing And Review ====
1. This series is only compiled test with allmodconfig.
2. Given the substantial size of this patch series, I have structured the mailing
   to facilitate efficient review. The cover letter, the first patch and the last one will be sent
   to all relevant mailing lists and key maintainers to ensure broad visibility and
   initial feedback on the overall approach. The remaining subsystem-specific patches
   will be sent only to the respective subsystem maintainers and their associated
   mailing lists, reducing noise.

Please help review it, much thanks!



Shawn Lin (37):
  PCI/MSI: Add Devres managed IRQ vectors allocation
  mmc: cavium: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  media: ipu6: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  gpio: merrifield: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  PCI: switchtec: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  PCI: vmd: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  spi: spi-pci1xxxx: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  spi: pxa2xx: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  i2c: amd-mp2: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  i2c: mchp-pci1xxxx: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  i2c: thunderx: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  i2c: designware: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  bus: mhi: host: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  serial: 8250_mid: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  serial: 8250_exar: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  platform/x86/intel: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  crypto: safexcel: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  crypto: octeontx2: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  cxl/pci: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  drm/hisilicon/hibmc: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  iommu/riscv: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  thunderbolt: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  accel/amdxdna: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  accel/ivpu: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  accel/qaic: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  net: stmmac: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  r8169: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  net: thunder_bgx: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  net: hibmcge: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  mfd: intel-lpss: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  dmaengine: hsu: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  dmaengine: hisilicon: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  i3c: mipi-i3c-hci-pci: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  HID: intel-ish-ipc: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  HID: Intel-thc-hid: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  misc: microchip: pci1xxxx: Replace pci_alloc_irq_vectors() with
    pcim_alloc_irq_vectors()
  PCI/MSI: Only check is_msi_managed in pcim_setup_msi_release()

 drivers/accel/amdxdna/aie2_pci.c                   |  2 +-
 drivers/accel/ivpu/ivpu_drv.c                      |  2 +-
 drivers/accel/qaic/qaic_drv.c                      |  4 ++--
 drivers/bus/mhi/host/pci_generic.c                 |  3 ++-
 drivers/crypto/inside-secure/safexcel.c            |  8 +++----
 drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c |  2 +-
 drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c |  4 ++--
 drivers/cxl/pci.c                                  |  8 ++-----
 drivers/dma/hisi_dma.c                             |  3 +--
 drivers/dma/hsu/pci.c                              |  2 +-
 drivers/gpio/gpio-merrifield.c                     |  2 +-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c    |  4 ++--
 drivers/hid/intel-ish-hid/ipc/pci-ish.c            |  2 +-
 .../intel-thc-hid/intel-quicki2c/pci-quicki2c.c    |  2 +-
 drivers/i2c/busses/i2c-amd-mp2-pci.c               |  2 +-
 drivers/i2c/busses/i2c-designware-pcidrv.c         |  2 +-
 drivers/i2c/busses/i2c-mchp-pci1xxxx.c             |  2 +-
 drivers/i2c/busses/i2c-thunderx-pcidrv.c           |  2 +-
 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c |  2 +-
 drivers/iommu/riscv/iommu-pci.c                    |  4 ++--
 drivers/media/pci/intel/ipu6/ipu6.c                |  2 +-
 drivers/mfd/intel-lpss-pci.c                       |  2 +-
 drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c      |  2 +-
 drivers/mmc/host/cavium-thunderx.c                 |  2 +-
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c  |  4 ++--
 drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c   |  4 ++--
 drivers/net/ethernet/realtek/r8169_main.c          |  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c  |  6 ++---
 drivers/pci/controller/vmd.c                       |  4 ++--
 drivers/pci/msi/api.c                              | 26 ++++++++++++++++++++++
 drivers/pci/msi/msi.c                              |  4 +---
 drivers/pci/switch/switchtec.c                     |  6 ++---
 drivers/platform/x86/intel/ehl_pse_io.c            |  2 +-
 drivers/spi/spi-pci1xxxx.c                         |  4 ++--
 drivers/spi/spi-pxa2xx-pci.c                       |  2 +-
 drivers/thunderbolt/nhi.c                          |  6 ++---
 drivers/tty/serial/8250/8250_exar.c                |  2 +-
 drivers/tty/serial/8250/8250_mid.c                 |  2 +-
 include/linux/pci.h                                | 22 ++++++++++++++++++
 39 files changed, 104 insertions(+), 62 deletions(-)

-- 
2.7.4


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

* [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
@ 2026-02-23 15:29 ` Shawn Lin
  2026-02-24  0:04   ` Jakub Kicinski
  2026-02-24 16:20   ` Jonathan Cameron
  2026-02-23 15:29 ` [PATCH 37/37] PCI/MSI: Only check is_msi_managed in pcim_setup_msi_release() Shawn Lin
                   ` (37 subsequent siblings)
  38 siblings, 2 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:29 UTC (permalink / raw)
  To: Bjorn Helgaas, Vaibhaav Ram T . L, Kumaravel Thiagarajan, Even Xu,
	Xinpeng Sun, Srinivas Pandruvada, Jiri Kosina, Alexandre Belloni,
	Zhou Wang, Longfang Liu, Vinod Koul, Lee Jones, Jijie Shao,
	Jian Shen, Sunil Goutham, Andrew Lunn, Heiner Kallweit,
	David S . Miller, Jeff Hugo, Oded Gabbay, Maciej Falkowski,
	Karol Wachowski, Min Ma, Lizhi Hou, Andreas Noever,
	Mika Westerberg, Tomasz Jeznach, Will Deacon, Xinliang Liu,
	Tian Tao, Davidlohr Bueso, Jonathan Cameron, Srujana Challa,
	Bharat Bhushan, Antoine Tenart, Herbert Xu, Raag Jadav,
	Hans de Goede, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Manivannan Sadhasivam, Mika Westerberg, Andi Shyti,
	Robert Richter, Mark Brown, Nirmal Patel, Kurt Schwemmer,
	Logan Gunthorpe, Linus Walleij, Bartosz Golaszewski, Sakari Ailus,
	Bingbu Cao, Ulf Hansson
  Cc: Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Andy Shevchenko, Jan Dabros, linux-i2c,
	Daniel Mack, Haojian Zhuang, linux-spi, Jonathan Derrick,
	linux-pci, linux-gpio, Mauro Carvalho Chehab, linux-media,
	linux-mmc, Shawn Lin

pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() are created for
pci device drivers which rely on the devres machinery to help cleanup the IRQ
vectors.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/pci/msi/api.c | 26 ++++++++++++++++++++++++++
 include/linux/pci.h   | 22 ++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c
index c18559b..2362fca 100644
--- a/drivers/pci/msi/api.c
+++ b/drivers/pci/msi/api.c
@@ -297,6 +297,32 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
 EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity);
 
 /**
+ * pcim_alloc_irq_vectors() - devres managed pci_alloc_irq_vectors()
+ * Interrupt vectors are automatically freed by the devres machinery
+ */
+int pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
+			   unsigned int max_vecs, unsigned int flags)
+{
+	return pcim_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs,
+					       flags, NULL);
+}
+EXPORT_SYMBOL(pcim_alloc_irq_vectors);
+
+/**
+ * pcim_alloc_irq_vectors_affinity() - devres managed pci_alloc_irq_vectors_affinity()
+ * Interrupt vectors are automatically freed by the devres machinery
+ */
+int pcim_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
+				   unsigned int max_vecs, unsigned int flags,
+				   struct irq_affinity *affd)
+{
+	dev->is_msi_managed = true;
+	return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs,
+					      flags, affd);
+}
+EXPORT_SYMBOL(pcim_alloc_irq_vectors_affinity);
+
+/**
  * pci_irq_vector() - Get Linux IRQ number of a device interrupt vector
  * @dev: the PCI device to operate on
  * @nr:  device-relative interrupt vector index (0-based); has different
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d5ec0f8..ae58f70 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1764,6 +1764,12 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
 				   unsigned int max_vecs, unsigned int flags,
 				   struct irq_affinity *affd);
 
+int pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
+			  unsigned int max_vecs, unsigned int flags);
+int pcim_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
+				   unsigned int max_vecs, unsigned int flags,
+				   struct irq_affinity *affd);
+
 bool pci_msix_can_alloc_dyn(struct pci_dev *dev);
 struct msi_map pci_msix_alloc_irq_at(struct pci_dev *dev, unsigned int index,
 				     const struct irq_affinity_desc *affdesc);
@@ -1806,6 +1812,22 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
 					      flags, NULL);
 }
 
+static inline int
+pcim_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
+			       unsigned int max_vecs, unsigned int flags,
+			       struct irq_affinity *aff_desc)
+{
+	return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs,
+					      flags, aff_desc);
+}
+static inline int
+pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
+		      unsigned int max_vecs, unsigned int flags)
+{
+	return pcim_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs,
+					      flags, NULL);
+}
+
 static inline bool pci_msix_can_alloc_dyn(struct pci_dev *dev)
 { return false; }
 static inline struct msi_map pci_msix_alloc_irq_at(struct pci_dev *dev, unsigned int index,
-- 
2.7.4


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

* [PATCH 37/37] PCI/MSI: Only check is_msi_managed in pcim_setup_msi_release()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
  2026-02-23 15:29 ` [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation Shawn Lin
@ 2026-02-23 15:29 ` Shawn Lin
  2026-02-23 15:41 ` [PATCH 02/37] mmc: cavium: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors() Shawn Lin
                   ` (36 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:29 UTC (permalink / raw)
  To: Bjorn Helgaas, Vaibhaav Ram T . L, Kumaravel Thiagarajan, Even Xu,
	Xinpeng Sun, Srinivas Pandruvada, Jiri Kosina, Alexandre Belloni,
	Zhou Wang, Longfang Liu, Vinod Koul, Lee Jones, Jijie Shao,
	Jian Shen, Sunil Goutham, Andrew Lunn, Heiner Kallweit,
	David S . Miller, Jeff Hugo, Oded Gabbay, Maciej Falkowski,
	Karol Wachowski, Min Ma, Lizhi Hou, Andreas Noever,
	Mika Westerberg, Tomasz Jeznach, Will Deacon, Xinliang Liu,
	Tian Tao, Davidlohr Bueso, Jonathan Cameron, Srujana Challa,
	Bharat Bhushan, Antoine Tenart, Herbert Xu, Raag Jadav,
	Hans de Goede, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Manivannan Sadhasivam, Mika Westerberg, Andi Shyti,
	Robert Richter, Mark Brown, Nirmal Patel, Kurt Schwemmer,
	Logan Gunthorpe, Linus Walleij, Bartosz Golaszewski, Sakari Ailus,
	Bingbu Cao, Ulf Hansson
  Cc: Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Andy Shevchenko, Jan Dabros, linux-i2c,
	Daniel Mack, Haojian Zhuang, linux-spi, Jonathan Derrick,
	linux-pci, linux-gpio, Mauro Carvalho Chehab, linux-media,
	linux-mmc, Shawn Lin

The function pcim_enable_device() sets the is_managed flag, which
causes the device's IRQ vectors to be automatically managed and released
by the devres framework. If a driver subsequently calls
pci_free_irq_vectors() manually, it can lead to a double-free of the
interrupt resources.

Analysis reveals most PCI drivers call pci_free_irq_vectors()
while also using pcim_enable_device(), making them susceptible to this
double-free issue. In contrast, 35 drivers follow the pattern of
relying on devres to handle the cleanup.

To address this inconsistency and enforce explicit, driver-managed
control of IRQ vectors, this patch removes the pci_is_managed() check
from pcim_setup_msi_release() and let devres help cleanup if is_msi_managed
is true. This change ensures that interrupt vectors are not automatically
freed by the devres machinery when pcim_enable_device() is used, placing
the responsibility for their release squarely on the driver logic via
pci_free_irq_vectors(). If the driver need devres to help cleanup, newly added
pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() helpers could be used.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

---

 drivers/pci/msi/msi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 81d24a2..0727a0a 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -70,7 +70,6 @@ static void pcim_msi_release(void *pcidev)
 {
 	struct pci_dev *dev = pcidev;
 
-	dev->is_msi_managed = false;
 	pci_free_irq_vectors(dev);
 }
 
@@ -92,14 +91,13 @@ static int pcim_setup_msi_release(struct pci_dev *dev)
 {
 	int ret;
 
-	if (!pci_is_managed(dev) || dev->is_msi_managed)
+	if (!dev->is_msi_managed)
 		return 0;
 
 	ret = devm_add_action(&dev->dev, pcim_msi_release, dev);
 	if (ret)
 		return ret;
 
-	dev->is_msi_managed = true;
 	return 0;
 }
 
-- 
2.7.4


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

* [PATCH 02/37] mmc: cavium: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
  2026-02-23 15:29 ` [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation Shawn Lin
  2026-02-23 15:29 ` [PATCH 37/37] PCI/MSI: Only check is_msi_managed in pcim_setup_msi_release() Shawn Lin
@ 2026-02-23 15:41 ` Shawn Lin
  2026-02-23 15:42 ` [PATCH 03/37] media: ipu6: " Shawn Lin
                   ` (35 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:41 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, linux-pci, Bjorn Helgaas, Philipp Stanner, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/cavium-thunderx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/cavium-thunderx.c b/drivers/mmc/host/cavium-thunderx.c
index 1373deb..55c46ae 100644
--- a/drivers/mmc/host/cavium-thunderx.c
+++ b/drivers/mmc/host/cavium-thunderx.c
@@ -39,7 +39,7 @@ static int thunder_mmc_register_interrupts(struct cvm_mmc_host *host,
 {
 	int nvec, ret, i;
 
-	nvec = pci_alloc_irq_vectors(pdev, 1, 9, PCI_IRQ_MSIX);
+	nvec = pcim_alloc_irq_vectors(pdev, 1, 9, PCI_IRQ_MSIX);
 	if (nvec < 0)
 		return nvec;
 
-- 
2.7.4


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

* [PATCH 03/37] media: ipu6: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (2 preceding siblings ...)
  2026-02-23 15:41 ` [PATCH 02/37] mmc: cavium: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors() Shawn Lin
@ 2026-02-23 15:42 ` Shawn Lin
  2026-02-23 15:42 ` [PATCH 04/37] gpio: merrifield: " Shawn Lin
                   ` (34 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:42 UTC (permalink / raw)
  To: Sakari Ailus, Bingbu Cao, Tianshu Qiu
  Cc: Mauro Carvalho Chehab, linux-media, linux-pci, Bjorn Helgaas,
	Philipp Stanner, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Bingbu Cao <bingbu.cao@intel.com>
To: Tianshu Qiu <tian.shu.qiu@intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/media/pci/intel/ipu6/ipu6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/intel/ipu6/ipu6.c b/drivers/media/pci/intel/ipu6/ipu6.c
index 24238f8..6ab94db 100644
--- a/drivers/media/pci/intel/ipu6/ipu6.c
+++ b/drivers/media/pci/intel/ipu6/ipu6.c
@@ -471,7 +471,7 @@ static int ipu6_pci_config_setup(struct pci_dev *dev, u8 hw_ver)
 		return 0;
 	}
 
-	ret = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_MSI);
+	ret = pcim_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_MSI);
 	if (ret < 0)
 		return dev_err_probe(&dev->dev, ret, "Request msi failed");
 
-- 
2.7.4


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

* [PATCH 04/37] gpio: merrifield: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (3 preceding siblings ...)
  2026-02-23 15:42 ` [PATCH 03/37] media: ipu6: " Shawn Lin
@ 2026-02-23 15:42 ` Shawn Lin
  2026-02-23 17:42   ` Andy Shevchenko
  2026-02-23 15:43 ` [PATCH 05/37] PCI: switchtec: " Shawn Lin
                   ` (33 subsequent siblings)
  38 siblings, 1 reply; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:42 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Andy Shevchenko, linux-gpio, Bjorn Helgaas, Philipp Stanner,
	linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

Cc: Andy Shevchenko <andy@kernel.org>
To: Linus Walleij <linusw@kernel.org>
To: Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-gpio@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/gpio/gpio-merrifield.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
index 4335a5d..9272474 100644
--- a/drivers/gpio/gpio-merrifield.c
+++ b/drivers/gpio/gpio-merrifield.c
@@ -108,7 +108,7 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id
 	priv->info.ngpio = MRFLD_NGPIO;
 	priv->info.first = irq_base;
 
-	retval = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	retval = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (retval < 0)
 		return retval;
 
-- 
2.7.4


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

* [PATCH 05/37] PCI: switchtec: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (4 preceding siblings ...)
  2026-02-23 15:42 ` [PATCH 04/37] gpio: merrifield: " Shawn Lin
@ 2026-02-23 15:43 ` Shawn Lin
  2026-02-23 15:43 ` [PATCH 06/37] PCI: vmd: " Shawn Lin
                   ` (32 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:43 UTC (permalink / raw)
  To: Kurt Schwemmer, Logan Gunthorpe, Bjorn Helgaas
  Cc: Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Kurt Schwemmer <kurt.schwemmer@microsemi.com>
To: Logan Gunthorpe <logang@deltatee.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/pci/switch/switchtec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index 5ff84fb..5b6d8b7 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -1493,9 +1493,9 @@ static int switchtec_init_isr(struct switchtec_dev *stdev)
 	if (nirqs < 4)
 		nirqs = 4;
 
-	nvecs = pci_alloc_irq_vectors(stdev->pdev, 1, nirqs,
-				      PCI_IRQ_MSIX | PCI_IRQ_MSI |
-				      PCI_IRQ_VIRTUAL);
+	nvecs = pcim_alloc_irq_vectors(stdev->pdev, 1, nirqs,
+				       PCI_IRQ_MSIX | PCI_IRQ_MSI |
+				       PCI_IRQ_VIRTUAL);
 	if (nvecs < 0)
 		return nvecs;
 
-- 
2.7.4


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

* [PATCH 06/37] PCI: vmd: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (5 preceding siblings ...)
  2026-02-23 15:43 ` [PATCH 05/37] PCI: switchtec: " Shawn Lin
@ 2026-02-23 15:43 ` Shawn Lin
  2026-02-23 15:44 ` [PATCH 07/37] spi: spi-pci1xxxx: " Shawn Lin
                   ` (31 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:43 UTC (permalink / raw)
  To: Nirmal Patel, Bjorn Helgaas
  Cc: Jonathan Derrick, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Nirmal Patel <nirmal.patel@linux.intel.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jonathan Derrick <jonathan.derrick@linux.dev>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/pci/controller/vmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index ec6afc3..7c3db78 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -684,8 +684,8 @@ static int vmd_alloc_irqs(struct vmd_dev *vmd)
 	if (vmd->msix_count < 0)
 		return -ENODEV;
 
-	vmd->msix_count = pci_alloc_irq_vectors(dev, vmd->first_vec + 1,
-						vmd->msix_count, PCI_IRQ_MSIX);
+	vmd->msix_count = pcim_alloc_irq_vectors(dev, vmd->first_vec + 1,
+						 vmd->msix_count, PCI_IRQ_MSIX);
 	if (vmd->msix_count < 0)
 		return vmd->msix_count;
 
-- 
2.7.4


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

* [PATCH 07/37] spi: spi-pci1xxxx: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (6 preceding siblings ...)
  2026-02-23 15:43 ` [PATCH 06/37] PCI: vmd: " Shawn Lin
@ 2026-02-23 15:44 ` Shawn Lin
  2026-02-23 15:44 ` [PATCH 08/37] spi: pxa2xx: " Shawn Lin
                   ` (30 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:44 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/spi/spi-pci1xxxx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-pci1xxxx.c b/drivers/spi/spi-pci1xxxx.c
index 8577a19..ccb22de 100644
--- a/drivers/spi/spi-pci1xxxx.c
+++ b/drivers/spi/spi-pci1xxxx.c
@@ -852,8 +852,8 @@ static int pci1xxxx_spi_probe(struct pci_dev *pdev, const struct pci_device_id *
 			if (!spi_bus->reg_base)
 				return -EINVAL;
 
-			num_vector = pci_alloc_irq_vectors(pdev, 1, hw_inst_cnt * NUM_VEC_PER_INST,
-							   PCI_IRQ_INTX | PCI_IRQ_MSI);
+			num_vector = pcim_alloc_irq_vectors(pdev, 1, hw_inst_cnt * NUM_VEC_PER_INST,
+							    PCI_IRQ_INTX | PCI_IRQ_MSI);
 			if (num_vector < 0) {
 				dev_err(&pdev->dev, "Error allocating MSI vectors\n");
 				return num_vector;
-- 
2.7.4


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

* [PATCH 08/37] spi: pxa2xx: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (7 preceding siblings ...)
  2026-02-23 15:44 ` [PATCH 07/37] spi: spi-pci1xxxx: " Shawn Lin
@ 2026-02-23 15:44 ` Shawn Lin
  2026-02-23 15:47 ` [PATCH 09/37] i2c: amd-mp2: " Shawn Lin
                   ` (29 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:44 UTC (permalink / raw)
  To: Mark Brown
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, linux-spi,
	Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Mark Brown <broonie@kernel.org>
Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: linux-spi@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/spi/spi-pxa2xx-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index cae77ac..551e8e7 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -291,7 +291,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 
 	pci_set_master(dev);
 
-	ret = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0)
 		return ret;
 	ssp->irq = pci_irq_vector(dev, 0);
-- 
2.7.4


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

* [PATCH 09/37] i2c: amd-mp2: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (8 preceding siblings ...)
  2026-02-23 15:44 ` [PATCH 08/37] spi: pxa2xx: " Shawn Lin
@ 2026-02-23 15:47 ` Shawn Lin
  2026-02-23 15:47 ` [PATCH 10/37] i2c: mchp-pci1xxxx: " Shawn Lin
                   ` (28 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:47 UTC (permalink / raw)
  To: Elie Morisse, Shyam Sundar S K, Andi Shyti
  Cc: linux-i2c, linux-pci, Bjorn Helgaas, Philipp Stanner, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Elie Morisse <syniurge@gmail.com>
To: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: linux-i2c@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/i2c/busses/i2c-amd-mp2-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c
index 5b41d18..3f42899 100644
--- a/drivers/i2c/busses/i2c-amd-mp2-pci.c
+++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c
@@ -313,7 +313,7 @@ static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
 
 	/* request and enable interrupt */
 	writel(0, privdata->mmio + AMD_P2C_MSG_INTEN);
-	rc = pci_alloc_irq_vectors(pci_dev, 1, 1, PCI_IRQ_ALL_TYPES);
+	rc = pcim_alloc_irq_vectors(pci_dev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (rc < 0) {
 		dev_err(&pci_dev->dev, "Failed to allocate single IRQ err=%d\n", rc);
 		goto err_dma_mask;
-- 
2.7.4


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

* [PATCH 10/37] i2c: mchp-pci1xxxx: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (9 preceding siblings ...)
  2026-02-23 15:47 ` [PATCH 09/37] i2c: amd-mp2: " Shawn Lin
@ 2026-02-23 15:47 ` Shawn Lin
  2026-02-23 15:48 ` [PATCH 11/37] i2c: thunderx: " Shawn Lin
                   ` (27 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:47 UTC (permalink / raw)
  To: Kumaravel Thiagarajan, Andi Shyti
  Cc: linux-i2c, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: linux-i2c@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/i2c/busses/i2c-mchp-pci1xxxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mchp-pci1xxxx.c b/drivers/i2c/busses/i2c-mchp-pci1xxxx.c
index bc0f1a0..0475e20 100644
--- a/drivers/i2c/busses/i2c-mchp-pci1xxxx.c
+++ b/drivers/i2c/busses/i2c-mchp-pci1xxxx.c
@@ -1162,7 +1162,7 @@ static int pci1xxxx_i2c_probe_pci(struct pci_dev *pdev,
 	if (ret)
 		return ret;
 
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0)
 		return ret;
 
-- 
2.7.4


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

* [PATCH 11/37] i2c: thunderx: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (10 preceding siblings ...)
  2026-02-23 15:47 ` [PATCH 10/37] i2c: mchp-pci1xxxx: " Shawn Lin
@ 2026-02-23 15:48 ` Shawn Lin
  2026-02-23 15:48 ` [PATCH 12/37] i2c: designware: " Shawn Lin
                   ` (26 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:48 UTC (permalink / raw)
  To: Robert Richter, Andi Shyti
  Cc: linux-i2c, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Robert Richter <rric@kernel.org>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: linux-i2c@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/i2c/busses/i2c-thunderx-pcidrv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-thunderx-pcidrv.c b/drivers/i2c/busses/i2c-thunderx-pcidrv.c
index 3959f23f..74e7d05 100644
--- a/drivers/i2c/busses/i2c-thunderx-pcidrv.c
+++ b/drivers/i2c/busses/i2c-thunderx-pcidrv.c
@@ -198,7 +198,7 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
 	i2c->hlc_int_enable = thunder_i2c_hlc_int_enable;
 	i2c->hlc_int_disable = thunder_i2c_hlc_int_disable;
 
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
 	if (ret < 0)
 		goto error;
 
-- 
2.7.4


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

* [PATCH 12/37] i2c: designware: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (11 preceding siblings ...)
  2026-02-23 15:48 ` [PATCH 11/37] i2c: thunderx: " Shawn Lin
@ 2026-02-23 15:48 ` Shawn Lin
  2026-02-23 15:48 ` [PATCH 13/37] bus: mhi: host: " Shawn Lin
                   ` (25 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:48 UTC (permalink / raw)
  To: Mika Westerberg, Andi Shyti
  Cc: Andy Shevchenko, Jan Dabros, linux-i2c, Bjorn Helgaas,
	Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Jan Dabros <jsd@semihalf.com>
Cc: linux-i2c@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/i2c/busses/i2c-designware-pcidrv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index f21f987..5bf944a 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -234,7 +234,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 	if (!dev)
 		return -ENOMEM;
 
-	r = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	r = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (r < 0)
 		return r;
 
-- 
2.7.4


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

* [PATCH 13/37] bus: mhi: host: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (12 preceding siblings ...)
  2026-02-23 15:48 ` [PATCH 12/37] i2c: designware: " Shawn Lin
@ 2026-02-23 15:48 ` Shawn Lin
  2026-02-23 15:49 ` [PATCH 14/37] serial: 8250_mid: " Shawn Lin
                   ` (24 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:48 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: mhi, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Manivannan Sadhasivam <mani@kernel.org>
Cc: mhi@lists.linux.dev
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/bus/mhi/host/pci_generic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
index 0884a38..bb8c766 100644
--- a/drivers/bus/mhi/host/pci_generic.c
+++ b/drivers/bus/mhi/host/pci_generic.c
@@ -1152,7 +1152,8 @@ static int mhi_pci_get_irqs(struct mhi_controller *mhi_cntrl,
 	 */
 	mhi_cntrl->nr_irqs = 1 + mhi_cntrl_config->num_events;
 
-	nr_vectors = pci_alloc_irq_vectors(pdev, 1, mhi_cntrl->nr_irqs, PCI_IRQ_MSIX | PCI_IRQ_MSI);
+	nr_vectors = pcim_alloc_irq_vectors(pdev, 1, mhi_cntrl->nr_irqs,
+					    PCI_IRQ_MSIX | PCI_IRQ_MSI);
 	if (nr_vectors < 0) {
 		dev_err(&pdev->dev, "Error allocating MSI vectors %d\n",
 			nr_vectors);
-- 
2.7.4


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

* [PATCH 14/37] serial: 8250_mid: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (13 preceding siblings ...)
  2026-02-23 15:48 ` [PATCH 13/37] bus: mhi: host: " Shawn Lin
@ 2026-02-23 15:49 ` Shawn Lin
  2026-02-23 15:49 ` [PATCH 15/37] serial: 8250_exar: " Shawn Lin
                   ` (23 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:49 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Bjorn Helgaas, Philipp Stanner, linux-pci,
	Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Andy Shevchenko <andy@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: linux-serial@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/tty/serial/8250/8250_mid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c
index 8ec0386..3ad9213 100644
--- a/drivers/tty/serial/8250/8250_mid.c
+++ b/drivers/tty/serial/8250/8250_mid.c
@@ -172,7 +172,7 @@ static int dnv_setup(struct mid8250 *mid, struct uart_port *p)
 
 	pci_set_master(pdev);
 
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0)
 		return ret;
 
-- 
2.7.4


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

* [PATCH 15/37] serial: 8250_exar: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (14 preceding siblings ...)
  2026-02-23 15:49 ` [PATCH 14/37] serial: 8250_mid: " Shawn Lin
@ 2026-02-23 15:49 ` Shawn Lin
  2026-02-23 15:50 ` [PATCH 16/37] platform/x86/intel: " Shawn Lin
                   ` (22 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Bjorn Helgaas, Philipp Stanner, linux-pci,
	Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: linux-serial@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/tty/serial/8250/8250_exar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index c682c0d..bde4d3a 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -1478,7 +1478,7 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 
 	pci_set_master(pcidev);
 
-	rc = pci_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
+	rc = pcim_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (rc < 0)
 		return rc;
 
-- 
2.7.4


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

* [PATCH 16/37] platform/x86/intel: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (15 preceding siblings ...)
  2026-02-23 15:49 ` [PATCH 15/37] serial: 8250_exar: " Shawn Lin
@ 2026-02-23 15:50 ` Shawn Lin
  2026-02-23 15:50 ` [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Andy Shevchenko
                   ` (21 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:50 UTC (permalink / raw)
  To: Raag Jadav, Hans de Goede
  Cc: platform-driver-x86, Bjorn Helgaas, Philipp Stanner, linux-pci,
	Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Raag Jadav <raag.jadav@intel.com>
To: Hans de Goede <hansg@kernel.org>
Cc: platform-driver-x86@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/platform/x86/intel/ehl_pse_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel/ehl_pse_io.c b/drivers/platform/x86/intel/ehl_pse_io.c
index 861e148..d554ba9 100644
--- a/drivers/platform/x86/intel/ehl_pse_io.c
+++ b/drivers/platform/x86/intel/ehl_pse_io.c
@@ -56,7 +56,7 @@ static int ehl_pse_io_probe(struct pci_dev *pci, const struct pci_device_id *id)
 
 	pci_set_master(pci);
 
-	ret = pci_alloc_irq_vectors(pci, 2, 2, PCI_IRQ_MSI);
+	ret = pcim_alloc_irq_vectors(pci, 2, 2, PCI_IRQ_MSI);
 	if (ret < 0)
 		return ret;
 
-- 
2.7.4


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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (16 preceding siblings ...)
  2026-02-23 15:50 ` [PATCH 16/37] platform/x86/intel: " Shawn Lin
@ 2026-02-23 15:50 ` Andy Shevchenko
  2026-02-23 16:09   ` Shawn Lin
  2026-02-23 15:51 ` [PATCH 17/37] crypto: safexcel: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors() Shawn Lin
                   ` (20 subsequent siblings)
  38 siblings, 1 reply; 62+ messages in thread
From: Andy Shevchenko @ 2026-02-23 15:50 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Bjorn Helgaas, Vaibhaav Ram T . L, Kumaravel Thiagarajan, Even Xu,
	Xinpeng Sun, Srinivas Pandruvada, Jiri Kosina, Alexandre Belloni,
	Zhou Wang, Longfang Liu, Vinod Koul, Lee Jones, Jijie Shao,
	Jian Shen, Sunil Goutham, Andrew Lunn, Heiner Kallweit,
	David S . Miller, Jeff Hugo, Oded Gabbay, Maciej Falkowski,
	Karol Wachowski, Min Ma, Lizhi Hou, Andreas Noever,
	Mika Westerberg, Tomasz Jeznach, Will Deacon, Xinliang Liu,
	Tian Tao, Davidlohr Bueso, Jonathan Cameron, Srujana Challa,
	Bharat Bhushan, Antoine Tenart, Herbert Xu, Raag Jadav,
	Hans de Goede, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Manivannan Sadhasivam, Mika Westerberg, Andi Shyti,
	Robert Richter, Mark Brown, Nirmal Patel, Kurt Schwemmer,
	Logan Gunthorpe, Linus Walleij, Bartosz Golaszewski, Sakari Ailus,
	Bingbu Cao, Ulf Hansson, Arnd Bergmann, Benjamin Tissoires,
	linux-input, linux-i3c, dmaengine, Philipp Stanner, netdev,
	nic_swsd, linux-arm-msm, dri-devel, linux-usb, iommu, linux-riscv,
	David Airlie, Simona Vetter, linux-cxl, linux-crypto,
	platform-driver-x86, linux-serial, mhi, Andy Shevchenko,
	Jan Dabros, linux-i2c, Daniel Mack, Haojian Zhuang, linux-spi,
	Jonathan Derrick, linux-pci, linux-gpio, Mauro Carvalho Chehab,
	linux-media, linux-mmc

On Mon, Feb 23, 2026 at 5:32 PM Shawn Lin <shawn.lin@rock-chips.com> wrote:
>
> This patch series addresses a long-standing design issue in the PCI/MSI
> subsystem where the implicit, automatic management of IRQ vectors by
> the devres framework conflicts with explicit driver cleanup, creating
> ambiguity and potential resource management bugs.
>
> ==== The Problem: Implicit vs. Explicit Management ====
> Historically, `pcim_enable_device()` not only manages standard PCI resources
> (BARs) via devres but also implicitly triggers automatic IRQ vector management
> by setting a flag that registers `pcim_msi_release()` as a cleanup action.
>
> This creates an ambiguous ownership model. Many drivers follow a pattern of:
> 1. Calling `pci_alloc_irq_vectors()` to allocate interrupts.
> 2. Also calling `pci_free_irq_vectors()` in their error paths or remove routines.
>
> When such a driver also uses `pcim_enable_device()`, the devres framework may
> attempt to free the IRQ vectors a second time upon device release, leading to
> a double-free. Analysis of the tree shows this hazardous pattern exists widely,
> while 35 other drivers correctly rely solely on the implicit cleanup.

Is this confirmed? What I read from the cover letter, this series was
only compile-tested, so how can you prove the problem exists in the
first place?

> ==== The Solution: Making Management Explicit ====
> This series enforces a clear, predictable model:
> 1.  New Managed API (Patch 1/37): Introduces pcim_alloc_irq_vectors() and
>     pcim_alloc_irq_vectors_affinity(). Drivers that desire devres-managed IRQ
>     vectors should use these functions, which set the is_msi_managed flag and
>     ensure automatic cleanup.
> 2.  Patches 2 through 36 convert each driver that uses pcim_enable_device() alongside
>     pci_alloc_irq_vectors() and relies on devres for IRQ vector cleanup to instead
>     make an explicit call to pcim_alloc_irq_vectors().
> 3.  Core Change (Patch 37/37): With the former cleanup, now modifies pcim_setup_msi_release()
>     to check only the is_msi_managed flag. This decouples automatic IRQ cleanup from
>     pcim_enable_device(). IRQ vectors allocated via pci_alloc_irq_vectors*()
>     are now solely the driver's responsibility to free with pci_free_irq_vectors().
>
> With these changes, we clear ownership model: Explicit resource management eliminates
> ambiguity and follows the "principle of least surprise." New drivers choose one model and
> be consistent.
> - Use `pci_alloc_irq_vectors()` + `pci_free_irq_vectors()` for explicit control.
> - Use `pcim_alloc_irq_vectors()` for devres-managed, automatic cleanup.

Have you checked previous attempts? Why is your series better than those?

> ==== Testing And Review ====
> 1. This series is only compiled test with allmodconfig.
> 2. Given the substantial size of this patch series, I have structured the mailing
>    to facilitate efficient review. The cover letter, the first patch and the last one will be sent
>    to all relevant mailing lists and key maintainers to ensure broad visibility and
>    initial feedback on the overall approach. The remaining subsystem-specific patches
>    will be sent only to the respective subsystem maintainers and their associated
>    mailing lists, reducing noise.

-- 
With Best Regards,
Andy Shevchenko

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

* [PATCH 17/37] crypto: safexcel: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (17 preceding siblings ...)
  2026-02-23 15:50 ` [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Andy Shevchenko
@ 2026-02-23 15:51 ` Shawn Lin
  2026-02-24 15:57   ` kernel test robot
  2026-02-23 15:52 ` [PATCH 18/37] crypto: octeontx2: " Shawn Lin
                   ` (19 subsequent siblings)
  38 siblings, 1 reply; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:51 UTC (permalink / raw)
  To: Antoine Tenart, Herbert Xu, davem
  Cc: linux-crypto, Bjorn Helgaas, Philipp Stanner, linux-pci,
	Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Antoine Tenart <atenart@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
To: davem@davemloft.net
Cc: linux-crypto@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/crypto/inside-secure/safexcel.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
index c3b2b22..4e4991e 100644
--- a/drivers/crypto/inside-secure/safexcel.c
+++ b/drivers/crypto/inside-secure/safexcel.c
@@ -1596,10 +1596,10 @@ static int safexcel_probe_generic(void *pdev,
 		 */
 		struct pci_dev *pci_pdev = pdev;
 
-		ret = pci_alloc_irq_vectors(pci_pdev,
-					    priv->config.rings + 1,
-					    priv->config.rings + 1,
-					    PCI_IRQ_MSI | PCI_IRQ_MSIX);
+		ret = pcim_alloc_irq_vectors(pci_pdev,
+					     priv->config.rings + 1,
+					     priv->config.rings + 1,
+					     PCI_IRQ_MSI | PCI_IRQ_MSIX);
 		if (ret < 0) {
 			dev_err(dev, "Failed to allocate PCI MSI interrupts\n");
 			return ret;
-- 
2.7.4


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

* [PATCH 18/37] crypto: octeontx2: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (18 preceding siblings ...)
  2026-02-23 15:51 ` [PATCH 17/37] crypto: safexcel: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors() Shawn Lin
@ 2026-02-23 15:52 ` Shawn Lin
  2026-02-23 15:52 ` [PATCH 19/37] cxl/pci: " Shawn Lin
                   ` (18 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:52 UTC (permalink / raw)
  To: Srujana Challa, Bharat Bhushan, Herbert Xu, davem
  Cc: linux-crypto, Bjorn Helgaas, Philipp Stanner, linux-pci,
	Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Srujana Challa <schalla@marvell.com>
To: Bharat Bhushan <bbhushan2@marvell.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
To: davem@davemloft.net
Cc: linux-crypto@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c | 2 +-
 drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c b/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c
index f54f905..fbcc65c 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c
@@ -774,7 +774,7 @@ static int otx2_cptpf_probe(struct pci_dev *pdev,
 		goto clear_drvdata;
 	}
 
-	err = pci_alloc_irq_vectors(pdev, num_vec, num_vec, PCI_IRQ_MSIX);
+	err = pcim_alloc_irq_vectors(pdev, num_vec, num_vec, PCI_IRQ_MSIX);
 	if (err < 0) {
 		dev_err(dev, "Request for %d msix vectors failed\n",
 			RVU_PF_INT_VEC_CNT);
diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c b/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c
index c1c44a7b..3f4d791 100644
--- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c
+++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c
@@ -42,8 +42,8 @@ static int cptvf_register_interrupts(struct otx2_cptvf_dev *cptvf)
 		return -EINVAL;
 
 	/* Enable MSI-X */
-	ret = pci_alloc_irq_vectors(cptvf->pdev, num_vec, num_vec,
-				    PCI_IRQ_MSIX);
+	ret = pcim_alloc_irq_vectors(cptvf->pdev, num_vec, num_vec,
+				     PCI_IRQ_MSIX);
 	if (ret < 0) {
 		dev_err(&cptvf->pdev->dev,
 			"Request for %d msix vectors failed\n", num_vec);
-- 
2.7.4


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

* [PATCH 19/37] cxl/pci: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (19 preceding siblings ...)
  2026-02-23 15:52 ` [PATCH 18/37] crypto: octeontx2: " Shawn Lin
@ 2026-02-23 15:52 ` Shawn Lin
  2026-02-24 16:09   ` Jonathan Cameron
  2026-03-02  1:54   ` Davidlohr Bueso
  2026-02-23 15:53 ` [PATCH 20/37] drm/hisilicon/hibmc: " Shawn Lin
                   ` (17 subsequent siblings)
  38 siblings, 2 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:52 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Dan Williams
  Cc: linux-cxl, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Davidlohr Bueso <dave@stgolabs.net>
To: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Dave Jiang <dave.jiang@intel.com>
To: Alison Schofield <alison.schofield@intel.com>
To: Vishal Verma <vishal.l.verma@intel.com>
To: Ira Weiny <ira.weiny@intel.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-cxl@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/cxl/pci.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index fbb300a..de5c9ff 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -565,13 +565,9 @@ static bool cxl_alloc_irq_vectors(struct pci_dev *pdev)
 	 * Per CXL 3.0 3.1.1 CXL.io Endpoint a function on a CXL device must
 	 * not generate INTx messages if that function participates in
 	 * CXL.cache or CXL.mem.
-	 *
-	 * Additionally pci_alloc_irq_vectors() handles calling
-	 * pci_free_irq_vectors() automatically despite not being called
-	 * pcim_*.  See pci_setup_msi_context().
 	 */
-	nvecs = pci_alloc_irq_vectors(pdev, 1, CXL_PCI_DEFAULT_MAX_VECTORS,
-				      PCI_IRQ_MSIX | PCI_IRQ_MSI);
+	nvecs = pcim_alloc_irq_vectors(pdev, 1, CXL_PCI_DEFAULT_MAX_VECTORS,
+				       PCI_IRQ_MSIX | PCI_IRQ_MSI);
 	if (nvecs < 1) {
 		dev_dbg(&pdev->dev, "Failed to alloc irq vectors: %d\n", nvecs);
 		return false;
-- 
2.7.4


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

* [PATCH 20/37] drm/hisilicon/hibmc: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (20 preceding siblings ...)
  2026-02-23 15:52 ` [PATCH 19/37] cxl/pci: " Shawn Lin
@ 2026-02-23 15:53 ` Shawn Lin
  2026-02-23 15:53 ` [PATCH 21/37] iommu/riscv: " Shawn Lin
                   ` (16 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:53 UTC (permalink / raw)
  To: Xinliang Liu, Tian Tao
  Cc: David Airlie, Simona Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, dri-devel, Bjorn Helgaas, Philipp Stanner,
	linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Xinliang Liu <xinliang.liu@linaro.org>
To: Tian Tao <tiantao6@hisilicon.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 2893045..7705c78 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -289,8 +289,8 @@ static int hibmc_msi_init(struct drm_device *dev)
 	int irq;
 	int ret;
 
-	ret = pci_alloc_irq_vectors(pdev, HIBMC_MIN_VECTORS,
-				    HIBMC_MAX_VECTORS, PCI_IRQ_MSI);
+	ret = pcim_alloc_irq_vectors(pdev, HIBMC_MIN_VECTORS,
+				     HIBMC_MAX_VECTORS, PCI_IRQ_MSI);
 	if (ret < 0) {
 		drm_err(dev, "enabling MSI failed: %d\n", ret);
 		return ret;
-- 
2.7.4


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

* [PATCH 21/37] iommu/riscv: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (21 preceding siblings ...)
  2026-02-23 15:53 ` [PATCH 20/37] drm/hisilicon/hibmc: " Shawn Lin
@ 2026-02-23 15:53 ` Shawn Lin
  2026-02-23 15:54 ` [PATCH 22/37] thunderbolt: " Shawn Lin
                   ` (15 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:53 UTC (permalink / raw)
  To: Tomasz Jeznach, Will Deacon, Joerg Roedel
  Cc: iommu, linux-riscv, Bjorn Helgaas, Philipp Stanner, linux-pci,
	Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Tomasz Jeznach <tjeznach@rivosinc.com>
To: Will Deacon <will@kernel.org>
To: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux.dev
Cc: linux-riscv@lists.infradead.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/iommu/riscv/iommu-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/riscv/iommu-pci.c b/drivers/iommu/riscv/iommu-pci.c
index d82d2b0..c5bb926 100644
--- a/drivers/iommu/riscv/iommu-pci.c
+++ b/drivers/iommu/riscv/iommu-pci.c
@@ -75,8 +75,8 @@ static int riscv_iommu_pci_probe(struct pci_dev *pdev, const struct pci_device_i
 	}
 
 	/* Allocate and assign IRQ vectors for the various events */
-	rc = pci_alloc_irq_vectors(pdev, 1, RISCV_IOMMU_INTR_COUNT,
-				   PCI_IRQ_MSIX | PCI_IRQ_MSI);
+	rc = pcim_alloc_irq_vectors(pdev, 1, RISCV_IOMMU_INTR_COUNT,
+				    PCI_IRQ_MSIX | PCI_IRQ_MSI);
 	if (rc <= 0)
 		return dev_err_probe(dev, -ENODEV,
 				     "unable to allocate irq vectors\n");
-- 
2.7.4


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

* [PATCH 22/37] thunderbolt: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (22 preceding siblings ...)
  2026-02-23 15:53 ` [PATCH 21/37] iommu/riscv: " Shawn Lin
@ 2026-02-23 15:54 ` Shawn Lin
  2026-02-23 15:55 ` [PATCH 23/37] accel/amdxdna: " Shawn Lin
                   ` (14 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:54 UTC (permalink / raw)
  To: Andreas Noever, Mika Westerberg, Yehezkel Bernat
  Cc: linux-usb, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Andreas Noever <andreas.noever@gmail.com>
To: Mika Westerberg <westeri@kernel.org>
To: Yehezkel Bernat <YehezkelShB@gmail.com>
Cc: linux-usb@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/thunderbolt/nhi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index 6d0c9d3..06c9a76 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -1281,10 +1281,10 @@ static int nhi_init_msi(struct tb_nhi *nhi)
 	 * one MSI-X. If for some reason that does not work out, we
 	 * fallback to a single MSI.
 	 */
-	nvec = pci_alloc_irq_vectors(pdev, MSIX_MIN_VECS, MSIX_MAX_VECS,
-				     PCI_IRQ_MSIX);
+	nvec = pcim_alloc_irq_vectors(pdev, MSIX_MIN_VECS, MSIX_MAX_VECS,
+				      PCI_IRQ_MSIX);
 	if (nvec < 0) {
-		nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
+		nvec = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
 		if (nvec < 0)
 			return nvec;
 
-- 
2.7.4


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

* [PATCH 23/37] accel/amdxdna: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (23 preceding siblings ...)
  2026-02-23 15:54 ` [PATCH 22/37] thunderbolt: " Shawn Lin
@ 2026-02-23 15:55 ` Shawn Lin
  2026-02-23 15:55 ` [PATCH 24/37] accel/ivpu: " Shawn Lin
                   ` (13 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:55 UTC (permalink / raw)
  To: Min Ma, Lizhi Hou
  Cc: Oded Gabbay, dri-devel, Bjorn Helgaas, Philipp Stanner, linux-pci,
	Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Min Ma <mamin506@gmail.com>
To: Lizhi Hou <lizhi.hou@amd.com>
Cc: Oded Gabbay <ogabbay@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/accel/amdxdna/aie2_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c
index f70ccf0..3935a22 100644
--- a/drivers/accel/amdxdna/aie2_pci.c
+++ b/drivers/accel/amdxdna/aie2_pci.c
@@ -551,7 +551,7 @@ static int aie2_init(struct amdxdna_dev *xdna)
 		goto release_fw;
 	}
 
-	ret = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_MSIX);
+	ret = pcim_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_MSIX);
 	if (ret < 0) {
 		XDNA_ERR(xdna, "failed to alloc irq vectors, ret %d", ret);
 		goto release_fw;
-- 
2.7.4


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

* [PATCH 24/37] accel/ivpu: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (24 preceding siblings ...)
  2026-02-23 15:55 ` [PATCH 23/37] accel/amdxdna: " Shawn Lin
@ 2026-02-23 15:55 ` Shawn Lin
  2026-02-23 15:55 ` [PATCH 25/37] accel/qaic: " Shawn Lin
                   ` (12 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:55 UTC (permalink / raw)
  To: Maciej Falkowski, Karol Wachowski, Oded Gabbay
  Cc: dri-devel, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Maciej Falkowski <maciej.falkowski@linux.intel.com>
To: Karol Wachowski <karol.wachowski@linux.intel.com>
To: Oded Gabbay <ogabbay@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/accel/ivpu/ivpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c
index 8ffda57..5673a07 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -487,7 +487,7 @@ static int ivpu_irq_init(struct ivpu_device *vdev)
 	struct pci_dev *pdev = to_pci_dev(vdev->drm.dev);
 	int ret;
 
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI | PCI_IRQ_MSIX);
 	if (ret < 0) {
 		ivpu_err(vdev, "Failed to allocate a MSI IRQ: %d\n", ret);
 		return ret;
-- 
2.7.4


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

* [PATCH 25/37] accel/qaic: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (25 preceding siblings ...)
  2026-02-23 15:55 ` [PATCH 24/37] accel/ivpu: " Shawn Lin
@ 2026-02-23 15:55 ` Shawn Lin
  2026-02-23 16:01   ` Jeff Hugo
  2026-02-23 15:56 ` [PATCH 26/37] net: stmmac: " Shawn Lin
                   ` (11 subsequent siblings)
  38 siblings, 1 reply; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:55 UTC (permalink / raw)
  To: Jeff Hugo, Oded Gabbay
  Cc: linux-arm-msm, dri-devel, Bjorn Helgaas, Philipp Stanner,
	linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
To: Oded Gabbay <ogabbay@kernel.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/accel/qaic/qaic_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/accel/qaic/qaic_drv.c b/drivers/accel/qaic/qaic_drv.c
index 4c70bd9..2b2e0c5 100644
--- a/drivers/accel/qaic/qaic_drv.c
+++ b/drivers/accel/qaic/qaic_drv.c
@@ -525,9 +525,9 @@ static int init_msi(struct qaic_device *qdev, struct pci_dev *pdev)
 	int i;
 
 	/* Managed release since we use pcim_enable_device */
-	ret = pci_alloc_irq_vectors(pdev, irq_count, irq_count, PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	ret = pcim_alloc_irq_vectors(pdev, irq_count, irq_count, PCI_IRQ_MSI | PCI_IRQ_MSIX);
 	if (ret == -ENOSPC) {
-		ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI | PCI_IRQ_MSIX);
+		ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI | PCI_IRQ_MSIX);
 		if (ret < 0)
 			return ret;
 
-- 
2.7.4


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

* [PATCH 26/37] net: stmmac: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (26 preceding siblings ...)
  2026-02-23 15:55 ` [PATCH 25/37] accel/qaic: " Shawn Lin
@ 2026-02-23 15:56 ` Shawn Lin
  2026-02-23 15:56 ` [PATCH 27/37] r8169: " Shawn Lin
                   ` (10 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:56 UTC (permalink / raw)
  To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Andrew Lunn <andrew+netdev@lunn.ch>
To: davem@davemloft.net
To: Eric Dumazet <edumazet@google.com>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index 92d77b0..e35c138a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -1122,7 +1122,7 @@ static int stmmac_config_single_msi(struct pci_dev *pdev,
 {
 	int ret;
 
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0) {
 		dev_info(&pdev->dev, "%s: Single IRQ enablement failed\n",
 			 __func__);
@@ -1152,8 +1152,8 @@ static int stmmac_config_multi_msi(struct pci_dev *pdev,
 		return -1;
 	}
 
-	ret = pci_alloc_irq_vectors(pdev, 2, STMMAC_MSI_VEC_MAX,
-				    PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	ret = pcim_alloc_irq_vectors(pdev, 2, STMMAC_MSI_VEC_MAX,
+				     PCI_IRQ_MSI | PCI_IRQ_MSIX);
 	if (ret < 0) {
 		dev_info(&pdev->dev, "%s: multi MSI enablement failed\n",
 			 __func__);
-- 
2.7.4


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

* [PATCH 27/37] r8169: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (27 preceding siblings ...)
  2026-02-23 15:56 ` [PATCH 26/37] net: stmmac: " Shawn Lin
@ 2026-02-23 15:56 ` Shawn Lin
  2026-02-23 15:57 ` [PATCH 28/37] net: thunder_bgx: " Shawn Lin
                   ` (9 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:56 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: nic_swsd, netdev, Andrew Lunn, davem, Bjorn Helgaas,
	Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: nic_swsd@realtek.com
Cc: netdev@vger.kernel.org
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: davem@davemloft.net
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/net/ethernet/realtek/r8169_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 2f7d980..e8dd1ef 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5337,7 +5337,7 @@ static int rtl_alloc_irq(struct rtl8169_private *tp)
 		break;
 	}
 
-	return pci_alloc_irq_vectors(tp->pci_dev, 1, 1, flags);
+	return pcim_alloc_irq_vectors(tp->pci_dev, 1, 1, flags);
 }
 
 static void rtl_read_mac_address(struct rtl8169_private *tp,
-- 
2.7.4


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

* [PATCH 28/37] net: thunder_bgx: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (28 preceding siblings ...)
  2026-02-23 15:56 ` [PATCH 27/37] r8169: " Shawn Lin
@ 2026-02-23 15:57 ` Shawn Lin
  2026-02-23 15:57 ` [PATCH 29/37] net: hibmcge: " Shawn Lin
                   ` (8 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:57 UTC (permalink / raw)
  To: Sunil Goutham, Andrew Lunn, davem
  Cc: netdev, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Sunil Goutham <sgoutham@marvell.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 9efb608..8857ac70 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1575,8 +1575,8 @@ static void bgx_register_intr(struct pci_dev *pdev)
 	struct bgx *bgx = pci_get_drvdata(pdev);
 	int ret;
 
-	ret = pci_alloc_irq_vectors(pdev, BGX_LMAC_VEC_OFFSET,
-				    BGX_LMAC_VEC_OFFSET, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pdev, BGX_LMAC_VEC_OFFSET,
+				     BGX_LMAC_VEC_OFFSET, PCI_IRQ_ALL_TYPES);
 	if (ret < 0) {
 		pci_err(pdev, "Req for #%d msix vectors failed\n",
 			BGX_LMAC_VEC_OFFSET);
-- 
2.7.4


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

* [PATCH 29/37] net: hibmcge: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (29 preceding siblings ...)
  2026-02-23 15:57 ` [PATCH 28/37] net: thunder_bgx: " Shawn Lin
@ 2026-02-23 15:57 ` Shawn Lin
  2026-02-23 15:58 ` [PATCH 30/37] mfd: intel-lpss: " Shawn Lin
                   ` (7 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:57 UTC (permalink / raw)
  To: Jijie Shao, Jian Shen, Salil Mehta
  Cc: Andrew Lunn, davem, netdev, Bjorn Helgaas, Philipp Stanner,
	linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Jijie Shao <shaojijie@huawei.com>
To: Jian Shen <shenjian15@huawei.com>
To: Salil Mehta <salil.mehta@huawei.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: davem@davemloft.net
Cc: netdev@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c
index ae4cb35..597c8c8 100644
--- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c
@@ -103,8 +103,8 @@ int hbg_irq_init(struct hbg_priv *priv)
 	u32 i;
 
 	/* used pcim_enable_device(),  so the vectors become device managed */
-	ret = pci_alloc_irq_vectors(priv->pdev, HBG_VECTOR_NUM, HBG_VECTOR_NUM,
-				    PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	ret = pcim_alloc_irq_vectors(priv->pdev, HBG_VECTOR_NUM, HBG_VECTOR_NUM,
+				     PCI_IRQ_MSI | PCI_IRQ_MSIX);
 	if (ret < 0)
 		return dev_err_probe(dev, ret, "failed to allocate vectors\n");
 
-- 
2.7.4


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

* [PATCH 30/37] mfd: intel-lpss: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (30 preceding siblings ...)
  2026-02-23 15:57 ` [PATCH 29/37] net: hibmcge: " Shawn Lin
@ 2026-02-23 15:58 ` Shawn Lin
  2026-02-23 15:58 ` [PATCH 31/37] dmaengine: hsu: " Shawn Lin
                   ` (6 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:58 UTC (permalink / raw)
  To: Lee Jones; +Cc: Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Lee Jones <lee@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mfd/intel-lpss-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c
index 713a5bf..e2bc016 100644
--- a/drivers/mfd/intel-lpss-pci.c
+++ b/drivers/mfd/intel-lpss-pci.c
@@ -54,7 +54,7 @@ static int intel_lpss_pci_probe(struct pci_dev *pdev,
 	if (ret)
 		return ret;
 
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0)
 		return ret;
 
-- 
2.7.4


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

* [PATCH 31/37] dmaengine: hsu: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (31 preceding siblings ...)
  2026-02-23 15:58 ` [PATCH 30/37] mfd: intel-lpss: " Shawn Lin
@ 2026-02-23 15:58 ` Shawn Lin
  2026-02-23 15:58 ` [PATCH 32/37] dmaengine: hisilicon: " Shawn Lin
                   ` (5 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:58 UTC (permalink / raw)
  To: Vinod Koul
  Cc: dmaengine, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/dma/hsu/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/hsu/pci.c b/drivers/dma/hsu/pci.c
index 0fcc0c0..2a306c9 100644
--- a/drivers/dma/hsu/pci.c
+++ b/drivers/dma/hsu/pci.c
@@ -77,7 +77,7 @@ static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (!chip)
 		return -ENOMEM;
 
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0)
 		return ret;
 
-- 
2.7.4


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

* [PATCH 32/37] dmaengine: hisilicon: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (32 preceding siblings ...)
  2026-02-23 15:58 ` [PATCH 31/37] dmaengine: hsu: " Shawn Lin
@ 2026-02-23 15:58 ` Shawn Lin
  2026-02-23 15:58 ` [PATCH 33/37] i3c: mipi-i3c-hci-pci: " Shawn Lin
                   ` (4 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:58 UTC (permalink / raw)
  To: Zhou Wang, Longfang Liu, Vinod Koul
  Cc: dmaengine, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Zhou Wang <wangzhou1@hisilicon.com>
To: Longfang Liu <liulongfang@huawei.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/dma/hisi_dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/hisi_dma.c b/drivers/dma/hisi_dma.c
index 25a4134..d35c5d63 100644
--- a/drivers/dma/hisi_dma.c
+++ b/drivers/dma/hisi_dma.c
@@ -997,8 +997,7 @@ static int hisi_dma_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	msi_num = hisi_dma_get_msi_num(pdev);
 
-	/* This will be freed by 'pcim_release()'. See 'pcim_enable_device()' */
-	ret = pci_alloc_irq_vectors(pdev, msi_num, msi_num, PCI_IRQ_MSI);
+	ret = pcim_alloc_irq_vectors(pdev, msi_num, msi_num, PCI_IRQ_MSI);
 	if (ret < 0) {
 		dev_err(dev, "Failed to allocate MSI vectors!\n");
 		return ret;
-- 
2.7.4


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

* [PATCH 33/37] i3c: mipi-i3c-hci-pci: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (33 preceding siblings ...)
  2026-02-23 15:58 ` [PATCH 32/37] dmaengine: hisilicon: " Shawn Lin
@ 2026-02-23 15:58 ` Shawn Lin
  2026-02-23 15:59 ` [PATCH 34/37] HID: intel-ish-ipc: " Shawn Lin
                   ` (3 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:58 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: linux-i3c, Bjorn Helgaas, Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-i3c@lists.infradead.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
index 0f05a15..4753008 100644
--- a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
+++ b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
@@ -282,7 +282,7 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (IS_ERR(hci->base))
 		return PTR_ERR(hci->base);
 
-	ret = pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0)
 		return ret;
 
-- 
2.7.4


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

* [PATCH 34/37] HID: intel-ish-ipc: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (34 preceding siblings ...)
  2026-02-23 15:58 ` [PATCH 33/37] i3c: mipi-i3c-hci-pci: " Shawn Lin
@ 2026-02-23 15:59 ` Shawn Lin
  2026-02-23 15:59 ` [PATCH 35/37] HID: Intel-thc-hid: " Shawn Lin
                   ` (2 subsequent siblings)
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:59 UTC (permalink / raw)
  To: Srinivas Pandruvada, Jiri Kosina
  Cc: Benjamin Tissoires, linux-input, Bjorn Helgaas, Philipp Stanner,
	linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-input@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/hid/intel-ish-hid/ipc/pci-ish.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
index 1612e8c..6933986 100644
--- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c
+++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
@@ -209,7 +209,7 @@ static int ish_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	ishtp->pdev = pdev;
 
 	/* request and enable interrupt */
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0) {
 		dev_err(dev, "ISH: Failed to allocate IRQ vectors\n");
 		return ret;
-- 
2.7.4


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

* [PATCH 35/37] HID: Intel-thc-hid: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (35 preceding siblings ...)
  2026-02-23 15:59 ` [PATCH 34/37] HID: intel-ish-ipc: " Shawn Lin
@ 2026-02-23 15:59 ` Shawn Lin
  2026-02-23 15:59 ` [PATCH 36/37] misc: microchip: pci1xxxx: " Shawn Lin
  2026-02-24  4:14 ` [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Simon Richter
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:59 UTC (permalink / raw)
  To: Even Xu, Xinpeng Sun
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, Bjorn Helgaas,
	Philipp Stanner, linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: Even Xu <even.xu@intel.com>
To: Xinpeng Sun <xinpeng.sun@intel.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-input@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
index f178017..2bed335 100644
--- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
+++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
@@ -654,7 +654,7 @@ static int quicki2c_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		}
 	}
 
-	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 	if (ret < 0) {
 		dev_err_once(&pdev->dev,
 			     "Failed to allocate IRQ vectors. ret = %d\n", ret);
-- 
2.7.4


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

* [PATCH 36/37] misc: microchip: pci1xxxx: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (36 preceding siblings ...)
  2026-02-23 15:59 ` [PATCH 35/37] HID: Intel-thc-hid: " Shawn Lin
@ 2026-02-23 15:59 ` Shawn Lin
  2026-02-24  4:14 ` [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Simon Richter
  38 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 15:59 UTC (permalink / raw)
  To: vaibhaavram.tl, Kumaravel Thiagarajan
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Bjorn Helgaas, Philipp Stanner,
	linux-pci, Shawn Lin

pcim_enable_device() no longer automatically manages IRQ vectors via devres.
Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
pcim_alloc_irq_vectors() should be used.

To: vaibhaavram.tl@microchip.com
To: Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
index 34c9be4..ef8446f 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
@@ -86,7 +86,7 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id
 	aux_bus->aux_device_wrapper[1]->gp_aux_data.region_start = pci_resource_start(pdev, 0);
 	aux_bus->aux_device_wrapper[1]->gp_aux_data.region_length = pci_resource_end(pdev, 0);
 
-	retval = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	retval = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
 
 	if (retval < 0)
 		goto err_aux_dev_init_1;
-- 
2.7.4


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

* Re: [PATCH 25/37] accel/qaic: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:55 ` [PATCH 25/37] accel/qaic: " Shawn Lin
@ 2026-02-23 16:01   ` Jeff Hugo
  2026-02-23 16:15     ` Shawn Lin
  0 siblings, 1 reply; 62+ messages in thread
From: Jeff Hugo @ 2026-02-23 16:01 UTC (permalink / raw)
  To: Shawn Lin, Oded Gabbay
  Cc: linux-arm-msm, dri-devel, Bjorn Helgaas, Philipp Stanner,
	linux-pci

On 2/23/2026 8:55 AM, Shawn Lin wrote:
> pcim_enable_device() no longer automatically manages IRQ vectors via devres.
> Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
> pcim_alloc_irq_vectors() should be used.

This seems to break bisect.  Surely you should update drivers before you 
go changing behavior.

-Jeff

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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-23 15:50 ` [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Andy Shevchenko
@ 2026-02-23 16:09   ` Shawn Lin
  2026-02-23 17:38     ` Andy Shevchenko
  0 siblings, 1 reply; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 16:09 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: shawn.lin, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson,
	Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Andy Shevchenko, Jan Dabros, linux-i2c,
	Daniel Mack, Haojian Zhuang, linux-spi, Jonathan Derrick,
	linux-pci, linux-gpio, Mauro Carvalho Chehab, linux-media,
	linux-mmc

Hi Andy

在 2026/02/23 星期一 23:50, Andy Shevchenko 写道:
> On Mon, Feb 23, 2026 at 5:32 PM Shawn Lin <shawn.lin@rock-chips.com> wrote:
>>
>> This patch series addresses a long-standing design issue in the PCI/MSI
>> subsystem where the implicit, automatic management of IRQ vectors by
>> the devres framework conflicts with explicit driver cleanup, creating
>> ambiguity and potential resource management bugs.
>>
>> ==== The Problem: Implicit vs. Explicit Management ====
>> Historically, `pcim_enable_device()` not only manages standard PCI resources
>> (BARs) via devres but also implicitly triggers automatic IRQ vector management
>> by setting a flag that registers `pcim_msi_release()` as a cleanup action.
>>
>> This creates an ambiguous ownership model. Many drivers follow a pattern of:
>> 1. Calling `pci_alloc_irq_vectors()` to allocate interrupts.
>> 2. Also calling `pci_free_irq_vectors()` in their error paths or remove routines.
>>
>> When such a driver also uses `pcim_enable_device()`, the devres framework may
>> attempt to free the IRQ vectors a second time upon device release, leading to
>> a double-free. Analysis of the tree shows this hazardous pattern exists widely,
>> while 35 other drivers correctly rely solely on the implicit cleanup.
> 
> Is this confirmed? What I read from the cover letter, this series was
> only compile-tested, so how can you prove the problem exists in the
> first place?

Yes, it's confirmed. My debug of a double free issue of a out-of-tree
PCIe wifi driver which uses
pcim_enable_device + pci_alloc_irq_vectors + pci_free_irq_vectors expose
it. And we did have a TODO to cleanup this hybrid usage, targeted in
this cycle[1] suggested by Philipp:

[1] https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=msi

> 
>> ==== The Solution: Making Management Explicit ====
>> This series enforces a clear, predictable model:
>> 1.  New Managed API (Patch 1/37): Introduces pcim_alloc_irq_vectors() and
>>      pcim_alloc_irq_vectors_affinity(). Drivers that desire devres-managed IRQ
>>      vectors should use these functions, which set the is_msi_managed flag and
>>      ensure automatic cleanup.
>> 2.  Patches 2 through 36 convert each driver that uses pcim_enable_device() alongside
>>      pci_alloc_irq_vectors() and relies on devres for IRQ vector cleanup to instead
>>      make an explicit call to pcim_alloc_irq_vectors().
>> 3.  Core Change (Patch 37/37): With the former cleanup, now modifies pcim_setup_msi_release()
>>      to check only the is_msi_managed flag. This decouples automatic IRQ cleanup from
>>      pcim_enable_device(). IRQ vectors allocated via pci_alloc_irq_vectors*()
>>      are now solely the driver's responsibility to free with pci_free_irq_vectors().
>>
>> With these changes, we clear ownership model: Explicit resource management eliminates
>> ambiguity and follows the "principle of least surprise." New drivers choose one model and
>> be consistent.
>> - Use `pci_alloc_irq_vectors()` + `pci_free_irq_vectors()` for explicit control.
>> - Use `pcim_alloc_irq_vectors()` for devres-managed, automatic cleanup.
> 
> Have you checked previous attempts? Why is your series better than those?

There seems not previous attempts.

> 
>> ==== Testing And Review ====
>> 1. This series is only compiled test with allmodconfig.
>> 2. Given the substantial size of this patch series, I have structured the mailing
>>     to facilitate efficient review. The cover letter, the first patch and the last one will be sent
>>     to all relevant mailing lists and key maintainers to ensure broad visibility and
>>     initial feedback on the overall approach. The remaining subsystem-specific patches
>>     will be sent only to the respective subsystem maintainers and their associated
>>     mailing lists, reducing noise.
> 

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

* Re: [PATCH 25/37] accel/qaic: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 16:01   ` Jeff Hugo
@ 2026-02-23 16:15     ` Shawn Lin
  2026-02-23 16:25       ` Jeff Hugo
  0 siblings, 1 reply; 62+ messages in thread
From: Shawn Lin @ 2026-02-23 16:15 UTC (permalink / raw)
  To: Jeff Hugo, Oded Gabbay
  Cc: shawn.lin, linux-arm-msm, dri-devel, Bjorn Helgaas,
	Philipp Stanner, linux-pci

Hi Jeff

在 2026/02/24 星期二 0:01, Jeff Hugo 写道:
> On 2/23/2026 8:55 AM, Shawn Lin wrote:
>> pcim_enable_device() no longer automatically manages IRQ vectors via 
>> devres.
>> Drivers must now manually call pci_free_irq_vectors() for cleanup. 
>> Alternatively,
>> pcim_alloc_irq_vectors() should be used.
> 
> This seems to break bisect.  Surely you should update drivers before you 
> go changing behavior.

Patch 1 introduces pcim_alloc_irq_vectors() and then convert all needed
users to it. Then the final patch(37) remove the implict IRQ vector
management in pci_alloc_irq_vectors(). So the individual patch for each
driver should be safe IMO. And if these patches go via a single
tree with acks, it seems unlikely to break bisect.

> 
> -Jeff
> 

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

* Re: [PATCH 25/37] accel/qaic: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 16:15     ` Shawn Lin
@ 2026-02-23 16:25       ` Jeff Hugo
  2026-02-24  7:35         ` Philipp Stanner
  0 siblings, 1 reply; 62+ messages in thread
From: Jeff Hugo @ 2026-02-23 16:25 UTC (permalink / raw)
  To: Shawn Lin, Oded Gabbay
  Cc: linux-arm-msm, dri-devel, Bjorn Helgaas, Philipp Stanner,
	linux-pci

On 2/23/2026 9:15 AM, Shawn Lin wrote:
> Hi Jeff
> 
> 在 2026/02/24 星期二 0:01, Jeff Hugo 写道:
>> On 2/23/2026 8:55 AM, Shawn Lin wrote:
>>> pcim_enable_device() no longer automatically manages IRQ vectors via 
>>> devres.
>>> Drivers must now manually call pci_free_irq_vectors() for cleanup. 
>>> Alternatively,
>>> pcim_alloc_irq_vectors() should be used.
>>
>> This seems to break bisect.  Surely you should update drivers before 
>> you go changing behavior.
> 
> Patch 1 introduces pcim_alloc_irq_vectors() and then convert all needed
> users to it. Then the final patch(37) remove the implict IRQ vector
> management in pci_alloc_irq_vectors(). So the individual patch for each
> driver should be safe IMO. And if these patches go via a single
> tree with acks, it seems unlikely to break bisect.

There is a conflict here between the patch description and what you have 
just described. It seems like the patch description is wrong.

The patch says that pcim_enable_device() has already changed behavior, 
and now drivers are broken and must update.

It seems that the description should be updated.

-Jeff

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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-23 16:09   ` Shawn Lin
@ 2026-02-23 17:38     ` Andy Shevchenko
  2026-02-24  2:29       ` Shawn Lin
  0 siblings, 1 reply; 62+ messages in thread
From: Andy Shevchenko @ 2026-02-23 17:38 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Andy Shevchenko, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson,
	Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Jan Dabros, linux-i2c, Daniel Mack,
	Haojian Zhuang, linux-spi, Jonathan Derrick, linux-pci,
	linux-gpio, Mauro Carvalho Chehab, linux-media, linux-mmc

On Tue, Feb 24, 2026 at 12:09:37AM +0800, Shawn Lin wrote:
> 在 2026/02/23 星期一 23:50, Andy Shevchenko 写道:
> > On Mon, Feb 23, 2026 at 5:32 PM Shawn Lin <shawn.lin@rock-chips.com> wrote:
> > > 
> > > This patch series addresses a long-standing design issue in the PCI/MSI
> > > subsystem where the implicit, automatic management of IRQ vectors by
> > > the devres framework conflicts with explicit driver cleanup, creating
> > > ambiguity and potential resource management bugs.
> > > 
> > > ==== The Problem: Implicit vs. Explicit Management ====
> > > Historically, `pcim_enable_device()` not only manages standard PCI resources
> > > (BARs) via devres but also implicitly triggers automatic IRQ vector management
> > > by setting a flag that registers `pcim_msi_release()` as a cleanup action.
> > > 
> > > This creates an ambiguous ownership model. Many drivers follow a pattern of:
> > > 1. Calling `pci_alloc_irq_vectors()` to allocate interrupts.
> > > 2. Also calling `pci_free_irq_vectors()` in their error paths or remove routines.
> > > 
> > > When such a driver also uses `pcim_enable_device()`, the devres framework may
> > > attempt to free the IRQ vectors a second time upon device release, leading to
> > > a double-free. Analysis of the tree shows this hazardous pattern exists widely,
> > > while 35 other drivers correctly rely solely on the implicit cleanup.
> > 
> > Is this confirmed? What I read from the cover letter, this series was
> > only compile-tested, so how can you prove the problem exists in the
> > first place?
> 
> Yes, it's confirmed. My debug of a double free issue of a out-of-tree
> PCIe wifi driver which uses
> pcim_enable_device + pci_alloc_irq_vectors + pci_free_irq_vectors expose
> it. And we did have a TODO to cleanup this hybrid usage, targeted in
> this cycle[1] suggested by Philipp:

Okay, fair enough. I think this bit was missing in the cover letter.

> [1] https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=msi

> > > ==== The Solution: Making Management Explicit ====
> > > This series enforces a clear, predictable model:
> > > 1.  New Managed API (Patch 1/37): Introduces pcim_alloc_irq_vectors() and
> > >      pcim_alloc_irq_vectors_affinity(). Drivers that desire devres-managed IRQ
> > >      vectors should use these functions, which set the is_msi_managed flag and
> > >      ensure automatic cleanup.
> > > 2.  Patches 2 through 36 convert each driver that uses pcim_enable_device() alongside
> > >      pci_alloc_irq_vectors() and relies on devres for IRQ vector cleanup to instead
> > >      make an explicit call to pcim_alloc_irq_vectors().
> > > 3.  Core Change (Patch 37/37): With the former cleanup, now modifies pcim_setup_msi_release()
> > >      to check only the is_msi_managed flag. This decouples automatic IRQ cleanup from
> > >      pcim_enable_device(). IRQ vectors allocated via pci_alloc_irq_vectors*()
> > >      are now solely the driver's responsibility to free with pci_free_irq_vectors().
> > > 
> > > With these changes, we clear ownership model: Explicit resource management eliminates
> > > ambiguity and follows the "principle of least surprise." New drivers choose one model and
> > > be consistent.
> > > - Use `pci_alloc_irq_vectors()` + `pci_free_irq_vectors()` for explicit control.
> > > - Use `pcim_alloc_irq_vectors()` for devres-managed, automatic cleanup.
> > 
> > Have you checked previous attempts? Why is your series better than those?
> 
> There seems not previous attempts.

Maybe we are looking to the different projects...

https://lore.kernel.org/all/?q=pcim_alloc_irq_vectors

> > > ==== Testing And Review ====
> > > 1. This series is only compiled test with allmodconfig.
> > > 2. Given the substantial size of this patch series, I have structured the mailing
> > >     to facilitate efficient review. The cover letter, the first patch and the last one will be sent
> > >     to all relevant mailing lists and key maintainers to ensure broad visibility and
> > >     initial feedback on the overall approach. The remaining subsystem-specific patches
> > >     will be sent only to the respective subsystem maintainers and their associated
> > >     mailing lists, reducing noise.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 04/37] gpio: merrifield: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:42 ` [PATCH 04/37] gpio: merrifield: " Shawn Lin
@ 2026-02-23 17:42   ` Andy Shevchenko
  2026-02-24  2:16     ` Shawn Lin
  0 siblings, 1 reply; 62+ messages in thread
From: Andy Shevchenko @ 2026-02-23 17:42 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, linux-gpio,
	Bjorn Helgaas, Philipp Stanner, linux-pci

On Mon, Feb 23, 2026 at 11:42:56PM +0800, Shawn Lin wrote:
> pcim_enable_device() no longer automatically manages IRQ vectors via devres.
> Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
> pcim_alloc_irq_vectors() should be used.

> Cc: Andy Shevchenko <andy@kernel.org>
> To: Linus Walleij <linusw@kernel.org>
> To: Bartosz Golaszewski <brgl@kernel.org>
> Cc: linux-gpio@vger.kernel.org
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Philipp Stanner <phasta@kernel.org>
> Cc: linux-pci@vger.kernel.org

Please, move the Cc: list in all your patches...

> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---

...to be after the cutter '---' line.

To prevent some questions and doubts read this (patch 18 subthread):
https://lore.kernel.org/all/20260123113708.416727-19-bigeasy@linutronix.de/

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation
  2026-02-23 15:29 ` [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation Shawn Lin
@ 2026-02-24  0:04   ` Jakub Kicinski
  2026-02-24  2:08     ` Shawn Lin
  2026-02-24 16:20   ` Jonathan Cameron
  1 sibling, 1 reply; 62+ messages in thread
From: Jakub Kicinski @ 2026-02-24  0:04 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Bjorn Helgaas, Vaibhaav Ram T . L, Kumaravel Thiagarajan, Even Xu,
	Xinpeng Sun, Srinivas Pandruvada, Jiri Kosina, Alexandre Belloni,
	Zhou Wang, Longfang Liu, Vinod Koul, Lee Jones, Jijie Shao,
	Jian Shen, Sunil Goutham, Andrew Lunn, Heiner Kallweit,
	David S . Miller, Jeff Hugo, Oded Gabbay, Maciej Falkowski,
	Karol Wachowski, Min Ma, Lizhi Hou, Andreas Noever,
	Mika Westerberg, Tomasz Jeznach, Will Deacon, Xinliang Liu,
	Tian Tao, Davidlohr Bueso, Jonathan Cameron, Srujana Challa,
	Bharat Bhushan, Antoine Tenart, Herbert Xu, Raag Jadav,
	Hans de Goede, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Manivannan Sadhasivam, Mika Westerberg, Andi Shyti,
	Robert Richter, Mark Brown, Nirmal Patel, Kurt Schwemmer,
	Logan Gunthorpe, Linus Walleij, Bartosz Golaszewski, Sakari Ailus,
	Bingbu Cao, Ulf Hansson, Arnd Bergmann, Benjamin Tissoires,
	linux-input, linux-i3c, dmaengine, Philipp Stanner, netdev,
	nic_swsd, linux-arm-msm, dri-devel, linux-usb, iommu, linux-riscv,
	David Airlie, Simona Vetter, linux-cxl, linux-crypto,
	platform-driver-x86, linux-serial, mhi, Andy Shevchenko,
	Jan Dabros, linux-i2c, Daniel Mack, Haojian Zhuang, linux-spi,
	Jonathan Derrick, linux-pci, linux-gpio, Mauro Carvalho Chehab,
	linux-media, linux-mmc

On Mon, 23 Feb 2026 23:29:40 +0800 Shawn Lin wrote:
> pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() are created for
> pci device drivers which rely on the devres machinery to help cleanup the IRQ
> vectors.

If you can please add this API with just a few users, and then convert
remaining users via the subsystem trees in the next cycle.
There's no need to risk wasting maintainer time on conflicts with
conversions like this.

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

* Re: [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation
  2026-02-24  0:04   ` Jakub Kicinski
@ 2026-02-24  2:08     ` Shawn Lin
  2026-02-24  7:47       ` Philipp Stanner
  0 siblings, 1 reply; 62+ messages in thread
From: Shawn Lin @ 2026-02-24  2:08 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: shawn.lin, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson,
	Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Andy Shevchenko, Jan Dabros, linux-i2c,
	Daniel Mack, Haojian Zhuang, linux-spi, Jonathan Derrick,
	linux-pci, linux-gpio, Mauro Carvalho Chehab, linux-media,
	linux-mmc

在 2026/02/24 星期二 8:04, Jakub Kicinski 写道:
> On Mon, 23 Feb 2026 23:29:40 +0800 Shawn Lin wrote:
>> pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() are created for
>> pci device drivers which rely on the devres machinery to help cleanup the IRQ
>> vectors.
> 
> If you can please add this API with just a few users, and then convert
> remaining users via the subsystem trees in the next cycle.
> There's no need to risk wasting maintainer time on conflicts with
> conversions like this.

Thanks for the suggestion, Jakub. I have little experience with 
cross-subsystem cleanups like this, so your suggestion is very helpful.

> 

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

* Re: [PATCH 04/37] gpio: merrifield: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 17:42   ` Andy Shevchenko
@ 2026-02-24  2:16     ` Shawn Lin
  0 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-24  2:16 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: shawn.lin, Linus Walleij, Bartosz Golaszewski, Andy Shevchenko,
	linux-gpio, Bjorn Helgaas, Philipp Stanner, linux-pci

在 2026/02/24 星期二 1:42, Andy Shevchenko 写道:
> On Mon, Feb 23, 2026 at 11:42:56PM +0800, Shawn Lin wrote:
>> pcim_enable_device() no longer automatically manages IRQ vectors via devres.
>> Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
>> pcim_alloc_irq_vectors() should be used.
> 
>> Cc: Andy Shevchenko <andy@kernel.org>
>> To: Linus Walleij <linusw@kernel.org>
>> To: Bartosz Golaszewski <brgl@kernel.org>
>> Cc: linux-gpio@vger.kernel.org
>> Cc: Bjorn Helgaas <bhelgaas@google.com>
>> Cc: Philipp Stanner <phasta@kernel.org>
>> Cc: linux-pci@vger.kernel.org
> 
> Please, move the Cc: list in all your patches...
> 
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>> ---
> 
> ...to be after the cutter '---' line.
> 
> To prevent some questions and doubts read this (patch 18 subthread):
> https://lore.kernel.org/all/20260123113708.416727-19-bigeasy@linutronix.de/

Ok, I was not aware of the doubts in the link you refer to. Will improve
my tool to let it help move the Cc list to be after the `---` line.

> 

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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-23 17:38     ` Andy Shevchenko
@ 2026-02-24  2:29       ` Shawn Lin
  0 siblings, 0 replies; 62+ messages in thread
From: Shawn Lin @ 2026-02-24  2:29 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: shawn.lin, Andy Shevchenko, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson,
	Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Jan Dabros, linux-i2c, Daniel Mack,
	Haojian Zhuang, linux-spi, Jonathan Derrick, linux-pci,
	linux-gpio, Mauro Carvalho Chehab, linux-media, linux-mmc

在 2026/02/24 星期二 1:38, Andy Shevchenko 写道:
> On Tue, Feb 24, 2026 at 12:09:37AM +0800, Shawn Lin wrote:
>> 在 2026/02/23 星期一 23:50, Andy Shevchenko 写道:
>>> On Mon, Feb 23, 2026 at 5:32 PM Shawn Lin <shawn.lin@rock-chips.com> wrote:
>>>>
>>>> This patch series addresses a long-standing design issue in the PCI/MSI
>>>> subsystem where the implicit, automatic management of IRQ vectors by
>>>> the devres framework conflicts with explicit driver cleanup, creating
>>>> ambiguity and potential resource management bugs.
>>>>
>>>> ==== The Problem: Implicit vs. Explicit Management ====
>>>> Historically, `pcim_enable_device()` not only manages standard PCI resources
>>>> (BARs) via devres but also implicitly triggers automatic IRQ vector management
>>>> by setting a flag that registers `pcim_msi_release()` as a cleanup action.
>>>>
>>>> This creates an ambiguous ownership model. Many drivers follow a pattern of:
>>>> 1. Calling `pci_alloc_irq_vectors()` to allocate interrupts.
>>>> 2. Also calling `pci_free_irq_vectors()` in their error paths or remove routines.
>>>>
>>>> When such a driver also uses `pcim_enable_device()`, the devres framework may
>>>> attempt to free the IRQ vectors a second time upon device release, leading to
>>>> a double-free. Analysis of the tree shows this hazardous pattern exists widely,
>>>> while 35 other drivers correctly rely solely on the implicit cleanup.
>>>
>>> Is this confirmed? What I read from the cover letter, this series was
>>> only compile-tested, so how can you prove the problem exists in the
>>> first place?
>>
>> Yes, it's confirmed. My debug of a double free issue of a out-of-tree
>> PCIe wifi driver which uses
>> pcim_enable_device + pci_alloc_irq_vectors + pci_free_irq_vectors expose
>> it. And we did have a TODO to cleanup this hybrid usage, targeted in
>> this cycle[1] suggested by Philipp:
> 
> Okay, fair enough. I think this bit was missing in the cover letter.
> 
>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=msi
> 
>>>> ==== The Solution: Making Management Explicit ====
>>>> This series enforces a clear, predictable model:
>>>> 1.  New Managed API (Patch 1/37): Introduces pcim_alloc_irq_vectors() and
>>>>       pcim_alloc_irq_vectors_affinity(). Drivers that desire devres-managed IRQ
>>>>       vectors should use these functions, which set the is_msi_managed flag and
>>>>       ensure automatic cleanup.
>>>> 2.  Patches 2 through 36 convert each driver that uses pcim_enable_device() alongside
>>>>       pci_alloc_irq_vectors() and relies on devres for IRQ vector cleanup to instead
>>>>       make an explicit call to pcim_alloc_irq_vectors().
>>>> 3.  Core Change (Patch 37/37): With the former cleanup, now modifies pcim_setup_msi_release()
>>>>       to check only the is_msi_managed flag. This decouples automatic IRQ cleanup from
>>>>       pcim_enable_device(). IRQ vectors allocated via pci_alloc_irq_vectors*()
>>>>       are now solely the driver's responsibility to free with pci_free_irq_vectors().
>>>>
>>>> With these changes, we clear ownership model: Explicit resource management eliminates
>>>> ambiguity and follows the "principle of least surprise." New drivers choose one model and
>>>> be consistent.
>>>> - Use `pci_alloc_irq_vectors()` + `pci_free_irq_vectors()` for explicit control.
>>>> - Use `pcim_alloc_irq_vectors()` for devres-managed, automatic cleanup.
>>>
>>> Have you checked previous attempts? Why is your series better than those?
>>

Thanks for sharing this 5-years-old discusstion, I totally missed it.

I read the V7 discussion, and it seems to have disappeared without much
follow-up, like a stone dropped into the ocean. For five years, newly
added drivers have continued to misuse these APIs incorrectly, and
we’ve been watching it happen. I can’t really claim this patch series
is inherently better than Dejin’s earlier work at its core, this is
just about fixing one entire category of misuse in a single pass.

According to Bjorn's final search and reply, if we include the removal
of deprecated APIs, it would require a massive amount of work and might
span many release cycles. Unfortunately, the work never began, and the
cleanup might never be completed. I’m not sure if folks have changed
their minds now. Can we at least start by completing the changes for the
pci_alloc_irq_vectors category?


>> There seems not previous attempts.
> 
> Maybe we are looking to the different projects...
> 
> https://lore.kernel.org/all/?q=pcim_alloc_irq_vectors
> 
>>>> ==== Testing And Review ====
>>>> 1. This series is only compiled test with allmodconfig.
>>>> 2. Given the substantial size of this patch series, I have structured the mailing
>>>>      to facilitate efficient review. The cover letter, the first patch and the last one will be sent
>>>>      to all relevant mailing lists and key maintainers to ensure broad visibility and
>>>>      initial feedback on the overall approach. The remaining subsystem-specific patches
>>>>      will be sent only to the respective subsystem maintainers and their associated
>>>>      mailing lists, reducing noise.
> 

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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
                   ` (37 preceding siblings ...)
  2026-02-23 15:59 ` [PATCH 36/37] misc: microchip: pci1xxxx: " Shawn Lin
@ 2026-02-24  4:14 ` Simon Richter
  2026-02-24  7:39   ` Philipp Stanner
  38 siblings, 1 reply; 62+ messages in thread
From: Simon Richter @ 2026-02-24  4:14 UTC (permalink / raw)
  To: Shawn Lin, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson
  Cc: Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Andy Shevchenko, Jan Dabros, linux-i2c,
	Daniel Mack, Haojian Zhuang, linux-spi, Jonathan Derrick,
	linux-pci, linux-gpio, Mauro Carvalho Chehab, linux-media,
	linux-mmc

Hi,

On 2/24/26 12:29 AM, Shawn Lin wrote:

> When such a driver also uses `pcim_enable_device()`, the devres framework may
> attempt to free the IRQ vectors a second time upon device release, leading to
> a double-free. Analysis of the tree shows this hazardous pattern exists widely,
> while 35 other drivers correctly rely solely on the implicit cleanup.

Would it make sense to have a function pcim_free_irq_vectors(), to allow 
explicit freeing even if the device is otherwise managed, analogous to 
pcim_iounmap()?

    Simon

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

* Re: [PATCH 25/37] accel/qaic: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 16:25       ` Jeff Hugo
@ 2026-02-24  7:35         ` Philipp Stanner
  0 siblings, 0 replies; 62+ messages in thread
From: Philipp Stanner @ 2026-02-24  7:35 UTC (permalink / raw)
  To: Jeff Hugo, Shawn Lin, Oded Gabbay
  Cc: linux-arm-msm, dri-devel, Bjorn Helgaas, Philipp Stanner,
	linux-pci

On Mon, 2026-02-23 at 09:25 -0700, Jeff Hugo wrote:
> On 2/23/2026 9:15 AM, Shawn Lin wrote:
> > Hi Jeff
> > 
> > 在 2026/02/24 星期二 0:01, Jeff Hugo 写道:
> > > On 2/23/2026 8:55 AM, Shawn Lin wrote:
> > > > pcim_enable_device() no longer automatically manages IRQ vectors via 
> > > > devres.
> > > > Drivers must now manually call pci_free_irq_vectors() for cleanup. 
> > > > Alternatively,
> > > > pcim_alloc_irq_vectors() should be used.
> > > 
> > > This seems to break bisect.  Surely you should update drivers before 
> > > you go changing behavior.
> > 
> > Patch 1 introduces pcim_alloc_irq_vectors() and then convert all needed
> > users to it. Then the final patch(37) remove the implict IRQ vector
> > management in pci_alloc_irq_vectors(). So the individual patch for each
> > driver should be safe IMO. And if these patches go via a single
> > tree with acks, it seems unlikely to break bisect.
> 
> There is a conflict here between the patch description and what you have 
> just described. It seems like the patch description is wrong.
> 
> The patch says that pcim_enable_device() has already changed behavior, 
> and now drivers are broken and must update.
> 
> It seems that the description should be updated.

+1, the commit message should state that the driver patches are cleanup
preparations.


P.

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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-24  4:14 ` [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Simon Richter
@ 2026-02-24  7:39   ` Philipp Stanner
  2026-02-24  9:12     ` Andy Shevchenko
  0 siblings, 1 reply; 62+ messages in thread
From: Philipp Stanner @ 2026-02-24  7:39 UTC (permalink / raw)
  To: Simon Richter, Shawn Lin, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson
  Cc: Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, Philipp Stanner, netdev, nic_swsd, linux-arm-msm,
	dri-devel, linux-usb, iommu, linux-riscv, David Airlie,
	Simona Vetter, linux-cxl, linux-crypto, platform-driver-x86,
	linux-serial, mhi, Andy Shevchenko, Jan Dabros, linux-i2c,
	Daniel Mack, Haojian Zhuang, linux-spi, Jonathan Derrick,
	linux-pci, linux-gpio, Mauro Carvalho Chehab, linux-media,
	linux-mmc

On Tue, 2026-02-24 at 13:14 +0900, Simon Richter wrote:
> Hi,
> 
> On 2/24/26 12:29 AM, Shawn Lin wrote:
> 
> > When such a driver also uses `pcim_enable_device()`, the devres framework may
> > attempt to free the IRQ vectors a second time upon device release, leading to
> > a double-free. Analysis of the tree shows this hazardous pattern exists widely,
> > while 35 other drivers correctly rely solely on the implicit cleanup.
> 
> Would it make sense to have a function pcim_free_irq_vectors(), to allow 
> explicit freeing even if the device is otherwise managed, analogous to 
> pcim_iounmap()?

We used to add those. In part because it is easier to port old users.

Nowadays I tend to think that those APIs were more on the too-complex
than too-simple side for a long time. As an expert or as the API
designer you wouldn't expect it, but there are actually far too many
users who came to believe they always have to use pcim_iounmap() and
counter parts.

If I could design it from scratch I would probably try to tell users to
use the unmanaged versions instead of revoking the devres consequence.

Devres is actually about your consequence always happening whenever the
driver unloads, for whatever reason.


P.

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

* Re: [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation
  2026-02-24  2:08     ` Shawn Lin
@ 2026-02-24  7:47       ` Philipp Stanner
  2026-02-24  8:21         ` Shawn Lin
  0 siblings, 1 reply; 62+ messages in thread
From: Philipp Stanner @ 2026-02-24  7:47 UTC (permalink / raw)
  To: Shawn Lin, Jakub Kicinski
  Cc: Bjorn Helgaas, Vaibhaav Ram T . L, Kumaravel Thiagarajan, Even Xu,
	Xinpeng Sun, Srinivas Pandruvada, Jiri Kosina, Alexandre Belloni,
	Zhou Wang, Longfang Liu, Vinod Koul, Lee Jones, Jijie Shao,
	Jian Shen, Sunil Goutham, Andrew Lunn, Heiner Kallweit,
	David S . Miller, Jeff Hugo, Oded Gabbay, Maciej Falkowski,
	Karol Wachowski, Min Ma, Lizhi Hou, Andreas Noever,
	Mika Westerberg, Tomasz Jeznach, Will Deacon, Xinliang Liu,
	Tian Tao, Davidlohr Bueso, Jonathan Cameron, Srujana Challa,
	Bharat Bhushan, Antoine Tenart, Herbert Xu, Raag Jadav,
	Hans de Goede, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Manivannan Sadhasivam, Mika Westerberg, Andi Shyti,
	Robert Richter, Mark Brown, Nirmal Patel, Kurt Schwemmer,
	Logan Gunthorpe, Linus Walleij, Bartosz Golaszewski, Sakari Ailus,
	Bingbu Cao, Ulf Hansson, Arnd Bergmann, Benjamin Tissoires,
	linux-input, linux-i3c, dmaengine, Philipp Stanner, netdev,
	nic_swsd, linux-arm-msm, dri-devel, linux-usb, iommu, linux-riscv,
	David Airlie, Simona Vetter, linux-cxl, linux-crypto,
	platform-driver-x86, linux-serial, mhi, Andy Shevchenko,
	Jan Dabros, linux-i2c, Daniel Mack, Haojian Zhuang, linux-spi,
	Jonathan Derrick, linux-pci, linux-gpio, Mauro Carvalho Chehab,
	linux-media, linux-mmc

On Tue, 2026-02-24 at 10:08 +0800, Shawn Lin wrote:
> 在 2026/02/24 星期二 8:04, Jakub Kicinski 写道:
> > On Mon, 23 Feb 2026 23:29:40 +0800 Shawn Lin wrote:
> > > pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() are created for
> > > pci device drivers which rely on the devres machinery to help cleanup the IRQ
> > > vectors.
> > 
> > If you can please add this API with just a few users, and then convert
> > remaining users via the subsystem trees in the next cycle.
> > There's no need to risk wasting maintainer time on conflicts with
> > conversions like this.
> 
> Thanks for the suggestion, Jakub. I have little experience with 
> cross-subsystem cleanups like this, so your suggestion is very helpful.


When I removed the hybrid nature of pci_request_region() et al., I
concluded that there were so few users that doing them all in one run
was sufficient.

For larger reworks, like removing pcim_iomap_table(), a slower step-by-
step strategy is necessary for the reasons that Jakub details.

It is then smart to omit an easy to port subsystem / driver for the
ultimate patch series where one then removes the hybrid behavior from
PCI itself, after porting the last driver.

In general,  as Jakub details, those step-by-step cleanups are a bit
safer, since you can proof valid behavior early on and in case of an
explosion they are very easy to revert.


P.

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

* Re: [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation
  2026-02-24  7:47       ` Philipp Stanner
@ 2026-02-24  8:21         ` Shawn Lin
  2026-02-24  8:32           ` Philipp Stanner
  0 siblings, 1 reply; 62+ messages in thread
From: Shawn Lin @ 2026-02-24  8:21 UTC (permalink / raw)
  To: phasta
  Cc: shawn.lin, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson,
	Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, netdev, nic_swsd, linux-arm-msm, dri-devel, linux-usb,
	iommu, linux-riscv, David Airlie, Simona Vetter, linux-cxl,
	linux-crypto, platform-driver-x86, linux-serial, mhi,
	Andy Shevchenko, Jan Dabros, linux-i2c, Daniel Mack,
	Haojian Zhuang, linux-spi, Jonathan Derrick, linux-pci,
	linux-gpio, Mauro Carvalho Chehab, linux-media, linux-mmc,
	Jakub Kicinski

在 2026/02/24 星期二 15:47, Philipp Stanner 写道:
> On Tue, 2026-02-24 at 10:08 +0800, Shawn Lin wrote:
>> 在 2026/02/24 星期二 8:04, Jakub Kicinski 写道:
>>> On Mon, 23 Feb 2026 23:29:40 +0800 Shawn Lin wrote:
>>>> pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() are created for
>>>> pci device drivers which rely on the devres machinery to help cleanup the IRQ
>>>> vectors.
>>>
>>> If you can please add this API with just a few users, and then convert
>>> remaining users via the subsystem trees in the next cycle.
>>> There's no need to risk wasting maintainer time on conflicts with
>>> conversions like this.
>>
>> Thanks for the suggestion, Jakub. I have little experience with
>> cross-subsystem cleanups like this, so your suggestion is very helpful.
> 
> 
> When I removed the hybrid nature of pci_request_region() et al., I
> concluded that there were so few users that doing them all in one run
> was sufficient.
> 
> For larger reworks, like removing pcim_iomap_table(), a slower step-by-
> step strategy is necessary for the reasons that Jakub details.
> 
> It is then smart to omit an easy to port subsystem / driver for the
> ultimate patch series where one then removes the hybrid behavior from
> PCI itself, after porting the last driver.
> 
> In general,  as Jakub details, those step-by-step cleanups are a bit
> safer, since you can proof valid behavior early on and in case of an
> explosion they are very easy to revert.
> 

Thank you, Philipp. I wish I had attended your talk at FOSDEM 2025 on
removing pcim_iomap_table earlier. This first version was perhaps a bit 
too aggressive. For v2, I think the plan should start with addressing 
the switchtec and vmd drivers, since both of those, along with the new 
API additions, can be handled entirely within the PCI subsystem scope.

> 
> P.
> 

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

* Re: [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation
  2026-02-24  8:21         ` Shawn Lin
@ 2026-02-24  8:32           ` Philipp Stanner
  0 siblings, 0 replies; 62+ messages in thread
From: Philipp Stanner @ 2026-02-24  8:32 UTC (permalink / raw)
  To: Shawn Lin, phasta
  Cc: Bjorn Helgaas, Vaibhaav Ram T . L, Kumaravel Thiagarajan, Even Xu,
	Xinpeng Sun, Srinivas Pandruvada, Jiri Kosina, Alexandre Belloni,
	Zhou Wang, Longfang Liu, Vinod Koul, Lee Jones, Jijie Shao,
	Jian Shen, Sunil Goutham, Andrew Lunn, Heiner Kallweit,
	David S . Miller, Jeff Hugo, Oded Gabbay, Maciej Falkowski,
	Karol Wachowski, Min Ma, Lizhi Hou, Andreas Noever,
	Mika Westerberg, Tomasz Jeznach, Will Deacon, Xinliang Liu,
	Tian Tao, Davidlohr Bueso, Jonathan Cameron, Srujana Challa,
	Bharat Bhushan, Antoine Tenart, Herbert Xu, Raag Jadav,
	Hans de Goede, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Manivannan Sadhasivam, Mika Westerberg, Andi Shyti,
	Robert Richter, Mark Brown, Nirmal Patel, Kurt Schwemmer,
	Logan Gunthorpe, Linus Walleij, Bartosz Golaszewski, Sakari Ailus,
	Bingbu Cao, Ulf Hansson, Arnd Bergmann, Benjamin Tissoires,
	linux-input, linux-i3c, dmaengine, netdev, nic_swsd,
	linux-arm-msm, dri-devel, linux-usb, iommu, linux-riscv,
	David Airlie, Simona Vetter, linux-cxl, linux-crypto,
	platform-driver-x86, linux-serial, mhi, Andy Shevchenko,
	Jan Dabros, linux-i2c, Daniel Mack, Haojian Zhuang, linux-spi,
	Jonathan Derrick, linux-pci, linux-gpio, Mauro Carvalho Chehab,
	linux-media, linux-mmc, Jakub Kicinski

On Tue, 2026-02-24 at 16:21 +0800, Shawn Lin wrote:
> 在 2026/02/24 星期二 15:47, Philipp Stanner 写道:
> > On Tue, 2026-02-24 at 10:08 +0800, Shawn Lin wrote:
> > > 在 2026/02/24 星期二 8:04, Jakub Kicinski 写道:
> > > > On Mon, 23 Feb 2026 23:29:40 +0800 Shawn Lin wrote:
> > > > > pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() are created for
> > > > > pci device drivers which rely on the devres machinery to help cleanup the IRQ
> > > > > vectors.
> > > > 
> > > > If you can please add this API with just a few users, and then convert
> > > > remaining users via the subsystem trees in the next cycle.
> > > > There's no need to risk wasting maintainer time on conflicts with
> > > > conversions like this.
> > > 
> > > Thanks for the suggestion, Jakub. I have little experience with
> > > cross-subsystem cleanups like this, so your suggestion is very helpful.
> > 
> > 
> > When I removed the hybrid nature of pci_request_region() et al., I
> > concluded that there were so few users that doing them all in one run
> > was sufficient.
> > 
> > For larger reworks, like removing pcim_iomap_table(), a slower step-by-
> > step strategy is necessary for the reasons that Jakub details.
> > 
> > It is then smart to omit an easy to port subsystem / driver for the
> > ultimate patch series where one then removes the hybrid behavior from
> > PCI itself, after porting the last driver.
> > 
> > In general,  as Jakub details, those step-by-step cleanups are a bit
> > safer, since you can proof valid behavior early on and in case of an
> > explosion they are very easy to revert.
> > 
> 
> Thank you, Philipp. I wish I had attended your talk at FOSDEM 2025 on
> removing pcim_iomap_table earlier. This first version was perhaps a bit 
> too aggressive.

No worries at all, it's very cool that you pick this work up!

>  For v2, I think the plan should start with addressing
> the switchtec and vmd drivers, since both of those, along with the new 
> API additions, can be handled entirely within the PCI subsystem scope.

Sounds reasonable to me.

Regards
Philipp

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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-24  7:39   ` Philipp Stanner
@ 2026-02-24  9:12     ` Andy Shevchenko
  2026-02-24 10:30       ` Philipp Stanner
  0 siblings, 1 reply; 62+ messages in thread
From: Andy Shevchenko @ 2026-02-24  9:12 UTC (permalink / raw)
  To: phasta
  Cc: Simon Richter, Shawn Lin, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson,
	Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, netdev, nic_swsd, linux-arm-msm, dri-devel, linux-usb,
	iommu, linux-riscv, David Airlie, Simona Vetter, linux-cxl,
	linux-crypto, platform-driver-x86, linux-serial, mhi, Jan Dabros,
	linux-i2c, Daniel Mack, Haojian Zhuang, linux-spi,
	Jonathan Derrick, linux-pci, linux-gpio, Mauro Carvalho Chehab,
	linux-media, linux-mmc

On Tue, Feb 24, 2026 at 08:39:43AM +0100, Philipp Stanner wrote:
> On Tue, 2026-02-24 at 13:14 +0900, Simon Richter wrote:
> > On 2/24/26 12:29 AM, Shawn Lin wrote:

> > > When such a driver also uses `pcim_enable_device()`, the devres framework may
> > > attempt to free the IRQ vectors a second time upon device release, leading to
> > > a double-free. Analysis of the tree shows this hazardous pattern exists widely,
> > > while 35 other drivers correctly rely solely on the implicit cleanup.
> > 
> > Would it make sense to have a function pcim_free_irq_vectors(), to allow 
> > explicit freeing even if the device is otherwise managed, analogous to 
> > pcim_iounmap()?
> 
> We used to add those. In part because it is easier to port old users.
> 
> Nowadays I tend to think that those APIs were more on the too-complex
> than too-simple side for a long time. As an expert or as the API
> designer you wouldn't expect it, but there are actually far too many
> users who came to believe they always have to use pcim_iounmap() and
> counter parts.
> 
> If I could design it from scratch I would probably try to tell users to
> use the unmanaged versions instead of revoking the devres consequence.

+many.

> Devres is actually about your consequence always happening whenever the
> driver unloads, for whatever reason.

I believe you meant "unbinds". The device<-->driver link can be broken
without unloading the driver.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-24  9:12     ` Andy Shevchenko
@ 2026-02-24 10:30       ` Philipp Stanner
  2026-02-24 10:39         ` Andy Shevchenko
  0 siblings, 1 reply; 62+ messages in thread
From: Philipp Stanner @ 2026-02-24 10:30 UTC (permalink / raw)
  To: Andy Shevchenko, phasta
  Cc: Simon Richter, Shawn Lin, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson,
	Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, netdev, nic_swsd, linux-arm-msm, dri-devel, linux-usb,
	iommu, linux-riscv, David Airlie, Simona Vetter, linux-cxl,
	linux-crypto, platform-driver-x86, linux-serial, mhi, Jan Dabros,
	linux-i2c, Daniel Mack, Haojian Zhuang, linux-spi,
	Jonathan Derrick, linux-pci, linux-gpio, Mauro Carvalho Chehab,
	linux-media, linux-mmc

On Tue, 2026-02-24 at 11:12 +0200, Andy Shevchenko wrote:
> On Tue, Feb 24, 2026 at 08:39:43AM +0100, Philipp Stanner wrote:
> > On Tue, 2026-02-24 at 13:14 +0900, Simon Richter wrote:
> > > On 2/24/26 12:29 AM, Shawn Lin wrote:
> 
> > > > When such a driver also uses `pcim_enable_device()`, the devres framework may
> > > > attempt to free the IRQ vectors a second time upon device release, leading to
> > > > a double-free. Analysis of the tree shows this hazardous pattern exists widely,
> > > > while 35 other drivers correctly rely solely on the implicit cleanup.
> > > 
> > > Would it make sense to have a function pcim_free_irq_vectors(), to allow 
> > > explicit freeing even if the device is otherwise managed, analogous to 
> > > pcim_iounmap()?
> > 
> > We used to add those. In part because it is easier to port old users.
> > 
> > Nowadays I tend to think that those APIs were more on the too-complex
> > than too-simple side for a long time. As an expert or as the API
> > designer you wouldn't expect it, but there are actually far too many
> > users who came to believe they always have to use pcim_iounmap() and
> > counter parts.
> > 
> > If I could design it from scratch I would probably try to tell users to
> > use the unmanaged versions instead of revoking the devres consequence.
> 
> +many.

hm?

> 
> > Devres is actually about your consequence always happening whenever the
> > driver unloads, for whatever reason.
> 
> I believe you meant "unbinds". The device<-->driver link can be broken
> without unloading the driver.

Yes, thx for pointing that out. Greg KH AFAIK always calls it "driver
detach".

P.

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

* Re: [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free
  2026-02-24 10:30       ` Philipp Stanner
@ 2026-02-24 10:39         ` Andy Shevchenko
  0 siblings, 0 replies; 62+ messages in thread
From: Andy Shevchenko @ 2026-02-24 10:39 UTC (permalink / raw)
  To: phasta
  Cc: Simon Richter, Shawn Lin, Bjorn Helgaas, Vaibhaav Ram T . L,
	Kumaravel Thiagarajan, Even Xu, Xinpeng Sun, Srinivas Pandruvada,
	Jiri Kosina, Alexandre Belloni, Zhou Wang, Longfang Liu,
	Vinod Koul, Lee Jones, Jijie Shao, Jian Shen, Sunil Goutham,
	Andrew Lunn, Heiner Kallweit, David S . Miller, Jeff Hugo,
	Oded Gabbay, Maciej Falkowski, Karol Wachowski, Min Ma, Lizhi Hou,
	Andreas Noever, Mika Westerberg, Tomasz Jeznach, Will Deacon,
	Xinliang Liu, Tian Tao, Davidlohr Bueso, Jonathan Cameron,
	Srujana Challa, Bharat Bhushan, Antoine Tenart, Herbert Xu,
	Raag Jadav, Hans de Goede, Greg Kroah-Hartman, Jiri Slaby,
	Andy Shevchenko, Manivannan Sadhasivam, Mika Westerberg,
	Andi Shyti, Robert Richter, Mark Brown, Nirmal Patel,
	Kurt Schwemmer, Logan Gunthorpe, Linus Walleij,
	Bartosz Golaszewski, Sakari Ailus, Bingbu Cao, Ulf Hansson,
	Arnd Bergmann, Benjamin Tissoires, linux-input, linux-i3c,
	dmaengine, netdev, nic_swsd, linux-arm-msm, dri-devel, linux-usb,
	iommu, linux-riscv, David Airlie, Simona Vetter, linux-cxl,
	linux-crypto, platform-driver-x86, linux-serial, mhi, Jan Dabros,
	linux-i2c, Daniel Mack, Haojian Zhuang, linux-spi,
	Jonathan Derrick, linux-pci, linux-gpio, Mauro Carvalho Chehab,
	linux-media, linux-mmc

On Tue, Feb 24, 2026 at 11:30:28AM +0100, Philipp Stanner wrote:
> On Tue, 2026-02-24 at 11:12 +0200, Andy Shevchenko wrote:
> > On Tue, Feb 24, 2026 at 08:39:43AM +0100, Philipp Stanner wrote:
> > > On Tue, 2026-02-24 at 13:14 +0900, Simon Richter wrote:

...

> > > If I could design it from scratch I would probably try to tell users to
> > > use the unmanaged versions instead of revoking the devres consequence.
> > 
> > +many.

> hm?

I'm supporting you with many hands up (more than I possess)!

> > > Devres is actually about your consequence always happening whenever the
> > > driver unloads, for whatever reason.
> > 
> > I believe you meant "unbinds". The device<-->driver link can be broken
> > without unloading the driver.
> 
> Yes, thx for pointing that out. Greg KH AFAIK always calls it "driver
> detach".

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 17/37] crypto: safexcel: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:51 ` [PATCH 17/37] crypto: safexcel: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors() Shawn Lin
@ 2026-02-24 15:57   ` kernel test robot
  0 siblings, 0 replies; 62+ messages in thread
From: kernel test robot @ 2026-02-24 15:57 UTC (permalink / raw)
  To: Shawn Lin, Antoine Tenart, Herbert Xu, davem
  Cc: oe-kbuild-all, linux-crypto, Bjorn Helgaas, Philipp Stanner,
	linux-pci, Shawn Lin

Hi Shawn,

kernel test robot noticed the following build errors:

[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus andi-shyti/i2c/i2c-host drm-misc/drm-misc-next linus/master v7.0-rc1 next-20260223]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shawn-Lin/PCI-MSI-Add-Devres-managed-IRQ-vectors-allocation/20260224-161502
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link:    https://lore.kernel.org/r/1771861910-88163-1-git-send-email-shawn.lin%40rock-chips.com
patch subject: [PATCH 17/37] crypto: safexcel: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
config: sh-allyesconfig (https://download.01.org/0day-ci/archive/20260224/202602242339.UGFAC9fD-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260224/202602242339.UGFAC9fD-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602242339.UGFAC9fD-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/crypto/inside-secure/safexcel.c: In function 'safexcel_probe_generic':
>> drivers/crypto/inside-secure/safexcel.c:1599:23: error: implicit declaration of function 'pcim_alloc_irq_vectors'; did you mean 'pci_alloc_irq_vectors'? [-Wimplicit-function-declaration]
    1599 |                 ret = pcim_alloc_irq_vectors(pci_pdev,
         |                       ^~~~~~~~~~~~~~~~~~~~~~
         |                       pci_alloc_irq_vectors


vim +1599 drivers/crypto/inside-secure/safexcel.c

  1381	
  1382	/*
  1383	 * Generic part of probe routine, shared by platform and PCI driver
  1384	 *
  1385	 * Assumes IO resources have been mapped, private data mem has been allocated,
  1386	 * clocks have been enabled, device pointer has been assigned etc.
  1387	 *
  1388	 */
  1389	static int safexcel_probe_generic(void *pdev,
  1390					  struct safexcel_crypto_priv *priv,
  1391					  int is_pci_dev)
  1392	{
  1393		struct device *dev = priv->dev;
  1394		u32 peid, version, mask, val, hiaopt, hwopt, peopt;
  1395		int i, ret, hwctg;
  1396	
  1397		priv->context_pool = dmam_pool_create("safexcel-context", dev,
  1398						      sizeof(struct safexcel_context_record),
  1399						      1, 0);
  1400		if (!priv->context_pool)
  1401			return -ENOMEM;
  1402	
  1403		/*
  1404		 * First try the EIP97 HIA version regs
  1405		 * For the EIP197, this is guaranteed to NOT return any of the test
  1406		 * values
  1407		 */
  1408		version = readl(priv->base + EIP97_HIA_AIC_BASE + EIP197_HIA_VERSION);
  1409	
  1410		mask = 0;  /* do not swap */
  1411		if (EIP197_REG_LO16(version) == EIP197_HIA_VERSION_LE) {
  1412			priv->hwconfig.hiaver = EIP197_VERSION_MASK(version);
  1413		} else if (EIP197_REG_HI16(version) == EIP197_HIA_VERSION_BE) {
  1414			/* read back byte-swapped, so complement byte swap bits */
  1415			mask = EIP197_MST_CTRL_BYTE_SWAP_BITS;
  1416			priv->hwconfig.hiaver = EIP197_VERSION_SWAP(version);
  1417		} else {
  1418			/* So it wasn't an EIP97 ... maybe it's an EIP197? */
  1419			version = readl(priv->base + EIP197_HIA_AIC_BASE +
  1420					EIP197_HIA_VERSION);
  1421			if (EIP197_REG_LO16(version) == EIP197_HIA_VERSION_LE) {
  1422				priv->hwconfig.hiaver = EIP197_VERSION_MASK(version);
  1423				priv->flags |= SAFEXCEL_HW_EIP197;
  1424			} else if (EIP197_REG_HI16(version) ==
  1425				   EIP197_HIA_VERSION_BE) {
  1426				/* read back byte-swapped, so complement swap bits */
  1427				mask = EIP197_MST_CTRL_BYTE_SWAP_BITS;
  1428				priv->hwconfig.hiaver = EIP197_VERSION_SWAP(version);
  1429				priv->flags |= SAFEXCEL_HW_EIP197;
  1430			} else {
  1431				return -ENODEV;
  1432			}
  1433		}
  1434	
  1435		/* Now initialize the reg offsets based on the probing info so far */
  1436		safexcel_init_register_offsets(priv);
  1437	
  1438		/*
  1439		 * If the version was read byte-swapped, we need to flip the device
  1440		 * swapping Keep in mind here, though, that what we write will also be
  1441		 * byte-swapped ...
  1442		 */
  1443		if (mask) {
  1444			val = readl(EIP197_HIA_AIC(priv) + EIP197_HIA_MST_CTRL);
  1445			val = val ^ (mask >> 24); /* toggle byte swap bits */
  1446			writel(val, EIP197_HIA_AIC(priv) + EIP197_HIA_MST_CTRL);
  1447		}
  1448	
  1449		/*
  1450		 * We're not done probing yet! We may fall through to here if no HIA
  1451		 * was found at all. So, with the endianness presumably correct now and
  1452		 * the offsets setup, *really* probe for the EIP97/EIP197.
  1453		 */
  1454		version = readl(EIP197_GLOBAL(priv) + EIP197_VERSION);
  1455		if (((priv->flags & SAFEXCEL_HW_EIP197) &&
  1456		     (EIP197_REG_LO16(version) != EIP197_VERSION_LE) &&
  1457		     (EIP197_REG_LO16(version) != EIP196_VERSION_LE)) ||
  1458		    ((!(priv->flags & SAFEXCEL_HW_EIP197) &&
  1459		     (EIP197_REG_LO16(version) != EIP97_VERSION_LE)))) {
  1460			/*
  1461			 * We did not find the device that matched our initial probing
  1462			 * (or our initial probing failed) Report appropriate error.
  1463			 */
  1464			dev_err(priv->dev, "Probing for EIP97/EIP19x failed - no such device (read %08x)\n",
  1465				version);
  1466			return -ENODEV;
  1467		}
  1468	
  1469		priv->hwconfig.hwver = EIP197_VERSION_MASK(version);
  1470		hwctg = version >> 28;
  1471		peid = version & 255;
  1472	
  1473		/* Detect EIP206 processing pipe */
  1474		version = readl(EIP197_PE(priv) + + EIP197_PE_VERSION(0));
  1475		if (EIP197_REG_LO16(version) != EIP206_VERSION_LE) {
  1476			dev_err(priv->dev, "EIP%d: EIP206 not detected\n", peid);
  1477			return -ENODEV;
  1478		}
  1479		priv->hwconfig.ppver = EIP197_VERSION_MASK(version);
  1480	
  1481		/* Detect EIP96 packet engine and version */
  1482		version = readl(EIP197_PE(priv) + EIP197_PE_EIP96_VERSION(0));
  1483		if (EIP197_REG_LO16(version) != EIP96_VERSION_LE) {
  1484			dev_err(dev, "EIP%d: EIP96 not detected.\n", peid);
  1485			return -ENODEV;
  1486		}
  1487		priv->hwconfig.pever = EIP197_VERSION_MASK(version);
  1488	
  1489		hwopt = readl(EIP197_GLOBAL(priv) + EIP197_OPTIONS);
  1490		hiaopt = readl(EIP197_HIA_AIC(priv) + EIP197_HIA_OPTIONS);
  1491	
  1492		priv->hwconfig.icever = 0;
  1493		priv->hwconfig.ocever = 0;
  1494		priv->hwconfig.psever = 0;
  1495		if (priv->flags & SAFEXCEL_HW_EIP197) {
  1496			/* EIP197 */
  1497			peopt = readl(EIP197_PE(priv) + EIP197_PE_OPTIONS(0));
  1498	
  1499			priv->hwconfig.hwdataw  = (hiaopt >> EIP197_HWDATAW_OFFSET) &
  1500						  EIP197_HWDATAW_MASK;
  1501			priv->hwconfig.hwcfsize = ((hiaopt >> EIP197_CFSIZE_OFFSET) &
  1502						   EIP197_CFSIZE_MASK) +
  1503						  EIP197_CFSIZE_ADJUST;
  1504			priv->hwconfig.hwrfsize = ((hiaopt >> EIP197_RFSIZE_OFFSET) &
  1505						   EIP197_RFSIZE_MASK) +
  1506						  EIP197_RFSIZE_ADJUST;
  1507			priv->hwconfig.hwnumpes	= (hiaopt >> EIP197_N_PES_OFFSET) &
  1508						  EIP197_N_PES_MASK;
  1509			priv->hwconfig.hwnumrings = (hiaopt >> EIP197_N_RINGS_OFFSET) &
  1510						    EIP197_N_RINGS_MASK;
  1511			if (hiaopt & EIP197_HIA_OPT_HAS_PE_ARB)
  1512				priv->flags |= EIP197_PE_ARB;
  1513			if (EIP206_OPT_ICE_TYPE(peopt) == 1) {
  1514				priv->flags |= EIP197_ICE;
  1515				/* Detect ICE EIP207 class. engine and version */
  1516				version = readl(EIP197_PE(priv) +
  1517					  EIP197_PE_ICE_VERSION(0));
  1518				if (EIP197_REG_LO16(version) != EIP207_VERSION_LE) {
  1519					dev_err(dev, "EIP%d: ICE EIP207 not detected.\n",
  1520						peid);
  1521					return -ENODEV;
  1522				}
  1523				priv->hwconfig.icever = EIP197_VERSION_MASK(version);
  1524			}
  1525			if (EIP206_OPT_OCE_TYPE(peopt) == 1) {
  1526				priv->flags |= EIP197_OCE;
  1527				/* Detect EIP96PP packet stream editor and version */
  1528				version = readl(EIP197_PE(priv) + EIP197_PE_PSE_VERSION(0));
  1529				if (EIP197_REG_LO16(version) != EIP96_VERSION_LE) {
  1530					dev_err(dev, "EIP%d: EIP96PP not detected.\n", peid);
  1531					return -ENODEV;
  1532				}
  1533				priv->hwconfig.psever = EIP197_VERSION_MASK(version);
  1534				/* Detect OCE EIP207 class. engine and version */
  1535				version = readl(EIP197_PE(priv) +
  1536					  EIP197_PE_ICE_VERSION(0));
  1537				if (EIP197_REG_LO16(version) != EIP207_VERSION_LE) {
  1538					dev_err(dev, "EIP%d: OCE EIP207 not detected.\n",
  1539						peid);
  1540					return -ENODEV;
  1541				}
  1542				priv->hwconfig.ocever = EIP197_VERSION_MASK(version);
  1543			}
  1544			/* If not a full TRC, then assume simple TRC */
  1545			if (!(hwopt & EIP197_OPT_HAS_TRC))
  1546				priv->flags |= EIP197_SIMPLE_TRC;
  1547			/* EIP197 always has SOME form of TRC */
  1548			priv->flags |= EIP197_TRC_CACHE;
  1549		} else {
  1550			/* EIP97 */
  1551			priv->hwconfig.hwdataw  = (hiaopt >> EIP197_HWDATAW_OFFSET) &
  1552						  EIP97_HWDATAW_MASK;
  1553			priv->hwconfig.hwcfsize = (hiaopt >> EIP97_CFSIZE_OFFSET) &
  1554						  EIP97_CFSIZE_MASK;
  1555			priv->hwconfig.hwrfsize = (hiaopt >> EIP97_RFSIZE_OFFSET) &
  1556						  EIP97_RFSIZE_MASK;
  1557			priv->hwconfig.hwnumpes	= 1; /* by definition */
  1558			priv->hwconfig.hwnumrings = (hiaopt >> EIP197_N_RINGS_OFFSET) &
  1559						    EIP197_N_RINGS_MASK;
  1560		}
  1561	
  1562		/* Scan for ring AIC's */
  1563		for (i = 0; i < EIP197_MAX_RING_AIC; i++) {
  1564			version = readl(EIP197_HIA_AIC_R(priv) +
  1565					EIP197_HIA_AIC_R_VERSION(i));
  1566			if (EIP197_REG_LO16(version) != EIP201_VERSION_LE)
  1567				break;
  1568		}
  1569		priv->hwconfig.hwnumraic = i;
  1570		/* Low-end EIP196 may not have any ring AIC's ... */
  1571		if (!priv->hwconfig.hwnumraic) {
  1572			dev_err(priv->dev, "No ring interrupt controller present!\n");
  1573			return -ENODEV;
  1574		}
  1575	
  1576		/* Get supported algorithms from EIP96 transform engine */
  1577		priv->hwconfig.algo_flags = readl(EIP197_PE(priv) +
  1578					    EIP197_PE_EIP96_OPTIONS(0));
  1579	
  1580		/* Print single info line describing what we just detected */
  1581		dev_info(priv->dev, "EIP%d:%x(%d,%d,%d,%d)-HIA:%x(%d,%d,%d),PE:%x/%x(alg:%08x)/%x/%x/%x\n",
  1582			 peid, priv->hwconfig.hwver, hwctg, priv->hwconfig.hwnumpes,
  1583			 priv->hwconfig.hwnumrings, priv->hwconfig.hwnumraic,
  1584			 priv->hwconfig.hiaver, priv->hwconfig.hwdataw,
  1585			 priv->hwconfig.hwcfsize, priv->hwconfig.hwrfsize,
  1586			 priv->hwconfig.ppver, priv->hwconfig.pever,
  1587			 priv->hwconfig.algo_flags, priv->hwconfig.icever,
  1588			 priv->hwconfig.ocever, priv->hwconfig.psever);
  1589	
  1590		safexcel_configure(priv);
  1591	
  1592		if (IS_ENABLED(CONFIG_PCI) && priv->data->version == EIP197_DEVBRD) {
  1593			/*
  1594			 * Request MSI vectors for global + 1 per ring -
  1595			 * or just 1 for older dev images
  1596			 */
  1597			struct pci_dev *pci_pdev = pdev;
  1598	
> 1599			ret = pcim_alloc_irq_vectors(pci_pdev,
  1600						     priv->config.rings + 1,
  1601						     priv->config.rings + 1,
  1602						     PCI_IRQ_MSI | PCI_IRQ_MSIX);
  1603			if (ret < 0) {
  1604				dev_err(dev, "Failed to allocate PCI MSI interrupts\n");
  1605				return ret;
  1606			}
  1607		}
  1608	
  1609		/* Register the ring IRQ handlers and configure the rings */
  1610		priv->ring = devm_kcalloc(dev, priv->config.rings,
  1611					  sizeof(*priv->ring),
  1612					  GFP_KERNEL);
  1613		if (!priv->ring)
  1614			return -ENOMEM;
  1615	
  1616		for (i = 0; i < priv->config.rings; i++) {
  1617			char wq_name[9] = {0};
  1618			int irq;
  1619			struct safexcel_ring_irq_data *ring_irq;
  1620	
  1621			ret = safexcel_init_ring_descriptors(priv,
  1622							     &priv->ring[i].cdr,
  1623							     &priv->ring[i].rdr);
  1624			if (ret) {
  1625				dev_err(dev, "Failed to initialize rings\n");
  1626				goto err_cleanup_rings;
  1627			}
  1628	
  1629			priv->ring[i].rdr_req = devm_kcalloc(dev,
  1630				EIP197_DEFAULT_RING_SIZE,
  1631				sizeof(*priv->ring[i].rdr_req),
  1632				GFP_KERNEL);
  1633			if (!priv->ring[i].rdr_req) {
  1634				ret = -ENOMEM;
  1635				goto err_cleanup_rings;
  1636			}
  1637	
  1638			ring_irq = devm_kzalloc(dev, sizeof(*ring_irq), GFP_KERNEL);
  1639			if (!ring_irq) {
  1640				ret = -ENOMEM;
  1641				goto err_cleanup_rings;
  1642			}
  1643	
  1644			ring_irq->priv = priv;
  1645			ring_irq->ring = i;
  1646	
  1647			irq = safexcel_request_ring_irq(pdev,
  1648							EIP197_IRQ_NUMBER(i, is_pci_dev),
  1649							is_pci_dev,
  1650							i,
  1651							safexcel_irq_ring,
  1652							safexcel_irq_ring_thread,
  1653							ring_irq);
  1654			if (irq < 0) {
  1655				dev_err(dev, "Failed to get IRQ ID for ring %d\n", i);
  1656				ret = irq;
  1657				goto err_cleanup_rings;
  1658			}
  1659	
  1660			priv->ring[i].irq = irq;
  1661			priv->ring[i].work_data.priv = priv;
  1662			priv->ring[i].work_data.ring = i;
  1663			INIT_WORK(&priv->ring[i].work_data.work,
  1664				  safexcel_dequeue_work);
  1665	
  1666			snprintf(wq_name, 9, "wq_ring%d", i);
  1667			priv->ring[i].workqueue =
  1668				create_singlethread_workqueue(wq_name);
  1669			if (!priv->ring[i].workqueue) {
  1670				ret = -ENOMEM;
  1671				goto err_cleanup_rings;
  1672			}
  1673	
  1674			priv->ring[i].requests = 0;
  1675			priv->ring[i].busy = false;
  1676	
  1677			crypto_init_queue(&priv->ring[i].queue,
  1678					  EIP197_DEFAULT_RING_SIZE);
  1679	
  1680			spin_lock_init(&priv->ring[i].lock);
  1681			spin_lock_init(&priv->ring[i].queue_lock);
  1682		}
  1683	
  1684		atomic_set(&priv->ring_used, 0);
  1685	
  1686		ret = safexcel_hw_init(priv);
  1687		if (ret) {
  1688			dev_err(dev, "HW init failed (%d)\n", ret);
  1689			goto err_cleanup_rings;
  1690		}
  1691	
  1692		ret = safexcel_register_algorithms(priv);
  1693		if (ret) {
  1694			dev_err(dev, "Failed to register algorithms (%d)\n", ret);
  1695			goto err_cleanup_rings;
  1696		}
  1697	
  1698		return 0;
  1699	
  1700	err_cleanup_rings:
  1701		for (i = 0; i < priv->config.rings; i++) {
  1702			if (priv->ring[i].irq)
  1703				irq_set_affinity_hint(priv->ring[i].irq, NULL);
  1704			if (priv->ring[i].workqueue)
  1705				destroy_workqueue(priv->ring[i].workqueue);
  1706		}
  1707	
  1708		return ret;
  1709	}
  1710	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 19/37] cxl/pci: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:52 ` [PATCH 19/37] cxl/pci: " Shawn Lin
@ 2026-02-24 16:09   ` Jonathan Cameron
  2026-03-02  1:54   ` Davidlohr Bueso
  1 sibling, 0 replies; 62+ messages in thread
From: Jonathan Cameron @ 2026-02-24 16:09 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Davidlohr Bueso, Dave Jiang, Alison Schofield, Vishal Verma,
	Ira Weiny, Dan Williams, linux-cxl, Bjorn Helgaas,
	Philipp Stanner, linux-pci

On Mon, 23 Feb 2026 23:52:47 +0800
Shawn Lin <shawn.lin@rock-chips.com> wrote:

> pcim_enable_device() no longer automatically manages IRQ vectors via devres.
> Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
> pcim_alloc_irq_vectors() should be used.
> 
> To: Davidlohr Bueso <dave@stgolabs.net>
> To: Jonathan Cameron <jonathan.cameron@huawei.com>
> To: Dave Jiang <dave.jiang@intel.com>
> To: Alison Schofield <alison.schofield@intel.com>
> To: Vishal Verma <vishal.l.verma@intel.com>
> To: Ira Weiny <ira.weiny@intel.com>
> To: Dan Williams <dan.j.williams@intel.com>
> Cc: linux-cxl@vger.kernel.org
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Philipp Stanner <phasta@kernel.org>
> Cc: linux-pci@vger.kernel.org
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
I am very much in favor of this change.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

> ---
> 
>  drivers/cxl/pci.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index fbb300a..de5c9ff 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -565,13 +565,9 @@ static bool cxl_alloc_irq_vectors(struct pci_dev *pdev)
>  	 * Per CXL 3.0 3.1.1 CXL.io Endpoint a function on a CXL device must
>  	 * not generate INTx messages if that function participates in
>  	 * CXL.cache or CXL.mem.
> -	 *
> -	 * Additionally pci_alloc_irq_vectors() handles calling
> -	 * pci_free_irq_vectors() automatically despite not being called
> -	 * pcim_*.  See pci_setup_msi_context().
>  	 */
> -	nvecs = pci_alloc_irq_vectors(pdev, 1, CXL_PCI_DEFAULT_MAX_VECTORS,
> -				      PCI_IRQ_MSIX | PCI_IRQ_MSI);
> +	nvecs = pcim_alloc_irq_vectors(pdev, 1, CXL_PCI_DEFAULT_MAX_VECTORS,
> +				       PCI_IRQ_MSIX | PCI_IRQ_MSI);
>  	if (nvecs < 1) {
>  		dev_dbg(&pdev->dev, "Failed to alloc irq vectors: %d\n", nvecs);
>  		return false;


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

* Re: [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation
  2026-02-23 15:29 ` [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation Shawn Lin
  2026-02-24  0:04   ` Jakub Kicinski
@ 2026-02-24 16:20   ` Jonathan Cameron
  1 sibling, 0 replies; 62+ messages in thread
From: Jonathan Cameron @ 2026-02-24 16:20 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Bjorn Helgaas, Vaibhaav Ram T . L, Kumaravel Thiagarajan, Even Xu,
	Xinpeng Sun, Srinivas Pandruvada, Jiri Kosina, Alexandre Belloni,
	Zhou Wang, Longfang Liu, Vinod Koul, Lee Jones, Jijie Shao,
	Jian Shen, Sunil Goutham, Andrew Lunn, Heiner Kallweit,
	David S . Miller, Jeff Hugo, Oded Gabbay, Maciej Falkowski,
	Karol Wachowski, Min Ma, Lizhi Hou, Andreas Noever,
	Mika Westerberg, Tomasz Jeznach, Will Deacon, Xinliang Liu,
	Tian Tao, Davidlohr Bueso, Srujana Challa, Bharat Bhushan,
	Antoine Tenart, Herbert Xu, Raag Jadav, Hans de Goede,
	Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
	Manivannan Sadhasivam, Mika Westerberg, Andi Shyti,
	Robert Richter, Mark Brown, Nirmal Patel, Kurt Schwemmer,
	Logan Gunthorpe, Linus Walleij, Bartosz Golaszewski, Sakari Ailus,
	Bingbu Cao, Ulf Hansson, Arnd Bergmann, Benjamin Tissoires,
	linux-input, linux-i3c, dmaengine, Philipp Stanner, netdev,
	nic_swsd, linux-arm-msm, dri-devel, linux-usb, iommu, linux-riscv,
	David Airlie, Simona Vetter, linux-cxl, linux-crypto,
	platform-driver-x86, linux-serial, mhi, Andy Shevchenko,
	Jan Dabros, linux-i2c, Daniel Mack, Haojian Zhuang, linux-spi,
	Jonathan Derrick, linux-pci, linux-gpio, Mauro Carvalho Chehab,
	linux-media, linux-mmc

On Mon, 23 Feb 2026 23:29:40 +0800
Shawn Lin <shawn.lin@rock-chips.com> wrote:

> pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() are created for
> pci device drivers which rely on the devres machinery to help cleanup the IRQ
> vectors.

It might be worth adding some details on why we need the is_msi_managed
flag in the first place vs just doing conventional devm_add_action_or_reset()
with pci_free_irq_vectors().



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

* Re: [PATCH 19/37] cxl/pci: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors()
  2026-02-23 15:52 ` [PATCH 19/37] cxl/pci: " Shawn Lin
  2026-02-24 16:09   ` Jonathan Cameron
@ 2026-03-02  1:54   ` Davidlohr Bueso
  1 sibling, 0 replies; 62+ messages in thread
From: Davidlohr Bueso @ 2026-03-02  1:54 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Jonathan Cameron, Dave Jiang, Alison Schofield, Vishal Verma,
	Ira Weiny, Dan Williams, linux-cxl, Bjorn Helgaas,
	Philipp Stanner, linux-pci

On Mon, 23 Feb 2026, Shawn Lin wrote:

>pcim_enable_device() no longer automatically manages IRQ vectors via devres.
>Drivers must now manually call pci_free_irq_vectors() for cleanup. Alternatively,
>pcim_alloc_irq_vectors() should be used.

Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>

>
>To: Davidlohr Bueso <dave@stgolabs.net>
>To: Jonathan Cameron <jonathan.cameron@huawei.com>
>To: Dave Jiang <dave.jiang@intel.com>
>To: Alison Schofield <alison.schofield@intel.com>
>To: Vishal Verma <vishal.l.verma@intel.com>
>To: Ira Weiny <ira.weiny@intel.com>
>To: Dan Williams <dan.j.williams@intel.com>
>Cc: linux-cxl@vger.kernel.org
>Cc: Bjorn Helgaas <bhelgaas@google.com>
>Cc: Philipp Stanner <phasta@kernel.org>
>Cc: linux-pci@vger.kernel.org
>Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>---
>
> drivers/cxl/pci.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
>index fbb300a..de5c9ff 100644
>--- a/drivers/cxl/pci.c
>+++ b/drivers/cxl/pci.c
>@@ -565,13 +565,9 @@ static bool cxl_alloc_irq_vectors(struct pci_dev *pdev)
> 	 * Per CXL 3.0 3.1.1 CXL.io Endpoint a function on a CXL device must
> 	 * not generate INTx messages if that function participates in
> 	 * CXL.cache or CXL.mem.
>-	 *
>-	 * Additionally pci_alloc_irq_vectors() handles calling
>-	 * pci_free_irq_vectors() automatically despite not being called
>-	 * pcim_*.  See pci_setup_msi_context().
> 	 */
>-	nvecs = pci_alloc_irq_vectors(pdev, 1, CXL_PCI_DEFAULT_MAX_VECTORS,
>-				      PCI_IRQ_MSIX | PCI_IRQ_MSI);
>+	nvecs = pcim_alloc_irq_vectors(pdev, 1, CXL_PCI_DEFAULT_MAX_VECTORS,
>+				       PCI_IRQ_MSIX | PCI_IRQ_MSI);
> 	if (nvecs < 1) {
> 		dev_dbg(&pdev->dev, "Failed to alloc irq vectors: %d\n", nvecs);
> 		return false;
>-- 
>2.7.4
>

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

end of thread, other threads:[~2026-03-02  1:54 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 15:29 [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Shawn Lin
2026-02-23 15:29 ` [PATCH 01/37] PCI/MSI: Add Devres managed IRQ vectors allocation Shawn Lin
2026-02-24  0:04   ` Jakub Kicinski
2026-02-24  2:08     ` Shawn Lin
2026-02-24  7:47       ` Philipp Stanner
2026-02-24  8:21         ` Shawn Lin
2026-02-24  8:32           ` Philipp Stanner
2026-02-24 16:20   ` Jonathan Cameron
2026-02-23 15:29 ` [PATCH 37/37] PCI/MSI: Only check is_msi_managed in pcim_setup_msi_release() Shawn Lin
2026-02-23 15:41 ` [PATCH 02/37] mmc: cavium: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors() Shawn Lin
2026-02-23 15:42 ` [PATCH 03/37] media: ipu6: " Shawn Lin
2026-02-23 15:42 ` [PATCH 04/37] gpio: merrifield: " Shawn Lin
2026-02-23 17:42   ` Andy Shevchenko
2026-02-24  2:16     ` Shawn Lin
2026-02-23 15:43 ` [PATCH 05/37] PCI: switchtec: " Shawn Lin
2026-02-23 15:43 ` [PATCH 06/37] PCI: vmd: " Shawn Lin
2026-02-23 15:44 ` [PATCH 07/37] spi: spi-pci1xxxx: " Shawn Lin
2026-02-23 15:44 ` [PATCH 08/37] spi: pxa2xx: " Shawn Lin
2026-02-23 15:47 ` [PATCH 09/37] i2c: amd-mp2: " Shawn Lin
2026-02-23 15:47 ` [PATCH 10/37] i2c: mchp-pci1xxxx: " Shawn Lin
2026-02-23 15:48 ` [PATCH 11/37] i2c: thunderx: " Shawn Lin
2026-02-23 15:48 ` [PATCH 12/37] i2c: designware: " Shawn Lin
2026-02-23 15:48 ` [PATCH 13/37] bus: mhi: host: " Shawn Lin
2026-02-23 15:49 ` [PATCH 14/37] serial: 8250_mid: " Shawn Lin
2026-02-23 15:49 ` [PATCH 15/37] serial: 8250_exar: " Shawn Lin
2026-02-23 15:50 ` [PATCH 16/37] platform/x86/intel: " Shawn Lin
2026-02-23 15:50 ` [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Andy Shevchenko
2026-02-23 16:09   ` Shawn Lin
2026-02-23 17:38     ` Andy Shevchenko
2026-02-24  2:29       ` Shawn Lin
2026-02-23 15:51 ` [PATCH 17/37] crypto: safexcel: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors() Shawn Lin
2026-02-24 15:57   ` kernel test robot
2026-02-23 15:52 ` [PATCH 18/37] crypto: octeontx2: " Shawn Lin
2026-02-23 15:52 ` [PATCH 19/37] cxl/pci: " Shawn Lin
2026-02-24 16:09   ` Jonathan Cameron
2026-03-02  1:54   ` Davidlohr Bueso
2026-02-23 15:53 ` [PATCH 20/37] drm/hisilicon/hibmc: " Shawn Lin
2026-02-23 15:53 ` [PATCH 21/37] iommu/riscv: " Shawn Lin
2026-02-23 15:54 ` [PATCH 22/37] thunderbolt: " Shawn Lin
2026-02-23 15:55 ` [PATCH 23/37] accel/amdxdna: " Shawn Lin
2026-02-23 15:55 ` [PATCH 24/37] accel/ivpu: " Shawn Lin
2026-02-23 15:55 ` [PATCH 25/37] accel/qaic: " Shawn Lin
2026-02-23 16:01   ` Jeff Hugo
2026-02-23 16:15     ` Shawn Lin
2026-02-23 16:25       ` Jeff Hugo
2026-02-24  7:35         ` Philipp Stanner
2026-02-23 15:56 ` [PATCH 26/37] net: stmmac: " Shawn Lin
2026-02-23 15:56 ` [PATCH 27/37] r8169: " Shawn Lin
2026-02-23 15:57 ` [PATCH 28/37] net: thunder_bgx: " Shawn Lin
2026-02-23 15:57 ` [PATCH 29/37] net: hibmcge: " Shawn Lin
2026-02-23 15:58 ` [PATCH 30/37] mfd: intel-lpss: " Shawn Lin
2026-02-23 15:58 ` [PATCH 31/37] dmaengine: hsu: " Shawn Lin
2026-02-23 15:58 ` [PATCH 32/37] dmaengine: hisilicon: " Shawn Lin
2026-02-23 15:58 ` [PATCH 33/37] i3c: mipi-i3c-hci-pci: " Shawn Lin
2026-02-23 15:59 ` [PATCH 34/37] HID: intel-ish-ipc: " Shawn Lin
2026-02-23 15:59 ` [PATCH 35/37] HID: Intel-thc-hid: " Shawn Lin
2026-02-23 15:59 ` [PATCH 36/37] misc: microchip: pci1xxxx: " Shawn Lin
2026-02-24  4:14 ` [PATCH 0/37] PCI/MSI: Enforce explicit IRQ vector management by removing devres auto-free Simon Richter
2026-02-24  7:39   ` Philipp Stanner
2026-02-24  9:12     ` Andy Shevchenko
2026-02-24 10:30       ` Philipp Stanner
2026-02-24 10:39         ` Andy Shevchenko

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