From: David Carlier <devnexen@gmail.com>
To: dan.scally@ideasonboard.com, jacopo.mondi@ideasonboard.com,
mchehab@kernel.org
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
David Carlier <devnexen@gmail.com>
Subject: [PATCH v2] media: mali-c55: Avoid unaligned access of AEC histogram zone weights
Date: Fri, 3 Jul 2026 17:35:06 +0100 [thread overview]
Message-ID: <20260703163506.715627-1-devnexen@gmail.com> (raw)
mali_c55_params_aexp_hist_weights() packs the 225 per-zone u8 weights
into the ISP registers four at a time by casting the zone_weights array
to u32 and dereferencing it. The array sits at offset 10 within the
parameter block, so it is only 2-byte aligned and the cast performs an
unaligned 32-bit read.
The Mali-C55 is only found on little-endian ARMv8 systems, where such an
access does not fault, so this is not a functional bug. Copy the four
bytes with memcpy() instead to avoid the unaligned access, which is a
little more efficient and drops the open-coded pointer cast.
No functional change intended.
Signed-off-by: David Carlier <devnexen@gmail.com>
---
v2:
- Use memcpy() instead of get_unaligned_le32() to copy the weights.
- Drop the Fixes: tag and Cc: stable; this is a cleanup, not a
functional fix (the IP is little-endian ARMv8 only, where the
unaligned access does not fault). Reword the commit message
accordingly.
drivers/media/platform/arm/mali-c55/mali-c55-params.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
index de0e9d898..832d8f49b 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
@@ -203,11 +203,11 @@ mali_c55_params_aexp_hist_weights(struct mali_c55 *mali_c55,
* of overwriting other registers.
*/
for (unsigned int i = 0; i < 56; i++) {
- val = ((u32 *)params->zone_weights)[i]
- & MALI_C55_AEXP_HIST_ZONE_WEIGHT_MASK;
+ memcpy(&val, ¶ms->zone_weights[4 * i], 4);
addr = base + MALI_C55_AEXP_HIST_ZONE_WEIGHTS_OFFSET + (4 * i);
- mali_c55_ctx_write(mali_c55, addr, val);
+ mali_c55_ctx_write(mali_c55, addr,
+ val & MALI_C55_AEXP_HIST_ZONE_WEIGHT_MASK);
}
val = params->zone_weights[MALI_C55_MAX_ZONES - 1];
--
2.53.0
reply other threads:[~2026-07-03 16:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260703163506.715627-1-devnexen@gmail.com \
--to=devnexen@gmail.com \
--cc=dan.scally@ideasonboard.com \
--cc=jacopo.mondi@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
/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