diff mbox series

[RFT,07/20] media: venus: pm_helpers: Use reset_bulk API

Message ID 20230911-topic-mars-v1-7-a7d38bf87bdb@linaro.org
State New
Headers show
Series Venus cleanups | expand

Commit Message

Konrad Dybcio Sept. 11, 2023, 3:10 p.m. UTC
All of the resets are toggled together. Use the bulk api to save on some
code complexity.

Note, this change is not exactly a NOP. Instead of waiting 150-250us
between each reset toggle, the behavior now is to assert all the resets,
wait 150-250us and deassert all the resets. This should be fine, but the
logic here is really abusive, as such assertion requirements should be
expressed per-reset_control, in the provider driver.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/media/platform/qcom/venus/core.c       | 15 ++++++++++-----
 drivers/media/platform/qcom/venus/core.h       |  4 ++--
 drivers/media/platform/qcom/venus/pm_helpers.c | 17 +++++------------
 3 files changed, 17 insertions(+), 19 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 2445a814b39f..be633e62263c 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -323,11 +323,16 @@  static int venus_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	for (i = 0; i < core->res->resets_num; i++) {
-		core->resets[i] = devm_reset_control_get_exclusive(dev, core->res->resets[i]);
-		if (IS_ERR(core->resets[i]))
-			return PTR_ERR(core->resets[i]);
-	}
+	core->resets = devm_kcalloc(dev, core->res->resets_num, sizeof(*core->resets), GFP_KERNEL);
+	if (core->res->resets_num && !core->resets)
+		return -ENOMEM;
+
+	for (i = 0; i < core->res->resets_num; i++)
+		core->resets[i].id = core->res->resets[i];
+
+	ret = devm_reset_control_bulk_get_exclusive(dev, core->res->resets_num, core->resets);
+	if (ret)
+		return ret;
 
 	if (core->pm_ops->core_get) {
 		ret = core->pm_ops->core_get(core);
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 4a633261ece4..515e7d78b7ab 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -137,7 +137,7 @@  struct venus_format {
  * @pmdomains:	an array of pmdomains struct device pointers
  * @opp_dl_venus: an device-link for device OPP
  * @opp_pmdomain: an OPP power-domain
- * @resets: an array of reset signals
+ * @resets: a reset_control_bulk_data array of hardware reset signals
  * @vdev_dec:	a reference to video device structure for decoder instances
  * @vdev_enc:	a reference to video device structure for encoder instances
  * @v4l2_dev:	a holder for v4l2 device structure
@@ -190,7 +190,7 @@  struct venus_core {
 	struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX];
 	struct device_link *opp_dl_venus;
 	struct device *opp_pmdomain;
-	struct reset_control *resets[VIDC_RESETS_NUM_MAX];
+	struct reset_control_bulk_data *resets;
 	struct video_device *vdev_dec;
 	struct video_device *vdev_enc;
 	struct v4l2_device v4l2_dev;
diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
index 0e04da8d7eb5..7f22a078b38a 100644
--- a/drivers/media/platform/qcom/venus/pm_helpers.c
+++ b/drivers/media/platform/qcom/venus/pm_helpers.c
@@ -934,22 +934,15 @@  static void vcodec_domains_put(struct venus_core *core)
 static int core_resets_reset(struct venus_core *core)
 {
 	const struct venus_resources *res = core->res;
-	unsigned int i;
 	int ret;
 
-	for (i = 0; i < res->resets_num; i++) {
-		ret = reset_control_assert(core->resets[i]);
-		if (ret)
-			goto err;
+	ret = reset_control_bulk_assert(res->resets_num, core->resets);
+	if (ret)
+		return ret;
 
-		usleep_range(150, 250);
-		ret = reset_control_deassert(core->resets[i]);
-		if (ret)
-			goto err;
-	}
+	usleep_range(150, 250);
 
-err:
-	return ret;
+	return reset_control_bulk_deassert(res->resets_num, core->resets);
 }
 
 static int core_get_v4(struct venus_core *core)