From: Charvi Mehta <charvi.mehta@arm.com>
To: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Charvi Mehta <charvi.mehta@arm.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Rathinavel Sankaralingam <rath.sankaralingam@arm.com>,
Shobhit Pandey <shobhit.pandey@arm.com>
Subject: [RFC PATCH 26/28] media: mali-vpu: handle firmware event responses
Date: Thu, 19 Nov 2026 15:37:56 +0000 [thread overview]
Message-ID: <20261119153758.1426673-27-charvi.mehta@arm.com> (raw)
In-Reply-To: <20261119153758.1426673-1-charvi.mehta@arm.com>
Add protocol definitions needed to parse firmware event responses.
Report corrupt and unsupported streams, and propagate unsupported-stream
events to the session as -EOPNOTSUPP. Ignore informational events that
require no session action.
Also retain sequence bit-depth and interlace information, and reject
interlaced or non-8-bit streams that aren't supported by the driver yet.
Signed-off-by: Charvi Mehta <charvi.mehta@arm.com>
---
.../platform/arm/mali-vpu/mali-vpu-firmware.c | 44 ++++++++++
.../platform/arm/mali-vpu/mali-vpu-firmware.h | 13 +++
.../arm/mali-vpu/mali-vpu-protocol-def-v3.h | 87 +++++++++++++++++++
.../platform/arm/mali-vpu/mali-vpu-session.c | 19 ++++
4 files changed, 163 insertions(+)
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.c b/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.c
index 34d57b288a682..99d191b194bfe 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.c
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.c
@@ -1036,6 +1036,7 @@ int mali_vpu_fw_parse_msg(struct mali_vpu_fw *fw, struct mali_vpu_fw_msg *msg)
struct mve_response_frame_alloc_parameters alloc_params;
struct mve_response_sequence_parameters seq_params;
struct mve_buffer_param buffer_param;
+ struct mve_response_event event;
struct mve_response_error error;
} fw_msg = {};
size_t size = sizeof(fw_msg);
@@ -1149,6 +1150,9 @@ int mali_vpu_fw_parse_msg(struct mali_vpu_fw *fw, struct mali_vpu_fw_msg *msg)
msg->code = MALI_VPU_FW_CODE_SEQUENCE_PARAMS;
msg->data.seq_params.planar.buffers_min = fw_msg.seq_params.num_buffers_planar;
+ msg->data.seq_params.bitdepth.luma = fw_msg.seq_params.bitdepth_luma;
+ msg->data.seq_params.bitdepth.chroma = fw_msg.seq_params.bitdepth_chroma;
+ msg->data.seq_params.interlaced = fw_msg.seq_params.interlace;
break;
case MVE_RESPONSE_CODE_INPUT_FLUSHED:
msg->code = MALI_VPU_FW_CODE_INPUT_FLUSH;
@@ -1169,6 +1173,46 @@ int mali_vpu_fw_parse_msg(struct mali_vpu_fw *fw, struct mali_vpu_fw_msg *msg)
case MVE_BUFFER_CODE_PARAM:
ret = mali_vpu_convert_buffer_param(msg, &fw_msg.buffer_param, size);
break;
+ case MVE_RESPONSE_CODE_EVENT: {
+ size_t message_offset = offsetof(struct mve_response_event, event_data.message);
+ size_t message_size;
+
+ msg->code = MALI_VPU_FW_CODE_EVENT;
+
+ if (size < sizeof(fw_msg.event.event_code))
+ return -EPROTO;
+
+ switch (fw_msg.event.event_code) {
+ case MVE_EVENT_ERROR_STREAM_CORRUPT:
+ if (size <= message_offset)
+ return -EPROTO;
+
+ message_size = min(size - message_offset,
+ sizeof(fw_msg.event.event_data.message));
+
+ dev_warn_ratelimited(fw->dev,
+ "firmware reports corrupt stream: %.*s\n",
+ (int)message_size,
+ fw_msg.event.event_data.message);
+
+ break;
+ case MVE_EVENT_ERROR_STREAM_NOT_SUPPORTED:
+ if (size <= message_offset)
+ return -EPROTO;
+
+ message_size = min(size - message_offset,
+ sizeof(fw_msg.event.event_data.message));
+ dev_warn_ratelimited(fw->dev,
+ "firmware reports unsupported stream: %.*s\n",
+ (int)message_size,
+ fw_msg.event.event_data.message);
+ msg->code = MALI_VPU_FW_CODE_STREAM_NOT_SUPPORTED;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
case MVE_RESPONSE_CODE_ERROR: {
size_t message_offset = offsetof(struct mve_response_error, message);
size_t message_size;
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.h b/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.h
index 6c46f23ac8638..d3928fdc9133f 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.h
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.h
@@ -86,13 +86,22 @@ struct mali_vpu_fw_set_option {
/**
* struct mali_vpu_fw_seq_param - Sequence parameters.
+ * @interlaced: Whether the decoded sequence is interlaced.
* @planar: Planar output-buffer requirements.
* @planar.buffers_min: Minimum number of planar buffers required.
+ * @bitdepth: Decoded luma and chroma bitdepths.
+ * @bitdepth.luma: Decoded luma bitdepth.
+ * @bitdepth.chroma: Decoded chroma bitdepth.
*/
struct mali_vpu_fw_seq_param {
+ bool interlaced;
struct {
u32 buffers_min;
} planar;
+ struct mali_vpu_fw_bitdepth {
+ u32 chroma;
+ u32 luma;
+ } bitdepth;
};
/**
@@ -146,6 +155,8 @@ struct mali_vpu_fw_error {
* @MALI_VPU_FW_CODE_ALLOC_PARAM: Firmware reported new frame allocation parameters.
* @MALI_VPU_FW_CODE_COLOR_DESC: Firmware reported colour-description metadata.
* @MALI_VPU_FW_CODE_DPB_HELD_FRAMES: Firmware reported the number of frames held in the DPB.
+ * @MALI_VPU_FW_CODE_STREAM_NOT_SUPPORTED: Firmware rejected the coded stream.
+ * @MALI_VPU_FW_CODE_EVENT: Firmware reported an informational event.
* @MALI_VPU_FW_CODE_UNKNOWN: Unrecognized firmware message.
* @MALI_VPU_FW_CODE_MAX: Sentinel marking the end of the message-code enum.
*/
@@ -168,6 +179,8 @@ enum mali_vpu_fw_code {
MALI_VPU_FW_CODE_ALLOC_PARAM, /* Driver <- Firmware. */
MALI_VPU_FW_CODE_COLOR_DESC, /* Driver <- Firmware. */
MALI_VPU_FW_CODE_DPB_HELD_FRAMES, /* Driver <- Firmware. */
+ MALI_VPU_FW_CODE_STREAM_NOT_SUPPORTED, /* Driver <- Firmware. */
+ MALI_VPU_FW_CODE_EVENT, /* Driver <- Firmware. */
MALI_VPU_FW_CODE_UNKNOWN, /* Driver <- Firmware. */
MALI_VPU_FW_CODE_MAX
};
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-protocol-def-v3.h b/drivers/media/platform/arm/mali-vpu/mali-vpu-protocol-def-v3.h
index 76dc7bf076c8f..3fe572b180d72 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-protocol-def-v3.h
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-protocol-def-v3.h
@@ -259,6 +259,8 @@ struct mve_msg_header {
#define MVE_RESPONSE_CODE_FRAME_ALLOC_PARAM (2014)
/* struct mve_response_sequence_parameters */
#define MVE_RESPONSE_CODE_SEQUENCE_PARAMETERS (2015)
+ /* struct mve_response_event (variable size) */
+ #define MVE_RESPONSE_CODE_EVENT (2016)
/* struct mve_response_set_option_fail */
#define MVE_RESPONSE_CODE_SET_OPTION_FAIL (2017)
@@ -440,6 +442,91 @@ struct mve_response_error {
char message[MVE_MAX_ERROR_MESSAGE_SIZE];
};
+/*
+ * Per-frame processing statistics emitted when firmware profiling is
+ * enabled.
+ */
+struct mve_event_processed {
+ u8 pic_format;
+ u8 qp;
+ u8 pad0;
+ u8 pad1;
+ u32 parse_start_time; /* Timestamp, absolute time */
+ u32 parse_end_time; /* Timestamp, absolute time */
+ u32 parse_idle_time; /* Waiting for in/out buffers or available RAM */
+ u32 pipe_start_time; /* Timestamp */
+ u32 pipe_end_time; /* Timestamp, end-start = process time. Idle time while in a frame
+ * is not measured.
+ */
+ u32 pipe_idle_time; /* Always 0 in decode, */
+ u32 parser_coreid; /* Core used to parse this frame */
+ u32 pipe_coreid; /* Core used to pipe this frame */
+ u32 bitstream_bits; /* Number of bitstream bits used for this frame. */
+ u32 intermediate_buffer_size; /* Size of intermediate (mbinfo/residuals) buffer after this
+ * frame was parsed.
+ */
+ u32 total_memory_allocated; /* after the frame was parsed. Including reference frames */
+ u32 bus_read_bytes; /* bus read bytes */
+ u32 bus_write_bytes; /* bus written bytes */
+ u32 afbc_bytes;
+ u32 slice0_end_time; /* Timestamp, absolute time */
+ u32 stream_start_time; /* Timestamp, absolute stream start time */
+ u32 stream_open_time; /* Timestamp, absolute stream open time */
+};
+
+/*
+ * Encoder reference-frame metadata emitted when reference-frame exposure
+ * is enabled.
+ */
+struct mve_event_ref_frame {
+ u32 ref_width; /* Width of display area in luma pixels */
+ u32 ref_height; /* Height of display area in luma pixels */
+ u32 ref_mb_width; /* Width in macroblocks */
+ u32 ref_mb_height; /* Height in macroblocks */
+ u32 ref_left_crop; /* Left crop in luma pixels */
+ u32 ref_top_crop; /* Top crop in luma pixels */
+ u32 ref_frame_size;
+ u32 ref_display_order;
+ u32 ref_addr;
+ u16 bit_width; /* bit width of the YUV either 8 or 10 */
+ u16 tiled_headers;
+};
+
+/*
+ * Trace-buffer allocations emitted by firmware build with event tracing
+ * enabled.
+ */
+struct mve_event_trace_buffers {
+ u16 reserved;
+ u8 num_cores;
+ u8 rasc_mask;
+ #define MVE_MAX_TRACE_BUFFERS 40
+ /* this array will contain one buffer per rasc in rasc_mask per num_core */
+ struct {
+ u32 rasc_addr; /* rasc address of the buffer */
+ u32 size; /* size of the buffer in bytes */
+ } buffers[MVE_MAX_TRACE_BUFFERS];
+};
+
+/*
+ * Firmware event response. Profiling and tracing events are informational,
+ * while stream-error events may require host action.
+ */
+struct mve_response_event {
+ u32 event_code;
+ #define MVE_EVENT_ERROR_STREAM_CORRUPT (1) /* message, text string */
+ #define MVE_EVENT_ERROR_STREAM_NOT_SUPPORTED (2) /* message, text string */
+ #define MVE_EVENT_PROCESSED (3) /* struct mve_event_processed */
+ #define MVE_EVENT_REF_FRAME (4) /* struct mve_event_ref_frame */
+ #define MVE_EVENT_TRACE_BUFFERS (5)
+ union {
+ struct mve_event_processed event_processed;
+ struct mve_event_ref_frame event_ref_frame;
+ struct mve_event_trace_buffers event_trace_buffers;
+ char message[MVE_MAX_ERROR_MESSAGE_SIZE];
+ } event_data;
+};
+
/*
* When a set-option succeeds, a confirmation message is
* sent, including the index-code for that particular option.
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-session.c b/drivers/media/platform/arm/mali-vpu/mali-vpu-session.c
index 411421e175e71..500d80788d0eb 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-session.c
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-session.c
@@ -584,6 +584,20 @@ static int mali_vpu_session_handle_fw_msg(struct mali_vpu_session *sess,
struct vb2_queue *dst_q;
u32 buffers_min;
+ if (fw_msg->data.seq_params.interlaced) {
+ dev_err(sess->vpu_dev->dev, "interlaced streams are not supported\n");
+ return -EOPNOTSUPP;
+ }
+
+ if (fw_msg->data.seq_params.bitdepth.luma != 8 ||
+ fw_msg->data.seq_params.bitdepth.chroma != 8) {
+ dev_err(sess->vpu_dev->dev,
+ "bitdepth luma=%u chroma=%u is not supported\n",
+ fw_msg->data.seq_params.bitdepth.luma,
+ fw_msg->data.seq_params.bitdepth.chroma);
+ return -EOPNOTSUPP;
+ }
+
buffers_min = fw_msg->data.seq_params.planar.buffers_min;
dst_q = v4l2_m2m_get_dst_vq(sess->m2m_ctx);
@@ -599,6 +613,11 @@ static int mali_vpu_session_handle_fw_msg(struct mali_vpu_session *sess,
return mali_vpu_session_fw_send_flush(sess, false);
}
+ case MALI_VPU_FW_CODE_STREAM_NOT_SUPPORTED:
+ return -EOPNOTSUPP;
+ case MALI_VPU_FW_CODE_EVENT:
+ /* No session action is required for informational events. */
+ return 0;
case MALI_VPU_FW_CODE_UNKNOWN:
case MALI_VPU_FW_CODE_MAX:
default:
--
2.43.0
next prev parent reply other threads:[~2026-11-19 15:39 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 15:37 [RFC PATCH 00/28] media: add arm Mali-V76 video decoder driver Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 01/28] dt-bindings: media: add Arm Mali-V76 VPU Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 02/28] media: mali-vpu: add Mali VPU platform driver Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 03/28] media: mali-vpu: register V4L2 decoder device and add querycap ioctl Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 04/28] media: mali-vpu: initialize decoder format state Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 05/28] media: mali-vpu: add V4L2 mem2mem and VB2 queue support Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 06/28] media: mali-vpu: implement format query ioctls Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 07/28] media: mali-vpu: implement TRY_FMT and S_FMT ioctls Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 08/28] media: mali-vpu: register V76 decoder controls and introduce UAPI controls Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 09/28] media: mali-vpu: add MMU software page table manager Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 10/28] media: mali-vpu: add firmware cache infrastructure Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 11/28] media: mali-vpu: load firmware for decoder sessions Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 12/28] media: mali-vpu: prepare firmware address space Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 13/28] media: mali-vpu: add firmware message transport Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 14/28] media: mali-vpu: route decoder controls to firmware Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 15/28] media: mali-vpu: handle firmware RPC requests Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 16/28] media: mali-vpu: add LSID hardware support Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 17/28] media: mali-vpu: add single session scheduler Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 18/28] media: mali-vpu: handle firmware interrupts Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 19/28] media: mali-vpu: start decoder firmware through LSID scheduling Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 20/28] media: mali-vpu: implement vb2 buffer queue handling Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 21/28] media: mali-vpu: handle firmware buffer exchange Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 22/28] media: mali-vpu: handle fatal firmware error Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 23/28] media: mali-vpu: propagate buffer metadata Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 24/28] media: mali-vpu: add decoder EOS and DRC handling Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 25/28] media: mali-vpu: handle firmware buffer parameters Charvi Mehta
2026-11-19 15:37 ` Charvi Mehta [this message]
2026-11-19 15:37 ` [RFC PATCH 27/28] media: mali-vpu: add stateful decoder state machine Charvi Mehta
2026-11-19 15:37 ` [RFC PATCH 28/28] media: MAINTAINERS: add Arm Mali-V76 VPU driver Charvi Mehta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119153758.1426673-27-charvi.mehta@arm.com \
--to=charvi.mehta@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=rath.sankaralingam@arm.com \
--cc=robh@kernel.org \
--cc=shobhit.pandey@arm.com \
--cc=vincenzo.frascino@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®