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
22 changes: 1 addition & 21 deletions drivers/media/pci/intel/ipu7/abi/ipu7_fw_isys_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,26 +352,6 @@ struct ipu7_insys_buffset {
};

struct ipu7_insys_resp {
u64 buf_id;
struct ipu7_insys_capture_output_pin_payload pin;
struct ia_gofo_msg_err error_info;
u32 timestamp[2];
u16 mipi_fn;
u8 type;
u8 msg_link_streaming_mode;
u8 stream_id;
u8 pin_id;
u8 frame_id;
u8 skip_frame;
};

/**
* TODO: Revert this change after firmware ABI fixed.
* This is an internal workaround.
* IPU7.5 firmware changed its ABI and breaks
* compatibility with IPU7 Lunar Lake.
*/
struct ipu7_insys_legacy_resp {
u64 buf_id;
struct ipu7_insys_capture_output_pin_payload pin;
struct ia_gofo_msg_err error_info;
Expand All @@ -382,7 +362,7 @@ struct ipu7_insys_legacy_resp {
u8 pin_id;
u8 frame_id;
u8 skip_frame;
u8 pad[2];
u16 mipi_fn;
};

struct ipu7_insys_resp_queue_token {
Expand Down
23 changes: 1 addition & 22 deletions drivers/media/pci/intel/ipu7/ipu7-fw-isys.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,30 +195,9 @@ int ipu7_fw_isys_close(struct ipu7_isys *isys)

struct ipu7_insys_resp *ipu7_fw_isys_get_resp(struct ipu7_isys *isys)
{
/**
* TODO: Revert this change after firmware ABI fixed.
* This is an internal workaround.
* IPU7.5 firmware changed its ABI and breaks
* compatibility with IPU7 Lunar Lake.
*/
struct ipu7_insys_resp *resp =
return (struct ipu7_insys_resp *)
ipu7_syscom_get_token(isys->adev->syscom,
IPU_INSYS_OUTPUT_MSG_QUEUE);

if (resp && isys->adev->isp->hw_ver == IPU_VER_7) {
struct ipu7_insys_legacy_resp lnl_resp;

memcpy(&lnl_resp, resp, sizeof(struct ipu7_insys_resp));
resp->mipi_fn = 0;
resp->type = lnl_resp.type;
resp->msg_link_streaming_mode = lnl_resp.msg_link_streaming_mode;
resp->stream_id = lnl_resp.stream_id;
resp->pin_id = lnl_resp.pin_id;
resp->frame_id = lnl_resp.frame_id;
resp->skip_frame = lnl_resp.skip_frame;
}

return resp;
}

void ipu7_fw_isys_put_resp(struct ipu7_isys *isys)
Expand Down
15 changes: 11 additions & 4 deletions drivers/media/pci/intel/ipu7/ipu7-isys-csi-phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
{ }
};

Expand Down Expand Up @@ -730,7 +731,7 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes,
u16 deass_thresh;
u16 delay_thresh;
u16 reset_thresh;
u16 cap_prog = 6U;
u16 cap_prog;
u16 reg;
u16 val;
u32 i;
Expand Down Expand Up @@ -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++)
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
45 changes: 33 additions & 12 deletions patch/v6.17_iot/0001-staging-add-ipu7-isys-reset-code.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
From b2ab04727acd72eee42f7f6094b8d88920f43787 Mon Sep 17 00:00:00 2001
From 147b28d7caf9418f72006ce50383c1c2c56f616b Mon Sep 17 00:00:00 2001
From: linya14x <linx.yang@intel.com>
Date: Fri, 24 Oct 2025 11:46:21 +0800
Subject: [PATCH] patch: staging add ipu7 isys reset code

Change-Id: I0fadb4657fbd933e3712c7bfc5c990250e78c469
Signed-off-by: linya14x <linx.yang@intel.com>
---
drivers/staging/media/ipu7/Kconfig | 10 +
drivers/staging/media/ipu7/ipu7-isys-queue.c | 359 ++++++++++++++++++-
drivers/staging/media/ipu7/ipu7-isys-queue.c | 379 ++++++++++++++++++-
drivers/staging/media/ipu7/ipu7-isys-queue.h | 3 +
drivers/staging/media/ipu7/ipu7-isys-video.c | 102 ++++++
drivers/staging/media/ipu7/ipu7-isys-video.c | 102 +++++
drivers/staging/media/ipu7/ipu7-isys-video.h | 8 +
drivers/staging/media/ipu7/ipu7-isys.c | 16 +
drivers/staging/media/ipu7/ipu7-isys.h | 16 +
7 files changed, 513 insertions(+), 1 deletion(-)
7 files changed, 533 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/ipu7/Kconfig b/drivers/staging/media/ipu7/Kconfig
index 7d831ba750..c4eee7c3e6 100644
Expand All @@ -33,7 +34,7 @@ index 7d831ba750..c4eee7c3e6 100644
+
+ If doubt, say N here.
diff --git a/drivers/staging/media/ipu7/ipu7-isys-queue.c b/drivers/staging/media/ipu7/ipu7-isys-queue.c
index 7046c29141..0c1596a2ba 100644
index 7046c29141..1f5fb7d20d 100644
--- a/drivers/staging/media/ipu7/ipu7-isys-queue.c
+++ b/drivers/staging/media/ipu7/ipu7-isys-queue.c
@@ -11,6 +11,9 @@
Expand Down Expand Up @@ -138,7 +139,7 @@ index 7046c29141..0c1596a2ba 100644

return 0;

@@ -614,17 +660,272 @@ out_return_buffers:
@@ -614,17 +660,292 @@ out_return_buffers:
return ret;
}

