From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: "Yan, Dongcheng" <dongcheng.yan@intel.com>,
Mehdi Djait <mehdi.djait@linux.intel.com>,
"Yu, Ong Hock" <ong.hock.yu@intel.com>,
"Ng, Khai Wen" <khai.wen.ng@intel.com>,
Antti Laakso <antti.laakso@linux.intel.com>,
"Bajpai, Manik" <manik.bajpai@intel.com>,
Divyamani Tripathi <divyamani.tripathi@intel.com>
Subject: [PATCH 18/21] media: ipu6: Serialise access to stream pointers by isys stream_lock
Date: Mon, 14 Sep 2026 23:53:55 +0300 [thread overview]
Message-ID: <20260914205358.735307-19-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20260914205358.735307-1-sakari.ailus@linux.intel.com>
Re-purpose the unused stream_lock in struct ipu6_isys to serialise access
to streams_by_handle (struct ipu6_isys) and streams_by_vc (struct
ipu6_isys_csi2). Switch to scoped_guard() while at it.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/pci/intel/ipu6/ipu6-fw-isys.c | 24 ++++++++++++-------
.../media/pci/intel/ipu6/ipu6-isys-video.c | 7 +++---
drivers/media/pci/intel/ipu6/ipu7-fw-isys.c | 8 ++++++-
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/drivers/media/pci/intel/ipu6/ipu6-fw-isys.c b/drivers/media/pci/intel/ipu6/ipu6-fw-isys.c
index 5e1b57ef650f..0214d7105fbe 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-fw-isys.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-fw-isys.c
@@ -556,6 +556,8 @@ int ipu6_isys_isr_one(struct ipu6_bus_device *adev)
"FW error resp error %d, details %d\n",
resp->error_info.error, resp->error_info.error_details);
+ guard(spinlock_irqsave)(&isys->streams_lock);
+
if (resp->stream_handle >= IPU6_ISYS_MAX_STREAMS) {
dev_err(&adev->auxdev.dev, "bad stream handle %u\n",
resp->stream_handle);
@@ -670,17 +672,23 @@ static void ipu6_isys_csi2_isr(struct ipu6_isys_csi2 *csi2)
writel(status, csi2->base + CSI_PORT_REG_BASE_IRQ_CSI_SYNC +
CSI_PORT_REG_BASE_IRQ_CLEAR_OFFSET);
- for (i = 0; i < NR_OF_CSI2_VC; i++) {
- if (status & IPU_CSI_RX_IRQ_FS_VC(i)) {
- stream = csi2->streams_by_vc[i];
- if (stream)
+ scoped_guard(spinlock, &csi2->isys->streams_lock) {
+ for (i = 0; i < NR_OF_CSI2_VC; i++) {
+ if (status & IPU_CSI_RX_IRQ_FS_VC(i)) {
+ stream = csi2->streams_by_vc[i];
+ if (!stream)
+ continue;
+
ipu6_isys_csi2_sof_event_by_stream(stream);
- }
+ }
+
+ if (status & IPU_CSI_RX_IRQ_FE_VC(i)) {
+ stream = csi2->streams_by_vc[i];
+ if (!stream)
+ continue;
- if (status & IPU_CSI_RX_IRQ_FE_VC(i)) {
- stream = csi2->streams_by_vc[i];
- if (stream)
ipu6_isys_csi2_eof_event_by_stream(stream);
+ }
}
}
}
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
index cea37442866e..feb0ad261252 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
@@ -628,7 +628,7 @@ void ipu6_isys_close_stream_firmware(struct ipu6_isys_stream *stream)
else
dev_dbg(dev, "close stream: complete\n");
- scoped_guard(spinlock_irqsave, &stream->isys->power_lock) {
+ scoped_guard(spinlock_irqsave, &stream->isys->streams_lock) {
stream->isys->streams_by_handle[stream->stream_handle] = NULL;
csi2->streams_by_vc[stream->vc] = NULL;
}
@@ -695,9 +695,8 @@ ipu6_isys_alloc_stream_firmware(struct ipu6_isys_csi2 *csi2,
stream->asd = &csi2->asd;
stream->vc = vc;
- scoped_guard(spinlock_irqsave, &stream->isys->power_lock) {
- stream->isys->streams_by_handle[stream->stream_handle] =
- stream;
+ scoped_guard(spinlock_irqsave, &stream->isys->streams_lock) {
+ stream->isys->streams_by_handle[stream->stream_handle] = stream;
csi2->streams_by_vc[stream->vc] = stream;
}
diff --git a/drivers/media/pci/intel/ipu6/ipu7-fw-isys.c b/drivers/media/pci/intel/ipu6/ipu7-fw-isys.c
index 1e29d0acddb3..96acd76dcd2e 100644
--- a/drivers/media/pci/intel/ipu6/ipu7-fw-isys.c
+++ b/drivers/media/pci/intel/ipu6/ipu7-fw-isys.c
@@ -550,6 +550,7 @@ static int ipu7_isys_isr_one(struct ipu6_bus_device *adev)
struct ipu7_fw_isys_msg_err err_info;
struct isys_fw_msgs *isys_fw_msg;
struct ipu7_insys_resp *resp;
+ unsigned long flags;
u64 ts;
if (!isys->fwctx)
@@ -597,9 +598,11 @@ static int ipu7_isys_isr_one(struct ipu6_bus_device *adev)
if (resp->stream_id >= IPU7_ISYS_MAX_STREAMS) {
dev_err(dev, "bad stream handle %u\n",
resp->stream_id);
- goto leave;
+ goto leave_nounlock;
}
+ spin_lock_irqsave(&isys->streams_lock, flags);
+
stream = resp->stream_id < IPU6_ISYS_MAX_STREAMS ?
isys->streams_by_handle[resp->stream_id] : NULL;
if (!stream) {
@@ -682,6 +685,9 @@ static int ipu7_isys_isr_one(struct ipu6_bus_device *adev)
}
leave:
+ spin_unlock_irqrestore(&isys->streams_lock, flags);
+
+leave_nounlock:
ipu7_fw_isys_put_resp(isys);
return 0;
--
2.47.3
next prev parent reply other threads:[~2026-09-14 20:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 20:53 [PATCH 00/21] IPU6 multi-stream and metadata support preparation Sakari Ailus
2026-09-14 20:53 ` [PATCH 01/21] media: ipu6: Fix releasing resources at failing streamon Sakari Ailus
2026-09-14 20:53 ` [PATCH 02/21] media: ipu6: Move streaming control to CSI-2 receiver driver Sakari Ailus
2026-09-14 20:53 ` [PATCH 03/21] media: ipu6: Stream number on CSI-2 receiver source pads is always 0 Sakari Ailus
2026-09-14 20:53 ` [PATCH 04/21] media: ipu6: Rename misnamed out_free_watermark label in video init Sakari Ailus
2026-09-14 20:53 ` [PATCH 05/21] media: ipu6: Always request a capture ack Sakari Ailus
2026-09-14 20:53 ` [PATCH 06/21] media: ipu6: Clean up link frequency calculation Sakari Ailus
2026-09-14 20:53 ` [PATCH 07/21] media: ipu6: Get watermark configuration directly from ipdata Sakari Ailus
2026-09-14 20:53 ` [PATCH 08/21] media: ipu6: Collect IPU streams into CSI-2 receiver sub-device context Sakari Ailus
2026-09-14 20:53 ` [PATCH 09/21] media: ipu6: Start streaming once all streams have started, stop when not Sakari Ailus
2026-09-15 7:15 ` Sakari Ailus
2026-09-14 20:53 ` [PATCH 10/21] media: ipu6: Add lockdep checks for CSI-2 streaming enable and disable Sakari Ailus
2026-09-14 20:53 ` [PATCH 11/21] media: ipu6: Remove nr_queues and nr_streaming fields in ipu6_isys_stream Sakari Ailus
2026-09-14 20:53 ` [PATCH 12/21] media: ipu6: Collect enabled stream IDs Sakari Ailus
2026-09-14 20:53 ` [PATCH 13/21] media: ipu6: Avoid accessing av->streams before streaming Sakari Ailus
2026-09-14 20:53 ` [PATCH 14/21] media: ipu6: Rework watermark calculation Sakari Ailus
2026-09-14 20:53 ` [PATCH 15/21] media: ipu6: Rework watermark setting Sakari Ailus
2026-09-14 20:53 ` [PATCH 16/21] media: ipu6: Bridge the gap between streams in V4L2 and IPU6 firmware Sakari Ailus
2026-09-16 16:09 ` Antti Laakso
2026-09-17 9:18 ` Sakari Ailus
2026-09-14 20:53 ` [PATCH 17/21] media: ipu6: Drop {get,put}_streams_opened() Sakari Ailus
2026-09-14 20:53 ` Sakari Ailus [this message]
2026-09-14 20:53 ` [PATCH 19/21] media: ipu6: Move firmware init/cleanup to RPM callbacks Sakari Ailus
2026-09-14 20:53 ` [PATCH 20/21] media: ipu6: Don't track power status, rely on runtime PM Sakari Ailus
2026-09-14 20:53 ` [PATCH 21/21] media: ipu6: Support upstream sub-devices without get_frame_desc() Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260914205358.735307-19-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=antti.laakso@linux.intel.com \
--cc=divyamani.tripathi@intel.com \
--cc=dongcheng.yan@intel.com \
--cc=khai.wen.ng@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=manik.bajpai@intel.com \
--cc=mehdi.djait@linux.intel.com \
--cc=ong.hock.yu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.