2023-02-28 15:24:41

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 00/18] Venus QoL / maintainability fixes

Currently upstream assumes all (well, almost all - see 7280 or CrOS
specific checks) Venus implementations using the same version of the
Hardware Firmware Interface can be treated the same way. This is
however not the case.

This series tries to introduce the groundwork to start differentiating
them based on the VPU (Video Processing Unit) hardware type, fixes a
couple of issues that were an effect of that generalized assumption
and lays the foundation for supporting 8150 (IRIS1) and SM6115/QCM2290
(AR50 Lite), which will hopefully come soon.

Tested on 8250, but pretty please test it on your boards too!

Signed-off-by: Konrad Dybcio <[email protected]>
---
Konrad Dybcio (18):
media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6
media: venus: Introduce VPU version distinction
media: venus: Add vpu_version to most SoCs
media: venus: firmware: Leave a clue for homegrown porters
media: venus: hfi_venus: Sanitize venus_boot_core() per-VPU-version
media: venus: hfi_venus: Write to VIDC_CTRL_INIT after unmasking interrupts
media: venus: core: Assign registers based on VPU version
media: venus: hfi_venus: Fix version checks in venus_halt_axi()
media: venus: hfi_venus: Fix version checks in venus_isr()
media: venus: hfi_venus: Fix version check in venus_cpu_and_video_core_idle()
media: venus: hfi_venus: Fix version check in venus_cpu_idle_and_pc_ready()
media: venus: firmware: Correct IS_V6() checks
media: venus: hfi_platform: Check vpu_version instead of device compatible
media: venus: vdec: Fix version check in vdec_set_work_route()
media: venus: Remap bufreq fields on HFI6XX
media: venus: Introduce accessors for remapped hfi_buffer_reqs members
media: venus: Use newly-introduced hfi_buffer_requirements accessors
media: venus: hfi_venus: Restrict writing SCIACMDARG3 to Venus V1/V2

drivers/media/platform/qcom/venus/core.c | 7 ++-
drivers/media/platform/qcom/venus/core.h | 15 ++++++
drivers/media/platform/qcom/venus/firmware.c | 20 +++++--
drivers/media/platform/qcom/venus/helpers.c | 7 +--
drivers/media/platform/qcom/venus/hfi_helper.h | 61 +++++++++++++++++++---
drivers/media/platform/qcom/venus/hfi_msgs.c | 2 +-
.../media/platform/qcom/venus/hfi_plat_bufs_v6.c | 22 ++++----
drivers/media/platform/qcom/venus/hfi_platform.c | 2 +-
drivers/media/platform/qcom/venus/hfi_venus.c | 29 +++++-----
drivers/media/platform/qcom/venus/vdec.c | 10 ++--
drivers/media/platform/qcom/venus/vdec_ctrls.c | 2 +-
drivers/media/platform/qcom/venus/venc.c | 4 +-
drivers/media/platform/qcom/venus/venc_ctrls.c | 2 +-
13 files changed, 132 insertions(+), 51 deletions(-)
---
base-commit: 058f4df42121baadbb8a980c06011e912784dbd2
change-id: 20230228-topic-venus-70ea3bc76688

Best regards,
--
Konrad Dybcio <[email protected]>



2023-02-28 15:24:47

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 02/18] media: venus: Introduce VPU version distinction

The Video Processing Unit hardware version is the differentiator,
based on which we should decide which code paths to take in hw
init. Up until now, we've relied on HFI versions, but that was
just a happy accident between recent SoCs. Add a field in the
res struct and add correlated definitions that will be used to
account for the aforementioned differences.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/core.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 32551c2602a9..4b785205c5b1 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -48,6 +48,14 @@ struct bw_tbl {
u32 peak_10bit;
};