Expand Down Expand Up @@ -231,7 +232,17 @@ index 7046c29141..0c1596a2ba 100644
+ goto out;
+
+ bl = &__bl;
+ ret = buffer_list_get(stream, bl);
+ int retry = 5;
+ while (retry--) {
+ ret = buffer_list_get(stream, bl);
+ if (ret < 0) {
+ dev_dbg(dev, "wait for incoming buffer, retry %d\n", retry);
+ usleep_range(100000, 110000);
+ continue;
+ }
+ break;
+ }
+
+ /*
+ * In reset start streaming and no buffer available,
+ * it is considered that gstreamer has been closed,
Expand Down Expand Up @@ -288,6 +299,7 @@ index 7046c29141..0c1596a2ba 100644
+ struct ipu7_isys_video *av = NULL;
+ struct ipu7_isys_stream *stream = NULL;
+ struct device *dev = &adev->auxdev.dev;
+ int ret = 0;
+ int i, j;
+ int has_streaming = 0;
+ const struct ipu7_isys_internal_csi2_pdata *csi2_pdata =
Expand Down Expand Up @@ -345,8 +357,12 @@ index 7046c29141..0c1596a2ba 100644
+ continue;
+
+ av->reset = false;
+ reset_start_streaming(av);
+ ret = reset_start_streaming(av);
+ if (ret)
+ break;
+ }
+ if (ret)
+ break;
+ }
+
+end_of_reset:
Expand All @@ -364,6 +380,7 @@ index 7046c29141..0c1596a2ba 100644
struct ipu7_isys_video *av = ipu7_isys_queue_to_video(aq);
struct ipu7_isys_stream *stream = av->stream;
+ int ret = 0;
+ int times = 5;
+
+ struct device *dev = &av->isys->adev->auxdev.dev;
+ bool need_reset;
Expand All @@ -373,7 +390,7 @@ index 7046c29141..0c1596a2ba 100644
+ mutex_lock(&av->isys->reset_mutex);
+ while (av->isys->state) {
+ mutex_unlock(&av->isys->reset_mutex);
+ dev_dbg(dev, "stop: %s: wait for rest or stop, isys->state = %d\n",
+ dev_dbg(dev, "stop: %s: wait for reset or stop, isys->state = %d\n",
+ av->vdev.name, av->isys->state);
+ usleep_range(10000, 11000);
+ mutex_lock(&av->isys->reset_mutex);
Expand All @@ -388,6 +405,10 @@ index 7046c29141..0c1596a2ba 100644
+ av->isys->state |= RESET_STATE_IN_STOP_STREAMING;
+ mutex_unlock(&av->isys->reset_mutex);
+
+ while (!list_empty(&aq->active) && times--) {
+ usleep_range(30000, 31000);
+ }
+
+ stream = av->stream;
+ if (!stream) {
+ dev_err(dev, "stop: %s: ip cleard!\n", av->vdev.name);
Expand All @@ -412,7 +433,7 @@ index 7046c29141..0c1596a2ba 100644

stream->nr_streaming--;
list_del(&aq->node);
@@ -637,7 +938,58 @@ static void stop_streaming(struct vb2_queue *q)
@@ -637,7 +958,58 @@ static void stop_streaming(struct vb2_queue *q)
return_buffers(aq, VB2_BUF_STATE_ERROR);

ipu7_isys_fw_close(av->isys);
Expand Down Expand Up @@ -471,7 +492,7 @@ index 7046c29141..0c1596a2ba 100644

static unsigned int
get_sof_sequence_by_timestamp(struct ipu7_isys_stream *stream, u64 time)
@@ -719,6 +1071,11 @@ static void ipu7_isys_queue_buf_done(struct ipu7_isys_buffer *ib)
@@ -719,6 +1091,11 @@ static void ipu7_isys_queue_buf_done(struct ipu7_isys_buffer *ib)
* to the userspace when it is de-queued
*/
atomic_set(&ib->str2mmio_flag, 0);
Expand Down Expand Up @@ -799,5 +820,5 @@ index ef1ab1b42f..17d4d56301 100644

struct isys_fw_msgs {
--
2.43.0
2.34.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 767afb431bcf19542965535d942597be0311c2e3 Mon Sep 17 00:00:00 2001
From: hepengpx <pengpengx.he@intel.com>
Date: Thu, 4 Dec 2025 11:19:32 +0800
Subject: [PATCH] media: ipu: invalidate MMU TLB in dma buffers creation

This patch ensures that the MMU TLB is properly invalidated during
the creation and mapping of DMA buffers for IPU devices. Without
explicit invalidation, stale or incorrect entries in the TLB can cause
invalid memory access in hardware.

Test Platform:
PTL CRB FAB B B0 silicon

Signed-off-by: hepengpx <pengpengx.he@intel.com>
---
drivers/staging/media/ipu7/ipu7-dma.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/ipu7/ipu7-dma.c b/drivers/staging/media/ipu7/ipu7-dma.c
index a118b41b2f..a0bdf6c37f 100644
--- a/drivers/staging/media/ipu7/ipu7-dma.c
+++ b/drivers/staging/media/ipu7/ipu7-dma.c
@@ -206,6 +206,8 @@ void *ipu7_dma_alloc(struct ipu7_bus_device *sys, size_t size,
}
}

+ mmu->tlb_invalidate(mmu);
+
info->vaddr = vmap(pages, count, VM_USERMAP, PAGE_KERNEL);
if (!info->vaddr)
goto out_unmap;
--
2.34.1

This file was deleted.

Loading