Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 63f2c63dc869a4e6a2e7e58040739b31c7894b6b Mon Sep 17 00:00:00 2001
From: linya14x <linx.yang@intel.com>
Date: Fri, 24 Oct 2025 12:44:25 +0800
Subject: [PATCH 1/6] staging: ipu7: Use DPHY as the default PHY mode

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
---
drivers/staging/media/ipu7/ipu7-isys.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/ipu7/ipu7-isys.c b/drivers/staging/media/ipu7/ipu7-isys.c
index cb2f49f3e0fa..dd481f9d848d 100644
--- a/drivers/staging/media/ipu7/ipu7-isys.c
+++ b/drivers/staging/media/ipu7/ipu7-isys.c
@@ -81,10 +81,10 @@ isys_complete_ext_device_registration(struct ipu7_isys *isys,
}

isys->csi2[csi2->port].nlanes = csi2->nlanes;
- if (csi2->bus_type == V4L2_MBUS_CSI2_DPHY)
- isys->csi2[csi2->port].phy_mode = PHY_MODE_DPHY;
- else
+ if (csi2->bus_type == V4L2_MBUS_CSI2_CPHY)
isys->csi2[csi2->port].phy_mode = PHY_MODE_CPHY;
+ else
+ isys->csi2[csi2->port].phy_mode = PHY_MODE_DPHY;

return 0;

--
2.43.0

275 changes: 275 additions & 0 deletions patch/v6.17.0/in-tree/0002-staging-ipu7-Add-IPU7-debugfs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
From 9626721dfbee9643864207dcbb3e18c8ea208782 Mon Sep 17 00:00:00 2001
From: linya14x <linx.yang@intel.com>
Date: Thu, 26 Mar 2026 14:23:10 +0800
Subject: [PATCH] staging: ipu7: Add IPU7 debugfs
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this patch? It's only for debug purpose.

Copy link
Copy Markdown
Contributor Author

@avinashiitk avinashiitk Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this patch? It's only for debug purpose.

kernel v6.18.3 and v6.17.7 is having debugfs patch. then why not for v6.17.0?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this is how we are working for kernel 6.18.3 and 6.17.7. And would be good short term solution.
As suggested by you, we can remove all debug_fs code from drivers and remove this patch from patch folder. This will need more validation time. We can take it up next.


Signed-off-by: Hao Yao <hao.yao@intel.com>
Signed-off-by: Avinash Kumar <avinash3.kumar@intel.com>
---
drivers/staging/media/ipu7/ipu7-isys.c | 84 ++++++++++++++++++++++++++
drivers/staging/media/ipu7/ipu7-isys.h | 7 +++
drivers/staging/media/ipu7/ipu7.c | 63 ++++++++++++++++++-
drivers/staging/media/ipu7/ipu7.h | 3 +
4 files changed, 156 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/ipu7/ipu7-isys.c b/drivers/staging/media/ipu7/ipu7-isys.c
index dd481f9d848d..b81ba4e7f786 100644
--- a/drivers/staging/media/ipu7/ipu7-isys.c
+++ b/drivers/staging/media/ipu7/ipu7-isys.c
@@ -9,6 +9,9 @@
#include <linux/bug.h>
#include <linux/completion.h>
#include <linux/container_of.h>
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+#endif
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
@@ -576,6 +579,10 @@ static void isys_remove(struct auxiliary_device *auxdev)
struct isys_fw_msgs *fwmsg, *safe;
struct ipu7_bus_device *adev = auxdev_to_adev(auxdev);

+#ifdef CONFIG_DEBUG_FS
+ if (adev->isp->ipu7_dir)
+ debugfs_remove_recursive(isys->debugfsdir);
+#endif
for (int i = 0; i < IPU_ISYS_MAX_STREAMS; i++)
mutex_destroy(&isys->streams[i].mutex);

