Skip to contentSkip to conversation

IPU6 and IPU7 driver fixes

PATCH Superseded [email protected] 1 participant 8 messages Dec 23, 2025

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover IPU6 and IPU7 driver fixes

From: Bingbu Cao <[email protected]>

This patchsets contains some fixes for IPU6 and IPU7 driver, and also cover a code cleanup for IPU6 driver. It also update the CPHY settings for IPU7 according to the PHY specification update.

Bingbu Cao (6):
media: ipu6: fix typo and wrong constant in ipu6-mmu.c
media: ipu6: fix RPM reference leak in probe error paths
media: staging/ipu7: ignore interrupts when device is suspended
media: staging/ipu7: call synchronous RPM suspend in probe failure
media: staging/ipu7: update CDPHY register settings
media: staging/ipu7: fix the loop number of in l2 table alloc

 drivers/media/pci/intel/ipu6/ipu6-mmu.c        |  4 ++--
 drivers/media/pci/intel/ipu6/ipu6.c            | 10 ++++++----
 drivers/staging/media/ipu7/ipu7-buttress.c     | 12 ++++++++++--
 drivers/staging/media/ipu7/ipu7-isys-csi-phy.c | 13 ++++++++++---
 drivers/staging/media/ipu7/ipu7-mmu.c          |  2 +-
 drivers/staging/media/ipu7/ipu7.c              |  6 +++++-
 6 files changed, 34 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 1/6 media: ipu6: fix typo and wrong constant in ipu6-mmu.c

From: Bingbu Cao <[email protected]>

Fix two coding errors in ipu6-mmu.c:

1. Fix syntax error in page_table_dump() where the closing parenthesis and semicolon were swapped in the TBL_PHYS_ADDR macro call.

2. Fix incorrect loop bound in alloc_l2_pt(). When initializing L2 page table entries, the loop was incorrectly using ISP_L1PT_PTES instead of ISP_L2PT_PTES.

Fixes 9163d83573e4 ("media: intel/ipu6: add IPU6 DMA mapping API and MMU table")
---
 drivers/media/pci/intel/ipu6/ipu6-mmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/intel/ipu6/ipu6-mmu.c +2 -2
index 6d1c0b90169d..85cc6d5b4dd1 100644
@@ -102,7 +102,7 @@ static void page_table_dump(struct ipu6_mmu_info *mmu_info)
 		if (mmu_info->l1_pt[l1_idx] == mmu_info->dummy_l2_pteval)
 			continue;
 
-		l2_phys = TBL_PHYS_ADDR(mmu_info->l1_pt[l1_idx];)
+		l2_phys = TBL_PHYS_ADDR(mmu_info->l1_pt[l1_idx]);
 		dev_dbg(mmu_info->dev,
 			"l1 entry %u; iovas 0x%8.8x-0x%8.8x, at %pap\n",
 			l1_idx, iova, iova + ISP_PAGE_SIZE, &l2_phys);
@@ -248,7 +248,7 @@ static u32 *alloc_l2_pt(struct ipu6_mmu_info *mmu_info)
 
 	dev_dbg(mmu_info->dev, "alloc_l2: get_zeroed_page() = %p\n", pt);
 
-	for (i = 0; i < ISP_L1PT_PTES; i++)
+	for (i = 0; i < ISP_L2PT_PTES; i++)
 		pt[i] = mmu_info->dummy_page_pteval;
 
 	return pt;
Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 2/6 media: ipu6: fix RPM reference leak in probe error paths

In reply to [email protected]

From: Bingbu Cao <[email protected]>

Several error paths in ipu6_pci_probe() were jumping directly to out_ipu6_bus_del_devices without releasing the runtime PM reference. Add pm_runtime_put_sync() before cleaning up other resources.

Fixes 25fedc021985 ("media: intel/ipu6: add Intel IPU6 PCI device driver")
---
 drivers/media/pci/intel/ipu6/ipu6.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/media/pci/intel/ipu6/ipu6.c +6 -4
