mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] media: venus: fix HFI parser payload size returns
@ 2026-06-10 12:56 Mohammed EL Kadiri
  2026-06-10 12:56 ` [PATCH 1/2] media: venus: fix payload size returned by parse_caps() and parse_alloc_mode() Mohammed EL Kadiri
  2026-06-10 12:56 ` [PATCH 2/2] media: venus: fix payload size calculation in parse_raw_formats() Mohammed EL Kadiri
  0 siblings, 2 replies; 5+ messages in thread
From: Mohammed EL Kadiri @ 2026-06-10 12:56 UTC (permalink / raw)
  To: quic_vgarodia, quic_dikshita, bryan.odonoghue, mchehab
  Cc: hverkuil, dmitry.baryshkov, linux-media, linux-arm-msm,
	linux-kernel, Mohammed EL Kadiri

Several parse functions return incorrect consumed sizes after the
refactor in commit 9edaaa8e3e15. hfi_parser() uses these values to
advance through the firmware response buffer, so incorrect sizes cause
parser desynchronization.

parse_profile_level() has the correct pattern. These patches align the
remaining functions to match it.

Compile-tested with arm64 cross-compiler (gcc 13.3).

Mohammed EL Kadiri (2):
  media: venus: fix payload size returned by parse_caps() and
    parse_alloc_mode()
  media: venus: fix payload size calculation in parse_raw_formats()

 drivers/media/platform/qcom/venus/hfi_parser.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] media: venus: fix payload size returned by parse_caps() and parse_alloc_mode()
  2026-06-10 12:56 [PATCH 0/2] media: venus: fix HFI parser payload size returns Mohammed EL Kadiri
@ 2026-06-10 12:56 ` Mohammed EL Kadiri
  2026-06-10 13:26   ` Dmitry Baryshkov
  2026-06-10 12:56 ` [PATCH 2/2] media: venus: fix payload size calculation in parse_raw_formats() Mohammed EL Kadiri
  1 sibling, 1 reply; 5+ messages in thread
From: Mohammed EL Kadiri @ 2026-06-10 12:56 UTC (permalink / raw)
  To: quic_vgarodia, quic_dikshita, bryan.odonoghue, mchehab
  Cc: hverkuil, dmitry.baryshkov, linux-media, linux-arm-msm,
	linux-kernel, Mohammed EL Kadiri, stable

parse_caps() and parse_alloc_mode() return only the size of their fixed
header fields, excluding the flexible array payload. hfi_parser() uses
this return value to advance through the firmware response buffer, so
underreporting causes parser desynchronization.

Return the full consumed size (header + entries), matching the correct
pattern used by parse_profile_level().

Fixes: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
Cc: stable@vger.kernel.org
Signed-off-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
---
 drivers/media/platform/qcom/venus/hfi_parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_parser.c b/drivers/media/platform/qcom/venus/hfi_parser.c
index 1b3db2caa99f..e2af4e9901ee 100644
--- a/drivers/media/platform/qcom/venus/hfi_parser.c
+++ b/drivers/media/platform/qcom/venus/hfi_parser.c
@@ -85,7 +85,7 @@ parse_alloc_mode(struct venus_core *core, u32 codecs, u32 domain, void *data)
 		type++;
 	}
 
-	return sizeof(*mode);
+	return mode->num_entries * sizeof(u32) + sizeof(*mode);
 }
 
 static void fill_profile_level(struct hfi_plat_caps *cap, const void *data,
@@ -146,7 +146,7 @@ parse_caps(struct venus_core *core, u32 codecs, u32 domain, void *data)
 	for_each_codec(core->caps, ARRAY_SIZE(core->caps), codecs, domain,
 		       fill_caps, caps_arr, num_caps);
 
-	return sizeof(*caps);
+	return num_caps * sizeof(*cap) + sizeof(u32);
 }
 
 static void fill_raw_fmts(struct hfi_plat_caps *cap, const void *fmts,
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] media: venus: fix payload size calculation in parse_raw_formats()
  2026-06-10 12:56 [PATCH 0/2] media: venus: fix HFI parser payload size returns Mohammed EL Kadiri
  2026-06-10 12:56 ` [PATCH 1/2] media: venus: fix payload size returned by parse_caps() and parse_alloc_mode() Mohammed EL Kadiri
@ 2026-06-10 12:56 ` Mohammed EL Kadiri
  2026-06-10 13:26   ` Dmitry Baryshkov
  1 sibling, 1 reply; 5+ messages in thread
From: Mohammed EL Kadiri @ 2026-06-10 12:56 UTC (permalink / raw)
  To: quic_vgarodia, quic_dikshita, bryan.odonoghue, mchehab
  Cc: hverkuil, dmitry.baryshkov, linux-media, linux-arm-msm,
	linux-kernel, Mohammed EL Kadiri, stable