@@ -596,6 +603,78 @@ static void isys_remove(struct auxiliary_device *auxdev)
mutex_destroy(&isys->mutex);
}

+#ifdef CONFIG_DEBUG_FS
+static ssize_t fwlog_read(struct file *file, char __user *userbuf, size_t size,
+ loff_t *pos)
+{
+ struct ipu7_isys *isys = file->private_data;
+ struct isys_fw_log *fw_log = isys->fw_log;
+ struct device *dev = &isys->adev->auxdev.dev;
+ u32 log_size;
+ int ret = 0;
+ void *buf;
+
+ if (!fw_log)
+ return 0;
+
+ buf = kvzalloc(FW_LOG_BUF_SIZE, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ mutex_lock(&fw_log->mutex);
+ if (!fw_log->size) {
+ dev_warn(dev, "no available fw log\n");
+ mutex_unlock(&fw_log->mutex);
+ goto free_and_return;
+ }
+
+ if (fw_log->size > FW_LOG_BUF_SIZE)
+ log_size = FW_LOG_BUF_SIZE;
+ else
+ log_size = fw_log->size;
+
+ memcpy(buf, fw_log->addr, log_size);
+ dev_info(dev, "copy %d bytes fw log to user...\n", log_size);
+ mutex_unlock(&fw_log->mutex);
+
+ ret = simple_read_from_buffer(userbuf, size, pos, buf,
+ log_size);
+free_and_return:
+ kvfree(buf);
+
+ return ret;
+}
+
+static const struct file_operations isys_fw_log_fops = {
+ .open = simple_open,
+ .owner = THIS_MODULE,
+ .read = fwlog_read,
+ .llseek = default_llseek,
+};
+
+static int ipu7_isys_init_debugfs(struct ipu7_isys *isys)
+{
+ struct dentry *file;
+ struct dentry *dir;
+
+ dir = debugfs_create_dir("isys", isys->adev->isp->ipu7_dir);
+ if (IS_ERR(dir))
+ return -ENOMEM;
+
+ file = debugfs_create_file("fwlog", 0400,
+ dir, isys, &isys_fw_log_fops);
+ if (IS_ERR(file))
+ goto err;
+
+ isys->debugfsdir = dir;
+
+ return 0;
+err:
+ debugfs_remove_recursive(dir);
+ return -ENOMEM;
+}
+#endif
+
static int alloc_fw_msg_bufs(struct ipu7_isys *isys, int amount)
{
struct ipu7_bus_device *adev = isys->adev;
@@ -750,6 +829,11 @@ static int isys_probe(struct auxiliary_device *auxdev,

isys_stream_init(isys);

+#ifdef CONFIG_DEBUG_FS
+ /* Debug fs failure is not fatal. */
+ ipu7_isys_init_debugfs(isys);
+#endif
+
cpu_latency_qos_add_request(&isys->pm_qos, PM_QOS_DEFAULT_VALUE);
ret = alloc_fw_msg_bufs(isys, 20);
if (ret < 0)
diff --git a/drivers/staging/media/ipu7/ipu7-isys.h b/drivers/staging/media/ipu7/ipu7-isys.h
index ef1ab1b42f6c..2579669c21a9 100644
--- a/drivers/staging/media/ipu7/ipu7-isys.h
+++ b/drivers/staging/media/ipu7/ipu7-isys.h
@@ -25,6 +25,10 @@
#include "ipu7-isys-csi2.h"
#include "ipu7-isys-video.h"

+#ifdef CONFIG_DEBUG_FS
+struct dentry;
+
+#endif
#define IPU_ISYS_ENTITY_PREFIX "Intel IPU7"

/* FW support max 16 streams */
@@ -92,6 +96,9 @@ struct ipu7_isys {
unsigned int ref_count;
unsigned int stream_opened;

+#ifdef CONFIG_DEBUG_FS
+ struct dentry *debugfsdir;
+#endif
struct mutex mutex; /* Serialise isys video open/release related */
struct mutex stream_mutex; /* Stream start, stop, queueing reqs */

diff --git a/drivers/staging/media/ipu7/ipu7.c b/drivers/staging/media/ipu7/ipu7.c
index 4a70d3527cb7..725bd36ce41b 100644
--- a/drivers/staging/media/ipu7/ipu7.c
+++ b/drivers/staging/media/ipu7/ipu7.c
@@ -7,6 +7,9 @@
#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/bug.h>
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+#endif
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/firmware.h>
@@ -2244,8 +2247,52 @@ void ipu7_dump_fw_error_log(const struct ipu7_bus_device *adev)
BUTTRESS_REG_FW_GP8);

memcpy_fromio(&fw_error_log[adev->subsys], reg,
- sizeof(fw_error_log[adev->subsys]));
+ sizeof(fw_error_log[adev->subsys]));
}
+
+#ifdef CONFIG_DEBUG_FS
+static struct debugfs_blob_wrapper isys_fw_error;
+static struct debugfs_blob_wrapper psys_fw_error;
+
+static int ipu7_init_debugfs(struct ipu7_device *isp)
+{
+ struct dentry *file;
+ struct dentry *dir;
+
+ dir = debugfs_create_dir(pci_name(isp->pdev), NULL);
+ if (!dir)
+ return -ENOMEM;
+
+ isys_fw_error.data = &fw_error_log[IPU_IS];
+ isys_fw_error.size = sizeof(fw_error_log[IPU_IS]);
+ file = debugfs_create_blob("is_fw_error", 0400, dir, &isys_fw_error);
+ if (!file)
+ goto err;
+ psys_fw_error.data = &fw_error_log[IPU_PS];
+ psys_fw_error.size = sizeof(fw_error_log[IPU_PS]);
+ file = debugfs_create_blob("ps_fw_error", 0400, dir, &psys_fw_error);
+ if (!file)
+ goto err;
+
+ isp->ipu7_dir = dir;
+
+ return 0;
+err:
+ debugfs_remove_recursive(dir);
+ return -ENOMEM;
+}
+
+static void ipu7_remove_debugfs(struct ipu7_device *isp)
+{
+ /*
+ * Since isys and psys debugfs dir will be created under ipu root dir,
+ * mark its dentry to NULL to avoid duplicate removal.
+ */
+ debugfs_remove_recursive(isp->ipu7_dir);
+ isp->ipu7_dir = NULL;
+}
+#endif /* CONFIG_DEBUG_FS */
+
EXPORT_SYMBOL_NS_GPL(ipu7_dump_fw_error_log, "INTEL_IPU7");

static int ipu7_pci_config_setup(struct pci_dev *dev)
@@ -2610,6 +2657,13 @@ static int ipu7_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pm_runtime_put(&isp->psys->auxdev.dev);
}

