Skip to contentSkip to conversation

media: staging/ipu7: convert to use pci_alloc_irq_vectors() API

PATCH In review [email protected] 3 participants 5 messages Aug 15, 2025 – Aug 18, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 media: staging/ipu7: convert to use pci_alloc_irq_vectors() API

From: Bingbu Cao <[email protected]>

pci_enable_msi() is a deprecated API, thus switch to use modern pci_alloc_irq_vectors().

Fixes b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")
---
 drivers/staging/media/ipu7/ipu7.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/staging/media/ipu7/ipu7.c +9 -12
index 1b4f01db13ca..a8e8b0e23198 100644
@@ -2248,20 +2248,13 @@ void ipu7_dump_fw_error_log(const struct ipu7_bus_device *adev)
 }
 EXPORT_SYMBOL_NS_GPL(ipu7_dump_fw_error_log, "INTEL_IPU7");
 
-static int ipu7_pci_config_setup(struct pci_dev *dev)
+static void ipu7_pci_config_setup(struct pci_dev *dev)
 {
 	u16 pci_command;
-	int ret;
 
 	pci_read_config_word(dev, PCI_COMMAND, &pci_command);
 	pci_command |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
 	pci_write_config_word(dev, PCI_COMMAND, pci_command);
-
-	ret = pci_enable_msi(dev);
-	if (ret)
-		dev_err(&dev->dev, "Failed to enable msi (%d)\n", ret);
-
-	return ret;
 }
 
 static int ipu7_map_fw_code_region(struct ipu7_bus_device *sys,
@@ -2510,13 +2503,15 @@ static int ipu7_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	dma_set_max_seg_size(dev, UINT_MAX);
 
-	ret = ipu7_pci_config_setup(pdev);
-	if (ret)
-		return ret;
+	ipu7_pci_config_setup(pdev);
+
+	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Failed to alloc irq vector\n");
 
 	ret = ipu_buttress_init(isp);
 	if (ret)
-		return ret;
+		goto pci_irq_free;
 
 	dev_info(dev, "firmware cpd file: %s\n", isp->cpd_fw_name);
 
@@ -2632,6 +2627,8 @@ static int ipu7_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	release_firmware(isp->cpd_fw);
 buttress_exit:
 	ipu_buttress_exit(isp);
+pci_irq_free:
+	pci_free_irq_vectors(pdev);
 
 	return ret;
 }
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/3 media: staging/ipu7: Don't set name for IPU7 PCI device

From: Bingbu Cao <[email protected]>

Driver better not dev_set_name() to change the PCI device name, so remove it.

Fixes b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")
---
 drivers/staging/media/ipu7/ipu7.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/media/ipu7/ipu7.c +0 -1
index a8e8b0e23198..aef931d23510 100644
@@ -2428,7 +2428,6 @@ static int ipu7_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (!isp)
 		return -ENOMEM;
 
-	dev_set_name(dev, "intel-ipu7");
 	isp->pdev = pdev;
 	INIT_LIST_HEAD(&isp->devices);
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 3/3 media: staging/ipu7: cleanup the MMU correctly in IPU7 driver release

In reply to [email protected]

From: Bingbu Cao <[email protected]>

IPU7 ISYS and PSYS auxiliary devices are released after ipu7_bus_del_devices(), so driver can not reference the MMU devices from ISYS and PSYS auxiliary devices, so move the MMUs cleanup before releasing the auxiliary devices.

Fixes b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")
---
 drivers/staging/media/ipu7/ipu7.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/media/ipu7/ipu7.c +3 -2
index aef931d23510..3de41b3d1ae1 100644
@@ -2644,6 +2644,9 @@ static void ipu7_pci_remove(struct pci_dev *pdev)
 	if (!IS_ERR_OR_NULL(isp->fw_code_region))
 		vfree(isp->fw_code_region);
 
+	ipu7_mmu_cleanup(isp->isys->mmu);
+	ipu7_mmu_cleanup(isp->psys->mmu);
+
 	ipu7_bus_del_devices(pdev);
 
 	pm_runtime_forbid(&pdev->dev);
@@ -2653,8 +2656,6 @@ static void ipu7_pci_remove(struct pci_dev *pdev)
 
 	release_firmware(isp->cpd_fw);
 
-	ipu7_mmu_cleanup(isp->psys->mmu);
-	ipu7_mmu_cleanup(isp->isys->mmu);
 }
 
 static void ipu7_pci_reset_prepare(struct pci_dev *pdev)
Signature · 1 line
2.34.1
maintainer
#3 lore raw

Re: [PATCH 3/3] media: staging/ipu7: cleanup the MMU correctly in IPU7 driver release

Hi Bingbu,

Thanks for the set.

Quoted 8 lines · On Fri, Aug 15, 2025 at 05:20:37PM +0800, [email protected] wrote:

From: Bingbu Cao <[email protected]>

IPU7 ISYS and PSYS auxiliary devices are released after ipu7_bus_del_devices(), so driver can not reference the MMU devices from ISYS and PSYS auxiliary devices, so move the MMUs cleanup before releasing the auxiliary devices.

Fixes b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")

Please also add Cc: stable tag if you have a Fixes: tag.

Quoted 20 lines
---
 drivers/staging/media/ipu7/ipu7.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/media/ipu7/ipu7.c +3 -0
index aef931d23510..3de41b3d1ae1 100644
@@ -2644,6 +2644,9 @@ static void ipu7_pci_remove(struct pci_dev *pdev)
 	if (!IS_ERR_OR_NULL(isp->fw_code_region))
 		vfree(isp->fw_code_region);
 
+	ipu7_mmu_cleanup(isp->isys->mmu);
+	ipu7_mmu_cleanup(isp->psys->mmu);
+
 	ipu7_bus_del_devices(pdev);
 
 	pm_runtime_forbid(&pdev->dev);

drivers/staging/media/ipu7/ipu7.c static void ipu7_pci_remove(struct pci_dev *pdev) · line 2658

Quoted 3 lines
drivers/staging/media/ipu7/ipu7.c +0 -0
@@ -2653,8 +2656,6 @@ static void ipu7_pci_remove(struct pci_dev *pdev)
 
 	release_firmware(isp->cpd_fw);
 

This newline will be extra once the two lines below have been removed.

Does the same issue exist in the IPU6 driver? These calls are located in the same location but I haven't checked if that's the right place for them.

Quoted 5 lines
drivers/staging/media/ipu7/ipu7.c +0 -2
-	ipu7_mmu_cleanup(isp->psys->mmu);
-	ipu7_mmu_cleanup(isp->isys->mmu);
 }
 
 static void ipu7_pci_reset_prepare(struct pci_dev *pdev)
Signature · 3 lines
Kind regards,

Sakari Ailus
#4 lore raw

Re: [PATCH 3/3] media: staging/ipu7: cleanup the MMU correctly in IPU7 driver release

Sakari,

Quoted 37 lines · Sakari Ailus

Hi Bingbu,

Thanks for the set.

Quoted 8 lines · On Fri, Aug 15, 2025 at 05:20:37PM +0800, [email protected] wrote:

From: Bingbu Cao <[email protected]>

IPU7 ISYS and PSYS auxiliary devices are released after ipu7_bus_del_devices(), so driver can not reference the MMU devices from ISYS and PSYS auxiliary devices, so move the MMUs cleanup before releasing the auxiliary devices.

Fixes b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")

Please also add Cc: stable tag if you have a Fixes: tag.

Quoted 21 lines
---
 drivers/staging/media/ipu7/ipu7.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/media/ipu7/ipu7.c +3 -0
index aef931d23510..3de41b3d1ae1 100644
@@ -2644,6 +2644,9 @@ static void ipu7_pci_remove(struct pci_dev *pdev)
 	if (!IS_ERR_OR_NULL(isp->fw_code_region))
 		vfree(isp->fw_code_region);
 
+	ipu7_mmu_cleanup(isp->isys->mmu);
+	ipu7_mmu_cleanup(isp->psys->mmu);
+
 	ipu7_bus_del_devices(pdev);
 
 	pm_runtime_forbid(&pdev->dev);
@@ -2653,8 +2656,6 @@ static void ipu7_pci_remove(struct pci_dev *pdev)
 
Quoted 8 lines

drivers/staging/media/ipu7/ipu7.c static void ipu7_pci_remove(struct pci_dev *pdev) · line 2658

Quoted 2 lines
drivers/staging/media/ipu7/ipu7.c +0 -0
 	release_firmware(isp->cpd_fw);
 

This newline will be extra once the two lines below have been removed.

Does the same issue exist in the IPU6 driver? These calls are located in the same location but I haven't checked if that's the right place for them.

IPU6 driver fix this problem in another way.

	struct ipu6_mmu *isys_mmu = isp->isys->mmu;
	struct ipu6_mmu *psys_mmu = isp->psys->mmu;
...
	release_firmware(isp->cpd_fw);

	ipu6_mmu_cleanup(psys_mmu);
	ipu6_mmu_cleanup(isys_mmu);

I think cleanup MMU before releasing auxdevs make more sense.

Quoted 6 lines
Quoted 5 lines
drivers/staging/media/ipu7/ipu7.c +0 -2
-	ipu7_mmu_cleanup(isp->psys->mmu);
-	ipu7_mmu_cleanup(isp->isys->mmu);
 }
 
 static void ipu7_pci_reset_prepare(struct pci_dev *pdev)
Signature · 2 lines
Best regards,
Bingbu Cao