[PATCH v12 82/86] media: ipu6: Drop {get,put}_streams_opened()

Sakari Ailus
2026-04-09T20:15:19Z

{get,put}_streams_opened() aren't needed anymore. Drop them. This also
requires acquiring isys->stream_mutex for system suspend.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
.../media/pci/intel/ipu6/ipu6-isys-video.c | 39 +++----------------
drivers/media/pci/intel/ipu6/ipu6-isys.c | 4 +-
drivers/media/pci/intel/ipu6/ipu6-isys.h | 1 -
3 files changed, 8 insertions(+), 36 deletions(-)

diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
index 2344e4a880d6..9eb22e456834 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
@@ -440,24 +440,6 @@ static int link_validate(struct media_link *link)
return ret;
}

-static void get_stream_opened(struct ipu6_isys *isys)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&isys->streams_lock, flags);
- isys->stream_opened++;
- spin_unlock_irqrestore(&isys->streams_lock, flags);
-}
-
-static void put_stream_opened(struct ipu6_isys *isys)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&isys->streams_lock, flags);
- isys->stream_opened--;
- spin_unlock_irqrestore(&isys->streams_lock, flags);
-}
-
static int ipu6_isys_fw_pin_cfg(struct ipu6_isys_video *av,
struct ipu6_fw_isys_stream_cfg_data_abi *cfg,
struct ipu6_isys_stream *stream,
@@ -607,8 +589,6 @@ static int ipu6_isys_start_stream_firmware(struct ipu6_isys_stream *stream,
return ret;
}

- get_stream_opened(stream->isys);
-
tout = wait_for_completion_timeout(&stream->stream_open_completion,
IPU6_FW_CALL_TIMEOUT_JIFFIES);

@@ -616,21 +596,17 @@ static int ipu6_isys_start_stream_firmware(struct ipu6_isys_stream *stream,

if (!tout) {
dev_err(dev, "stream open time out\n");
- ret = -ETIMEDOUT;
- goto out_put_stream_opened;
+ return -ETIMEDOUT;
}
if (stream->error) {
dev_err(dev, "stream open error: %d\n", stream->error);
- ret = -EIO;
- goto out_put_stream_opened;
+ return -EIO;
}
dev_dbg(dev, "start stream: open complete\n");

msg = ipu6_get_fw_msg_buf(stream);
- if (!msg) {
- ret = -ENOMEM;
- goto out_put_stream_opened;
- }
+ if (!msg)
+ return -ENOMEM;
buf = &msg->fw_msg.frame;
ipu6_isys_buf_to_fw_frame_buf(buf, stream, &bl);
ipu6_isys_buffer_list_queue(&bl, IPU6_ISYS_BUFFER_LIST_FL_ACTIVE, 0);
@@ -670,7 +646,7 @@ static int ipu6_isys_start_stream_firmware(struct ipu6_isys_stream *stream,
IPU6_FW_ISYS_SEND_TYPE_STREAM_CLOSE);
if (retout < 0) {
dev_dbg(dev, "can't close stream (%d)\n", retout);
- goto out_put_stream_opened;
+ return retout;
}

tout = wait_for_completion_timeout(&stream->stream_close_completion,
@@ -682,9 +658,6 @@ static int ipu6_isys_start_stream_firmware(struct ipu6_isys_stream *stream,
else
dev_dbg(dev, "stream close complete\n");

-out_put_stream_opened:
- put_stream_opened(stream->isys);
-
return ret;
}

@@ -741,8 +714,6 @@ static int ipu6_isys_close_streaming_firmware(struct ipu6_isys_stream *stream,
else
dev_dbg(dev, "close stream: complete\n");

- put_stream_opened(stream->isys);
-
scoped_guard(spinlock_irqsave, &stream->isys->power_lock) {
stream->isys->streams_by_handle[stream->stream_handle] = NULL;
csi2->streams_by_vc[stream->vc] = NULL;
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.c b/drivers/media/pci/intel/ipu6/ipu6-isys.c
index d7e69195c84d..fb46ded122fa 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys.c
@@ -853,8 +853,10 @@ static int isys_suspend(struct device *dev)
{
struct ipu6_isys *isys = dev_get_drvdata(dev);

+ guard(mutex)(&isys->stream_mutex);
+
/* If stream is open, refuse to suspend */
- if (isys->stream_opened)
+ if (!ida_is_empty(&isys->streams))
return -EBUSY;

return 0;
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.h b/drivers/media/pci/intel/ipu6/ipu6-isys.h
index 8a5086439f21..157b27a8eb6d 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys.h
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys.h
@@ -112,7 +112,6 @@ struct ipu6_isys {
bool csi2_cse_ipc_not_supported;
bool iwake_watermark_enabled;
unsigned int ref_count;
- unsigned int stream_opened;
unsigned int sensor_type;

struct mutex mutex;
--
2.47.3