[PATCH v12 80/86] media: ipu6: Rework watermark setting

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

Remove structs to maintain watermark related configuration, by using the
values where they're obtained, apart from keeping watermark enabled status
in struct ipu6_isys.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/pci/intel/ipu6/ipu6-isys.c | 76 ++++++++----------------
drivers/media/pci/intel/ipu6/ipu6-isys.h | 34 +----------
2 files changed, 26 insertions(+), 84 deletions(-)

diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.c b/drivers/media/pci/intel/ipu6/ipu6-isys.c
index aa892f86d17c..04058252ac01 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys.c
@@ -98,6 +98,27 @@ enum ltr_did_type {
LTR_TYPE_MAX
};

+struct ltr_did {
+ union {
+ u32 value;
+ struct {
+ u8 val0;
+ u8 val1;
+ u8 val2;
+ u8 val3;
+ } bits;
+ } lut_ltr;
+ union {
+ u32 value;
+ struct {
+ u8 th0;
+ u8 th1;
+ u8 th2;
+ u8 th3;
+ } bits;
+ } lut_fill_time;
+};
+
#define ISYS_PM_QOS_VALUE 300

static int isys_isr_one(struct ipu6_bus_device *adev);
@@ -403,20 +424,6 @@ static irqreturn_t isys_isr(struct ipu6_bus_device *adev)
return IRQ_HANDLED;
}

-static void get_lut_ltrdid(struct ipu6_isys *isys, struct ltr_did *pltr_did)
-{
- struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark;
- struct ltr_did ltrdid_default;
-
- ltrdid_default.lut_ltr.value = LTR_DEFAULT_VALUE;
- ltrdid_default.lut_fill_time.value = FILL_TIME_DEFAULT_VALUE;
-
- if (iwake_watermark->ltrdid.lut_ltr.value)
- *pltr_did = iwake_watermark->ltrdid;
- else
- *pltr_did = ltrdid_default;
-}
-
static int set_iwake_register(struct ipu6_isys *isys, u32 index, u32 value)
{
struct device *dev = &isys->adev->auxdev.dev;
@@ -512,21 +519,14 @@ static void set_iwake_ltrdid(struct ipu6_isys *isys, u16 ltr, u16 did,
*/
static void enable_iwake(struct ipu6_isys *isys, bool enable)
{
- struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark;
int ret;

- mutex_lock(&iwake_watermark->mutex);
-
- if (iwake_watermark->iwake_enabled == enable) {
- mutex_unlock(&iwake_watermark->mutex);
+ if (isys->iwake_watermark_enabled == enable)
return;
- }

ret = set_iwake_register(isys, GDA_ENABLE_IWAKE_INDEX, enable);
if (!ret)
- iwake_watermark->iwake_enabled = enable;
-
- mutex_unlock(&iwake_watermark->mutex);
+ isys->iwake_watermark_enabled = enable;
}

void ipu6_isys_update_watermark_setting(struct ipu6_isys *isys)
@@ -580,7 +580,8 @@ void ipu6_isys_update_watermark_setting(struct ipu6_isys *isys)
did = calc_fill_time_us * DEFAULT_DID_RATIO / 100;
ltr_did_type = LTR_ENHANNCE_IWAKE;
} else {
- get_lut_ltrdid(isys, &ltrdid);
+ ltrdid.lut_ltr.value = LTR_DEFAULT_VALUE;
+ ltrdid.lut_fill_time.value = FILL_TIME_DEFAULT_VALUE;

if (calc_fill_time_us <= ltrdid.lut_fill_time.bits.th0)
ltr = 0;
@@ -637,30 +638,6 @@ void ipu6_isys_update_watermark_setting(struct ipu6_isys *isys)
isys->adev->isp->base + REG_PKGC_PMON_CFG);
}

-static void isys_iwake_watermark_init(struct ipu6_isys *isys)
-{
- struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark;
-
- INIT_LIST_HEAD(&iwake_watermark->video_list);
- mutex_init(&iwake_watermark->mutex);
-
- iwake_watermark->ltrdid.lut_ltr.value = 0;
- iwake_watermark->isys = isys;
- iwake_watermark->iwake_enabled = false;
- iwake_watermark->force_iwake_disable = false;
-}
-
-static void isys_iwake_watermark_cleanup(struct ipu6_isys *isys)
-{
- struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark;
-
- mutex_lock(&iwake_watermark->mutex);
- list_del(&iwake_watermark->video_list);
- mutex_unlock(&iwake_watermark->mutex);
-
- mutex_destroy(&iwake_watermark->mutex);
-}
-
/* The .bound() notifier callback when a match is found */
static int isys_notifier_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *sd,
@@ -1094,8 +1071,6 @@ static int isys_probe(struct auxiliary_device *auxdev,
if (ret < 0)
goto out_remove_pkg_dir_shared_buffer;

- isys_iwake_watermark_init(isys);
-
if (is_ipu6se(adev->isp->hw_ver))
isys->phy_set_power = ipu6_isys_jsl_phy_set_power;
else if (is_ipu6ep_mtl(adev->isp->hw_ver))
@@ -1154,7 +1129,6 @@ static void isys_remove(struct auxiliary_device *auxdev)
for (i = 0; i < IPU6_ISYS_MAX_STREAMS; i++)
mutex_destroy(&isys->streams[i].mutex);

- isys_iwake_watermark_cleanup(isys);
mutex_destroy(&isys->stream_mutex);
mutex_destroy(&isys->mutex);
}
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.h b/drivers/media/pci/intel/ipu6/ipu6-isys.h
index c171e4e053c3..0689b4485c7f 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys.h
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys.h
@@ -60,38 +60,6 @@ struct ipu6_bus_device;
#define IPU6EP_MTL_LTR_VALUE 1023
#define IPU6EP_MTL_MIN_MEMOPEN_TH 0xc

-struct ltr_did {
- union {
- u32 value;
- struct {
- u8 val0;
- u8 val1;
- u8 val2;
- u8 val3;
- } bits;
- } lut_ltr;
- union {
- u32 value;
- struct {
- u8 th0;
- u8 th1;
- u8 th2;
- u8 th3;
- } bits;
- } lut_fill_time;
-};
-
-struct isys_iwake_watermark {
- bool iwake_enabled;
- bool force_iwake_disable;
- u32 iwake_threshold;
- u64 isys_pixelbuffer_datarate;
- struct ltr_did ltrdid;
- struct mutex mutex; /* protect whole struct */
- struct ipu6_isys *isys;
- struct list_head video_list;
-};
-
struct ipu6_isys_csi2_config {
u32 nlanes;
u32 port;
@@ -141,6 +109,7 @@ struct ipu6_isys {
bool need_reset;
bool icache_prefetch;
bool csi2_cse_ipc_not_supported;
+ bool iwake_watermark_enabled;
unsigned int ref_count;
unsigned int stream_opened;
unsigned int sensor_type;
@@ -162,7 +131,6 @@ struct ipu6_isys {
struct list_head framebuflist;
struct list_head framebuflist_fw;
struct v4l2_async_notifier notifier;
- struct isys_iwake_watermark iwake_watermark;
};

struct isys_fw_msgs {
--
2.47.3