+#ifdef CONFIG_DEBUG_FS
+ ret = ipu7_init_debugfs(isp);
+ if (ret) {
+ dev_err_probe(dev, ret, "Failed to initialize debugfs\n");
+ goto out_ipu_bus_del_devices;
+ }
+#endif
pm_runtime_put_noidle(dev);
pm_runtime_allow(dev);

@@ -2622,6 +2676,10 @@ static int ipu7_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
ipu7_unmap_fw_code_region(isp->isys);
if (!IS_ERR_OR_NULL(isp->psys) && isp->psys->fw_sgt.nents)
ipu7_unmap_fw_code_region(isp->psys);
+#ifdef CONFIG_DEBUG_FS
+ if (!IS_ERR_OR_NULL(isp->fw_code_region))
+ vfree(isp->fw_code_region);
+#endif
if (!IS_ERR_OR_NULL(isp->psys) && !IS_ERR_OR_NULL(isp->psys->mmu))
ipu7_mmu_cleanup(isp->psys->mmu);
if (!IS_ERR_OR_NULL(isp->isys) && !IS_ERR_OR_NULL(isp->isys->mmu))
@@ -2640,6 +2698,9 @@ static void ipu7_pci_remove(struct pci_dev *pdev)
{
struct ipu7_device *isp = pci_get_drvdata(pdev);

+#ifdef CONFIG_DEBUG_FS
+ ipu7_remove_debugfs(isp);
+#endif
if (!IS_ERR_OR_NULL(isp->isys) && isp->isys->fw_sgt.nents)
ipu7_unmap_fw_code_region(isp->isys);
if (!IS_ERR_OR_NULL(isp->psys) && isp->psys->fw_sgt.nents)
diff --git a/drivers/staging/media/ipu7/ipu7.h b/drivers/staging/media/ipu7/ipu7.h
index ac8ac0689468..3b3ea5fb613f 100644
--- a/drivers/staging/media/ipu7/ipu7.h
+++ b/drivers/staging/media/ipu7/ipu7.h
@@ -81,6 +81,9 @@ struct ipu7_device {

void __iomem *base;
void __iomem *pb_base;
+#ifdef CONFIG_DEBUG_FS
+ struct dentry *ipu7_dir;
+#endif
u8 hw_ver;
bool ipc_reinit;
bool secure_mode;
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 48c13f11ca06badf5f84ba286015c05f7e54892d Mon Sep 17 00:00:00 2001
From: linya14x <linx.yang@intel.com>
Date: Mon, 17 Nov 2025 16:39:47 +0800
Subject: [PATCH 3/6] staging: ipu7: Add PSYS Makefile and Kconfig

Signed-off-by: Hao Yao <hao.yao@intel.com>
---
drivers/staging/media/ipu7/Kconfig | 11 ++++++++---
drivers/staging/media/ipu7/Makefile | 2 ++
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/ipu7/Kconfig b/drivers/staging/media/ipu7/Kconfig
index 7d831ba7501d..561665561b46 100644
--- a/drivers/staging/media/ipu7/Kconfig
+++ b/drivers/staging/media/ipu7/Kconfig
@@ -4,7 +4,12 @@ config VIDEO_INTEL_IPU7
depends on VIDEO_DEV
depends on X86 && HAS_DMA
depends on IPU_BRIDGE || !IPU_BRIDGE
- depends on PCI
+ #
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is wrong, please remove.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReUsed as it is from patch/v6.17.7/in-tree/0003-staging-ipu7-Add-PSYS-Makefile-and-Kconfig.patch

+ # This driver incorrectly tries to override the dma_ops. It should
+ # never have done that, but for now keep it working on architectures
+ # that use dma ops
+ #
+ depends on ARCH_HAS_DMA_OPS
select AUXILIARY_BUS
select IOMMU_IOVA
select VIDEO_V4L2_SUBDEV_API
@@ -15,5 +20,5 @@ config VIDEO_INTEL_IPU7
This is the 7th Gen Intel Image Processing Unit, found in Intel SoCs
and used for capturing images and video from camera sensors.

- To compile this driver, say Y here! It contains 2 modules -
- intel_ipu7 and intel_ipu7_isys.
+ To compile this driver, say Y here! It contains 3 modules -
+ intel_ipu7, intel_ipu7_isys and intel_ipu7_psys.
diff --git a/drivers/staging/media/ipu7/Makefile b/drivers/staging/media/ipu7/Makefile
index 6d2aec219e65..8c62d730e5f8 100644
--- a/drivers/staging/media/ipu7/Makefile
+++ b/drivers/staging/media/ipu7/Makefile
@@ -21,3 +21,5 @@ intel-ipu7-isys-objs += ipu7-isys.o \
ipu7-isys-subdev.o

obj-$(CONFIG_VIDEO_INTEL_IPU7) += intel-ipu7-isys.o
+
+obj-$(CONFIG_VIDEO_INTEL_IPU7) += psys/
--
2.43.0

Loading
Loading