index 1f4f20b9c94d..a2768f44017a 100644
@@ -630,21 +630,21 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (ret) {
 		dev_err_probe(&isp->pdev->dev, ret,
 			      "Failed to set MMU hardware\n");
-		goto out_ipu6_bus_del_devices;
+		goto out_ipu6_rpm_put;
 	}
 
 	ret = ipu6_buttress_map_fw_image(isp->psys, isp->cpd_fw,
 					 &isp->psys->fw_sgt);
 	if (ret) {
 		dev_err_probe(&isp->pdev->dev, ret, "failed to map fw image\n");
-		goto out_ipu6_bus_del_devices;
+		goto out_ipu6_rpm_put;
 	}
 
 	ret = ipu6_cpd_create_pkg_dir(isp->psys, isp->cpd_fw->data);
 	if (ret) {
 		dev_err_probe(&isp->pdev->dev, ret,
 			      "failed to create pkg dir\n");
-		goto out_ipu6_bus_del_devices;
+		goto out_ipu6_rpm_put;
 	}
 
 	ret = devm_request_threaded_irq(dev, pdev->irq, ipu6_buttress_isr,
@@ -652,7 +652,7 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 					IRQF_SHARED, IPU6_NAME, isp);
 	if (ret) {
 		dev_err_probe(dev, ret, "Requesting irq failed\n");
-		goto out_ipu6_bus_del_devices;
+		goto out_ipu6_rpm_put;
 	}
 
 	ret = ipu6_buttress_authenticate(isp);
@@ -683,6 +683,8 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 out_free_irq:
 	devm_free_irq(dev, pdev->irq, isp);