The consumed size is computed after the loop using the num_planes value
from the last iteration for all entries. When entries have different
plane counts, this produces an incorrect total.

Accumulate the actual size during the loop instead.

Fixes: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
Cc: stable@vger.kernel.org
Signed-off-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
---
 drivers/media/platform/qcom/venus/hfi_parser.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/hfi_parser.c b/drivers/media/platform/qcom/venus/hfi_parser.c
index e2af4e9901ee..522bac7ba154 100644
--- a/drivers/media/platform/qcom/venus/hfi_parser.c
+++ b/drivers/media/platform/qcom/venus/hfi_parser.c
@@ -171,7 +171,7 @@ parse_raw_formats(struct venus_core *core, u32 codecs, u32 domain, void *data)
 	u32 entries = fmt->format_entries;
 	unsigned int i = 0;
 	u32 num_planes = 0;
-	u32 size;
+	u32 size = 2 * sizeof(u32);
 
 	while (entries) {
 		num_planes = pinfo->num_planes;
@@ -186,6 +186,7 @@ parse_raw_formats(struct venus_core *core, u32 codecs, u32 domain, void *data)
 		if (pinfo->num_planes > MAX_PLANES)
 			break;
 
+		size += sizeof(*constr) * num_planes + 2 * sizeof(u32);
 		pinfo = (void *)pinfo + sizeof(*constr) * num_planes +
 			2 * sizeof(u32);
 		entries--;
@@ -193,8 +194,6 @@ parse_raw_formats(struct venus_core *core, u32 codecs, u32 domain, void *data)
 
 	for_each_codec(core->caps, ARRAY_SIZE(core->caps), codecs, domain,
 		       fill_raw_fmts, rawfmts, i);
-	size = fmt->format_entries * (sizeof(*constr) * num_planes + 2 * sizeof(u32))
-		+ 2 * sizeof(u32);
 
 	return size;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] media: venus: fix payload size returned by parse_caps() and parse_alloc_mode()
  2026-06-10 12:56 ` [PATCH 1/2] media: venus: fix payload size returned by parse_caps() and parse_alloc_mode() Mohammed EL Kadiri
@ 2026-06-10 13:26   ` Dmitry Baryshkov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Baryshkov @ 2026-06-10 13:26 UTC (permalink / raw)
  To: Mohammed EL Kadiri
  Cc: quic_vgarodia, quic_dikshita, bryan.odonoghue, mchehab, hverkuil,
	linux-media, linux-arm-msm, linux-kernel, stable

On Wed, Jun 10, 2026 at 01:56:54PM +0100, Mohammed EL Kadiri wrote:
> parse_caps() and parse_alloc_mode() return only the size of their fixed
> header fields, excluding the flexible array payload. hfi_parser() uses
> this return value to advance through the firmware response buffer, so
> underreporting causes parser desynchronization.
> 
> Return the full consumed size (header + entries), matching the correct
> pattern used by parse_profile_level().
> 
> Fixes: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
> ---
>  drivers/media/platform/qcom/venus/hfi_parser.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] media: venus: fix payload size calculation in parse_raw_formats()
  2026-06-10 12:56 ` [PATCH 2/2] media: venus: fix payload size calculation in parse_raw_formats() Mohammed EL Kadiri
@ 2026-06-10 13:26   ` Dmitry Baryshkov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Baryshkov @ 2026-06-10 13:26 UTC (permalink / raw)
  To: Mohammed EL Kadiri
  Cc: quic_vgarodia, quic_dikshita, bryan.odonoghue, mchehab, hverkuil,
	linux-media, linux-arm-msm, linux-kernel, stable

On Wed, Jun 10, 2026 at 01:56:55PM +0100, Mohammed EL Kadiri wrote:
> The consumed size is computed after the loop using the num_planes value
> from the last iteration for all entries. When entries have different
> plane counts, this produces an incorrect total.
> 
> Accumulate the actual size during the loop instead.
> 
> Fixes: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
> ---
>  drivers/media/platform/qcom/venus/hfi_parser.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-10 13:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-10 12:56 [PATCH 0/2] media: venus: fix HFI parser payload size returns Mohammed EL Kadiri
2026-06-10 12:56 ` [PATCH 1/2] media: venus: fix payload size returned by parse_caps() and parse_alloc_mode() Mohammed EL Kadiri
2026-06-10 13:26   ` Dmitry Baryshkov
2026-06-10 12:56 ` [PATCH 2/2] media: venus: fix payload size calculation in parse_raw_formats() Mohammed EL Kadiri
2026-06-10 13:26   ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®