From nobody Fri Sep 25 05:29:23 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C0543812FB; Wed, 16 Sep 2026 12:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563293; cv=none; b=lz60yLlftcGV1vhhOkoJVx33WStyNfkVTJwlV7psIbsOkbf4OZScOUR80SYTq59I1crAUMpvVmeYlsbgbVm4mjRR69kNWiWTGn2Tj4WJbztJdIwtYPjeAiRYeHnf194UJzmzpmFF2LVb6AdEMB1e5YWNIPrWnFM+J+nwSJP6DP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563293; c=relaxed/simple; bh=NQVqy4hE+EYQflOm/DmxGobFKmKFXpxdIAMwBlCuXFY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aT8NGSnP4GG8EDiQ4tsU9KmTo2tVWzI35xm/JKMi6vVYC+qgvWQXkUqflUjdCWp74qVAY6icruHOW16ILinaUNyFtjqPTGAe2pwL/nRrjPyAF8spcbo2mTbPNBQpSsEeNVCJkLWse90WinvwlRKpIcDtwSwgcOhjubGHNa/3jTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=X70Y/Pjm; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="X70Y/Pjm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789563289; bh=NQVqy4hE+EYQflOm/DmxGobFKmKFXpxdIAMwBlCuXFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X70Y/Pjmu6XmGEaxyMewbmGW/v6HiNjHdNWMN3VRrI1fMgbOghI2XK3KSh9PReAOD UWPAgScPWTGjFoNUsTZHJKP/Te9HcoWWRMZg18vqvMQ/gdM3YZIET2EdZwvz0jqYSi LmCTjuDGuSw7NkkTOoOPlurjN4HTt2vAa4tKQnH2pQOY5Pz/uBDowq5lr87WGr5dN7 3bEyNV02EvluaAvwVozhRvKbk7bB7laCkQdsUzxQl+hILXS32SVXQhh+soiSWa8W+h OBF71IgJrM1TjR/xeU9Bw40svIjM0qjECiOULvKrgdZqv8kd9LyT9L0znGrHkxdNsW sWVGMt6o+7lfA== Received: from benjamin-XPS-13-9310 (unknown [100.64.1.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bali.collaboradmins.com (Postfix) with ESMTPSA id 6513417E0C7E; Wed, 16 Sep 2026 14:54:49 +0200 (CEST) From: Benjamin Gaignard To: nicolas.dufresne@collabora.com, benjamin.gaignard@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 1/7] media: verisilicon: Add helpers to allocate and free auxiliary buffers Date: Wed, 16 Sep 2026 14:54:37 +0200 Message-ID: <20260916125443.78602-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916125443.78602-1-benjamin.gaignard@collabora.com> References: <20260916125443.78602-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add helpers functions to allocate and free the auxiliary buffers. That simplify the code and make it more easy to read and maintain. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro.h | 4 +++ .../platform/verisilicon/hantro_postproc.c | 21 ++--------- .../media/platform/verisilicon/hantro_v4l2.c | 35 +++++++++++++++++++ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/pl= atform/verisilicon/hantro.h index 0353de154a1e..f2f02522a543 100644 --- a/drivers/media/platform/verisilicon/hantro.h +++ b/drivers/media/platform/verisilicon/hantro.h @@ -507,4 +507,8 @@ void hantro_postproc_free(struct hantro_ctx *ctx); int hanto_postproc_enum_framesizes(struct hantro_ctx *ctx, struct v4l2_frmsizeenum *fsize); =20 +int hantro_allocate_aux_buf(struct hantro_ctx *ctx, struct hantro_aux_buf = *aux_buf, + size_t size); +void hantro_free_aux_buf(struct hantro_ctx *ctx, struct hantro_aux_buf *au= x_buf); + #endif /* HANTRO_H_ */ diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers= /media/platform/verisilicon/hantro_postproc.c index e94d1ba5ef10..3e202076bd2f 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -180,7 +180,6 @@ static int hantro_postproc_g2_enum_framesizes(struct ha= ntro_ctx *ctx, =20 void hantro_postproc_free(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct v4l2_m2m_ctx *m2m_ctx =3D ctx->fh.m2m_ctx; struct vb2_queue *queue =3D &m2m_ctx->cap_q_ctx.q; unsigned int i; @@ -188,11 +187,7 @@ void hantro_postproc_free(struct hantro_ctx *ctx) for (i =3D 0; i < queue->max_num_buffers; ++i) { struct hantro_aux_buf *priv =3D &ctx->postproc.dec_q[i]; =20 - if (priv->cpu) { - dma_free_attrs(vpu->dev, priv->size, priv->cpu, - priv->dma, priv->attrs); - priv->cpu =3D NULL; - } + hantro_free_aux_buf(ctx, priv); } } =20 @@ -223,7 +218,6 @@ static unsigned int hantro_postproc_buffer_size(struct = hantro_ctx *ctx) =20 static int hantro_postproc_alloc(struct hantro_ctx *ctx, int index) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_aux_buf *priv =3D &ctx->postproc.dec_q[index]; unsigned int buf_size =3D hantro_postproc_buffer_size(ctx); =20 @@ -235,13 +229,7 @@ static int hantro_postproc_alloc(struct hantro_ctx *ct= x, int index) * buffers for the decoder, so no mapping is needed. */ priv->attrs =3D DMA_ATTR_NO_KERNEL_MAPPING; - priv->cpu =3D dma_alloc_attrs(vpu->dev, buf_size, &priv->dma, - GFP_KERNEL, priv->attrs); - if (!priv->cpu) - return -ENOMEM; - priv->size =3D buf_size; - - return 0; + return hantro_allocate_aux_buf(ctx, priv, buf_size); } =20 int hantro_postproc_init(struct hantro_ctx *ctx) @@ -268,14 +256,11 @@ hantro_postproc_get_dec_buf_addr(struct hantro_ctx *c= tx, int index) { struct hantro_aux_buf *priv =3D &ctx->postproc.dec_q[index]; unsigned int buf_size =3D hantro_postproc_buffer_size(ctx); - struct hantro_dev *vpu =3D ctx->dev; int ret; =20 if (priv->size < buf_size && priv->cpu) { /* buffer is too small, release it */ - dma_free_attrs(vpu->dev, priv->size, priv->cpu, - priv->dma, priv->attrs); - priv->cpu =3D NULL; + hantro_free_aux_buf(ctx, priv); } =20 if (!priv->cpu) { diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/med= ia/platform/verisilicon/hantro_v4l2.c index 83af9fa1ce94..ec12950a1ae1 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -1029,3 +1029,38 @@ const struct vb2_ops hantro_queue_ops =3D { .start_streaming =3D hantro_start_streaming, .stop_streaming =3D hantro_stop_streaming, }; + +int hantro_allocate_aux_buf(struct hantro_ctx *ctx, struct hantro_aux_buf = *aux_buf, + size_t size) +{ + struct hantro_dev *vpu =3D ctx->dev; + + if (!aux_buf || !ctx || !size) + return -EINVAL; + + aux_buf->cpu =3D dma_alloc_attrs(vpu->dev, size, + &aux_buf->dma, + GFP_KERNEL, + aux_buf->attrs); + if (!aux_buf->cpu) + return -ENOMEM; + + aux_buf->size =3D size; + + return 0; +} + +void hantro_free_aux_buf(struct hantro_ctx *ctx, struct hantro_aux_buf *au= x_buf) +{ + struct hantro_dev *vpu =3D ctx->dev; + + if (!aux_buf || !ctx) + return; + + if (aux_buf->cpu) + dma_free_attrs(vpu->dev, aux_buf->size, + aux_buf->cpu, aux_buf->dma, + aux_buf->attrs); + aux_buf->cpu =3D NULL; + aux_buf->size =3D 0; +} --=20 2.53.0 From nobody Fri Sep 25 05:29:23 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD1913815C3; Wed, 16 Sep 2026 12:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563295; cv=none; b=g24LH1OCOcHUt4dsLUk+TISNpS/XabEz/xqsIpv2adw8bYqt9pC/W/36UEXMaDG8MK/FDEzOnanq2uabRj3BjTrvQm/aj2GWg5XtET4vO5lIvRXUUAjLJCQzbU3e0YViaUgGgNj/i7MlM1zGLFpRssYnejvA2Kxg9y8rDhaRVJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563295; c=relaxed/simple; bh=024vXHBL3M4Nza6LGz1p+RSiowISrkhNEPP+TzTqIUU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=So7qzRCK5MccylW8mX6o8AwR6AJcN6nujOawCBtrEbtBWMsuzN6rP4cRCvfqh1qXpv9IQfP8CnVAOH+PLCcMSWBWf7F/Uf8qIQ8TsNtexoSNOUH4iiVJRfpuYFMFH1820PsRbjNVY5461C2DNhtqxPW8VRMeWptWQZt2YKuTikU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=BjNh4kyK; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="BjNh4kyK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789563290; bh=024vXHBL3M4Nza6LGz1p+RSiowISrkhNEPP+TzTqIUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BjNh4kyKv2bWwfoYAxCrmXnDEjpt0ID9cNVrNrteimR3Wc9wrRwZk0xsBJr8jBYfz qtaOc9mMnARoudVijGVcF7t59YP7qR2vJiL2nTn6tuYFO9ybGWZT8/3Go3WJVHEAwa ZByZ2wZ/j0DEgnIY2Is8d01/sSgVwtw5NaBenUOMjQhocrJi/CPvEg1hKznVfM468b iBW3OlkN7leGGkRj3QNMeaR2qR9Il/ho/Qt8WzOkVDX+X0EgMN01eGNmtaqlAUsh5H NKfvBrUn5PIhXDwisGwezHc2cjl6utj5eQr2QfBI/Z5NgPeTME3T9+hEta++sd/Lxq oAderI16sN1OQ== Received: from benjamin-XPS-13-9310 (unknown [100.64.1.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bali.collaboradmins.com (Postfix) with ESMTPSA id BFCAC17E1289; Wed, 16 Sep 2026 14:54:49 +0200 (CEST) From: Benjamin Gaignard To: nicolas.dufresne@collabora.com, benjamin.gaignard@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 2/7] media: verisilicon: AV1: Use alloc/free helpers for auxiliary buffers Date: Wed, 16 Sep 2026 14:54:38 +0200 Message-ID: <20260916125443.78602-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916125443.78602-1-benjamin.gaignard@collabora.com> References: <20260916125443.78602-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify and clean up the code by using the helpers. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_av1.c | 177 ++++-------------- 1 file changed, 39 insertions(+), 138 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_av1.c b/drivers/medi= a/platform/verisilicon/hantro_av1.c index 2cde32f0e935..e05816c7dfa3 100644 --- a/drivers/media/platform/verisilicon/hantro_av1.c +++ b/drivers/media/platform/verisilicon/hantro_av1.c @@ -235,40 +235,17 @@ size_t hantro_av1_chroma_size(struct hantro_ctx *ctx) =20 static void hantro_av1_tiles_free(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_av1_dec_hw_ctx *av1_dec =3D &ctx->av1_dec; =20 - if (av1_dec->db_data_col.cpu) - dma_free_coherent(vpu->dev, av1_dec->db_data_col.size, - av1_dec->db_data_col.cpu, - av1_dec->db_data_col.dma); - av1_dec->db_data_col.cpu =3D NULL; - - if (av1_dec->db_ctrl_col.cpu) - dma_free_coherent(vpu->dev, av1_dec->db_ctrl_col.size, - av1_dec->db_ctrl_col.cpu, - av1_dec->db_ctrl_col.dma); - av1_dec->db_ctrl_col.cpu =3D NULL; - - if (av1_dec->cdef_col.cpu) - dma_free_coherent(vpu->dev, av1_dec->cdef_col.size, - av1_dec->cdef_col.cpu, av1_dec->cdef_col.dma); - av1_dec->cdef_col.cpu =3D NULL; - - if (av1_dec->sr_col.cpu) - dma_free_coherent(vpu->dev, av1_dec->sr_col.size, - av1_dec->sr_col.cpu, av1_dec->sr_col.dma); - av1_dec->sr_col.cpu =3D NULL; - - if (av1_dec->lr_col.cpu) - dma_free_coherent(vpu->dev, av1_dec->lr_col.size, - av1_dec->lr_col.cpu, av1_dec->lr_col.dma); - av1_dec->lr_col.cpu =3D NULL; + hantro_free_aux_buf(ctx, &av1_dec->db_data_col); + hantro_free_aux_buf(ctx, &av1_dec->db_ctrl_col); + hantro_free_aux_buf(ctx, &av1_dec->cdef_col); + hantro_free_aux_buf(ctx, &av1_dec->sr_col); + hantro_free_aux_buf(ctx, &av1_dec->lr_col); } =20 static int hantro_av1_tiles_reallocate(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_av1_dec_hw_ctx *av1_dec =3D &ctx->av1_dec; struct hantro_av1_dec_ctrls *ctrls =3D &av1_dec->ctrls; const struct v4l2_av1_tile_info *tile_info =3D &ctrls->frame->tile_info; @@ -277,6 +254,7 @@ static int hantro_av1_tiles_reallocate(struct hantro_ct= x *ctx) unsigned int height_in_sb =3D height / 64; unsigned int stripe_num =3D ((height + 8) + 63) / 64; size_t size; + int ret; =20 if (av1_dec->db_data_col.size >=3D ALIGN(height * 12 * ctx->bit_depth / 8, 128) * num_tile_cols) @@ -285,44 +263,22 @@ static int hantro_av1_tiles_reallocate(struct hantro_= ctx *ctx) hantro_av1_tiles_free(ctx); =20 size =3D ALIGN(height * 12 * ctx->bit_depth / 8, 128) * num_tile_cols; - av1_dec->db_data_col.cpu =3D dma_alloc_coherent(vpu->dev, size, - &av1_dec->db_data_col.dma, - GFP_KERNEL); - if (!av1_dec->db_data_col.cpu) - goto buffer_allocation_error; - av1_dec->db_data_col.size =3D size; + ret =3D hantro_allocate_aux_buf(ctx, &av1_dec->db_data_col, size); =20 size =3D ALIGN(height * 2 * 16 / 4, 128) * num_tile_cols; - av1_dec->db_ctrl_col.cpu =3D dma_alloc_coherent(vpu->dev, size, - &av1_dec->db_ctrl_col.dma, - GFP_KERNEL); - if (!av1_dec->db_ctrl_col.cpu) - goto buffer_allocation_error; - av1_dec->db_ctrl_col.size =3D size; + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->db_ctrl_col, size); =20 size =3D ALIGN(height_in_sb * 44 * ctx->bit_depth * 16 / 8, 128) * num_ti= le_cols; - av1_dec->cdef_col.cpu =3D dma_alloc_coherent(vpu->dev, size, - &av1_dec->cdef_col.dma, - GFP_KERNEL); - if (!av1_dec->cdef_col.cpu) - goto buffer_allocation_error; - av1_dec->cdef_col.size =3D size; + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->cdef_col, size); =20 size =3D ALIGN(height_in_sb * (3040 + 1280), 128) * num_tile_cols; - av1_dec->sr_col.cpu =3D dma_alloc_coherent(vpu->dev, size, - &av1_dec->sr_col.dma, - GFP_KERNEL); - if (!av1_dec->sr_col.cpu) - goto buffer_allocation_error; - av1_dec->sr_col.size =3D size; + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->sr_col, size); =20 size =3D ALIGN(stripe_num * 1536 * ctx->bit_depth / 8, 128) * num_tile_co= ls; - av1_dec->lr_col.cpu =3D dma_alloc_coherent(vpu->dev, size, - &av1_dec->lr_col.dma, - GFP_KERNEL); - if (!av1_dec->lr_col.cpu) + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->lr_col, size); + + if (ret) goto buffer_allocation_error; - av1_dec->lr_col.size =3D size; =20 av1_dec->num_tile_cols_allocated =3D num_tile_cols; return 0; @@ -334,105 +290,50 @@ static int hantro_av1_tiles_reallocate(struct hantro= _ctx *ctx) =20 void hantro_av1_exit(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_av1_dec_hw_ctx *av1_dec =3D &ctx->av1_dec; =20 - if (av1_dec->global_model.cpu) - dma_free_coherent(vpu->dev, av1_dec->global_model.size, - av1_dec->global_model.cpu, - av1_dec->global_model.dma); - av1_dec->global_model.cpu =3D NULL; - - if (av1_dec->tile_info.cpu) - dma_free_coherent(vpu->dev, av1_dec->tile_info.size, - av1_dec->tile_info.cpu, - av1_dec->tile_info.dma); - av1_dec->tile_info.cpu =3D NULL; - - if (av1_dec->film_grain.cpu) - dma_free_coherent(vpu->dev, av1_dec->film_grain.size, - av1_dec->film_grain.cpu, - av1_dec->film_grain.dma); - av1_dec->film_grain.cpu =3D NULL; - - if (av1_dec->prob_tbl.cpu) - dma_free_coherent(vpu->dev, av1_dec->prob_tbl.size, - av1_dec->prob_tbl.cpu, av1_dec->prob_tbl.dma); - av1_dec->prob_tbl.cpu =3D NULL; - - if (av1_dec->prob_tbl_out.cpu) - dma_free_coherent(vpu->dev, av1_dec->prob_tbl_out.size, - av1_dec->prob_tbl_out.cpu, - av1_dec->prob_tbl_out.dma); - av1_dec->prob_tbl_out.cpu =3D NULL; - - if (av1_dec->tile_buf.cpu) - dma_free_coherent(vpu->dev, av1_dec->tile_buf.size, - av1_dec->tile_buf.cpu, av1_dec->tile_buf.dma); - av1_dec->tile_buf.cpu =3D NULL; + hantro_free_aux_buf(ctx, &av1_dec->global_model); + hantro_free_aux_buf(ctx, &av1_dec->tile_info); + hantro_free_aux_buf(ctx, &av1_dec->film_grain); + hantro_free_aux_buf(ctx, &av1_dec->prob_tbl); + hantro_free_aux_buf(ctx, &av1_dec->prob_tbl_out); =20 hantro_av1_tiles_free(ctx); } =20 int hantro_av1_init(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_av1_dec_hw_ctx *av1_dec =3D &ctx->av1_dec; + int ret =3D 0; =20 memset(av1_dec, 0, sizeof(*av1_dec)); =20 - av1_dec->global_model.cpu =3D dma_alloc_coherent(vpu->dev, GLOBAL_MODEL_S= IZE, - &av1_dec->global_model.dma, - GFP_KERNEL); - if (!av1_dec->global_model.cpu) - return -ENOMEM; - av1_dec->global_model.size =3D GLOBAL_MODEL_SIZE; - - av1_dec->tile_info.cpu =3D dma_alloc_coherent(vpu->dev, AV1_TILE_INFO_SIZ= E, - &av1_dec->tile_info.dma, - GFP_KERNEL); - if (!av1_dec->tile_info.cpu) - return -ENOMEM; - av1_dec->tile_info.size =3D AV1_TILE_INFO_SIZE; - - av1_dec->film_grain.cpu =3D dma_alloc_coherent(vpu->dev, - ALIGN(sizeof(struct hantro_av1_film_grain), - 2048), - &av1_dec->film_grain.dma, - GFP_KERNEL); - if (!av1_dec->film_grain.cpu) - return -ENOMEM; - av1_dec->film_grain.size =3D ALIGN(sizeof(struct hantro_av1_film_grain), = 2048); - - av1_dec->prob_tbl.cpu =3D dma_alloc_coherent(vpu->dev, - ALIGN(sizeof(struct av1cdfs), 2048), - &av1_dec->prob_tbl.dma, - GFP_KERNEL); - if (!av1_dec->prob_tbl.cpu) - return -ENOMEM; - av1_dec->prob_tbl.size =3D ALIGN(sizeof(struct av1cdfs), 2048); - - av1_dec->prob_tbl_out.cpu =3D dma_alloc_coherent(vpu->dev, - ALIGN(sizeof(struct av1cdfs), 2048), - &av1_dec->prob_tbl_out.dma, - GFP_KERNEL); - if (!av1_dec->prob_tbl_out.cpu) - return -ENOMEM; - av1_dec->prob_tbl_out.size =3D ALIGN(sizeof(struct av1cdfs), 2048); + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->global_model, GLOBAL_MODE= L_SIZE); + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->tile_info, AV1_TILE_INFO_= SIZE); + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->film_grain, + ALIGN(sizeof(struct hantro_av1_film_grain), 2048)); + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->prob_tbl, + ALIGN(sizeof(struct av1cdfs), 2048)); + ret |=3D hantro_allocate_aux_buf(ctx, &av1_dec->prob_tbl_out, + ALIGN(sizeof(struct av1cdfs), 2048)); + if (ret) + goto buffer_allocation_error; + av1_dec->cdfs =3D &av1_dec->default_cdfs; av1_dec->cdfs_ndvc =3D &av1_dec->default_cdfs_ndvc; =20 hantro_av1_set_default_cdfs(av1_dec->cdfs, av1_dec->cdfs_ndvc); =20 - av1_dec->tile_buf.cpu =3D dma_alloc_coherent(vpu->dev, - AV1_TILE_SIZE, - &av1_dec->tile_buf.dma, - GFP_KERNEL); - if (!av1_dec->tile_buf.cpu) - return -ENOMEM; - av1_dec->tile_buf.size =3D AV1_TILE_SIZE; - return 0; + +buffer_allocation_error: + hantro_free_aux_buf(ctx, &av1_dec->global_model); + hantro_free_aux_buf(ctx, &av1_dec->tile_info); + hantro_free_aux_buf(ctx, &av1_dec->film_grain); + hantro_free_aux_buf(ctx, &av1_dec->prob_tbl); + hantro_free_aux_buf(ctx, &av1_dec->prob_tbl_out); + + return -ENOMEM; } =20 int hantro_av1_prepare_run(struct hantro_ctx *ctx) --=20 2.53.0 From nobody Fri Sep 25 05:29:23 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52C2537DAD7; Wed, 16 Sep 2026 12:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563294; cv=none; b=XiZGXDbPjksvK2sgUyOxY0cXVmBbkLGVF0fyyBhfZ7jfzqGJRfIJ16lokefbjE+740QGDHqHxvvQ3xmx3MldGrvMDkaXBHPIbRc9438QpgbK5cMjUgIKMD/ZElHEPk8wZ34WmiXH1aZuUfmz0S45IB1XfPrNarOEIbybnu9bYFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563294; c=relaxed/simple; bh=qUx4hsf6eU4bj1x64ZWHjM8moLvtJhuV3tVMfQYaZOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QWfvjmt1z0Na77TJWOyxEt+vuqWpN42oIZSRAM46zOkE0Qd19RYEm0/Lha9H61EcPuKPUQfOsZtmZcz0lItrddZ2MEQbhXDyeMPg2nbHZlLckcrIMd/lAAmlPq75hNXm/ghGbEIHlRdZ8MilfXSBxBZQg1u2dP1RsOJmaPJQglA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=NqoAekRt; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="NqoAekRt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789563290; bh=qUx4hsf6eU4bj1x64ZWHjM8moLvtJhuV3tVMfQYaZOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NqoAekRtgVNCDR3hKlL17SGzg9fGWjHvpIFWQftUc0zvHPv6M6t6Y4KQAfkw/IPfT nzG0OzfozDMQsJXRxD8+ouZUvN4RDSWDXgvB5SV6V6rrZq10fX7nrZYtCEDoxhITwR yj0GIPFQ612JROA33/95ei7siYtiizW+1ae8aIGlGCvZbvzzDG9ylhKM+OQawS3MqT 7bPMSkjgDWWq/lWseZtnZVaSeMR1ek2QCfWqTLBmuCRUkfGSZ9tcsflvl+5sYfQ2y0 QPaXOj3j8Kofjy8tOcvE1GRfy5V5i5QWeyd/SFQrRr3YYcG0ftMIZ0xSEVOqvw3e3a BRAkFTdZkv6FA== Received: from benjamin-XPS-13-9310 (unknown [100.64.1.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bali.collaboradmins.com (Postfix) with ESMTPSA id 2329917E12B9; Wed, 16 Sep 2026 14:54:50 +0200 (CEST) From: Benjamin Gaignard To: nicolas.dufresne@collabora.com, benjamin.gaignard@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 3/7] media: verisilicon: h264: Use alloc/free helpers for auxiliary buffers Date: Wed, 16 Sep 2026 14:54:39 +0200 Message-ID: <20260916125443.78602-4-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916125443.78602-1-benjamin.gaignard@collabora.com> References: <20260916125443.78602-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify and clean up the code by using the helpers. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro_h264.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_h264.c b/drivers/med= ia/platform/verisilicon/hantro_h264.c index 2414782f1eb6..68dde1cd1ac2 100644 --- a/drivers/media/platform/verisilicon/hantro_h264.c +++ b/drivers/media/platform/verisilicon/hantro_h264.c @@ -494,26 +494,21 @@ int hantro_h264_dec_prepare_run(struct hantro_ctx *ct= x) =20 void hantro_h264_dec_exit(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_h264_dec_hw_ctx *h264_dec =3D &ctx->h264_dec; struct hantro_aux_buf *priv =3D &h264_dec->priv; =20 - dma_free_coherent(vpu->dev, priv->size, priv->cpu, priv->dma); + hantro_free_aux_buf(ctx, priv); } =20 int hantro_h264_dec_init(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_h264_dec_hw_ctx *h264_dec =3D &ctx->h264_dec; struct hantro_aux_buf *priv =3D &h264_dec->priv; struct hantro_h264_dec_priv_tbl *tbl; =20 - priv->cpu =3D dma_alloc_coherent(vpu->dev, sizeof(*tbl), &priv->dma, - GFP_KERNEL); - if (!priv->cpu) + if (hantro_allocate_aux_buf(ctx, priv, sizeof(*tbl))) return -ENOMEM; =20 - priv->size =3D sizeof(*tbl); tbl =3D priv->cpu; memcpy(tbl->cabac_table, h264_cabac_table, sizeof(tbl->cabac_table)); =20 --=20 2.53.0 From nobody Fri Sep 25 05:29:23 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B3EB354AE3; Wed, 16 Sep 2026 12:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563294; cv=none; b=heWDpo+U5peEKX41LXDl8Lr9yyNO0n8Ed98jy2+ScJAavs3r+cRgd7n6xIZzRH6iF42RzpjLXlaYMK543GKg/zu6giXsto4ZAOmDn7OVEloV9HfW6Lp3Go+v80YNs94sq3y/s75Xf86Iuv8hzUwe6nIO+nLPPGiuDrGx0dpXzZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563294; c=relaxed/simple; bh=LvhiMCoVTpSz165Ay1Y3k9yppYJjXIMP9WfM997Eh84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nn30Q6SsXB/mF1NQCjRckjfoI+/0RfV2/UJhTOIZOmao6EHsaXCN/m6GjpyCVnItTLgH2NisfT7IexRh9c/Vrnf4fpp/RkacqxaUgHDvSEUa59Vv303d3F5EJNNJnL1fARmDpwNJXePmRnaDe6GrZxvdsOAOQW+FtS7woYEyGdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=cxrFLu0s; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="cxrFLu0s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789563290; bh=LvhiMCoVTpSz165Ay1Y3k9yppYJjXIMP9WfM997Eh84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cxrFLu0sUxBJeDsdhFOeYO1aD7qcebeiYCEuaa1fVkeECqJnyCMCkOMRG8BXZ+5rI rLG0l0zBmJP/wIsN4kRsCt0RlWdreNjkaCgCi6eUrZZu0iPhWfzyO9f9VUz6GyjPCZ 1d1/jCZZYHMNuZqPiycZ2tUkRZg1K48LeA2GjS1fKSHwNt3hLujb77SS/ulfu9mEx+ QbJTs5xcXRYqdKijA+Ohnmy3hc+/69nunnmWlsuuM8kKwGXFuK2CAL8WXClhhcOw1L lJt0KTdrnnXMxXYNrPDjeCD1h2LJoXQiJSRRkHvnQRaK1DtQyqDkmQzA27+an98w3Q kEwZon+Fyr8OQ== Received: from benjamin-XPS-13-9310 (unknown [100.64.1.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bali.collaboradmins.com (Postfix) with ESMTPSA id 7C3F617E130A; Wed, 16 Sep 2026 14:54:50 +0200 (CEST) From: Benjamin Gaignard To: nicolas.dufresne@collabora.com, benjamin.gaignard@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 4/7] media: verisilicon: hevc: Use alloc/free helpers for auxiliary buffers Date: Wed, 16 Sep 2026 14:54:40 +0200 Message-ID: <20260916125443.78602-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916125443.78602-1-benjamin.gaignard@collabora.com> References: <20260916125443.78602-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify and clean up the code by using the helpers. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_hevc.c | 130 +++++------------- 1 file changed, 33 insertions(+), 97 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_hevc.c b/drivers/med= ia/platform/verisilicon/hantro_hevc.c index 83cd12b0ddd6..cc6fa233c0a0 100644 --- a/drivers/media/platform/verisilicon/hantro_hevc.c +++ b/drivers/media/platform/verisilicon/hantro_hevc.c @@ -74,7 +74,6 @@ int hantro_hevc_add_ref_buf(struct hantro_ctx *ctx, int p= oc, dma_addr_t addr) =20 static int tile_buffer_reallocate(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_hevc_dec_hw_ctx *hevc_dec =3D &ctx->hevc_dec; const struct hantro_hevc_dec_ctrls *ctrls =3D &ctx->hevc_dec.ctrls; const struct v4l2_ctrl_hevc_pps *pps =3D ctrls->pps; @@ -82,74 +81,40 @@ static int tile_buffer_reallocate(struct hantro_ctx *ct= x) unsigned int num_tile_cols =3D pps->num_tile_columns_minus1 + 1; unsigned int height64 =3D (sps->pic_height_in_luma_samples + 63) & ~63; unsigned int size; + int ret; =20 if (num_tile_cols <=3D 1 || num_tile_cols <=3D hevc_dec->num_tile_cols_allocated) return 0; =20 /* Need to reallocate due to tiles passed via PPS */ - if (hevc_dec->tile_filter.cpu) { - dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size, - hevc_dec->tile_filter.cpu, - hevc_dec->tile_filter.dma); - hevc_dec->tile_filter.cpu =3D NULL; - } - - if (hevc_dec->tile_sao.cpu) { - dma_free_coherent(vpu->dev, hevc_dec->tile_sao.size, - hevc_dec->tile_sao.cpu, - hevc_dec->tile_sao.dma); - hevc_dec->tile_sao.cpu =3D NULL; - } - - if (hevc_dec->tile_bsd.cpu) { - dma_free_coherent(vpu->dev, hevc_dec->tile_bsd.size, - hevc_dec->tile_bsd.cpu, - hevc_dec->tile_bsd.dma); - hevc_dec->tile_bsd.cpu =3D NULL; - } + hantro_free_aux_buf(ctx, &hevc_dec->tile_filter); + hantro_free_aux_buf(ctx, &hevc_dec->tile_sao); + hantro_free_aux_buf(ctx, &hevc_dec->tile_bsd); =20 size =3D (VERT_FILTER_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bi= t_depth) / 8; - hevc_dec->tile_filter.cpu =3D dma_alloc_coherent(vpu->dev, size, - &hevc_dec->tile_filter.dma, - GFP_KERNEL); - if (!hevc_dec->tile_filter.cpu) - return -ENOMEM; - hevc_dec->tile_filter.size =3D size; + hevc_dec->tile_filter.attrs =3D DMA_ATTR_NO_KERNEL_MAPPING; + ret =3D hantro_allocate_aux_buf(ctx, &hevc_dec->tile_filter, size); =20 size =3D (VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_d= epth) / 8; - hevc_dec->tile_sao.cpu =3D dma_alloc_coherent(vpu->dev, size, - &hevc_dec->tile_sao.dma, - GFP_KERNEL); - if (!hevc_dec->tile_sao.cpu) - goto err_free_tile_buffers; - hevc_dec->tile_sao.size =3D size; + hevc_dec->tile_sao.attrs =3D DMA_ATTR_NO_KERNEL_MAPPING; + ret |=3D hantro_allocate_aux_buf(ctx, &hevc_dec->tile_sao, size); =20 size =3D BSD_CTRL_RAM_SIZE * height64 * (num_tile_cols - 1); - hevc_dec->tile_bsd.cpu =3D dma_alloc_coherent(vpu->dev, size, - &hevc_dec->tile_bsd.dma, - GFP_KERNEL); - if (!hevc_dec->tile_bsd.cpu) - goto err_free_sao_buffers; - hevc_dec->tile_bsd.size =3D size; + hevc_dec->tile_bsd.attrs =3D DMA_ATTR_NO_KERNEL_MAPPING; + ret |=3D hantro_allocate_aux_buf(ctx, &hevc_dec->tile_bsd, size); + + if (ret) + goto error; =20 hevc_dec->num_tile_cols_allocated =3D num_tile_cols; =20 return 0; =20 -err_free_sao_buffers: - if (hevc_dec->tile_sao.cpu) - dma_free_coherent(vpu->dev, hevc_dec->tile_sao.size, - hevc_dec->tile_sao.cpu, - hevc_dec->tile_sao.dma); - hevc_dec->tile_sao.cpu =3D NULL; - -err_free_tile_buffers: - if (hevc_dec->tile_filter.cpu) - dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size, - hevc_dec->tile_filter.cpu, - hevc_dec->tile_filter.dma); - hevc_dec->tile_filter.cpu =3D NULL; +error: + hantro_free_aux_buf(ctx, &hevc_dec->tile_filter); + hantro_free_aux_buf(ctx, &hevc_dec->tile_sao); + hantro_free_aux_buf(ctx, &hevc_dec->tile_bsd); =20 return -ENOMEM; } @@ -214,45 +179,20 @@ int hantro_hevc_dec_prepare_run(struct hantro_ctx *ct= x) =20 void hantro_hevc_dec_exit(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_hevc_dec_hw_ctx *hevc_dec =3D &ctx->hevc_dec; =20 - if (hevc_dec->tile_sizes.cpu) - dma_free_coherent(vpu->dev, hevc_dec->tile_sizes.size, - hevc_dec->tile_sizes.cpu, - hevc_dec->tile_sizes.dma); - hevc_dec->tile_sizes.cpu =3D NULL; - - if (hevc_dec->scaling_lists.cpu) - dma_free_coherent(vpu->dev, hevc_dec->scaling_lists.size, - hevc_dec->scaling_lists.cpu, - hevc_dec->scaling_lists.dma); - hevc_dec->scaling_lists.cpu =3D NULL; - - if (hevc_dec->tile_filter.cpu) - dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size, - hevc_dec->tile_filter.cpu, - hevc_dec->tile_filter.dma); - hevc_dec->tile_filter.cpu =3D NULL; - - if (hevc_dec->tile_sao.cpu) - dma_free_coherent(vpu->dev, hevc_dec->tile_sao.size, - hevc_dec->tile_sao.cpu, - hevc_dec->tile_sao.dma); - hevc_dec->tile_sao.cpu =3D NULL; - - if (hevc_dec->tile_bsd.cpu) - dma_free_coherent(vpu->dev, hevc_dec->tile_bsd.size, - hevc_dec->tile_bsd.cpu, - hevc_dec->tile_bsd.dma); - hevc_dec->tile_bsd.cpu =3D NULL; + hantro_free_aux_buf(ctx, &hevc_dec->tile_sizes); + hantro_free_aux_buf(ctx, &hevc_dec->scaling_lists); + hantro_free_aux_buf(ctx, &hevc_dec->tile_filter); + hantro_free_aux_buf(ctx, &hevc_dec->tile_sao); + hantro_free_aux_buf(ctx, &hevc_dec->tile_bsd); } =20 int hantro_hevc_dec_init(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_hevc_dec_hw_ctx *hevc_dec =3D &ctx->hevc_dec; unsigned int size; + int ret; =20 memset(hevc_dec, 0, sizeof(*hevc_dec)); =20 @@ -262,21 +202,11 @@ int hantro_hevc_dec_init(struct hantro_ctx *ctx) * chunk (HW guys wanted to have this). */ size =3D round_up(MAX_TILE_COLS * MAX_TILE_ROWS * 4 * sizeof(u16) + 16, 1= 6); - hevc_dec->tile_sizes.cpu =3D dma_alloc_coherent(vpu->dev, size, - &hevc_dec->tile_sizes.dma, - GFP_KERNEL); - if (!hevc_dec->tile_sizes.cpu) - return -ENOMEM; - - hevc_dec->tile_sizes.size =3D size; - - hevc_dec->scaling_lists.cpu =3D dma_alloc_coherent(vpu->dev, SCALING_LIST= _SIZE, - &hevc_dec->scaling_lists.dma, - GFP_KERNEL); - if (!hevc_dec->scaling_lists.cpu) - return -ENOMEM; + ret =3D hantro_allocate_aux_buf(ctx, &hevc_dec->tile_sizes, size); + ret =3D hantro_allocate_aux_buf(ctx, &hevc_dec->scaling_lists, SCALING_LI= ST_SIZE); =20 - hevc_dec->scaling_lists.size =3D SCALING_LIST_SIZE; + if (ret) + goto error; =20 hantro_hevc_ref_init(ctx); =20 @@ -284,4 +214,10 @@ int hantro_hevc_dec_init(struct hantro_ctx *ctx) hevc_use_compression & hantro_needs_postproc(ctx, ctx->vpu_dst_fmt); =20 return 0; + +error: + hantro_free_aux_buf(ctx, &hevc_dec->tile_sizes); + hantro_free_aux_buf(ctx, &hevc_dec->scaling_lists); + + return -ENOMEM; } --=20 2.53.0 From nobody Fri Sep 25 05:29:23 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F99148D874; Wed, 16 Sep 2026 12:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563297; cv=none; b=N+f1E56ybJj63ET5Oy+CntbkLG7pbCFD/9cCkHUJ2jpOHOMHRWfnwyOCTOBAloN7xfsqjojpaHx+otrAsXXSQAdFoTkLqts2yRNqewh8pbNZXkykSUR9R9a+x4WS+ryXHWIzrMDPw07OyjLfmoff1TZlXADrBykrirg3AtDl7Cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563297; c=relaxed/simple; bh=3zKw4K0SxfBg0yduDZURnZ1s2u3ud89HZ8goJk4/ZGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kCQKXv1itdsytBBnWrfAc7Ju5bWWx0Y6OjGGatNPC0sYwCc8NkjkggJ+59qxLtM7aYr9qlKdV/YUXrUKr2/k0/Zb0AUrk0O2ezcHirTuoZ9lXYGitrhRJ5psoAb9FrA/4Lts1xFhX+ZZsCNlMcDZIR1FCT7YioBrof2P9p5RI50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=gxMvh4Kb; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="gxMvh4Kb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789563291; bh=3zKw4K0SxfBg0yduDZURnZ1s2u3ud89HZ8goJk4/ZGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxMvh4KbzfJgdo5wyOaRN1EtdQAsSwX0NVCpX9OageWzyYwkeFiKFcx/M3Y2pExuq QMSfyGnkW9w6tpU0SqCICYkef4aUgFIzO90iE4Kzr8+Or2+no5PMC3IonuJwVxnc0i FYKg9Mm1r/kkdKIDIRPiDuH4RkS3nZ39qz6Vg/pT1c3h0jW7stcBs31CES9jS9WfA1 0fnRfpTMpCyEbTNaH6lH7euR783RtnrO2Fus8VsCcw/URwf5kWkj15L6Eh6uD1LsMT EbxrF1FnuhsPDyqtLnkaGLPQDz4xXPOtlCY37AXDq4DJTC7K+ODuN89cmH36IpO/KX ITTdmqnr3D2Sg== Received: from benjamin-XPS-13-9310 (unknown [100.64.1.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bali.collaboradmins.com (Postfix) with ESMTPSA id D710D17E138B; Wed, 16 Sep 2026 14:54:50 +0200 (CEST) From: Benjamin Gaignard To: nicolas.dufresne@collabora.com, benjamin.gaignard@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 5/7] media: verisilicon: vp8: Use alloc/free helpers for auxiliary buffers Date: Wed, 16 Sep 2026 14:54:41 +0200 Message-ID: <20260916125443.78602-6-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916125443.78602-1-benjamin.gaignard@collabora.com> References: <20260916125443.78602-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify and clean up the code by using the helpers. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_vp8.c | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_vp8.c b/drivers/medi= a/platform/verisilicon/hantro_vp8.c index 381bc1d3bfda..881e6c21f0fa 100644 --- a/drivers/media/platform/verisilicon/hantro_vp8.c +++ b/drivers/media/platform/verisilicon/hantro_vp8.c @@ -144,11 +144,9 @@ void hantro_vp8_prob_update(struct hantro_ctx *ctx, =20 int hantro_vp8_dec_init(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_aux_buf *aux_buf; unsigned int mb_width, mb_height; size_t segment_map_size; - int ret; =20 /* segment map table size calculation */ mb_width =3D DIV_ROUND_UP(ctx->dst_fmt.width, 16); @@ -160,42 +158,27 @@ int hantro_vp8_dec_init(struct hantro_ctx *ctx) * And the data in segment map buffer must be set to all zero. */ aux_buf =3D &ctx->vp8_dec.segment_map; - aux_buf->size =3D segment_map_size; - aux_buf->cpu =3D dma_alloc_coherent(vpu->dev, aux_buf->size, - &aux_buf->dma, GFP_KERNEL); - if (!aux_buf->cpu) - return -ENOMEM; + if (hantro_allocate_aux_buf(ctx, aux_buf, segment_map_size)) + goto error; =20 /* * Allocate probability table buffer, * total 1208 bytes, 4K page is far enough. */ aux_buf =3D &ctx->vp8_dec.prob_tbl; - aux_buf->size =3D sizeof(struct vp8_prob_tbl_packed); - aux_buf->cpu =3D dma_alloc_coherent(vpu->dev, aux_buf->size, - &aux_buf->dma, GFP_KERNEL); - if (!aux_buf->cpu) { - ret =3D -ENOMEM; - goto err_free_seg_map; - } + if (hantro_allocate_aux_buf(ctx, aux_buf, sizeof(struct vp8_prob_tbl_pack= ed))) + goto error; =20 return 0; =20 -err_free_seg_map: - dma_free_coherent(vpu->dev, ctx->vp8_dec.segment_map.size, - ctx->vp8_dec.segment_map.cpu, - ctx->vp8_dec.segment_map.dma); - - return ret; +error: + hantro_free_aux_buf(ctx, &ctx->vp8_dec.segment_map); + hantro_free_aux_buf(ctx, &ctx->vp8_dec.prob_tbl); + return -ENOMEM; } =20 void hantro_vp8_dec_exit(struct hantro_ctx *ctx) { - struct hantro_vp8_dec_hw_ctx *vp8_dec =3D &ctx->vp8_dec; - struct hantro_dev *vpu =3D ctx->dev; - - dma_free_coherent(vpu->dev, vp8_dec->segment_map.size, - vp8_dec->segment_map.cpu, vp8_dec->segment_map.dma); - dma_free_coherent(vpu->dev, vp8_dec->prob_tbl.size, - vp8_dec->prob_tbl.cpu, vp8_dec->prob_tbl.dma); + hantro_free_aux_buf(ctx, &ctx->vp8_dec.segment_map); + hantro_free_aux_buf(ctx, &ctx->vp8_dec.prob_tbl); } --=20 2.53.0 From nobody Fri Sep 25 05:29:23 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FBFB499F11; Wed, 16 Sep 2026 12:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563297; cv=none; b=SSpubhTsNrDbcvrrxGVufNQV4QzvXlhRSVxyGhjAsmIQ2c4J2ATp+4lBDmt9SmNBuE53ipzKdEXgEm0JQHr3+x08yYjvfs5D9rRCKHt2fa6TPJvXi7DC0wHx/4qBnmwvrVRRnLCO/yuM1hFmYLfuGKj5GB5YVnRsBxNLWmWqxEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563297; c=relaxed/simple; bh=6PqgZGG44xEHnNJLqRnqFADHyuaxg3PALlytKAhKjTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Znb3O3AhLL1U+a+WnWjvOZhdfpiNhq/GGISM7tv13A4YXzefiqHPuDk881zoPQge+y3W+kdztqn2IhuMmM3Lp/u7sl91cW3uSOH2B5iD9T9/Ex62rK7q86RVkDuYr750ibgn057sT5IqL1gmPEJVa7igVTIKiVisuqqujIsP4tk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=LSbyXXWV; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="LSbyXXWV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789563291; bh=6PqgZGG44xEHnNJLqRnqFADHyuaxg3PALlytKAhKjTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LSbyXXWVIiUUmKzRY4I/h1E103Y2p9TNVCckhdyOobQNuk+tn4xbOV1eqQjx+vXmj THvoJkBJOS2jAxKZX82VWRZCTNo3wPtn5NmFkb6K8ECuZ+PAPVmXMZMNM7LH4FezYA b61FtyULRiTWN/1XCi1uGvFrxgCvbVEhz2ShrJ6yM0lnyEIhecAMN891POgwlDRExO KpeUj452HzXfIX/X1fDLXUradLAXFzw/+7eFP+gLz1ZrpdLXelNL8xIgruc7ym0BUK QX8Es6LIsYRoIYAf1RLqMd+NVzFaN1JVYL/YEjMUWAyv3t8n2w6A5VmRrMx88tC0yS i+p/6FoQ9w2zQ== Received: from benjamin-XPS-13-9310 (unknown [100.64.1.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bali.collaboradmins.com (Postfix) with ESMTPSA id 3A8AD17E13A8; Wed, 16 Sep 2026 14:54:51 +0200 (CEST) From: Benjamin Gaignard To: nicolas.dufresne@collabora.com, benjamin.gaignard@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 6/7] media: verisilicon: vp9: Use alloc/free helpers for auxiliary buffers Date: Wed, 16 Sep 2026 14:54:42 +0200 Message-ID: <20260916125443.78602-7-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916125443.78602-1-benjamin.gaignard@collabora.com> References: <20260916125443.78602-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify and clean up the code by using the helpers. For upstream it should be merged into only one commit. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_vp9.c | 37 ++++++------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_vp9.c b/drivers/medi= a/platform/verisilicon/hantro_vp9.c index 566cd376c097..7a46a4767254 100644 --- a/drivers/media/platform/verisilicon/hantro_vp9.c +++ b/drivers/media/platform/verisilicon/hantro_vp9.c @@ -181,23 +181,17 @@ int hantro_vp9_dec_init(struct hantro_ctx *ctx) size =3D hantro_vp9_tile_filter_size(max_height); vp9_dec->bsd_ctrl_offset =3D size; size +=3D hantro_vp9_bsd_control_size(max_height); - - tile_edge->cpu =3D dma_alloc_coherent(vpu->dev, size, &tile_edge->dma, GF= P_KERNEL); - if (!tile_edge->cpu) + if (hantro_allocate_aux_buf(ctx, tile_edge, size)) return -ENOMEM; =20 - tile_edge->size =3D size; memset(tile_edge->cpu, 0, size); =20 size =3D hantro_vp9_segment_map_size(max_width, max_height); vp9_dec->segment_map_size =3D size; size *=3D 2; /* we need two areas of this size, used alternately */ + if (hantro_allocate_aux_buf(ctx, segment_map, size)) + goto error; =20 - segment_map->cpu =3D dma_alloc_coherent(vpu->dev, size, &segment_map->dma= , GFP_KERNEL); - if (!segment_map->cpu) - goto err_segment_map; - - segment_map->size =3D size; memset(segment_map->cpu, 0, size); =20 size =3D hantro_vp9_prob_tab_size(); @@ -205,36 +199,27 @@ int hantro_vp9_dec_init(struct hantro_ctx *ctx) size +=3D hantro_vp9_count_tab_size(); vp9_dec->tile_info_offset =3D size; size +=3D hantro_vp9_tile_info_size(); + if (hantro_allocate_aux_buf(ctx, misc, size)) + goto error; =20 - misc->cpu =3D dma_alloc_coherent(vpu->dev, size, &misc->dma, GFP_KERNEL); - if (!misc->cpu) - goto err_misc; - - misc->size =3D size; memset(misc->cpu, 0, size); =20 init_v4l2_vp9_count_tbl(ctx); =20 return 0; =20 -err_misc: - dma_free_coherent(vpu->dev, segment_map->size, segment_map->cpu, segment_= map->dma); - -err_segment_map: - dma_free_coherent(vpu->dev, tile_edge->size, tile_edge->cpu, tile_edge->d= ma); +error: + hantro_free_aux_buf(ctx, segment_map); + hantro_free_aux_buf(ctx, tile_edge); =20 return -ENOMEM; } =20 void hantro_vp9_dec_exit(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; struct hantro_vp9_dec_hw_ctx *vp9_dec =3D &ctx->vp9_dec; - struct hantro_aux_buf *tile_edge =3D &vp9_dec->tile_edge; - struct hantro_aux_buf *segment_map =3D &vp9_dec->segment_map; - struct hantro_aux_buf *misc =3D &vp9_dec->misc; =20 - dma_free_coherent(vpu->dev, misc->size, misc->cpu, misc->dma); - dma_free_coherent(vpu->dev, segment_map->size, segment_map->cpu, segment_= map->dma); - dma_free_coherent(vpu->dev, tile_edge->size, tile_edge->cpu, tile_edge->d= ma); + hantro_free_aux_buf(ctx, &vp9_dec->tile_edge); + hantro_free_aux_buf(ctx, &vp9_dec->segment_map); + hantro_free_aux_buf(ctx, &vp9_dec->misc); } --=20 2.53.0 From nobody Fri Sep 25 05:29:23 2026 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B37044BFE61; Wed, 16 Sep 2026 12:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563297; cv=none; b=Mo42n8doVDLq28xXDs/P+G3E3Pbx4elN5Jf3VLpO46BhthwO9E+oTnu/zHfoDt3goAltc530OYINykhIEoj81foAZ4tSCWavxiOpfqx6YwR6I/07jl6x7vQsV+9D9ouMEotdqZnNfQwBcWFk312PHftec52AgSHbxfGBUAjXnGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789563297; c=relaxed/simple; bh=eOI2q3uxCKkIliMe03rIur3xYlkC3y6bAVkEvyKeEnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OW9tgU41JE8epENxYTWrR52vwEIKbxK0CrosChHZSvmxQ+RYKyinYVsbHkTY+P0kmTTwdOHmjgvLx8WndsCZAYUSEvstN/do9wWlT3r5EQcuaWirC0+vBhrCmCwte2OhL5toMEAk8cBmAL7XOMsbcbVpuQ/Ran2xrsxqwuFTdiM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=cgcLUcRl; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="cgcLUcRl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1789563291; bh=eOI2q3uxCKkIliMe03rIur3xYlkC3y6bAVkEvyKeEnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgcLUcRl1F3UpKx6T+FPc+kyCicbxNO0aAc1nJzhNfNj9tr0ZSBe7loLNsDL9cX0S Nf93ozBYxWJ54qLgZYYhHcbNpwORE0un5IoQa/EWrrysZ16OPKGtUHkcNaVrD2OoHC 3J1LFjc410SxZDKw8pmCJ/oXpmQkul0FV6jl9+O4PLRqowOeupWMTmM4BRppaVKJoP iQOvldl7V+bUVu3Zl7Cat1V+OBre3fZ/+V96xUQz6t3xPr43tfoNMBQVm1kBpnLdn7 71ysPJCepqh9RtpTqjdl0ansxP/j0DG5BxfCaV669g+6n1Xyz286FTC8kPhOurSNE7 5ivo9iV8vs4uA== Received: from benjamin-XPS-13-9310 (unknown [100.64.1.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by bali.collaboradmins.com (Postfix) with ESMTPSA id 9543317E13C3; Wed, 16 Sep 2026 14:54:51 +0200 (CEST) From: Benjamin Gaignard To: nicolas.dufresne@collabora.com, benjamin.gaignard@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 7/7] media: verisilicon: mpeg4: Use alloc/free helpers for auxiliary buffers Date: Wed, 16 Sep 2026 14:54:43 +0200 Message-ID: <20260916125443.78602-8-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916125443.78602-1-benjamin.gaignard@collabora.com> References: <20260916125443.78602-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify and clean up the code by using the helpers. Signed-off-by: Benjamin Gaignard --- .../media/platform/verisilicon/hantro_mpeg2.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_mpeg2.c b/drivers/me= dia/platform/verisilicon/hantro_mpeg2.c index 04e545eb0a83..f21115e6bdbe 100644 --- a/drivers/media/platform/verisilicon/hantro_mpeg2.c +++ b/drivers/media/platform/verisilicon/hantro_mpeg2.c @@ -37,25 +37,12 @@ void hantro_mpeg2_dec_copy_qtable(u8 *qtable, =20 int hantro_mpeg2_dec_init(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; - - ctx->mpeg2_dec.qtable.size =3D ARRAY_SIZE(zigzag) * 4; - ctx->mpeg2_dec.qtable.cpu =3D - dma_alloc_coherent(vpu->dev, - ctx->mpeg2_dec.qtable.size, - &ctx->mpeg2_dec.qtable.dma, - GFP_KERNEL); - if (!ctx->mpeg2_dec.qtable.cpu) + if (hantro_allocate_aux_buf(ctx, &ctx->mpeg2_dec.qtable, ARRAY_SIZE(zigza= g) * 4)) return -ENOMEM; return 0; } =20 void hantro_mpeg2_dec_exit(struct hantro_ctx *ctx) { - struct hantro_dev *vpu =3D ctx->dev; - - dma_free_coherent(vpu->dev, - ctx->mpeg2_dec.qtable.size, - ctx->mpeg2_dec.qtable.cpu, - ctx->mpeg2_dec.qtable.dma); + hantro_free_aux_buf(ctx, &ctx->mpeg2_dec.qtable); } --=20 2.53.0