[PATCH v10 5/7] media: verisilicon: AV1: Restore IOMMU context before decoding a frame

Nicolas Dufresne nicolas.dufresne at collabora.com
Tue Jan 6 12:07:15 PST 2026


Hi,

Le lundi 15 décembre 2025 à 09:53 +0100, Benjamin Gaignard a écrit :
> AV1 is a stateless decoder which means multiple AV1 bitstreams could be
> decoded at the same time using the same hardware block. Before decoding
> a frame it is needed to restore the iommu tables to avoid mixing decode
> contexts.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard at collabora.com>

With the config fix you mentioned earlier, you can add my Rb in the next
revision please.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>

> ---
> changes in version 10:
> - Fix build as module issue when Verisilicon video decoder is built-in.
> 
>  drivers/media/platform/verisilicon/Kconfig        |  1 +
>  .../verisilicon/rockchip_vpu981_hw_av1_dec.c      | 15 +++++++++++++++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/media/platform/verisilicon/Kconfig b/drivers/media/platform/verisilicon/Kconfig
> index 3272a24db71d..e64bc8b55235 100644
> --- a/drivers/media/platform/verisilicon/Kconfig
> +++ b/drivers/media/platform/verisilicon/Kconfig
> @@ -49,6 +49,7 @@ config VIDEO_HANTRO_ROCKCHIP
>  	bool "Hantro VPU Rockchip support"
>  	depends on VIDEO_HANTRO
>  	depends on ARCH_ROCKCHIP || COMPILE_TEST
> +	select VSI_IOMMU
>  	default y
>  	help
>  	  Enable support for RK3288, RK3328, and RK3399 SoCs.
> diff --git a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> index e4703bb6be7c..d9e68e0ded68 100644
> --- a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> +++ b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> @@ -5,6 +5,9 @@
>   * Author: Benjamin Gaignard <benjamin.gaignard at collabora.com>
>   */
>  
> +#include <linux/iommu.h>
> +#include <linux/vsi-iommu.h>
> +
>  #include <media/v4l2-mem2mem.h>
>  #include "hantro.h"
>  #include "hantro_v4l2.h"
> @@ -2095,12 +2098,24 @@ rockchip_vpu981_av1_dec_set_output_buffer(struct hantro_ctx *ctx)
>  	hantro_write_addr(vpu, AV1_TILE_OUT_MV, mv_addr);
>  }
>  
> +static void rockchip_vpu981_av1_restore_iommu(struct hantro_ctx *ctx)
> +{
> +	struct iommu_domain *domain;
> +
> +	/* Before decoding any frame iommu context need to be restored */
> +	domain = iommu_get_domain_for_dev(ctx->dev->v4l2_dev.dev);
> +	if (domain)
> +		vsi_iommu_restore_ctx(domain);
> +}
> +
>  int rockchip_vpu981_av1_dec_run(struct hantro_ctx *ctx)
>  {
>  	struct hantro_dev *vpu = ctx->dev;
>  	struct vb2_v4l2_buffer *vb2_src;
>  	int ret;
>  
> +	rockchip_vpu981_av1_restore_iommu(ctx);
> +
>  	hantro_start_prepare_run(ctx);
>  
>  	ret = rockchip_vpu981_av1_dec_prepare_run(ctx);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20260106/38f8e299/attachment.sig>


More information about the linux-arm-kernel mailing list