+enum vpu_version {
+ VPU_VERSION_AR50, /* VPU4 */
+ VPU_VERSION_AR50_LITE, /* VPU4.4 */
+ VPU_VERSION_IRIS1, /* VPU5 */
+ VPU_VERSION_IRIS2,
+ VPU_VERSION_IRIS2_1,
+};
+
struct venus_resources {
u64 dma_mask;
const struct freq_tbl *freq_tbl;
@@ -71,6 +79,7 @@ struct venus_resources {
const char * const resets[VIDC_RESETS_NUM_MAX];
unsigned int resets_num;
enum hfi_version hfi_version;
+ enum vpu_version vpu_version;
u8 num_vpp_pipes;
u32 max_load;
unsigned int vmem_id;
@@ -473,6 +482,12 @@ struct venus_inst {
#define IS_V4(core) ((core)->res->hfi_version == HFI_VERSION_4XX)
#define IS_V6(core) ((core)->res->hfi_version == HFI_VERSION_6XX)

+#define IS_AR50(core) ((core)->res->vpu_version == VPU_VERSION_AR50)
+#define IS_AR50_LITE(core) ((core)->res->vpu_version == VPU_VERSION_AR50_LITE)
+#define IS_IRIS1(core) ((core)->res->vpu_version == VPU_VERSION_IRIS1)
+#define IS_IRIS2(core) ((core)->res->vpu_version == VPU_VERSION_IRIS2)
+#define IS_IRIS2_1(core) ((core)->res->vpu_version == VPU_VERSION_IRIS2_1)
+
#define ctrl_to_inst(ctrl) \
container_of((ctrl)->handler, struct venus_inst, ctrl_handler)


--
2.39.2


2023-02-28 15:24:57

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6

This call does not seem to have been cast on any kernel with support
for VPU-1.0 or newer (and by extension, HFI6 and newer). Restrict it
to V4 only, as it seems to have been enabled by mistake and causes a
hang & reboot to EDL on at least one occasion with SM6115 / AR50L

Fixes: 7ed9e0b3393c ("media: venus: hfi, vdec: v6 Add IS_V6() to existing IS_V4() if locations")
Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index 2ad40b3945b0..4ccf31147c2a 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -952,7 +952,7 @@ static int venus_sys_set_default_properties(struct venus_hfi_device *hdev)
* enable it explicitly in order to make suspend functional by checking
* WFI (wait-for-interrupt) bit.
*/
- if (IS_V4(hdev->core) || IS_V6(hdev->core))
+ if (IS_V4(hdev->core))
venus_sys_idle_indicator = true;

ret = venus_sys_set_idle_message(hdev, venus_sys_idle_indicator);

--
2.39.2


2023-02-28 15:25:05

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 04/18] media: venus: firmware: Leave a clue for homegrown porters

Leave a clue about where the seemingly magic values come from, as it
is not obvious and requires some digging downstream..

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/firmware.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c
index 61ff20a7e935..1bb6406af564 100644
--- a/drivers/media/platform/qcom/venus/firmware.c
+++ b/drivers/media/platform/qcom/venus/firmware.c
@@ -241,6 +241,13 @@ int venus_boot(struct venus_core *core)
return ret;

if (core->use_tz && res->cp_size) {
+ /*
+ * Clues for porting using downstream data:
+ * cp_start = 0
+ * cp_size = venus_ns/virtual-addr-pool[0] (yes, addr not size)
+ * cp_nonpixel_start = venus_sec_non_pixel/virtual-addr-pool[0]
+ * cp_nonpixel_size = venus_sec_non_pixel/virtual-addr-pool[1]
+ */
ret = qcom_scm_mem_protect_video_var(res->cp_start,
res->cp_size,
res->cp_nonpixel_start,

--
2.39.2


2023-02-28 15:25:08

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 03/18] media: venus: Add vpu_version to most SoCs

Add vpu_version where I was able to retrieve the information to
allow for more precise hardware-specific code path matching.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/core.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 990a1519f968..c13436d58ed3 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -686,6 +686,7 @@ static const struct venus_resources sdm845_res = {
.vcodec_clks_num = 2,
.max_load = 3110400, /* 4096x2160@90 */
.hfi_version = HFI_VERSION_4XX,
+ .vpu_version = VPU_VERSION_AR50,
.vmem_id = VIDC_RESOURCE_NONE,
.vmem_size = 0,
.vmem_addr = 0,
@@ -711,6 +712,7 @@ static const struct venus_resources sdm845_res_v2 = {
.vcodec_num = 2,
.max_load = 3110400, /* 4096x2160@90 */
.hfi_version = HFI_VERSION_4XX,
+ .vpu_version = VPU_VERSION_AR50,
.vmem_id = VIDC_RESOURCE_NONE,
.vmem_size = 0,
.vmem_addr = 0,
@@ -758,6 +760,7 @@ static const struct venus_resources sc7180_res = {
.opp_pmdomain = (const char *[]) { "cx", NULL },
.vcodec_num = 1,
.hfi_version = HFI_VERSION_4XX,
+ .vpu_version = VPU_VERSION_AR50,
.vmem_id = VIDC_RESOURCE_NONE,
.vmem_size = 0,
.vmem_addr = 0,
@@ -811,6 +814,7 @@ static const struct venus_resources sm8250_res = {
.vcodec_num = 1,
.max_load = 7833600,
.hfi_version = HFI_VERSION_6XX,
+ .vpu_version = VPU_VERSION_IRIS2,
.num_vpp_pipes = 4,
.vmem_id = VIDC_RESOURCE_NONE,
.vmem_size = 0,
@@ -868,6 +872,7 @@ static const struct venus_resources sc7280_res = {
.opp_pmdomain = (const char *[]) { "cx", NULL },
.vcodec_num = 1,
.hfi_version = HFI_VERSION_6XX,
+ .vpu_version = VPU_VERSION_IRIS2_1,
.num_vpp_pipes = 1,
.vmem_id = VIDC_RESOURCE_NONE,
.vmem_size = 0,

--
2.39.2


2023-02-28 15:25:10

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 05/18] media: venus: hfi_venus: Sanitize venus_boot_core() per-VPU-version

The current assumption of IS_V6 is overgeneralized. Adjust the logic
to take the VPU hardware version into account.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index 4ccf31147c2a..772e5e9cf127 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -448,20 +448,21 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
{
struct device *dev = hdev->core->dev;
static const unsigned int max_tries = 100;
- u32 ctrl_status = 0, mask_val;
+ u32 ctrl_status = 0, mask_val = 0;
unsigned int count = 0;
void __iomem *cpu_cs_base = hdev->core->cpu_cs_base;
void __iomem *wrapper_base = hdev->core->wrapper_base;
int ret = 0;

writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
- if (IS_V6(hdev->core)) {
+ if (IS_IRIS1(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
mask_val = readl(wrapper_base + WRAPPER_INTR_MASK);
mask_val &= ~(WRAPPER_INTR_MASK_A2HWD_BASK_V6 |
WRAPPER_INTR_MASK_A2HCPU_MASK);
} else {
mask_val = WRAPPER_INTR_MASK_A2HVCODEC_MASK;
}
+
writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);

@@ -480,10 +481,11 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
if (count >= max_tries)
ret = -ETIMEDOUT;

- if (IS_V6(hdev->core)) {
+ if (IS_AR50_LITE(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
writel(0x1, cpu_cs_base + CPU_CS_H2XSOFTINTEN_V6);
+
+ if (IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
writel(0x0, cpu_cs_base + CPU_CS_X2RPMH_V6);
- }

return ret;
}

--
2.39.2


2023-02-28 15:25:13

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 06/18] media: venus: hfi_venus: Write to VIDC_CTRL_INIT after unmasking interrupts

The downstream driver signals the hardware to be enabled only after the
interrupts are unmasked, which... makes sense. Follow suit.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index 772e5e9cf127..4d785e53aa0b 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -454,7 +454,6 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
void __iomem *wrapper_base = hdev->core->wrapper_base;
int ret = 0;

- writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
if (IS_IRIS1(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
mask_val = readl(wrapper_base + WRAPPER_INTR_MASK);
mask_val &= ~(WRAPPER_INTR_MASK_A2HWD_BASK_V6 |
@@ -466,6 +465,7 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);

+ writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
while (!ctrl_status && count < max_tries) {
ctrl_status = readl(cpu_cs_base + CPU_CS_SCIACMDARG0);
if ((ctrl_status & CPU_CS_SCIACMDARG0_ERROR_STATUS_MASK) == 4) {

--
2.39.2


2023-02-28 15:25:15

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 07/18] media: venus: core: Assign registers based on VPU version

IRIS2(_1) has a different register map compared to other HFI6XX-
using VPUs. Take care of it.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index c13436d58ed3..bdc14acc8399 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -246,7 +246,7 @@ static int venus_enumerate_codecs(struct venus_core *core, u32 type)

static void venus_assign_register_offsets(struct venus_core *core)
{
- if (IS_V6(core)) {
+ if (IS_IRIS2(core) || IS_IRIS2_1(core)) {
core->vbif_base = core->base + VBIF_BASE;
core->cpu_base = core->base + CPU_BASE_V6;
core->cpu_cs_base = core->base + CPU_CS_BASE_V6;

--
2.39.2


2023-02-28 15:25:17

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 08/18] media: venus: hfi_venus: Fix version checks in venus_halt_axi()

Only IRIS2(_1) should enter the until-now-IS_V6() path and the
condition for skipping part of it should be IS_IRIS2_1 and not the
number of VPP pipes. Fix that.

Fixes: 4b0b6e147dc9 ("media: venus: hfi: Add 6xx AXI halt logic")
Fixes: 78d434ba8659 ("media: venus: hfi: Skip AON register programming for V6 1pipe")
Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index 4d785e53aa0b..0d137e070407 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -550,10 +550,10 @@ static int venus_halt_axi(struct venus_hfi_device *hdev)
u32 mask_val;
int ret;

- if (IS_V6(hdev->core)) {
+ if (IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
writel(0x3, cpu_cs_base + CPU_CS_X2RPMH_V6);

- if (hdev->core->res->num_vpp_pipes == 1)
+ if (IS_IRIS2_1(hdev->core))
goto skip_aon_mvp_noc;

writel(0x1, aon_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL);

--
2.39.2


2023-02-28 15:25:25

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 09/18] media: venus: hfi_venus: Fix version checks in venus_isr()

IS_V6 was used there IS_IRIS2(_1) should have been and the !IS_V6
condition was only correct by luck and for now. Replace them both
with VPU version checks.

Fixes: 24fcc0522d87 ("media: venus: hfi: Add 6xx interrupt support")
Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index 0d137e070407..ecfbac36de20 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -1136,7 +1136,7 @@ static irqreturn_t venus_isr(struct venus_core *core)
wrapper_base = hdev->core->wrapper_base;

status = readl(wrapper_base + WRAPPER_INTR_STATUS);
- if (IS_V6(core)) {
+ if (IS_IRIS2(core) || IS_IRIS2_1(core)) {
if (status & WRAPPER_INTR_STATUS_A2H_MASK ||
status & WRAPPER_INTR_STATUS_A2HWD_MASK_V6 ||
status & CPU_CS_SCIACMDARG0_INIT_IDLE_MSG_MASK)
@@ -1148,7 +1148,7 @@ static irqreturn_t venus_isr(struct venus_core *core)
hdev->irq_status = status;
}
writel(1, cpu_cs_base + CPU_CS_A2HSOFTINTCLR);
- if (!IS_V6(core))
+ if (!(IS_AR50_LITE(core) || IS_IRIS2(core) || IS_IRIS2_1(core)))
writel(status, wrapper_base + WRAPPER_INTR_CLEAR);

return IRQ_WAKE_THREAD;

--
2.39.2


2023-02-28 15:25:28

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 10/18] media: venus: hfi_venus: Fix version check in venus_cpu_and_video_core_idle()

IS_V6() should have instead checked for specific VPU versions. Fix it.

Fixes: e396e75fc254 ("media: venus: hfi: Read WRAPPER_TZ_CPU_STATUS_V6 on 6xx")
Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index ecfbac36de20..584c84125887 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -1543,7 +1543,7 @@ static bool venus_cpu_and_video_core_idle(struct venus_hfi_device *hdev)
void __iomem *cpu_cs_base = hdev->core->cpu_cs_base;
u32 ctrl_status, cpu_status;

- if (IS_V6(hdev->core))
+ if (IS_AR50_LITE(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
cpu_status = readl(wrapper_tz_base + WRAPPER_TZ_CPU_STATUS_V6);
else
cpu_status = readl(wrapper_base + WRAPPER_CPU_STATUS);

--
2.39.2


2023-02-28 15:25:32

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 11/18] media: venus: hfi_venus: Fix version check in venus_cpu_idle_and_pc_ready()

IS_V6() should have instead checked for specific VPU versions. Fix it.

Fixes: e396e75fc254 ("media: venus: hfi: Read WRAPPER_TZ_CPU_STATUS_V6 on 6xx")
Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index 584c84125887..c2d134e04c30 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -1563,7 +1563,7 @@ static bool venus_cpu_idle_and_pc_ready(struct venus_hfi_device *hdev)
void __iomem *cpu_cs_base = hdev->core->cpu_cs_base;
u32 ctrl_status, cpu_status;

- if (IS_V6(hdev->core))
+ if (IS_AR50_LITE(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
cpu_status = readl(wrapper_tz_base + WRAPPER_TZ_CPU_STATUS_V6);
else
cpu_status = readl(wrapper_base + WRAPPER_CPU_STATUS);

--
2.39.2


2023-02-28 15:25:47

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 12/18] media: venus: firmware: Correct IS_V6() checks

Most of these checks should have checked for TZ presence (or well,
absence), as we shouldn't really be doing things that the black box
does for us on non-CrOS platforms.

The IS_V6() check in venus_shutdown_no_tz() should have checked
whether the core version is IRIS2_1 (so, SC7280). Fix that.

Fixes: afeae6ef0780 ("media: venus: firmware: enable no tz fw loading for sc7280")
Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/firmware.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c
index 1bb6406af564..10d3805dc2cb 100644
--- a/drivers/media/platform/qcom/venus/firmware.c
+++ b/drivers/media/platform/qcom/venus/firmware.c
@@ -29,7 +29,12 @@ static void venus_reset_cpu(struct venus_core *core)
u32 fw_size = core->fw.mapped_mem_size;
void __iomem *wrapper_base;

- if (IS_V6(core))
+ /*
+ * This may sound counter-intuitive, but when there's no TZ, we gotta
+ * do things that it would otherwise do for us, such as initializing
+ * the hardware at a very basic level.
+ * */
+ if (!core->use_tz)
wrapper_base = core->wrapper_tz_base;
else
wrapper_base = core->wrapper_base;
@@ -41,7 +46,7 @@ static void venus_reset_cpu(struct venus_core *core)
writel(0, wrapper_base + WRAPPER_NONPIX_START_ADDR);
writel(0, wrapper_base + WRAPPER_NONPIX_END_ADDR);

- if (IS_V6(core)) {
+ if (!core->use_tz) {
/* Bring XTSS out of reset */
writel(0, wrapper_base + WRAPPER_TZ_XTSS_SW_RESET);
} else {
@@ -67,7 +72,7 @@ int venus_set_hw_state(struct venus_core *core, bool resume)
if (resume) {
venus_reset_cpu(core);
} else {
- if (IS_V6(core))
+ if (!core->use_tz)
writel(WRAPPER_XTSS_SW_RESET_BIT,
core->wrapper_tz_base + WRAPPER_TZ_XTSS_SW_RESET);
else
@@ -179,7 +184,7 @@ static int venus_shutdown_no_tz(struct venus_core *core)
void __iomem *wrapper_base = core->wrapper_base;
void __iomem *wrapper_tz_base = core->wrapper_tz_base;

- if (IS_V6(core)) {
+ if (IS_IRIS2_1(core)) {
/* Assert the reset to XTSS */
reg = readl(wrapper_tz_base + WRAPPER_TZ_XTSS_SW_RESET);
reg |= WRAPPER_XTSS_SW_RESET_BIT;

--
2.39.2


2023-02-28 15:25:51

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 13/18] media: venus: hfi_platform: Check vpu_version instead of device compatible

This is not a matter of the host SoC, but the VPU chip in Venus. Fix it.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_platform.c b/drivers/media/platform/qcom/venus/hfi_platform.c
index f07f554bc5fe..d163d5b0e6b7 100644
--- a/drivers/media/platform/qcom/venus/hfi_platform.c
+++ b/drivers/media/platform/qcom/venus/hfi_platform.c
@@ -80,7 +80,7 @@ hfi_platform_get_codecs(struct venus_core *core, u32 *enc_codecs, u32 *dec_codec
if (plat->codecs)
plat->codecs(enc_codecs, dec_codecs, count);

- if (of_device_is_compatible(core->dev->of_node, "qcom,sc7280-venus")) {
+ if (IS_IRIS2_1(core)) {
*enc_codecs &= ~HFI_VIDEO_CODEC_VP8;
*dec_codecs &= ~HFI_VIDEO_CODEC_VP8;
}

--
2.39.2


2023-02-28 15:25:54

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 15/18] media: venus: Remap bufreq fields on HFI6XX

Similarly to HFI4XX, the fields are remapped on 6XX as well. Fix it.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_helper.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h
index d2d6719a2ba4..8d683a6e07af 100644
--- a/drivers/media/platform/qcom/venus/hfi_helper.h
+++ b/drivers/media/platform/qcom/venus/hfi_helper.h
@@ -1152,11 +1152,14 @@ struct hfi_buffer_display_hold_count_actual {

/* HFI 4XX reorder the fields, use these macros */
#define HFI_BUFREQ_HOLD_COUNT(bufreq, ver) \
- ((ver) == HFI_VERSION_4XX ? 0 : (bufreq)->hold_count)
+ ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
+ ? 0 : (bufreq)->hold_count)
#define HFI_BUFREQ_COUNT_MIN(bufreq, ver) \
- ((ver) == HFI_VERSION_4XX ? (bufreq)->hold_count : (bufreq)->count_min)
+ ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
+ ? (bufreq)->hold_count : (bufreq)->count_min)
#define HFI_BUFREQ_COUNT_MIN_HOST(bufreq, ver) \
- ((ver) == HFI_VERSION_4XX ? (bufreq)->count_min : 0)
+ ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
+ ? (bufreq)->count_min : 0)

struct hfi_buffer_requirements {
u32 type;

--
2.39.2


2023-02-28 15:26:03

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 14/18] media: venus: vdec: Fix version check in vdec_set_work_route()

This is not so much V6-dependent as it's IRIS(1|2|2_1). Fix it.

Fixes: 6483a8cbea54 ("media: venus: vdec: set work route to fw")
Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/vdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index 4ceaba37e2e5..f55d6cce163c 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -688,7 +688,7 @@ static int vdec_set_work_route(struct venus_inst *inst)
u32 ptype = HFI_PROPERTY_PARAM_WORK_ROUTE;
struct hfi_video_work_route wr;

- if (!IS_V6(inst->core))
+ if (!(IS_IRIS1(inst->core) || IS_IRIS2(inst->core) || IS_IRIS2_1(inst->core)))
return 0;

wr.video_work_route = inst->core->res->num_vpp_pipes;

--
2.39.2


2023-02-28 15:26:06

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 16/18] media: venus: Introduce accessors for remapped hfi_buffer_reqs members

Currently we have macros to access these, but they don't provide a
way to override the remapped fields. Replace the macros with actual
get/set pairs to fix that.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/helpers.c | 2 +-
drivers/media/platform/qcom/venus/hfi_helper.h | 64 +++++++++++++++++++++-----
drivers/media/platform/qcom/venus/hfi_msgs.c | 2 +-
drivers/media/platform/qcom/venus/vdec.c | 8 ++--
drivers/media/platform/qcom/venus/vdec_ctrls.c | 2 +-
drivers/media/platform/qcom/venus/venc.c | 4 +-
drivers/media/platform/qcom/venus/venc_ctrls.c | 2 +-
7 files changed, 63 insertions(+), 21 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index ab6a29ffc81e..502f45da84fb 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -189,7 +189,7 @@ int venus_helper_alloc_dpb_bufs(struct venus_inst *inst)
if (ret)
return ret;

- count = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+ count = hfi_bufreq_get_count_min(&bufreq, ver);

for (i = 0; i < count; i++) {
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h
index 8d683a6e07af..8c35670f02f3 100644
--- a/drivers/media/platform/qcom/venus/hfi_helper.h
+++ b/drivers/media/platform/qcom/venus/hfi_helper.h
@@ -1150,17 +1150,6 @@ struct hfi_buffer_display_hold_count_actual {
u32 hold_count;
};

-/* HFI 4XX reorder the fields, use these macros */
-#define HFI_BUFREQ_HOLD_COUNT(bufreq, ver) \
- ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
- ? 0 : (bufreq)->hold_count)
-#define HFI_BUFREQ_COUNT_MIN(bufreq, ver) \
- ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
- ? (bufreq)->hold_count : (bufreq)->count_min)
-#define HFI_BUFREQ_COUNT_MIN_HOST(bufreq, ver) \
- ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
- ? (bufreq)->count_min : 0)
-
struct hfi_buffer_requirements {
u32 type;
u32 size;
@@ -1172,6 +1161,59 @@ struct hfi_buffer_requirements {
u32 alignment;
};

+/* Starting with HFI 4XX, some properties were swapped.. */
+static inline u32 hfi_bufreq_get_hold_count(struct hfi_buffer_requirements *req,
+ u32 ver)
+{
+ if (ver == HFI_VERSION_4XX || ver == HFI_VERSION_6XX)
+ return 0;
+
+ return req->hold_count;
+};
+
+static inline u32 hfi_bufreq_get_count_min(struct hfi_buffer_requirements *req,
+ u32 ver)
+{
+ if (ver == HFI_VERSION_4XX || ver == HFI_VERSION_6XX)
+ return req->hold_count;
+
+ return req->count_min;
+};
+
+static inline u32 hfi_bufreq_get_count_min_host(struct hfi_buffer_requirements *req,
+ u32 ver)
+{
+ if (ver == HFI_VERSION_4XX || ver == HFI_VERSION_6XX)
+ return req->count_min;
+
+ return 0;
+};
+
+static inline void hfi_bufreq_set_hold_count(struct hfi_buffer_requirements *req,
+ u32 ver, u32 val)
+{
+ if (ver == HFI_VERSION_4XX || ver == HFI_VERSION_6XX)
+ return;
+
+ req->hold_count = val;
+};
+
+static inline void hfi_bufreq_set_count_min(struct hfi_buffer_requirements *req,
+ u32 ver, u32 val)
+{
+ if (ver == HFI_VERSION_4XX || ver == HFI_VERSION_6XX)
+ req->hold_count = val;
+
+ req->count_min = val;
+};
+
+static inline void hfi_bufreq_set_count_min_host(struct hfi_buffer_requirements *req,
+ u32 ver, u32 val)
+{
+ if (ver == HFI_VERSION_4XX || ver == HFI_VERSION_6XX)
+ req->count_min = val;
+};
+
struct hfi_data_payload {
u32 size;
u8 data[1];
diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.c b/drivers/media/platform/qcom/venus/hfi_msgs.c
index df96db3761a7..c320ebbdb24e 100644
--- a/drivers/media/platform/qcom/venus/hfi_msgs.c
+++ b/drivers/media/platform/qcom/venus/hfi_msgs.c
@@ -99,7 +99,7 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst,
case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS:
data_ptr += sizeof(u32);
bufreq = (struct hfi_buffer_requirements *)data_ptr;
- event.buf_count = HFI_BUFREQ_COUNT_MIN(bufreq, ver);
+ event.buf_count = hfi_bufreq_get_count_min(bufreq, ver);
data_ptr += sizeof(*bufreq);
break;
case HFI_INDEX_EXTRADATA_INPUT_CROP:
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index f55d6cce163c..3149b032a1e8 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -857,13 +857,13 @@ static int vdec_num_buffers(struct venus_inst *inst, unsigned int *in_num,
if (ret)
return ret;

- *in_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+ *in_num = hfi_bufreq_get_count_min(&bufreq, ver);

ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
if (ret)
return ret;

- *out_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+ *out_num = hfi_bufreq_get_count_min(&bufreq, ver);

return 0;
}
@@ -977,14 +977,14 @@ static int vdec_verify_conf(struct venus_inst *inst)
return ret;

if (inst->num_output_bufs < bufreq.count_actual ||
- inst->num_output_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver))
+ inst->num_output_bufs < hfi_bufreq_get_count_min(&bufreq, ver))
return -EINVAL;

ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
if (ret)
return ret;

- if (inst->num_input_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver))
+ if (inst->num_input_bufs < hfi_bufreq_get_count_min(&bufreq, ver))
return -EINVAL;

return 0;
diff --git a/drivers/media/platform/qcom/venus/vdec_ctrls.c b/drivers/media/platform/qcom/venus/vdec_ctrls.c
index fbe12a608b21..7e0f29bf7fae 100644
--- a/drivers/media/platform/qcom/venus/vdec_ctrls.c
+++ b/drivers/media/platform/qcom/venus/vdec_ctrls.c
@@ -79,7 +79,7 @@ static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
if (!ret)
- ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+ ctrl->val = hfi_bufreq_get_count_min(&bufreq, ver);
break;
default:
return -EINVAL;
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index cdb12546c4fa..0ad5f9926c2e 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -1131,7 +1131,7 @@ static int venc_verify_conf(struct venus_inst *inst)
return ret;

if (inst->num_output_bufs < bufreq.count_actual ||
- inst->num_output_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver))
+ inst->num_output_bufs < hfi_bufreq_get_count_min(&bufreq, ver))
return -EINVAL;

ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
@@ -1139,7 +1139,7 @@ static int venc_verify_conf(struct venus_inst *inst)
return ret;

if (inst->num_input_bufs < bufreq.count_actual ||
- inst->num_input_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver))
+ inst->num_input_bufs < hfi_bufreq_get_count_min(&bufreq, ver))
return -EINVAL;

return 0;
diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c
index 7468e43800a9..d9d2a293f3ef 100644
--- a/drivers/media/platform/qcom/venus/venc_ctrls.c
+++ b/drivers/media/platform/qcom/venus/venc_ctrls.c
@@ -358,7 +358,7 @@ static int venc_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
if (!ret)
- ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+ ctrl->val = hfi_bufreq_get_count_min(&bufreq, ver);
break;
default:
return -EINVAL;

--
2.39.2


2023-02-28 15:26:08

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 18/18] media: venus: hfi_venus: Restrict writing SCIACMDARG3 to Venus V1/V2

This write was last present on msm-3.10, which means before HFI3XX
platforms were introduced. Guard it with an appropriate if condition.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index c2d134e04c30..deeceb86414d 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -463,7 +463,8 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
}

writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
- writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
+ if (IS_V1(hdev->core))
+ writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);

writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
while (!ctrl_status && count < max_tries) {

--
2.39.2


2023-02-28 15:26:12

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH 17/18] media: venus: Use newly-introduced hfi_buffer_requirements accessors

Now that we have a way to HFI-ver-independently set the correct
fields in hfi_buffer_requirements, use it!

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/media/platform/qcom/venus/helpers.c | 5 +++--
.../media/platform/qcom/venus/hfi_plat_bufs_v6.c | 22 +++++++++++-----------
2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index 502f45da84fb..aa7a2059bec1 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -667,6 +667,7 @@ int venus_helper_get_bufreq(struct venus_inst *inst, u32 type,
struct hfi_buffer_requirements *req)
{
u32 ptype = HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS;
+ enum hfi_version ver = inst->core->res->hfi_version;
union hfi_get_property hprop;
unsigned int i;
int ret;
@@ -674,12 +675,12 @@ int venus_helper_get_bufreq(struct venus_inst *inst, u32 type,
memset(req, 0, sizeof(*req));

if (type == HFI_BUFFER_OUTPUT || type == HFI_BUFFER_OUTPUT2)
- req->count_min = inst->fw_min_cnt;
+ hfi_bufreq_set_count_min(req, ver, inst->fw_min_cnt);

ret = platform_get_bufreq(inst, type, req);
if (!ret) {
if (type == HFI_BUFFER_OUTPUT || type == HFI_BUFFER_OUTPUT2)
- inst->fw_min_cnt = req->count_min;
+ inst->fw_min_cnt = hfi_bufreq_get_count_min(req, ver);
return 0;
}

diff --git a/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c b/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c
index ea25c451222b..d3466b46c868 100644
--- a/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c
+++ b/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c
@@ -1214,25 +1214,25 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype,

out_min_count = output_buffer_count(VIDC_SESSION_TYPE_DEC, codec);
/* Max of driver and FW count */
- out_min_count = max(out_min_count, bufreq->count_min);
+ out_min_count = max(out_min_count, hfi_bufreq_get_count_min(bufreq, version));

bufreq->type = buftype;
bufreq->region_size = 0;
- bufreq->count_min = 1;
bufreq->count_actual = 1;
- bufreq->hold_count = 1;
+ hfi_bufreq_set_count_min(bufreq, version, 1);
+ hfi_bufreq_set_count_min_host(bufreq, version, 1);
bufreq->contiguous = 1;
bufreq->alignment = 256;

if (buftype == HFI_BUFFER_INPUT) {
- bufreq->count_min = MIN_INPUT_BUFFERS;
+ hfi_bufreq_set_count_min(bufreq, version, MIN_INPUT_BUFFERS);
bufreq->size =
calculate_dec_input_frame_size(width, height, codec,
max_mbs_per_frame,
buffer_size_limit);
} else if (buftype == HFI_BUFFER_OUTPUT ||
buftype == HFI_BUFFER_OUTPUT2) {
- bufreq->count_min = out_min_count;
+ hfi_bufreq_set_count_min(bufreq, version, out_min_count);
bufreq->size =
venus_helper_get_framesz_raw(params->hfi_color_fmt,
width, height);
@@ -1264,7 +1264,7 @@ static int bufreq_enc(struct hfi_plat_buffers_params *params, u32 buftype,
u32 work_mode = params->enc.work_mode;
u32 rc_type = params->enc.rc_type;
u32 num_vpp_pipes = params->num_vpp_pipes;
- u32 num_ref;
+ u32 num_ref, count_min;

switch (codec) {
case V4L2_PIX_FMT_H264:
@@ -1284,21 +1284,21 @@ static int bufreq_enc(struct hfi_plat_buffers_params *params, u32 buftype,

bufreq->type = buftype;
bufreq->region_size = 0;
- bufreq->count_min = 1;
bufreq->count_actual = 1;
- bufreq->hold_count = 1;
+ hfi_bufreq_set_count_min(bufreq, version, 1);
+ hfi_bufreq_set_count_min_host(bufreq, version, 1);
bufreq->contiguous = 1;
bufreq->alignment = 256;

if (buftype == HFI_BUFFER_INPUT) {
- bufreq->count_min = MIN_INPUT_BUFFERS;
+ hfi_bufreq_set_count_min(bufreq, version, MIN_INPUT_BUFFERS);
bufreq->size =
venus_helper_get_framesz_raw(params->hfi_color_fmt,
width, height);
} else if (buftype == HFI_BUFFER_OUTPUT ||
buftype == HFI_BUFFER_OUTPUT2) {
- bufreq->count_min =
- output_buffer_count(VIDC_SESSION_TYPE_ENC, codec);
+ count_min = output_buffer_count(VIDC_SESSION_TYPE_ENC, codec);
+ hfi_bufreq_set_count_min(bufreq, version, count_min);
bufreq->size = calculate_enc_output_frame_size(width, height,
rc_type);
} else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH(version)) {

--
2.39.2


2023-02-28 15:28:59

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6

On 28/02/2023 15:24, Konrad Dybcio wrote:
> This call does not seem to have been cast on any kernel with support
> for VPU-1.0 or newer (and by extension, HFI6 and newer).

We tested this on sm8250

Restrict it
> to V4 only, as it seems to have been enabled by mistake and causes a
> hang & reboot to EDL on at least one occasion with SM6115 / AR50L
>
> Fixes: 7ed9e0b3393c ("media: venus: hfi, vdec: v6 Add IS_V6() to existing IS_V4() if locations")
> Signed-off-by: Konrad Dybcio<[email protected]>

Right. This may indeed fix it for you on SM6115, could you test it on
RB5 and verify the above statement ?

---
bod

2023-02-28 15:32:09

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6

On 28/02/2023 15:26, Bryan O'Donoghue wrote:
> On 28/02/2023 15:24, Konrad Dybcio wrote:
>> This call does not seem to have been cast on any kernel with support
>> for VPU-1.0 or newer (and by extension, HFI6 and newer).
>
> We tested this on sm8250
>
> Restrict it
>> to V4 only, as it seems to have been enabled by mistake and causes a
>> hang & reboot to EDL on at least one occasion with SM6115 / AR50L
>>
>> Fixes: 7ed9e0b3393c ("media: venus: hfi, vdec: v6 Add IS_V6() to
>> existing IS_V4() if locations")
>> Signed-off-by: Konrad Dybcio<[email protected]>
>
> Right. This may indeed fix it for you on SM6115, could you test it on
> RB5 and verify the above statement ?
>
> ---
> bod

For example.

Doesn't your later patch take account of VPU h/w version ? IRIS_1,
IRIS_2 etc.

When we added for V6 here, we meant for current tested V6 hardware at
that point - at least sm8250.

Can you not differentiate sm6115 based on VPU hardware identifier ? We
want to retain this logic for 8250 and then assuming your patch is
correct, not do this for sm6115.

---
bod

2023-02-28 15:33:52

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 06/18] media: venus: hfi_venus: Write to VIDC_CTRL_INIT after unmasking interrupts

On 28/02/2023 15:24, Konrad Dybcio wrote:
> The downstream driver signals the hardware to be enabled only after the
> interrupts are unmasked, which... makes sense. Follow suit.
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index 772e5e9cf127..4d785e53aa0b 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -454,7 +454,6 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
> void __iomem *wrapper_base = hdev->core->wrapper_base;
> int ret = 0;
>
> - writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
> if (IS_IRIS1(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
> mask_val = readl(wrapper_base + WRAPPER_INTR_MASK);
> mask_val &= ~(WRAPPER_INTR_MASK_A2HWD_BASK_V6 |
> @@ -466,6 +465,7 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
> writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
> writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>
> + writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
> while (!ctrl_status && count < max_tries) {
> ctrl_status = readl(cpu_cs_base + CPU_CS_SCIACMDARG0);
> if ((ctrl_status & CPU_CS_SCIACMDARG0_ERROR_STATUS_MASK) == 4) {
>

This should go before you add your new macros in-place of IS_V6() and it
should have a fixes.

---
bod

2023-02-28 15:37:07

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 08/18] media: venus: hfi_venus: Fix version checks in venus_halt_axi()

On 28/02/2023 15:24, Konrad Dybcio wrote:
> Only IRIS2(_1) should enter the until-now-IS_V6() path and the
> condition for skipping part of it should be IS_IRIS2_1 and not the
> number of VPP pipes. Fix that.
>
> Fixes: 4b0b6e147dc9 ("media: venus: hfi: Add 6xx AXI halt logic")
> Fixes: 78d434ba8659 ("media: venus: hfi: Skip AON register programming for V6 1pipe")
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/hfi_venus.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index 4d785e53aa0b..0d137e070407 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -550,10 +550,10 @@ static int venus_halt_axi(struct venus_hfi_device *hdev)
> u32 mask_val;
> int ret;
>
> - if (IS_V6(hdev->core)) {
> + if (IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
> writel(0x3, cpu_cs_base + CPU_CS_X2RPMH_V6);
>
> - if (hdev->core->res->num_vpp_pipes == 1)
> + if (IS_IRIS2_1(hdev->core))
> goto skip_aon_mvp_noc;
>
> writel(0x1, aon_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL);
>

If you want to denote these as fixes, you need your patch 02/18 as a
depend...

---
bod

2023-02-28 15:37:21

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6



On 28.02.2023 16:31, Bryan O'Donoghue wrote:
> On 28/02/2023 15:26, Bryan O'Donoghue wrote:
>> On 28/02/2023 15:24, Konrad Dybcio wrote:
>>> This call does not seem to have been cast on any kernel with support
>>> for VPU-1.0 or newer (and by extension, HFI6 and newer).
>>
>> We tested this on sm8250
>>
>> Restrict it
>>> to V4 only, as it seems to have been enabled by mistake and causes a
>>> hang & reboot to EDL on at least one occasion with SM6115 / AR50L
>>>
>>> Fixes: 7ed9e0b3393c ("media: venus: hfi, vdec: v6 Add IS_V6() to existing IS_V4() if locations")
>>> Signed-off-by: Konrad Dybcio<[email protected]>
>>
>> Right. This may indeed fix it for you on SM6115, could you test it on RB5 and verify the above statement ?
>>
>> ---
>> bod
>
> For example.
>
> Doesn't your later patch take account of VPU h/w version ? IRIS_1, IRIS_2 etc.
>
> When we added for V6 here, we meant for current tested V6 hardware at that point - at least sm8250.
>
> Can you not differentiate sm6115 based on VPU hardware identifier ? We want to retain this logic for 8250 and then assuming your patch is correct, not do this for sm6115.
As far as my only source of information (msm-4.19 techpack) goes, this is
unnecessary/incorrect on 8250 as well. I doubt downstream would ship Venus
with no/broken low-power modes..

Konrad
>
> ---
> bod

2023-02-28 15:38:58

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6

On 28/02/2023 15:37, Konrad Dybcio wrote:
>
>
> On 28.02.2023 16:31, Bryan O'Donoghue wrote:
>> On 28/02/2023 15:26, Bryan O'Donoghue wrote:
>>> On 28/02/2023 15:24, Konrad Dybcio wrote:
>>>> This call does not seem to have been cast on any kernel with support
>>>> for VPU-1.0 or newer (and by extension, HFI6 and newer).
>>>
>>> We tested this on sm8250
>>>
>>> Restrict it
>>>> to V4 only, as it seems to have been enabled by mistake and causes a
>>>> hang & reboot to EDL on at least one occasion with SM6115 / AR50L
>>>>
>>>> Fixes: 7ed9e0b3393c ("media: venus: hfi, vdec: v6 Add IS_V6() to existing IS_V4() if locations")
>>>> Signed-off-by: Konrad Dybcio<[email protected]>
>>>
>>> Right. This may indeed fix it for you on SM6115, could you test it on RB5 and verify the above statement ?
>>>
>>> ---
>>> bod
>>
>> For example.
>>
>> Doesn't your later patch take account of VPU h/w version ? IRIS_1, IRIS_2 etc.
>>
>> When we added for V6 here, we meant for current tested V6 hardware at that point - at least sm8250.
>>
>> Can you not differentiate sm6115 based on VPU hardware identifier ? We want to retain this logic for 8250 and then assuming your patch is correct, not do this for sm6115.
> As far as my only source of information (msm-4.19 techpack) goes, this is
> unnecessary/incorrect on 8250 as well. I doubt downstream would ship Venus
> with no/broken low-power modes..

Can you test it and make sure ?

---
bod


2023-02-28 15:40:20

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 10/18] media: venus: hfi_venus: Fix version check in venus_cpu_and_video_core_idle()

On 28/02/2023 15:24, Konrad Dybcio wrote:
> IS_V6() should have instead checked for specific VPU versions. Fix it.
>
> Fixes: e396e75fc254 ("media: venus: hfi: Read WRAPPER_TZ_CPU_STATUS_V6 on 6xx")
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index ecfbac36de20..584c84125887 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -1543,7 +1543,7 @@ static bool venus_cpu_and_video_core_idle(struct venus_hfi_device *hdev)
> void __iomem *cpu_cs_base = hdev->core->cpu_cs_base;
> u32 ctrl_status, cpu_status;
>
> - if (IS_V6(hdev->core))
> + if (IS_AR50_LITE(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
> cpu_status = readl(wrapper_tz_base + WRAPPER_TZ_CPU_STATUS_V6);
> else
> cpu_status = readl(wrapper_base + WRAPPER_CPU_STATUS);
>

Same comment on the Fixes.

You need 02/18 to apply this to pervious kernels.

---
bod

2023-02-28 15:41:25

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6



On 28.02.2023 16:38, Bryan O'Donoghue wrote:
> On 28/02/2023 15:37, Konrad Dybcio wrote:
>>
>>
>> On 28.02.2023 16:31, Bryan O'Donoghue wrote:
>>> On 28/02/2023 15:26, Bryan O'Donoghue wrote:
>>>> On 28/02/2023 15:24, Konrad Dybcio wrote:
>>>>> This call does not seem to have been cast on any kernel with support
>>>>> for VPU-1.0 or newer (and by extension, HFI6 and newer).
>>>>
>>>> We tested this on sm8250
>>>>
>>>> Restrict it
>>>>> to V4 only, as it seems to have been enabled by mistake and causes a
>>>>> hang & reboot to EDL on at least one occasion with SM6115 / AR50L
>>>>>
>>>>> Fixes: 7ed9e0b3393c ("media: venus: hfi, vdec: v6 Add IS_V6() to existing IS_V4() if locations")
>>>>> Signed-off-by: Konrad Dybcio<[email protected]>
>>>>
>>>> Right. This may indeed fix it for you on SM6115, could you test it on RB5 and verify the above statement ?
>>>>
>>>> ---
>>>> bod
>>>
>>> For example.
>>>
>>> Doesn't your later patch take account of VPU h/w version ? IRIS_1, IRIS_2 etc.
>>>
>>> When we added for V6 here, we meant for current tested V6 hardware at that point - at least sm8250.
>>>
>>> Can you not differentiate sm6115 based on VPU hardware identifier ? We want to retain this logic for 8250 and then assuming your patch is correct, not do this for sm6115.
>> As far as my only source of information (msm-4.19 techpack) goes, this is
>> unnecessary/incorrect on 8250 as well. I doubt downstream would ship Venus
>> with no/broken low-power modes..
>
> Can you test it and make sure ?
As I mentioned in the cover letter, 8250 still seems to work with this
patchset. I have no idea how one would go about validating the
functionality enabled through this call.

Konrad
>
> ---
> bod
>

2023-02-28 15:48:55

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 12/18] media: venus: firmware: Correct IS_V6() checks

On 28/02/2023 15:24, Konrad Dybcio wrote:
> - if (IS_V6(core))
> + /*
> + * This may sound counter-intuitive, but when there's no TZ, we gotta
> + * do things that it would otherwise do for us, such as initializing
> + * the hardware at a very basic level.
> + * */

Suggest "When there is no TZ we have got to initialize hardware in-lieu
of TZ" as an example.

Either way please drop that "gotta" - I ain't gonna ACK such a
butchering of the language.

Then

Reviewed-by: Bryan O'Donoghue <[email protected]>

2023-02-28 15:49:36

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 13/18] media: venus: hfi_platform: Check vpu_version instead of device compatible

On 28/02/2023 15:24, Konrad Dybcio wrote:
> This is not a matter of the host SoC, but the VPU chip in Venus. Fix it.
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/hfi_platform.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_platform.c b/drivers/media/platform/qcom/venus/hfi_platform.c
> index f07f554bc5fe..d163d5b0e6b7 100644
> --- a/drivers/media/platform/qcom/venus/hfi_platform.c
> +++ b/drivers/media/platform/qcom/venus/hfi_platform.c
> @@ -80,7 +80,7 @@ hfi_platform_get_codecs(struct venus_core *core, u32 *enc_codecs, u32 *dec_codec
> if (plat->codecs)
> plat->codecs(enc_codecs, dec_codecs, count);
>
> - if (of_device_is_compatible(core->dev->of_node, "qcom,sc7280-venus")) {
> + if (IS_IRIS2_1(core)) {
> *enc_codecs &= ~HFI_VIDEO_CODEC_VP8;
> *dec_codecs &= ~HFI_VIDEO_CODEC_VP8;
> }
>

Reviewed-by: Bryan O'Donoghue <[email protected]>

2023-02-28 15:50:58

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 14/18] media: venus: vdec: Fix version check in vdec_set_work_route()

On 28/02/2023 15:24, Konrad Dybcio wrote:
> This is not so much V6-dependent as it's IRIS(1|2|2_1). Fix it.
>
> Fixes: 6483a8cbea54 ("media: venus: vdec: set work route to fw")
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/vdec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
> index 4ceaba37e2e5..f55d6cce163c 100644
> --- a/drivers/media/platform/qcom/venus/vdec.c
> +++ b/drivers/media/platform/qcom/venus/vdec.c
> @@ -688,7 +688,7 @@ static int vdec_set_work_route(struct venus_inst *inst)
> u32 ptype = HFI_PROPERTY_PARAM_WORK_ROUTE;
> struct hfi_video_work_route wr;
>
> - if (!IS_V6(inst->core))
> + if (!(IS_IRIS1(inst->core) || IS_IRIS2(inst->core) || IS_IRIS2_1(inst->core)))
> return 0;
>
> wr.video_work_route = inst->core->res->num_vpp_pipes;
>

Assuming you make it possible and explicit to bring in the macros's that
enable the cherry-picking.

Reviewed-by: Bryan O'Donoghue <[email protected]>

2023-02-28 15:52:02

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 15/18] media: venus: Remap bufreq fields on HFI6XX

On 28/02/2023 15:24, Konrad Dybcio wrote:
> Similarly to HFI4XX, the fields are remapped on 6XX as well. Fix it.
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/hfi_helper.h | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h
> index d2d6719a2ba4..8d683a6e07af 100644
> --- a/drivers/media/platform/qcom/venus/hfi_helper.h
> +++ b/drivers/media/platform/qcom/venus/hfi_helper.h
> @@ -1152,11 +1152,14 @@ struct hfi_buffer_display_hold_count_actual {
>
> /* HFI 4XX reorder the fields, use these macros */
> #define HFI_BUFREQ_HOLD_COUNT(bufreq, ver) \
> - ((ver) == HFI_VERSION_4XX ? 0 : (bufreq)->hold_count)
> + ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
> + ? 0 : (bufreq)->hold_count)
> #define HFI_BUFREQ_COUNT_MIN(bufreq, ver) \
> - ((ver) == HFI_VERSION_4XX ? (bufreq)->hold_count : (bufreq)->count_min)
> + ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
> + ? (bufreq)->hold_count : (bufreq)->count_min)
> #define HFI_BUFREQ_COUNT_MIN_HOST(bufreq, ver) \
> - ((ver) == HFI_VERSION_4XX ? (bufreq)->count_min : 0)
> + ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
> + ? (bufreq)->count_min : 0)
>
> struct hfi_buffer_requirements {
> u32 type;
>

Doesn't this need a Fixes ?

---
bod

2023-02-28 15:55:02

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 16/18] media: venus: Introduce accessors for remapped hfi_buffer_reqs members

On 28/02/2023 15:24, Konrad Dybcio wrote:
> Currently we have macros to access these, but they don't provide a
> way to override the remapped fields. Replace the macros with actual
> get/set pairs to fix that.
>
> Signed-off-by: Konrad Dybcio <[email protected]>

Nice

Reviewed-by: Bryan O'Donoghue <[email protected]>


2023-02-28 15:57:10

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 17/18] media: venus: Use newly-introduced hfi_buffer_requirements accessors

On 28/02/2023 15:24, Konrad Dybcio wrote:
> Now that we have a way to HFI-ver-independently set the correct
> fields in hfi_buffer_requirements, use it!

"Now that we have a way which is independent of the HFI version"

---
bod

2023-02-28 15:58:13

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 18/18] media: venus: hfi_venus: Restrict writing SCIACMDARG3 to Venus V1/V2

On 28/02/2023 15:24, Konrad Dybcio wrote:
> This write was last present on msm-3.10, which means before HFI3XX
> platforms were introduced. Guard it with an appropriate if condition.
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/hfi_venus.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index c2d134e04c30..deeceb86414d 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -463,7 +463,8 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
> }
>
> writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
> - writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
> + if (IS_V1(hdev->core))
> + writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>
> writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
> while (!ctrl_status && count < max_tries) {
>

Looks good.

Which platforms have you tested this change on ? Can you include that
detail in the commit log ?

---
bod

2023-02-28 15:59:16

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 06/18] media: venus: hfi_venus: Write to VIDC_CTRL_INIT after unmasking interrupts



On 28.02.2023 16:33, Bryan O'Donoghue wrote:
> On 28/02/2023 15:24, Konrad Dybcio wrote:
>> The downstream driver signals the hardware to be enabled only after the
>> interrupts are unmasked, which... makes sense. Follow suit.
>>
>> Signed-off-by: Konrad Dybcio <[email protected]>
>> ---
>>   drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
>> index 772e5e9cf127..4d785e53aa0b 100644
>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>> @@ -454,7 +454,6 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>       void __iomem *wrapper_base = hdev->core->wrapper_base;
>>       int ret = 0;
>>   -    writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
>>       if (IS_IRIS1(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
>>           mask_val = readl(wrapper_base + WRAPPER_INTR_MASK);
>>           mask_val &= ~(WRAPPER_INTR_MASK_A2HWD_BASK_V6 |
>> @@ -466,6 +465,7 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>       writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
>>       writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>>   +    writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
>>       while (!ctrl_status && count < max_tries) {
>>           ctrl_status = readl(cpu_cs_base + CPU_CS_SCIACMDARG0);
>>           if ((ctrl_status & CPU_CS_SCIACMDARG0_ERROR_STATUS_MASK) == 4) {
>>
>
> This should go before you add your new macros in-place of IS_V6() and it should have a fixes.
Ack

Konrad
>
> ---
> bod

2023-02-28 16:01:22

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 08/18] media: venus: hfi_venus: Fix version checks in venus_halt_axi()



On 28.02.2023 16:36, Bryan O'Donoghue wrote:
> On 28/02/2023 15:24, Konrad Dybcio wrote:
>> Only IRIS2(_1) should enter the until-now-IS_V6() path and the
>> condition for skipping part of it should be IS_IRIS2_1 and not the
>> number of VPP pipes. Fix that.
>>
>> Fixes: 4b0b6e147dc9 ("media: venus: hfi: Add 6xx AXI halt logic")
>> Fixes: 78d434ba8659 ("media: venus: hfi: Skip AON register programming for V6 1pipe")
>> Signed-off-by: Konrad Dybcio <[email protected]>
>> ---
>>   drivers/media/platform/qcom/venus/hfi_venus.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
>> index 4d785e53aa0b..0d137e070407 100644
>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>> @@ -550,10 +550,10 @@ static int venus_halt_axi(struct venus_hfi_device *hdev)
>>       u32 mask_val;
>>       int ret;
>>   -    if (IS_V6(hdev->core)) {
>> +    if (IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
>>           writel(0x3, cpu_cs_base + CPU_CS_X2RPMH_V6);
>>   -        if (hdev->core->res->num_vpp_pipes == 1)
>> +        if (IS_IRIS2_1(hdev->core))
>>               goto skip_aon_mvp_noc;
>>             writel(0x1, aon_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL);
>>
>
> If you want to denote these as fixes, you need your patch 02/18 as a depend...
The main purpose of the Fixes tag is to mark commits that fix bugs in
existing code and it only assists in autoselecting stable patches.
Backporting this makes little sense, as we only support IRIS2 (8250)
and IRIS2_1 (7280) HFI6 platforms and new additions won't be backported.

Konrad
>
> ---
> bod

2023-02-28 16:05:38

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 15/18] media: venus: Remap bufreq fields on HFI6XX



On 28.02.2023 16:51, Bryan O'Donoghue wrote:
> On 28/02/2023 15:24, Konrad Dybcio wrote:
>> Similarly to HFI4XX, the fields are remapped on 6XX as well. Fix it.
>>
>> Signed-off-by: Konrad Dybcio <[email protected]>
>> ---
>>   drivers/media/platform/qcom/venus/hfi_helper.h | 9 ++++++---
>>   1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h
>> index d2d6719a2ba4..8d683a6e07af 100644
>> --- a/drivers/media/platform/qcom/venus/hfi_helper.h
>> +++ b/drivers/media/platform/qcom/venus/hfi_helper.h
>> @@ -1152,11 +1152,14 @@ struct hfi_buffer_display_hold_count_actual {
>>     /* HFI 4XX reorder the fields, use these macros */
>>   #define HFI_BUFREQ_HOLD_COUNT(bufreq, ver)    \
>> -    ((ver) == HFI_VERSION_4XX ? 0 : (bufreq)->hold_count)
>> +    ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
>> +    ? 0 : (bufreq)->hold_count)
>>   #define HFI_BUFREQ_COUNT_MIN(bufreq, ver)    \
>> -    ((ver) == HFI_VERSION_4XX ? (bufreq)->hold_count : (bufreq)->count_min)
>> +    ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
>> +    ? (bufreq)->hold_count : (bufreq)->count_min)
>>   #define HFI_BUFREQ_COUNT_MIN_HOST(bufreq, ver)    \
>> -    ((ver) == HFI_VERSION_4XX ? (bufreq)->count_min : 0)
>> +    ((ver) == HFI_VERSION_4XX || (ver) == HFI_VERSION_6XX \
>> +    ? (bufreq)->count_min : 0)
>>     struct hfi_buffer_requirements {
>>       u32 type;
>>
>
> Doesn't this need a Fixes ?
Definitely could use some..

Konrad
>
> ---
> bod

2023-02-28 16:09:10

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 12/18] media: venus: firmware: Correct IS_V6() checks



On 28.02.2023 16:48, Bryan O'Donoghue wrote:
> On 28/02/2023 15:24, Konrad Dybcio wrote:
>> -    if (IS_V6(core))
>> +    /*
>> +     * This may sound counter-intuitive, but when there's no TZ, we gotta
>> +     * do things that it would otherwise do for us, such as initializing
>> +     * the hardware at a very basic level.
>> +     * */
>
> Suggest "When there is no TZ we have got to initialize hardware in-lieu of TZ" as an example.
>
> Either way please drop that "gotta" - I ain't gonna ACK such a butchering of the language.
Gotta do what you gotta do.. :P I can reword it.

Konrad
>
> Then
>
> Reviewed-by: Bryan O'Donoghue <[email protected]>

2023-02-28 16:09:23

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 17/18] media: venus: Use newly-introduced hfi_buffer_requirements accessors



On 28.02.2023 16:56, Bryan O'Donoghue wrote:
> On 28/02/2023 15:24, Konrad Dybcio wrote:
>> Now that we have a way to HFI-ver-independently set the correct
>> fields in hfi_buffer_requirements, use it!
>
> "Now that we have a way which is independent of the HFI version"
Right, I've been inventing words a lot lately..

Konrad
>
> ---
> bod

2023-02-28 16:10:19

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 18/18] media: venus: hfi_venus: Restrict writing SCIACMDARG3 to Venus V1/V2



On 28.02.2023 16:57, Bryan O'Donoghue wrote:
> On 28/02/2023 15:24, Konrad Dybcio wrote:
>> This write was last present on msm-3.10, which means before HFI3XX
>> platforms were introduced. Guard it with an appropriate if condition.
>>
>> Signed-off-by: Konrad Dybcio <[email protected]>
>> ---
>>   drivers/media/platform/qcom/venus/hfi_venus.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
>> index c2d134e04c30..deeceb86414d 100644
>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>> @@ -463,7 +463,8 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>       }
>>         writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
>> -    writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>> +    if (IS_V1(hdev->core))
>> +        writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>>         writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
>>       while (!ctrl_status && count < max_tries) {
>>
>
> Looks good.
>
> Which platforms have you tested this change on ?
8250

Can you include that detail in the commit log ?
Sure!

Konrad
>
> ---
> bod

2023-02-28 16:54:41

by Bryan O'Donoghue

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6

On 28/02/2023 15:41, Konrad Dybcio wrote:
>> Can you test it and make sure ?
> As I mentioned in the cover letter, 8250 still seems to work with this
> patchset. I have no idea how one would go about validating the
> functionality enabled through this call.

We offlined about this.

I think it is correct to say you don't have access to a display to test
this on sm8250.

I do so, I will try this out for you, though I'll wait for your V2 for
this series.

---
bod

2023-03-02 06:40:43

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6


On 2/28/2023 10:23 PM, Bryan O'Donoghue wrote:
> On 28/02/2023 15:41, Konrad Dybcio wrote:
>>> Can you test it and make sure ?
>> As I mentioned in the cover letter, 8250 still seems to work with this
>> patchset. I have no idea how one would go about validating the
>> functionality enabled through this call.
>
> We offlined about this.
>
> I think it is correct to say you don't have access to a display to
> test this on sm8250.
>
> I do so, I will try this out for you, though I'll wait for your V2 for
> this series.
>
> ---
> bod

Hi Konrad,

I understand from your commit text, setting this indicator for AR50L is
causing issue with suspend.

Ideally it shouldn't cause any such issue. I checked with FW team and
got to know that this property is not supported on AR50LT so if you set
it there should be some property not supported error.

In my opinion it would be good to replace these versions checks with VPU
version check you have introduced in your other patch and keep this
setting for current targets and not set wherever not needed eg AR50LT.

Thanks,

Dikshita


2023-03-02 07:13:48

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 02/18] media: venus: Introduce VPU version distinction


On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
> The Video Processing Unit hardware version is the differentiator,
> based on which we should decide which code paths to take in hw
> init. Up until now, we've relied on HFI versions, but that was
> just a happy accident between recent SoCs. Add a field in the
> res struct and add correlated definitions that will be used to
> account for the aforementioned differences.
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/core.h | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
> index 32551c2602a9..4b785205c5b1 100644
> --- a/drivers/media/platform/qcom/venus/core.h
> +++ b/drivers/media/platform/qcom/venus/core.h
> @@ -48,6 +48,14 @@ struct bw_tbl {
> u32 peak_10bit;
> };
>
> +enum vpu_version {
> + VPU_VERSION_AR50, /* VPU4 */
> + VPU_VERSION_AR50_LITE, /* VPU4.4 */
> + VPU_VERSION_IRIS1, /* VPU5 */
> + VPU_VERSION_IRIS2,
> + VPU_VERSION_IRIS2_1,
> +};
> +
> struct venus_resources {
> u64 dma_mask;
> const struct freq_tbl *freq_tbl;
> @@ -71,6 +79,7 @@ struct venus_resources {
> const char * const resets[VIDC_RESETS_NUM_MAX];
> unsigned int resets_num;
> enum hfi_version hfi_version;
> + enum vpu_version vpu_version;
> u8 num_vpp_pipes;
> u32 max_load;
> unsigned int vmem_id;
> @@ -473,6 +482,12 @@ struct venus_inst {
> #define IS_V4(core) ((core)->res->hfi_version == HFI_VERSION_4XX)
> #define IS_V6(core) ((core)->res->hfi_version == HFI_VERSION_6XX)
>
> +#define IS_AR50(core) ((core)->res->vpu_version == VPU_VERSION_AR50)
> +#define IS_AR50_LITE(core) ((core)->res->vpu_version == VPU_VERSION_AR50_LITE)
> +#define IS_IRIS1(core) ((core)->res->vpu_version == VPU_VERSION_IRIS1)
> +#define IS_IRIS2(core) ((core)->res->vpu_version == VPU_VERSION_IRIS2)
> +#define IS_IRIS2_1(core) ((core)->res->vpu_version == VPU_VERSION_IRIS2_1)
> +
> #define ctrl_to_inst(ctrl) \
> container_of((ctrl)->handler, struct venus_inst, ctrl_handler)
>

Adding VPU version check seems a good idea to me. Can we remove HFI
Version checks now?


2023-03-02 08:19:01

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 04/18] media: venus: firmware: Leave a clue for homegrown porters


On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
> Leave a clue about where the seemingly magic values come from, as it
> is not obvious and requires some digging downstream..
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/firmware.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c
> index 61ff20a7e935..1bb6406af564 100644
> --- a/drivers/media/platform/qcom/venus/firmware.c
> +++ b/drivers/media/platform/qcom/venus/firmware.c
> @@ -241,6 +241,13 @@ int venus_boot(struct venus_core *core)
> return ret;
>
> if (core->use_tz && res->cp_size) {
> + /*
> + * Clues for porting using downstream data:
> + * cp_start = 0
> + * cp_size = venus_ns/virtual-addr-pool[0] (yes, addr not size)
> + * cp_nonpixel_start = venus_sec_non_pixel/virtual-addr-pool[0]
> + * cp_nonpixel_size = venus_sec_non_pixel/virtual-addr-pool[1]
> + */
> ret = qcom_scm_mem_protect_video_var(res->cp_start,
> res->cp_size,
> res->cp_nonpixel_start,
reviewed-by: Dikshita Agarwal <[email protected]>

2023-03-02 11:01:39

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 05/18] media: venus: hfi_venus: Sanitize venus_boot_core() per-VPU-version


On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
> The current assumption of IS_V6 is overgeneralized. Adjust the logic
> to take the VPU hardware version into account.
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/hfi_venus.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index 4ccf31147c2a..772e5e9cf127 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -448,20 +448,21 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
> {
> struct device *dev = hdev->core->dev;
> static const unsigned int max_tries = 100;
> - u32 ctrl_status = 0, mask_val;
> + u32 ctrl_status = 0, mask_val = 0;
> unsigned int count = 0;
> void __iomem *cpu_cs_base = hdev->core->cpu_cs_base;
> void __iomem *wrapper_base = hdev->core->wrapper_base;
> int ret = 0;
>
> writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
> - if (IS_V6(hdev->core)) {
> + if (IS_IRIS1(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {

I think the IRIS1 check can be removed from here as we are not handling
IRIS1 related things at other places.

we can add the required checks for IRIS1 when we add support for any
IRIS1 based chipset.

Thanks,

Dikshita

> mask_val = readl(wrapper_base + WRAPPER_INTR_MASK);
> mask_val &= ~(WRAPPER_INTR_MASK_A2HWD_BASK_V6 |
> WRAPPER_INTR_MASK_A2HCPU_MASK);
> } else {
> mask_val = WRAPPER_INTR_MASK_A2HVCODEC_MASK;
> }
> +
> writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
> writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>
> @@ -480,10 +481,11 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
> if (count >= max_tries)
> ret = -ETIMEDOUT;
>
> - if (IS_V6(hdev->core)) {
> + if (IS_AR50_LITE(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
> writel(0x1, cpu_cs_base + CPU_CS_H2XSOFTINTEN_V6);
> +
> + if (IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
> writel(0x0, cpu_cs_base + CPU_CS_X2RPMH_V6);
> - }
>
> return ret;
> }
>

2023-03-02 11:10:26

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 05/18] media: venus: hfi_venus: Sanitize venus_boot_core() per-VPU-version



On 2.03.2023 12:00, Dikshita Agarwal wrote:
>
> On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
>> The current assumption of IS_V6 is overgeneralized. Adjust the logic
>> to take the VPU hardware version into account.
>>
>> Signed-off-by: Konrad Dybcio <[email protected]>
>> ---
>>   drivers/media/platform/qcom/venus/hfi_venus.c | 10 ++++++----
>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
>> index 4ccf31147c2a..772e5e9cf127 100644
>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>> @@ -448,20 +448,21 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>   {
>>       struct device *dev = hdev->core->dev;
>>       static const unsigned int max_tries = 100;
>> -    u32 ctrl_status = 0, mask_val;
>> +    u32 ctrl_status = 0, mask_val = 0;
>>       unsigned int count = 0;
>>       void __iomem *cpu_cs_base = hdev->core->cpu_cs_base;
>>       void __iomem *wrapper_base = hdev->core->wrapper_base;
>>       int ret = 0;
>>         writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
>> -    if (IS_V6(hdev->core)) {
>> +    if (IS_IRIS1(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
>
> I think the IRIS1 check can be removed from here as we are not handling IRIS1 related things at other places.
>
> we can add the required checks for IRIS1 when we add support for any IRIS1 based chipset.
Up to you really, I plan on getting IRIS1 (SM8150) supported and have
some mumbling going on for that on my local branch. FWIW these checks
are logically correct and I would personally prefer not to have to go
through each one of them and remove them just to bring them back soon.

Konrad
>
> Thanks,
>
> Dikshita
>
>>           mask_val = readl(wrapper_base + WRAPPER_INTR_MASK);
>>           mask_val &= ~(WRAPPER_INTR_MASK_A2HWD_BASK_V6 |
>>                     WRAPPER_INTR_MASK_A2HCPU_MASK);
>>       } else {
>>           mask_val = WRAPPER_INTR_MASK_A2HVCODEC_MASK;
>>       }
>> +
>>       writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
>>       writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>>   @@ -480,10 +481,11 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>       if (count >= max_tries)
>>           ret = -ETIMEDOUT;
>>   -    if (IS_V6(hdev->core)) {
>> +    if (IS_AR50_LITE(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
>>           writel(0x1, cpu_cs_base + CPU_CS_H2XSOFTINTEN_V6);
>> +
>> +    if (IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
>>           writel(0x0, cpu_cs_base + CPU_CS_X2RPMH_V6);
>> -    }
>>         return ret;
>>   }
>>

2023-03-02 11:34:08

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6



On 2.03.2023 07:39, Dikshita Agarwal wrote:
>
> On 2/28/2023 10:23 PM, Bryan O'Donoghue wrote:
>> On 28/02/2023 15:41, Konrad Dybcio wrote:
>>>> Can you test it and make sure ?
>>> As I mentioned in the cover letter, 8250 still seems to work with this
>>> patchset. I have no idea how one would go about validating the
>>> functionality enabled through this call.
>>
>> We offlined about this.
>>
>> I think it is correct to say you don't have access to a display to test this on sm8250.
>>
>> I do so, I will try this out for you, though I'll wait for your V2 for this series.
>>
>> ---
>> bod
>
> Hi Konrad,
>
> I understand from your commit text, setting this indicator for AR50L is causing issue with suspend.
>
> Ideally it shouldn't cause any such issue. I checked with FW team and got to know that this property is not supported on AR50LT so if you set it there should be some property not supported error.
>
> In my opinion it would be good to replace these versions checks with VPU version check you have introduced in your other patch and keep this setting for current targets and not set wherever not needed eg AR50LT.
Okay, I have two questions then:

1. Can the firmware team confirm it shouldn't crash on a fw tag
that's close to VIDEO.VE.6.0-00042-PROD-1?

2. Are there any other SoCs that SYS_IDLE is not supported on?
It hasn't been sent to the hardware by the vidc driver for
any SoC using the downstream vidc (NOT the legacy vidc_3x)
driver starting with msm-4.14, AFAICS.. check out this link:

https://github.com/sonyxperiadev/kernel/commit/8889a7d26943e96eae2f318f87b15efa4b907f28

Konrad
>
> Thanks,
>
> Dikshita
>

2023-03-02 11:38:02

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 02/18] media: venus: Introduce VPU version distinction



On 2.03.2023 08:12, Dikshita Agarwal wrote:
>
> On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
>> The Video Processing Unit hardware version is the differentiator,
>> based on which we should decide which code paths to take in hw
>> init. Up until now, we've relied on HFI versions, but that was
>> just a happy accident between recent SoCs. Add a field in the
>> res struct and add correlated definitions that will be used to
>> account for the aforementioned differences.
>>
>> Signed-off-by: Konrad Dybcio <[email protected]>
>> ---
>>   drivers/media/platform/qcom/venus/core.h | 15 +++++++++++++++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
>> index 32551c2602a9..4b785205c5b1 100644
>> --- a/drivers/media/platform/qcom/venus/core.h
>> +++ b/drivers/media/platform/qcom/venus/core.h
>> @@ -48,6 +48,14 @@ struct bw_tbl {
>>       u32 peak_10bit;
>>   };
>>   +enum vpu_version {
>> +    VPU_VERSION_AR50, /* VPU4 */
>> +    VPU_VERSION_AR50_LITE, /* VPU4.4 */
>> +    VPU_VERSION_IRIS1, /* VPU5 */
>> +    VPU_VERSION_IRIS2,
>> +    VPU_VERSION_IRIS2_1,
>> +};
>> +
>>   struct venus_resources {
>>       u64 dma_mask;
>>       const struct freq_tbl *freq_tbl;
>> @@ -71,6 +79,7 @@ struct venus_resources {
>>       const char * const resets[VIDC_RESETS_NUM_MAX];
>>       unsigned int resets_num;
>>       enum hfi_version hfi_version;
>> +    enum vpu_version vpu_version;
>>       u8 num_vpp_pipes;
>>       u32 max_load;
>>       unsigned int vmem_id;
>> @@ -473,6 +482,12 @@ struct venus_inst {
>>   #define IS_V4(core)    ((core)->res->hfi_version == HFI_VERSION_4XX)
>>   #define IS_V6(core)    ((core)->res->hfi_version == HFI_VERSION_6XX)
>>   +#define IS_AR50(core)        ((core)->res->vpu_version == VPU_VERSION_AR50)
>> +#define IS_AR50_LITE(core)    ((core)->res->vpu_version == VPU_VERSION_AR50_LITE)
>> +#define IS_IRIS1(core)        ((core)->res->vpu_version == VPU_VERSION_IRIS1)
>> +#define IS_IRIS2(core)        ((core)->res->vpu_version == VPU_VERSION_IRIS2)
>> +#define IS_IRIS2_1(core)    ((core)->res->vpu_version == VPU_VERSION_IRIS2_1)
>> +
>>   #define ctrl_to_inst(ctrl)    \
>>       container_of((ctrl)->handler, struct venus_inst, ctrl_handler)
>>  
>
> Adding VPU version check seems a good idea to me. Can we remove HFI Version checks now?
If all implementations using VPU x.y *always* use the
same HFI generation for given x, y, we could.

That said, I think keeping it as-is would be convenient
from the maintainability standpoint if nothing else.. For
example functions that only appear in ancient msm-3.10
releases can be easily guarded with IS_V1 or what have you
without having to dig up all n VPU revisions.

Konrad
>

2023-03-02 11:55:23

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6


On 3/2/2023 5:03 PM, Konrad Dybcio wrote:
>
> On 2.03.2023 07:39, Dikshita Agarwal wrote:
>> On 2/28/2023 10:23 PM, Bryan O'Donoghue wrote:
>>> On 28/02/2023 15:41, Konrad Dybcio wrote:
>>>>> Can you test it and make sure ?
>>>> As I mentioned in the cover letter, 8250 still seems to work with this
>>>> patchset. I have no idea how one would go about validating the
>>>> functionality enabled through this call.
>>> We offlined about this.
>>>
>>> I think it is correct to say you don't have access to a display to test this on sm8250.
>>>
>>> I do so, I will try this out for you, though I'll wait for your V2 for this series.
>>>
>>> ---
>>> bod
>> Hi Konrad,
>>
>> I understand from your commit text, setting this indicator for AR50L is causing issue with suspend.
>>
>> Ideally it shouldn't cause any such issue. I checked with FW team and got to know that this property is not supported on AR50LT so if you set it there should be some property not supported error.
>>
>> In my opinion it would be good to replace these versions checks with VPU version check you have introduced in your other patch and keep this setting for current targets and not set wherever not needed eg AR50LT.
> Okay, I have two questions then:
>
> 1. Can the firmware team confirm it shouldn't crash on a fw tag
> that's close to VIDEO.VE.6.0-00042-PROD-1?
>
> 2. Are there any other SoCs that SYS_IDLE is not supported on?
> It hasn't been sent to the hardware by the vidc driver for
> any SoC using the downstream vidc (NOT the legacy vidc_3x)
> driver starting with msm-4.14, AFAICS.. check out this link:
>
> https://github.com/sonyxperiadev/kernel/commit/8889a7d26943e96eae2f318f87b15efa4b907f28
>
> Konrad

Yes, that's correct, I have already confirmed from FW team that this
idle check is always enabled in FW now.

so driver doesn't have to set itexplicitly, that's why it works for you
on 8250 I believe. So removing this setting seems fine.

My only concern is that why we see a crash when setting it on AR50LT.

Thanks,

Dikshita


>> Thanks,
>>
>> Dikshita
>>

2023-03-02 12:00:02

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 05/18] media: venus: hfi_venus: Sanitize venus_boot_core() per-VPU-version


On 3/2/2023 4:40 PM, Konrad Dybcio wrote:
>
> On 2.03.2023 12:00, Dikshita Agarwal wrote:
>> On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
>>> The current assumption of IS_V6 is overgeneralized. Adjust the logic
>>> to take the VPU hardware version into account.
>>>
>>> Signed-off-by: Konrad Dybcio <[email protected]>
>>> ---
>>>   drivers/media/platform/qcom/venus/hfi_venus.c | 10 ++++++----
>>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
>>> index 4ccf31147c2a..772e5e9cf127 100644
>>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>>> @@ -448,20 +448,21 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>>   {
>>>       struct device *dev = hdev->core->dev;
>>>       static const unsigned int max_tries = 100;
>>> -    u32 ctrl_status = 0, mask_val;
>>> +    u32 ctrl_status = 0, mask_val = 0;
>>>       unsigned int count = 0;
>>>       void __iomem *cpu_cs_base = hdev->core->cpu_cs_base;
>>>       void __iomem *wrapper_base = hdev->core->wrapper_base;
>>>       int ret = 0;
>>>         writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
>>> -    if (IS_V6(hdev->core)) {
>>> +    if (IS_IRIS1(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
>> I think the IRIS1 check can be removed from here as we are not handling IRIS1 related things at other places.
>>
>> we can add the required checks for IRIS1 when we add support for any IRIS1 based chipset.
> Up to you really, I plan on getting IRIS1 (SM8150) supported and have
> some mumbling going on for that on my local branch. FWIW these checks
> are logically correct and I would personally prefer not to have to go
> through each one of them and remove them just to bring them back soon.
>
> Konrad

oh, I see. I wasn't aware about the plan for IRIS1.

if you plan to add these checks on all relevant places then it should be
fine.

Thanks,

Dikshita

>> Thanks,
>>
>> Dikshita
>>
>>>           mask_val = readl(wrapper_base + WRAPPER_INTR_MASK);
>>>           mask_val &= ~(WRAPPER_INTR_MASK_A2HWD_BASK_V6 |
>>>                     WRAPPER_INTR_MASK_A2HCPU_MASK);
>>>       } else {
>>>           mask_val = WRAPPER_INTR_MASK_A2HVCODEC_MASK;
>>>       }
>>> +
>>>       writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
>>>       writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>>>   @@ -480,10 +481,11 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>>       if (count >= max_tries)
>>>           ret = -ETIMEDOUT;
>>>   -    if (IS_V6(hdev->core)) {
>>> +    if (IS_AR50_LITE(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
>>>           writel(0x1, cpu_cs_base + CPU_CS_H2XSOFTINTEN_V6);
>>> +
>>> +    if (IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core))
>>>           writel(0x0, cpu_cs_base + CPU_CS_X2RPMH_V6);
>>> -    }
>>>         return ret;
>>>   }
>>>

2023-03-02 12:27:23

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 06/18] media: venus: hfi_venus: Write to VIDC_CTRL_INIT after unmasking interrupts


On 2/28/2023 9:29 PM, Konrad Dybcio wrote:
>
> On 28.02.2023 16:33, Bryan O'Donoghue wrote:
>> On 28/02/2023 15:24, Konrad Dybcio wrote:
>>> The downstream driver signals the hardware to be enabled only after the
>>> interrupts are unmasked, which... makes sense. Follow suit.
>>>
>>> Signed-off-by: Konrad Dybcio <[email protected]>
>>> ---
>>>   drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
>>> index 772e5e9cf127..4d785e53aa0b 100644
>>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>>> @@ -454,7 +454,6 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>>       void __iomem *wrapper_base = hdev->core->wrapper_base;
>>>       int ret = 0;
>>>   -    writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
>>>       if (IS_IRIS1(hdev->core) || IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
>>>           mask_val = readl(wrapper_base + WRAPPER_INTR_MASK);
>>>           mask_val &= ~(WRAPPER_INTR_MASK_A2HWD_BASK_V6 |
>>> @@ -466,6 +465,7 @@ static int venus_boot_core(struct venus_hfi_device *hdev)
>>>       writel(mask_val, wrapper_base + WRAPPER_INTR_MASK);
>>>       writel(1, cpu_cs_base + CPU_CS_SCIACMDARG3);
>>>   +    writel(BIT(VIDC_CTRL_INIT_CTRL_SHIFT), cpu_cs_base + VIDC_CTRL_INIT);
>>>       while (!ctrl_status && count < max_tries) {
>>>           ctrl_status = readl(cpu_cs_base + CPU_CS_SCIACMDARG0);
>>>           if ((ctrl_status & CPU_CS_SCIACMDARG0_ERROR_STATUS_MASK) == 4) {
>>>
>> This should go before you add your new macros in-place of IS_V6() and it should have a fixes.
> Ack
>
> Konrad

Agree with Bryan and this change looks fine to me.

>> ---
>> bod

2023-03-02 12:36:48

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 08/18] media: venus: hfi_venus: Fix version checks in venus_halt_axi()


On 2/28/2023 9:31 PM, Konrad Dybcio wrote:
>
> On 28.02.2023 16:36, Bryan O'Donoghue wrote:
>> On 28/02/2023 15:24, Konrad Dybcio wrote:
>>> Only IRIS2(_1) should enter the until-now-IS_V6() path and the
>>> condition for skipping part of it should be IS_IRIS2_1 and not the
>>> number of VPP pipes. Fix that.
>>>
>>> Fixes: 4b0b6e147dc9 ("media: venus: hfi: Add 6xx AXI halt logic")
>>> Fixes: 78d434ba8659 ("media: venus: hfi: Skip AON register programming for V6 1pipe")
>>> Signed-off-by: Konrad Dybcio <[email protected]>
>>> ---
>>>   drivers/media/platform/qcom/venus/hfi_venus.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
>>> index 4d785e53aa0b..0d137e070407 100644
>>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>>> @@ -550,10 +550,10 @@ static int venus_halt_axi(struct venus_hfi_device *hdev)
>>>       u32 mask_val;
>>>       int ret;
>>>   -    if (IS_V6(hdev->core)) {
>>> +    if (IS_IRIS2(hdev->core) || IS_IRIS2_1(hdev->core)) {
>>>           writel(0x3, cpu_cs_base + CPU_CS_X2RPMH_V6);
>>>   -        if (hdev->core->res->num_vpp_pipes == 1)
>>> +        if (IS_IRIS2_1(hdev->core))
>>>               goto skip_aon_mvp_noc;
>>>             writel(0x1, aon_base + AON_WRAPPER_MVP_NOC_LPI_CONTROL);
>>>
>> If you want to denote these as fixes, you need your patch 02/18 as a depend...
> The main purpose of the Fixes tag is to mark commits that fix bugs in
> existing code and it only assists in autoselecting stable patches.
> Backporting this makes little sense, as we only support IRIS2 (8250)
> and IRIS2_1 (7280) HFI6 platforms and new additions won't be backported.
>
> Konrad

IRIS2_1 is nothing but IRIS2 with 1 VPP pipe (just a downstream notation
to differentiate between two IRIS2 based chips).

So having the num_vpp_pipes check was fine, nothing wrong with that.

but since now you are introducing new VPU based check, it can be
replaced with IRIS2_1 check.

Thanks,

Dikshita

>> ---
>> bod

2023-03-07 04:58:48

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 07/18] media: venus: core: Assign registers based on VPU version


On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
> IRIS2(_1) has a different register map compared to other HFI6XX-
> using VPUs. Take care of it.
>
> Signed-off-by: Konrad Dybcio<[email protected]>
> ---
> drivers/media/platform/qcom/venus/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index c13436d58ed3..bdc14acc8399 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -246,7 +246,7 @@ static int venus_enumerate_codecs(struct venus_core *core, u32 type)
>
> static void venus_assign_register_offsets(struct venus_core *core)
> {
> - if (IS_V6(core)) {
> + if (IS_IRIS2(core) || IS_IRIS2_1(core)) {
> core->vbif_base = core->base + VBIF_BASE;
> core->cpu_base = core->base + CPU_BASE_V6;
> core->cpu_cs_base = core->base + CPU_CS_BASE_V6;

AR50_LITE also should be added here, as I see you have added the same to
places where we are using V6 based registers.

if the base addresses are not assigned here properly. the register
writing at other places will be wrong, ex: patch 05/18

Thanks,

Dikshita


2023-03-07 06:12:33

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 09/18] media: venus: hfi_venus: Fix version checks in venus_isr()


On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
> IS_V6 was used there IS_IRIS2(_1) should have been and the !IS_V6
> condition was only correct by luck and for now. Replace them both
> with VPU version checks.
>
> Fixes: 24fcc0522d87 ("media: venus: hfi: Add 6xx interrupt support")
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> drivers/media/platform/qcom/venus/hfi_venus.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index 0d137e070407..ecfbac36de20 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -1136,7 +1136,7 @@ static irqreturn_t venus_isr(struct venus_core *core)
> wrapper_base = hdev->core->wrapper_base;
>
> status = readl(wrapper_base + WRAPPER_INTR_STATUS);
> - if (IS_V6(core)) {
> + if (IS_IRIS2(core) || IS_IRIS2_1(core)) {
> if (status & WRAPPER_INTR_STATUS_A2H_MASK ||
> status & WRAPPER_INTR_STATUS_A2HWD_MASK_V6 ||
> status & CPU_CS_SCIACMDARG0_INIT_IDLE_MSG_MASK)
> @@ -1148,7 +1148,7 @@ static irqreturn_t venus_isr(struct venus_core *core)
> hdev->irq_status = status;
> }
> writel(1, cpu_cs_base + CPU_CS_A2HSOFTINTCLR);
> - if (!IS_V6(core))
> + if (!(IS_AR50_LITE(core) || IS_IRIS2(core) || IS_IRIS2_1(core)))
> writel(status, wrapper_base + WRAPPER_INTR_CLEAR);
>
> return IRQ_WAKE_THREAD;
reviewed-by: Dikshita Agarwal <[email protected]>

2023-03-07 06:14:37

by Dikshita Agarwal

[permalink] [raw]
Subject: Re: [PATCH 09/18] media: venus: hfi_venus: Fix version checks in venus_isr()


On 3/7/2023 11:42 AM, Dikshita Agarwal wrote:
>
> On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
>> IS_V6 was used there IS_IRIS2(_1) should have been and the !IS_V6
>> condition was only correct by luck and for now. Replace them both
>> with VPU version checks.
>>
>> Fixes: 24fcc0522d87 ("media: venus: hfi: Add 6xx interrupt support")
>> Signed-off-by: Konrad Dybcio <[email protected]>
>> ---
>>   drivers/media/platform/qcom/venus/hfi_venus.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c
>> b/drivers/media/platform/qcom/venus/hfi_venus.c
>> index 0d137e070407..ecfbac36de20 100644
>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>> @@ -1136,7 +1136,7 @@ static irqreturn_t venus_isr(struct venus_core
>> *core)
>>       wrapper_base = hdev->core->wrapper_base;
>>         status = readl(wrapper_base + WRAPPER_INTR_STATUS);
>> -    if (IS_V6(core)) {
>> +    if (IS_IRIS2(core) || IS_IRIS2_1(core)) {
>>           if (status & WRAPPER_INTR_STATUS_A2H_MASK ||
>>               status & WRAPPER_INTR_STATUS_A2HWD_MASK_V6 ||
>>               status & CPU_CS_SCIACMDARG0_INIT_IDLE_MSG_MASK)
>> @@ -1148,7 +1148,7 @@ static irqreturn_t venus_isr(struct venus_core
>> *core)
>>               hdev->irq_status = status;
>>       }
>>       writel(1, cpu_cs_base + CPU_CS_A2HSOFTINTCLR);
>> -    if (!IS_V6(core))
>> +    if (!(IS_AR50_LITE(core) || IS_IRIS2(core) || IS_IRIS2_1(core)))
>>           writel(status, wrapper_base + WRAPPER_INTR_CLEAR);
>>         return IRQ_WAKE_THREAD;

this change looks good to me , once base register values are fixed in
other patch.

reviewed-by: Dikshita Agarwal <[email protected]>


2023-03-07 11:19:03

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 07/18] media: venus: core: Assign registers based on VPU version



On 7.03.2023 05:57, Dikshita Agarwal wrote:
>
> On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
>> IRIS2(_1) has a different register map compared to other HFI6XX-
>> using VPUs. Take care of it.
>>
>> Signed-off-by: Konrad Dybcio<[email protected]>
>> ---
>>   drivers/media/platform/qcom/venus/core.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
>> index c13436d58ed3..bdc14acc8399 100644
>> --- a/drivers/media/platform/qcom/venus/core.c
>> +++ b/drivers/media/platform/qcom/venus/core.c
>> @@ -246,7 +246,7 @@ static int venus_enumerate_codecs(struct venus_core *core, u32 type)
>>     static void venus_assign_register_offsets(struct venus_core *core)
>>   {
>> -    if (IS_V6(core)) {
>> +    if (IS_IRIS2(core) || IS_IRIS2_1(core)) {
>>           core->vbif_base = core->base + VBIF_BASE;
>>           core->cpu_base = core->base + CPU_BASE_V6;
>>           core->cpu_cs_base = core->base + CPU_CS_BASE_V6;
>
> AR50_LITE also should be added here, as I see you have added the same to places where we are using V6 based registers.
>
> if the base addresses are not assigned here properly. the register writing at other places will be wrong, ex: patch 05/18
I have a separate patch set which specifically adds AR50L data,
and they're not 1:1, vbif_base and aon_base are gone (at least
according to techpack/video). I intend to push it when I get it
all working, but here's what it looks like right now:


diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index fd9ecb1f7a05..f88b4781c5d0 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -254,6 +254,14 @@ static void venus_assign_register_offsets(struct venus_core *core)
core->wrapper_base = core->base + WRAPPER_BASE_V6;
core->wrapper_tz_base = core->base + WRAPPER_TZ_BASE_V6;
core->aon_base = core->base + AON_BASE_V6;
+ } else if (IS_AR50_LITE(core)) {
+ core->vbif_base = NULL;
+ core->cpu_base = core->base + CPU_BASE_V6;
+ core->cpu_cs_base = core->base + CPU_CS_BASE_V6;
+ core->cpu_ic_base = core->base + CPU_IC_BASE_V6;
+ core->wrapper_base = core->base + WRAPPER_BASE_V6;
+ core->wrapper_tz_base = core->base + WRAPPER_TZ_BASE_V6;
+ core->aon_base = NULL;
} else {
core->vbif_base = core->base + VBIF_BASE;
core->cpu_base = core->base + CPU_BASE;
--
2.39.2


Konrad

>
> Thanks,
>
> Dikshita
>

2023-03-20 14:56:44

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6



On 2.03.2023 07:39, Dikshita Agarwal wrote:
>
> On 2/28/2023 10:23 PM, Bryan O'Donoghue wrote:
>> On 28/02/2023 15:41, Konrad Dybcio wrote:
>>>> Can you test it and make sure ?
>>> As I mentioned in the cover letter, 8250 still seems to work with this
>>> patchset. I have no idea how one would go about validating the
>>> functionality enabled through this call.
>>
>> We offlined about this.
>>
>> I think it is correct to say you don't have access to a display to test this on sm8250.
>>
>> I do so, I will try this out for you, though I'll wait for your V2 for this series.
>>
>> ---
>> bod
>
> Hi Konrad,
>
> I understand from your commit text, setting this indicator for AR50L is causing issue with suspend.
>
> Ideally it shouldn't cause any such issue. I checked with FW team and got to know that this property is not supported on AR50LT so if you set it there should be some property not supported error.
>
> In my opinion it would be good to replace these versions checks with VPU version check you have introduced in your other patch and keep this setting for current targets and not set wherever not needed eg AR50LT.
So.. I did *something* and I'm no longer getting a jump to EDL.

The *something* being knocking off hfi_core_suspend().

If I send a sys_idle_indicator = true, I get (reformatted for
better legibility):


[ 0.576543] qcom-venus 5a00000.video-codec: VenusFW :
<VFW_H:HostDr:unkn:--------:-> IMAGE_VARIANT_STRING=PROD

[ 0.603818] qcom-venus 5a00000.video-codec: VenusFW :
<VFW_H:HostDr:unkn:--------:-> OEM_IMAGE_VERSION_STRING=CRM

[ 0.608633] qcom-venus 5a00000.video-codec: VenusFW :
<VFW_H:HostDr:unkn:--------:-> BUILD_TIME: Mar 15 2021 04:24:58

[ 0.608644] qcom-venus 5a00000.video-codec: VenusFW :
<VFW_L:HostDr:unkn:--------:-> Host cmd 0x10005

[ 0.608655] qcom-venus 5a00000.video-codec: VenusFW :
<VFW_E:HostDr:unkn:--------:-> VenusHostDriver_SetSysProperty(1019): HostDriver: VenusHostDriver_SetSysProperty unsupport property!

[ 0.608667] qcom-venus 5a00000.video-codec: VenusFW :
<VFW_E:HostDr:unkn:--------:-> WaitForHWidle(408): VENUS is idle, no HW is running

[ 0.650759] qcom-venus 5a00000.video-codec: VenusFW :
<VFW_E:HostDr:unkn:--------:-> assert_loop(433):
FW Assertion - Z:/b/venus_proc/venus/drivers/src/VenusHostDriver.c:1020:5ab9a


Which then crashes Venus for good (perhaps we're missing a
handler for such errors that would hard reset the hw), meaning
trying to access it through ffmpeg will result in it never firing
any IRQs, so no submitted commands ever complete.

With this information, after uncommenting the hfi_core_suspend
call and changing:

[1]
--- hfi_venus.c : venus_suspend_3xx() --

- venus_prepare_power_collapse(hdev, true);
+ venus_prepare_power_collapse(hdev, false);

----------------------------------------

I was able to test further. Turning the ARM9 core off messes
with the sys_idle things. Perhaps some power sequencing is
wrong. The diff I just mentioned comes from the fact that
AR50L will never ever ever send a PC_PREP_DONE ack, or at
least downstream never expects it (or any other HFI6XX
target FWIW) to do so.


Now, I also realized the adjacent set_power_control doesn't seem to be used at
all on msm-4.19 techpack/video. Testing all the possible combinations, I get
(to make it extra clear, with all the powerdown stuff in place and only diff
[1] in place atop what I already had before):


[set_idle_message] [set_power_control] [result]
0 0 - no crash at boot, venus doesn't work ->
"Too many packets buffered for output stream 0:1."

0 1 - no crash at boot, ffmpeg hangs near vdec session init ->
jump to EDL shortly after

1 0 - hang at boot, even before display subsys initializes ->
platform totally hangs

1 1 - same as (1, 0), probably due to sys_idle_indicator being on ->
platform totally hangs as well

Perhaps (0, 0) is "good" and things can be worked up from there?
Can you recheck with the firmware team if this is expected?

Konrad
>
> Thanks,
>
> Dikshita
>

2023-03-30 11:10:39

by Vikash Garodia

[permalink] [raw]
Subject: Re: [PATCH 02/18] media: venus: Introduce VPU version distinction

On 3/2/2023 5:07 PM, Konrad Dybcio wrote:
>
> On 2.03.2023 08:12, Dikshita Agarwal wrote:
>> On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
>>> The Video Processing Unit hardware version is the differentiator,
>>> based on which we should decide which code paths to take in hw
>>> init. Up until now, we've relied on HFI versions, but that was
>>> just a happy accident between recent SoCs. Add a field in the
>>> res struct and add correlated definitions that will be used to
>>> account for the aforementioned differences.
>>>
>>> Signed-off-by: Konrad Dybcio <[email protected]>
>>> ---
>>>   drivers/media/platform/qcom/venus/core.h | 15 +++++++++++++++
>>>   1 file changed, 15 insertions(+)
>>>
>>> diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
>>> index 32551c2602a9..4b785205c5b1 100644
>>> --- a/drivers/media/platform/qcom/venus/core.h
>>> +++ b/drivers/media/platform/qcom/venus/core.h
>>> @@ -48,6 +48,14 @@ struct bw_tbl {
>>>       u32 peak_10bit;
>>>   };
>>>   +enum vpu_version {
>>> +    VPU_VERSION_AR50, /* VPU4 */
>>> +    VPU_VERSION_AR50_LITE, /* VPU4.4 */
>>> +    VPU_VERSION_IRIS1, /* VPU5 */

There was Venus3X, followed by a different generation of video hardware.
Driver just extended the versions for next generation incrementally.

Existing versions in driver are not the VPU versions, so we can drop
them from comments.

>>> +    VPU_VERSION_IRIS2,
>>> +    VPU_VERSION_IRIS2_1,
>>> +};
>>> +
>>>   struct venus_resources {
>>>       u64 dma_mask;
>>>       const struct freq_tbl *freq_tbl;
>>> @@ -71,6 +79,7 @@ struct venus_resources {
>>>       const char * const resets[VIDC_RESETS_NUM_MAX];
>>>       unsigned int resets_num;
>>>       enum hfi_version hfi_version;
>>> +    enum vpu_version vpu_version;
>>>       u8 num_vpp_pipes;
>>>       u32 max_load;
>>>       unsigned int vmem_id;
>>> @@ -473,6 +482,12 @@ struct venus_inst {
>>>   #define IS_V4(core)    ((core)->res->hfi_version == HFI_VERSION_4XX)
>>>   #define IS_V6(core)    ((core)->res->hfi_version == HFI_VERSION_6XX)
>>>   +#define IS_AR50(core)        ((core)->res->vpu_version == VPU_VERSION_AR50)
>>> +#define IS_AR50_LITE(core)    ((core)->res->vpu_version == VPU_VERSION_AR50_LITE)
>>> +#define IS_IRIS1(core)        ((core)->res->vpu_version == VPU_VERSION_IRIS1)
>>> +#define IS_IRIS2(core)        ((core)->res->vpu_version == VPU_VERSION_IRIS2)
>>> +#define IS_IRIS2_1(core)    ((core)->res->vpu_version == VPU_VERSION_IRIS2_1)
>>> +
>>>   #define ctrl_to_inst(ctrl)    \
>>>       container_of((ctrl)->handler, struct venus_inst, ctrl_handler)
>>>
>> Adding VPU version check seems a good idea to me. Can we remove HFI Version checks now?
> If all implementations using VPU x.y *always* use the
> same HFI generation for given x, y, we could.

HFIs generally does not change, so we can be sure that they would always
use the same HFI.

We might add a new interface (HFI) for a feature requirement, but always
support the existing ones.

>
> That said, I think keeping it as-is would be convenient
> from the maintainability standpoint if nothing else.. For
> example functions that only appear in ancient msm-3.10
> releases can be easily guarded with IS_V1 or what have you
> without having to dig up all n VPU revisions.
>
> Konrad

2023-03-30 11:16:07

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 02/18] media: venus: Introduce VPU version distinction



On 30.03.2023 13:02, Vikash Garodia wrote:
> On 3/2/2023 5:07 PM, Konrad Dybcio wrote:
>>
>> On 2.03.2023 08:12, Dikshita Agarwal wrote:
>>> On 2/28/2023 8:54 PM, Konrad Dybcio wrote:
>>>> The Video Processing Unit hardware version is the differentiator,
>>>> based on which we should decide which code paths to take in hw
>>>> init. Up until now, we've relied on HFI versions, but that was
>>>> just a happy accident between recent SoCs. Add a field in the
>>>> res struct and add correlated definitions that will be used to
>>>> account for the aforementioned differences.
>>>>
>>>> Signed-off-by: Konrad Dybcio <[email protected]>
>>>> ---
>>>>    drivers/media/platform/qcom/venus/core.h | 15 +++++++++++++++
>>>>    1 file changed, 15 insertions(+)
>>>>
>>>> diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
>>>> index 32551c2602a9..4b785205c5b1 100644
>>>> --- a/drivers/media/platform/qcom/venus/core.h
>>>> +++ b/drivers/media/platform/qcom/venus/core.h
>>>> @@ -48,6 +48,14 @@ struct bw_tbl {
>>>>        u32 peak_10bit;
>>>>    };
>>>>    +enum vpu_version {
>>>> +    VPU_VERSION_AR50, /* VPU4 */
>>>> +    VPU_VERSION_AR50_LITE, /* VPU4.4 */
>>>> +    VPU_VERSION_IRIS1, /* VPU5 */
>
> There was Venus3X, followed by a different generation of video hardware. Driver just extended the versions for next generation incrementally.
>
> Existing versions in driver are not the VPU versions, so we can drop them from comments.
Ack!

>
>>>> +    VPU_VERSION_IRIS2,
>>>> +    VPU_VERSION_IRIS2_1,
>>>> +};
>>>> +
>>>>    struct venus_resources {
>>>>        u64 dma_mask;
>>>>        const struct freq_tbl *freq_tbl;
>>>> @@ -71,6 +79,7 @@ struct venus_resources {
>>>>        const char * const resets[VIDC_RESETS_NUM_MAX];
>>>>        unsigned int resets_num;
>>>>        enum hfi_version hfi_version;
>>>> +    enum vpu_version vpu_version;
>>>>        u8 num_vpp_pipes;
>>>>        u32 max_load;
>>>>        unsigned int vmem_id;
>>>> @@ -473,6 +482,12 @@ struct venus_inst {
>>>>    #define IS_V4(core)    ((core)->res->hfi_version == HFI_VERSION_4XX)
>>>>    #define IS_V6(core)    ((core)->res->hfi_version == HFI_VERSION_6XX)
>>>>    +#define IS_AR50(core)        ((core)->res->vpu_version == VPU_VERSION_AR50)
>>>> +#define IS_AR50_LITE(core)    ((core)->res->vpu_version == VPU_VERSION_AR50_LITE)
>>>> +#define IS_IRIS1(core)        ((core)->res->vpu_version == VPU_VERSION_IRIS1)
>>>> +#define IS_IRIS2(core)        ((core)->res->vpu_version == VPU_VERSION_IRIS2)
>>>> +#define IS_IRIS2_1(core)    ((core)->res->vpu_version == VPU_VERSION_IRIS2_1)
>>>> +
>>>>    #define ctrl_to_inst(ctrl)    \
>>>>        container_of((ctrl)->handler, struct venus_inst, ctrl_handler)
>>>>   
>>> Adding VPU version check seems a good idea to me. Can we remove HFI Version checks now?
>> If all implementations using VPU x.y *always* use the
>> same HFI generation for given x, y, we could.
>
> HFIs generally does not change, so we can be sure that they would always use the same HFI.
>
> We might add a new interface (HFI) for a feature requirement, but always support the existing ones.
Okay, will do. Thanks!

Konrad
>
>>
>> That said, I think keeping it as-is would be convenient
>> from the maintainability standpoint if nothing else.. For
>> example functions that only appear in ancient msm-3.10
>> releases can be easily guarded with IS_V1 or what have you
>> without having to dig up all n VPU revisions.
>>
>> Konrad

2023-04-04 17:59:56

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 01/18] media: venus: hfi_venus: Set venus_sys_idle_indicator to false on V6



On 30.03.2023 12:44, Vikash Garodia wrote:
> On 3/24/2023 2:46 PM, Dikshita Agarwal wrote:
>>
>>
>> On 3/20/2023 8:24 PM, Konrad Dybcio wrote:
>>> On 2.03.2023 07:39, Dikshita Agarwal wrote:
>>>> On 2/28/2023 10:23 PM, Bryan O'Donoghue wrote:
>>>>> On 28/02/2023 15:41, Konrad Dybcio wrote:
>>>>>>> Can you test it and make sure ?
>>>>>> As I mentioned in the cover letter, 8250 still seems to work with this
>>>>>> patchset. I have no idea how one would go about validating the
>>>>>> functionality enabled through this call.
>>>>> We offlined about this.
>>>>>
>>>>> I think it is correct to say you don't have access to a display to test this on sm8250.
>>>>>
>>>>> I do so, I will try this out for you, though I'll wait for your V2 for this series.
>>>>>
>>>>> ---
>>>>> bod
>>>> Hi Konrad,
>>>>
>>>> I understand from your commit text, setting this indicator for AR50L is causing issue with suspend.
>>>>
>>>> Ideally it shouldn't cause any such issue. I checked with FW team and got to know that this property is not supported on AR50LT so if you set it there should be some property not supported error.
>>>>
>>>> In my opinion it would be good to replace these versions checks with VPU version check you have introduced in your other patch and keep this setting for current targets and not set wherever not needed eg AR50LT.
>>> So.. I did *something* and I'm no longer getting a jump to EDL.
>>>
>>> The *something* being knocking off hfi_core_suspend().
>>>
>>> If I send a sys_idle_indicator = true, I get (reformatted for
>>> better legibility):
>>>
>>>
>>> [    0.576543] qcom-venus 5a00000.video-codec: VenusFW  :
>>> <VFW_H:HostDr:unkn:--------:-> IMAGE_VARIANT_STRING=PROD
>>>
>>> [    0.603818] qcom-venus 5a00000.video-codec: VenusFW  :
>>> <VFW_H:HostDr:unkn:--------:-> OEM_IMAGE_VERSION_STRING=CRM
>>>
>>> [    0.608633] qcom-venus 5a00000.video-codec: VenusFW  :
>>> <VFW_H:HostDr:unkn:--------:-> BUILD_TIME: Mar 15 2021 04:24:58
>>>
>>> [    0.608644] qcom-venus 5a00000.video-codec: VenusFW  :
>>> <VFW_L:HostDr:unkn:--------:-> Host cmd 0x10005
>>>
>>> [    0.608655] qcom-venus 5a00000.video-codec: VenusFW  :
>>> <VFW_E:HostDr:unkn:--------:-> VenusHostDriver_SetSysProperty(1019): HostDriver:  VenusHostDriver_SetSysProperty unsupport property!
>>>
>>> [    0.608667] qcom-venus 5a00000.video-codec: VenusFW  :
>>> <VFW_E:HostDr:unkn:--------:-> WaitForHWidle(408): VENUS is idle, no HW is running
>>>
>>> [    0.650759] qcom-venus 5a00000.video-codec: VenusFW  :
>>> <VFW_E:HostDr:unkn:--------:-> assert_loop(433):
>>> FW Assertion - Z:/b/venus_proc/venus/drivers/src/VenusHostDriver.c:1020:5ab9a
>>
>> this "unsupported property" error and then the assert from FW is expected on AR50LT if driver sets HFI_PROPERTY_SYS_IDLE_INDICATOR to FW.
>>
>> As I mentioned in my other reply, this property doesn't need to be set by driver now, FW internally always enables it.
>>
>>> Which then crashes Venus for good (perhaps we're missing a
>>> handler for such errors that would hard reset the hw), meaning
>>> trying to access it through ffmpeg will result in it never firing
>>> any IRQs, so no submitted commands ever complete.
>>>
>>> With this information, after uncommenting the hfi_core_suspend
>>> call and changing:
>>>
>>> [1]
>>> --- hfi_venus.c : venus_suspend_3xx() --
>>>
>>> - venus_prepare_power_collapse(hdev, true);
>>> + venus_prepare_power_collapse(hdev, false);
>>>
>>> ----------------------------------------
>>>
>>> I was able to test further. Turning the ARM9 core off messes
>>> with the sys_idle things. Perhaps some power sequencing is
>>> wrong. The diff I just mentioned comes from the fact that
>>> AR50L will never ever ever send a PC_PREP_DONE ack, or at
>>> least downstream never expects it (or any other HFI6XX
>>> target FWIW) to do so.
>>>
>>>
>>> Now, I also realized the adjacent set_power_control doesn't seem to be used at
>>> all on msm-4.19 techpack/video. Testing all the possible combinations, I get
>>> (to make it extra clear, with all the powerdown stuff in place and only diff
>>> [1] in place atop what I already had before):
>>>
>>>
>>> [set_idle_message] [set_power_control] [result]
>>> 0 0 - no crash at boot, venus doesn't work ->
>>>     "Too many packets buffered for output stream 0:1."
>>>
>>> 0 1 - no crash at boot, ffmpeg hangs near vdec session init ->
>>>     jump to EDL shortly after
>>>
>>> 1 0 - hang at boot, even before display subsys initializes ->
>>>     platform totally hangs
>>>
>>> 1 1 - same as (1, 0), probably due to sys_idle_indicator being on ->
>>>     platform totally hangs as well
>>>
>>> Perhaps (0, 0) is "good" and things can be worked up from there?
>>> Can you recheck with the firmware team if this is expected?
>>
>> I will check regarding set_power_control(HFI_PROPERTY_SYS_CODEC_POWER_PLANE_CTRL) with FW team and get back.
>>
> HFI_PROPERTY_SYS_IDLE_INDICATOR is not supported beyond 8916 (which is versioned as V1 in video driver). This can be dropped.
>
> Since the property is not functionally active, it is upto firmware when they might decide to start error out as unsupported property.
>
> SYS_CODEC_POWER_PLANE_CTRL is supported for AR50/AR50L/IRIS1/2. It is a mandatory HFI to get the required power benefits.
>
> vcodec0 GDSC should be also configured as HW_CTRL while setting POWER_PLANE_CTRL to firmware.
>
Okay that's very good to know. To sum it up, the outcome you would
expect is (more or less):

- static bool venus_sys_idle_indicator = true;

[...]

- if(IS_V4(hdev->core) || IS_V6(hdev->core))
- venus_sys_idle_indicator = true;

+ venus_sys_idle_indicator = IS_V1(hdev->core);


?

Konrad
>> Thanks,
>>
>> Dikshita
>>
>>> Konrad
>>>> Thanks,
>>>>
>>>> Dikshita
>>>>