Re: [PATCH v5 08/19] accel: ethosu: Validate all feature map tiles
From: Tomeu Vizoso
Date: Sat Nov 28 2026 - 07:47:27 EST
Hi Rob,
On Fri, Nov 20, 2026 at 3:58 PM Rob Herring (Arm) <robh@xxxxxxxxxx> wrote:
>
> The command-stream validator checked only the final feature-map
> coordinate. For tiled tensors, this can leave an earlier tile base
> address unchecked even though the operation accesses it.
>
> Check the final coordinate of every tile touched by an operation. Also
> treat U65 feature maps as 2x2 tiled: its precision rounding bits are not
> the U85 storage encoding.
>
> Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Rob Herring (Arm) <robh@xxxxxxxxxx>
> ---
> v5:
> - No changes.
>
> v4:
> - NHCWB16 feature maps may be vertically tiled. Account for tile 0's
> maximum Y coordinate when calculating the feature map bounds.
>
> v3:
> - Fix for storage mode 0 intermediate tile calculations
>
> v2:
> - no changes
> ---
> drivers/accel/ethosu/ethosu_gem.c | 147 ++++++++++++++++++++++++++++++--------
> 1 file changed, 119 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/accel/ethosu/ethosu_gem.c b/drivers/accel/ethosu/ethosu_gem.c
> index 9a66d8439408..11f41382dc5d 100644
> --- a/drivers/accel/ethosu/ethosu_gem.c
> +++ b/drivers/accel/ethosu/ethosu_gem.c
> @@ -444,6 +444,96 @@ static u64 feat_matrix_length(struct ethosu_device *edev,
> return addr;
> }
>
> +static int feat_matrix_check_location(struct ethosu_device *edev,
> + struct ethosu_validated_cmdstream_info *info,
> + struct cmd_state *st, struct feat_matrix *fm,
> + enum feat_matrix_type type, u32 x, u32 y,
> + u32 c, bool ofm, u64 *max_len)
> +{
> + u64 len;
> +
> + len = feat_matrix_length(edev, info, st, fm, type, x, y, c, ofm);
> + if (len == U64_MAX)
> + return -EINVAL;
> +
> + *max_len = max(*max_len, len);
> + return 0;
> +}
> +
> +static int feat_matrix_size(struct ethosu_device *edev,
> + struct ethosu_validated_cmdstream_info *info,
> + struct cmd_state *st, struct feat_matrix *fm,
> + enum feat_matrix_type type,
> + u32 x, u32 y, u32 c, bool ofm, u64 *max_len)
> +{
> + u32 storage = ethosu_is_u65(edev) ? 0 : fm->precision >> 14;
Not something this patch introduces, but an OFM with storage none (3)
ends in the default case of feat_matrix_length() and is rejected. The
U85 TRM (3.6.5, write_ofm) allows it: nothing is written and the result
stays in the accumulator. Vela uses it when it splits an operator over
several operations. Could it be handled like chained storage?
Future optimizations in Mesa will need this fixed.
Thanks,
Tomeu