Skip to contentSkip to conversation

media: verisilicon: AV1: Fix tile info buffer size

PATCH In review Benjamin Gaignard 2 participants 2 messages Jan 14 – Jan 18

Subsystems (3)
lore
Share & tools
lore

Benjamin Gaignard

author maintainer
#0 lore raw

PATCH 1/1 media: verisilicon: AV1: Fix tile info buffer size

Each tile info is composed of: row_sb, col_sb, start_pos and end_pos (4 bytes each). So the total required memory is AV1_MAX_TILES * 16 bytes.
Use the correct #define to allocate the buffer and avoid writing tile info in non-allocated memory.

Fixes 727a400686a2c ("media: verisilicon: Add Rockchip AV1 decoder")
---
 .../media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +2 -2
index e4703bb6be7c..af854b149f35 100644
@@ -373,12 +373,12 @@ int rockchip_vpu981_av1_dec_init(struct hantro_ctx *ctx)
 		return -ENOMEM;
 	av1_dec->global_model.size = GLOBAL_MODEL_SIZE;
 
-	av1_dec->tile_info.cpu = dma_alloc_coherent(vpu->dev, AV1_MAX_TILES,
+	av1_dec->tile_info.cpu = dma_alloc_coherent(vpu->dev, AV1_TILE_INFO_SIZE,
 						    &av1_dec->tile_info.dma,
 						    GFP_KERNEL);
 	if (!av1_dec->tile_info.cpu)
 		return -ENOMEM;
-	av1_dec->tile_info.size = AV1_MAX_TILES;
+	av1_dec->tile_info.size = AV1_TILE_INFO_SIZE;
 
 	av1_dec->film_grain.cpu = dma_alloc_coherent(vpu->dev,
 						     ALIGN(sizeof(struct rockchip_av1_film_grain), 2048),
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Le mercredi 14 janvier 2026 à 10:07 +0100, Benjamin Gaignard a écrit :

Quoted 26 lines

Each tile info is composed of: row_sb, col_sb, start_pos and end_pos (4 bytes each). So the total required memory is AV1_MAX_TILES * 16 bytes.
Use the correct #define to allocate the buffer and avoid writing tile info in non-allocated memory.

Fixes 727a400686a2c ("media: verisilicon: Add Rockchip AV1 decoder")

---
 .../media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c   | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +0 -0
index e4703bb6be7c..af854b149f35 100644
@@ -373,12 +373,12 @@ int rockchip_vpu981_av1_dec_init(struct hantro_ctx *ctx)
  		return -ENOMEM;
  	av1_dec->global_model.size = GLOBAL_MODEL_SIZE;

drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +1 -1
-	av1_dec->tile_info.cpu = dma_alloc_coherent(vpu->dev, AV1_MAX_TILES,
+	av1_dec->tile_info.cpu = dma_alloc_coherent(vpu->dev, AV1_TILE_INFO_SIZE,

      &av1_dec->tile_info.dma, GFP_KERNEL); if (!av1_dec->tile_info.cpu)
  return -ENOMEM;

drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c int rockchip_vpu981_av1_dec_init(struct hantro_ctx *ctx) · line 381

Quoted 2 lines
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +1 -1
-	av1_dec->tile_info.size = AV1_MAX_TILES;
+	av1_dec->tile_info.size = AV1_TILE_INFO_SIZE;

After checking the sizes, I can only conclude the we rarely have more then 8 tiles in our tests.

Quoted 3 lines


  av1_dec->film_grain.cpu = dma_alloc_coherent(vpu->dev,
       ALIGN(sizeof(struct rockchip_av1_film_grain), 2048),