+out_ipu6_rpm_put:
+	pm_runtime_put_sync(&isp->psys->auxdev.dev);
 out_ipu6_bus_del_devices:
 	if (isp->psys) {
 		ipu6_cpd_free_pkg_dir(isp->psys);
Signature · 1 line
2.34.1
#3 lore raw

PATCH v3 3/6 media: staging/ipu7: ignore interrupts when device is suspended

In reply to [email protected]

From: Bingbu Cao <[email protected]>

IPU7 devices have shared interrupts with others. In some case when IPU7 device is suspended, driver get unexpected interrupt and invalid irq status 0xffffffff from ISR_STATUS and PB LOCAL_STATUS registers as interrupt is triggered from other device on shared irq line.

In order to avoid this issue use pm_runtime_get_if_active() to check if IPU7 device is resumed, ignore the invalid irq status and use synchronize_irq() in suspend.

Fixes b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")
---
 drivers/staging/media/ipu7/ipu7-buttress.c | 12 ++++++++++--
 drivers/staging/media/ipu7/ipu7.c          |  4 ++++
 2 files changed, 14 insertions(+), 2 deletions(-)
drivers/staging/media/ipu7/ipu7-buttress.c +10 -2
index e5707f5e300b..e4328cafe91d 100644
@@ -342,14 +342,22 @@ irqreturn_t ipu_buttress_isr(int irq, void *isp_ptr)
 	u32 disable_irqs = 0;
 	u32 irq_status;
 	unsigned int i;
+	int active;
 
-	pm_runtime_get_noresume(dev);
+	active = pm_runtime_get_if_active(dev);
+	if (active <= 0)
+		return IRQ_NONE;
 
 	pb_irq = readl(isp->pb_base + INTERRUPT_STATUS);
 	writel(pb_irq, isp->pb_base + INTERRUPT_STATUS);
 
 	/* check btrs ATS, CFI and IMR errors, BIT(0) is unused for IPU */
 	pb_local_irq = readl(isp->pb_base + BTRS_LOCAL_INTERRUPT_MASK);
+	if (WARN_ON_ONCE(pb_local_irq == 0xffffffff)) {
+		pm_runtime_put_noidle(dev);
+		return IRQ_NONE;
+	}
+
 	if (pb_local_irq & ~BIT(0)) {
 		dev_warn(dev, "PB interrupt status 0x%x local 0x%x\n", pb_irq,
 			 pb_local_irq);
@@ -365,7 +373,7 @@ irqreturn_t ipu_buttress_isr(int irq, void *isp_ptr)
 	}
 
 	irq_status = readl(isp->base + BUTTRESS_REG_IRQ_STATUS);
-	if (!irq_status) {
+	if (!irq_status || WARN_ON_ONCE(irq_status == 0xffffffff)) {
 		pm_runtime_put_noidle(dev);
 		return IRQ_NONE;
 	}
drivers/staging/media/ipu7/ipu7.c +4 -0
index 5cddc09c72bf..6c8c3eea44ac 100644
@@ -2684,6 +2684,10 @@ static void ipu7_pci_reset_done(struct pci_dev *pdev)
  */
 static int ipu7_suspend(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	synchronize_irq(pdev->irq);
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v3 3/6] media: staging/ipu7: ignore interrupts when device is suspended

Sakari,

I forget to fix the WARN_ON_ONCE comment, let me address it in v4.

------------------------------------------------------------------------
BRs,
Bingbu Cao

________________________________________
From: Cao, Bingbu <[email protected]>
Sent: Tuesday, December 23, 2025 1:38 PM
To: [email protected] <[email protected]>; [email protected] <[email protected]>
Cc: Cao, Bingbu <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> Subject: [PATCH v3 3/6] media: staging/ipu7: ignore interrupts when device is suspended

From: Bingbu Cao <[email protected]>

IPU7 devices have shared interrupts with others. In some case when IPU7

device is suspended, driver get unexpected interrupt and invalid irq

status 0xffffffff from ISR_STATUS and PB LOCAL_STATUS registers as

interrupt is triggered from other device on shared irq line.

In order to avoid this issue use pm_runtime_get_if_active() to check if

IPU7 device is resumed, ignore the invalid irq status and use

synchronize_irq() in suspend.

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

---

 drivers/staging/media/ipu7/ipu7-buttress.c | 12 ++++++++++--

 drivers/staging/media/ipu7/ipu7.c          |  4 ++++

 2 files changed, 14 insertions(+), 2 deletions(-)
drivers/staging/media/ipu7/ipu7-buttress.c +0 -0

index e5707f5e300b..e4328cafe91d 100644

--- a/drivers/staging/media/ipu7/ipu7-buttress.c

+++ b/drivers/staging/media/ipu7/ipu7-buttress.c

@@ -342,14 +342,22 @@ irqreturn_t ipu_buttress_isr(int irq, void *isp_ptr)

         u32 disable_irqs = 0;

         u32 irq_status;

         unsigned int i;

+       int active;

-       pm_runtime_get_noresume(dev);

+       active = pm_runtime_get_if_active(dev);

+       if (active <= 0)

+               return IRQ_NONE;

         pb_irq = readl(isp->pb_base + INTERRUPT_STATUS);

         writel(pb_irq, isp->pb_base + INTERRUPT_STATUS);

         /* check btrs ATS, CFI and IMR errors, BIT(0) is unused for IPU */

         pb_local_irq = readl(isp->pb_base + BTRS_LOCAL_INTERRUPT_MASK);

+       if (WARN_ON_ONCE(pb_local_irq == 0xffffffff)) {

+               pm_runtime_put_noidle(dev);

+               return IRQ_NONE;

+       }

+

         if (pb_local_irq & ~BIT(0)) {

                 dev_warn(dev, "PB interrupt status 0x%x local 0x%x\n", pb_irq,

                          pb_local_irq);

@@ -365,7 +373,7 @@ irqreturn_t ipu_buttress_isr(int irq, void *isp_ptr)

         }

         irq_status = readl(isp->base + BUTTRESS_REG_IRQ_STATUS);

-       if (!irq_status) {

+       if (!irq_status || WARN_ON_ONCE(irq_status == 0xffffffff)) {

                 pm_runtime_put_noidle(dev);

                 return IRQ_NONE;

         }

drivers/staging/media/ipu7/ipu7.c +0 -0

index 5cddc09c72bf..6c8c3eea44ac 100644

--- a/drivers/staging/media/ipu7/ipu7.c

+++ b/drivers/staging/media/ipu7/ipu7.c

@@ -2684,6 +2684,10 @@ static void ipu7_pci_reset_done(struct pci_dev *pdev)

  */

 static int ipu7_suspend(struct device *dev)

 {

+       struct pci_dev *pdev = to_pci_dev(dev);

+

+       synchronize_irq(pdev->irq);

+

         return 0;

 }

--

2.34.1

#5 lore raw

PATCH v3 4/6 media: staging/ipu7: call synchronous RPM suspend in probe failure

In reply to [email protected]

From: Bingbu Cao <[email protected]>

If firmware authentication failed during driver probe, driver call an asynchronous API to suspend the psys device but the bus device will be removed soon, thus runtime PM of bus device will be disabled soon, that will cancel the suspend request, so use synchronous suspend to make sure the runtime suspend before disabling its RPM.

IPU7 hardware has constraints that the PSYS device must be powered off before ISYS, otherwise it will cause machine check error.

Fixes b7fe4c0019b1 ("media: staging/ipu7: add Intel IPU7 PCI device driver")
---
 drivers/staging/media/ipu7/ipu7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu7/ipu7.c +1 -1
index 6c8c3eea44ac..fa5a1867626f 100644
@@ -2620,7 +2620,7 @@ static int ipu7_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (!IS_ERR_OR_NULL(isp->isys) && !IS_ERR_OR_NULL(isp->isys->mmu))
 		ipu7_mmu_cleanup(isp->isys->mmu);
 	if (!IS_ERR_OR_NULL(isp->psys))
-		pm_runtime_put(&isp->psys->auxdev.dev);
+		pm_runtime_put_sync(&isp->psys->auxdev.dev);
 	ipu7_bus_del_devices(pdev);
 	release_firmware(isp->cpd_fw);
 buttress_exit:
Signature · 1 line
2.34.1
#6 lore raw

PATCH v3 5/6 media: staging/ipu7: update CDPHY register settings

In reply to [email protected]

From: Bingbu Cao <[email protected]>

Some CPHY settings needs to updated according to the latest guide from SNPS. This patch program 45ohm for tuning resistance to fix CPHY problem and update the ITMINRX and GMODE for CPHY.

Fixes a516d36bdc3d ("media: staging/ipu7: add IPU7 input system device driver")
---
 drivers/staging/media/ipu7/ipu7-isys-csi-phy.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/staging/media/ipu7/ipu7-isys-csi-phy.c +10 -3
index 2d5717883518..3f15af3b4c79 100644
@@ -124,6 +124,7 @@ static const struct cdr_fbk_cap_prog_params table7[] = {
 	{ 1350, 1589, 4 },
 	{ 1590, 1949, 5 },
 	{ 1950, 2499, 6 },
+	{ 2500, 3500, 7 },
 	{ }
 };
 
@@ -838,9 +839,10 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes,
 		dwc_phy_write_mask(isys, id, reg + 0x400 * i,
 				   reset_thresh, 9, 11);
 
+	/* Tuning ITMINRX to 2 for CPHY */
 	reg = CORE_DIG_CLANE_0_RW_LP_0;
 	for (i = 0; i < trios; i++)
-		dwc_phy_write_mask(isys, id, reg + 0x400 * i, 1, 12, 15);
+		dwc_phy_write_mask(isys, id, reg + 0x400 * i, 2, 12, 15);
 
 	reg = CORE_DIG_CLANE_0_RW_LP_2;
 	for (i = 0; i < trios; i++)
@@ -860,7 +862,11 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes,
 	for (i = 0; i < (lanes + 1); i++) {
 		reg = CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_9 + 0x400 * i;
 		dwc_phy_write_mask(isys, id, reg, 4U, 0, 2);
-		dwc_phy_write_mask(isys, id, reg, 0U, 3, 4);
+		/* Set GMODE to 2 when CPHY >= 1.5Gsps */
+		if (mbps >= 1500)
+			dwc_phy_write_mask(isys, id, reg, 2U, 3, 4);
+		else
+			dwc_phy_write_mask(isys, id, reg, 0U, 3, 4);
 
 		reg = CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_7 + 0x400 * i;
 		dwc_phy_write_mask(isys, id, reg, cap_prog, 10, 12);
@@ -930,8 +936,9 @@ static int ipu7_isys_phy_config(struct ipu7_isys *isys, u8 id, u8 lanes,
 			   7, 12, 14);
 	dwc_phy_write_mask(isys, id, CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_7,
 			   0, 8, 10);
+	/* resistance tuning: 1 for 45ohm, 0 for 50ohm */
 	dwc_phy_write_mask(isys, id, CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_5,
-			   0, 8, 8);
+			   1, 8, 8);
 
 	if (aggregation)
 		phy_mode = isys->csi2[0].phy_mode;
Signature · 1 line
2.34.1
#7 lore raw

PATCH v3 6/6 media: staging/ipu7: fix the loop number of in l2 table alloc

In reply to [email protected]

From: Bingbu Cao <[email protected]>

This patch fixes the incorrect loop bound in alloc_l2_pt(). When initializing L2 page table entries, the loop was incorrectly using ISP_L1PT_PTES instead of ISP_L2PT_PTES though the ISP_L1PT_PTES is equal to ISP_L2PT_PTES.

Fixes 71d81c25683a ("media: staging/ipu7: add IPU7 DMA APIs and MMU mapping")
---
 drivers/staging/media/ipu7/ipu7-mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu7/ipu7-mmu.c +1 -1
index ded1986eb8ba..ea35cce4830a 100644
@@ -231,7 +231,7 @@ static u32 *alloc_l2_pt(struct ipu7_mmu_info *mmu_info)
 
 	dev_dbg(mmu_info->dev, "alloc_l2: get_zeroed_page() = %p\n", pt);
 
-	for (i = 0; i < ISP_L1PT_PTES; i++)
+	for (i = 0; i < ISP_L2PT_PTES; i++)
 		pt[i] = mmu_info->dummy_page_pteval;
 
 	return pt;
Signature · 1 line
2.34.1