Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1862603lqb; Sun, 26 May 2024 22:59:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXaJNIR/XG2H/cf7a05ffKyl2VARqZoCLo8frS/0mPBGFUIFa3ellmty2oKDoCmlfvby6bKO5dHvW9JE0M5HGMEH6qGfkWj3u611bsROQ== X-Google-Smtp-Source: AGHT+IHL7p4x8gqH3u59sByrkL+OeDmOD1AXmdBK4iJolgPmLrQLAP+Ls76fD227+EstJ0AVGd2H X-Received: by 2002:a17:906:29cb:b0:a59:c208:a4c with SMTP id a640c23a62f3a-a62642d82bbmr490784166b.17.1716789565699; Sun, 26 May 2024 22:59:25 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626c80124esi350608966b.99.2024.05.26.22.59.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 22:59:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190058-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=kaht9kZc; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-190058-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190058-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 43BEC1F21208 for ; Mon, 27 May 2024 05:59:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 016FD101C5; Mon, 27 May 2024 05:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kaht9kZc" Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63EEE8F6B for ; Mon, 27 May 2024 05:59:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716789553; cv=none; b=F1wmdhEuIjStnyq8r346QagbFBALNRmfPjc5QhrLsDR5igZUCp0LB+9a4H9VBrmrUWf6yVWQZmvqfOSTK60SDftY+4FBtFPeaN6n2mtVBSusMm74KyOA3gQCy3s4XVUvbAChVHkRWw/LHtKE/ZCospTkG+2rlENgtLjeWDVDQfw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716789553; c=relaxed/simple; bh=7FwO+WsHSRy4iDQGVle0ccViY4h+C4pb7T7XHHQkTew=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=L6RllbLNxdqQmJILAu21vIlDOPCxCBpPIkyY/AZ2tttl6xMcWs80I62rNHZP510HFqhEgtdU3yjnNyn1Hu7BDwl8N+mBbAWI527wt1F+sm2zcIYugbfn1zNDeT8FL8TYkUQHEJ/rRHEUMhq9o/e7/SifJEX1qo4zpRo0JtOcBcg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=kaht9kZc; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-529b4011070so109075e87.1 for ; Sun, 26 May 2024 22:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1716789548; x=1717394348; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+OR9Ad61axMvkG4/g8VNT1kP9S3TZSgBw5EMpfEC30Q=; b=kaht9kZc1Do+CO7Twygo/2HYosmqE8vII7cvrbL0rXHz9fa2CIWCmHOhhQSUfqgxUN +lYrEw2Bm2HZ4BFUuIbasfn6SMYEzlYU5Cq1mlB0E9IMPjMShgRYlt/kyR4CAN+Xa1ld 01XzZzo5m+jb0iXCFx7uAOybaot0J4ywqKAWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716789548; x=1717394348; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+OR9Ad61axMvkG4/g8VNT1kP9S3TZSgBw5EMpfEC30Q=; b=L5qZdzpsb+kbdZ44Hqp+NalfzYk4CclSeOgDT3S0KTeVR879zCzQKjDFLNLPkkB9iR CCdbXIgKDPLlUqXD72shhA/7L1fNKp0YBvGC8zC+XLA0R7kDMYwfzlPuQYQ11oQbpR2A Ww2xyDWjDMM0UxT/YAOYD9T3PDhCR3WcvJY8yd2/4yROAY7orUDXp9Ay8JQCXUMabkpK 6AraQRr5UAqnwZT+jH4liC28xcmvc52PxxKZ97o/AbEKb0w998mlWXS58vMO7VFvnrrV 11hjCYAT3HQApkd8FgUDb1BpXpyBrzX/RZfa1pVbdnrsSFdfBxLP20OWWdB2rla0N5lL TQLQ== X-Forwarded-Encrypted: i=1; AJvYcCV35ae/2IX+qZKkg3YiCtUQhvKM1WyOUoxbgfwFHqOlYQQPkr0jwJIjii6qoBwIEFpTEtL1PpyNqRF6vBLQd2NCmslfo+XdrP0iSJd2 X-Gm-Message-State: AOJu0Yycj6RjdHBdwj77UX9zhYB81CKC8Nd2vJy1Z9ZDtpygPssdtIy2 aeRUoHyAOVk3wIn4I6c5lZHwLUWZxZPKF7oO+BtBMFHYltKoNqpB07DXg/NoYah91NXqeWNfKiw Dxoky8d1V/gztI4lRgoAGZEnqgzi2YYmn9Ho2 X-Received: by 2002:a19:8c58:0:b0:51f:53e0:1bc3 with SMTP id 2adb3069b0e04-529646df12bmr4604947e87.25.1716789548537; Sun, 26 May 2024 22:59:08 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240516122102.16379-1-yunfei.dong@mediatek.com> <20240516122102.16379-18-yunfei.dong@mediatek.com> In-Reply-To: <20240516122102.16379-18-yunfei.dong@mediatek.com> From: Chen-Yu Tsai Date: Mon, 27 May 2024 13:58:57 +0800 Message-ID: Subject: Re: [PATCH v6,17/24] media: mediatek: vcodec: re-construct h264 driver to support svp mode To: Yunfei Dong , Sebastian Fricke , Hans Verkuil Cc: Jeffrey Kardatzke , =?UTF-8?B?TsOtY29sYXMgRiAuIFIgLiBBIC4gUHJhZG8=?= , Nathan Hebert , Nicolas Dufresne , AngeloGioacchino Del Regno , Benjamin Gaignard , Tomasz Figa , Mauro Carvalho Chehab , Marek Szyprowski , Yong Wu , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Sumit Semwal , Brian Starkey , John Stultz , "T . J . Mercier" , =?UTF-8?Q?Christian_K=C3=B6nig?= , Matthias Brugger , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 16, 2024 at 8:21=E2=80=AFPM Yunfei Dong wrote: > > Need secure buffer size to convert secure handle to secure > pa in optee-os, re-construct the vsi struct to store each > secure buffer size. > > Separate svp and normal wait interrupt condition for svp mode > waiting hardware interrupt in optee-os. > > Signed-off-by: Yunfei Dong > --- > .../decoder/vdec/vdec_h264_req_multi_if.c | 261 +++++++++++------- > .../mediatek/vcodec/decoder/vdec_msg_queue.c | 9 +- > 2 files changed, 168 insertions(+), 102 deletions(-) > > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h26= 4_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec= _h264_req_multi_if.c > index d7fec1887ab5..40836673f7fe 100644 > --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_m= ulti_if.c > +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_h264_req_m= ulti_if.c > @@ -60,14 +60,36 @@ struct vdec_h264_slice_lat_dec_param { > * @crc: Used to check whether hardware's status is right > */ > struct vdec_h264_slice_info { > + u64 wdma_end_addr_offset; > u16 nal_info; > u16 timeout; > - u32 bs_buf_size; > - u64 bs_buf_addr; > - u64 y_fb_dma; > - u64 c_fb_dma; > u64 vdec_fb_va; > u32 crc[8]; > + u32 reserved; > +}; > + > +/* > + * struct vdec_h264_slice_mem - memory address and size > + */ > +struct vdec_h264_slice_mem { > + union { > + u64 buf; > + u64 dma_addr; > + }; > + union { > + size_t size; > + u64 dma_addr_end; > + }; > +}; > + > +/** > + * struct vdec_h264_slice_fb - frame buffer for decoding > + * @y: current y buffer address info > + * @c: current c buffer address info > + */ > +struct vdec_h264_slice_fb { > + struct vdec_h264_slice_mem y; > + struct vdec_h264_slice_mem c; > }; > > /** > @@ -92,18 +114,16 @@ struct vdec_h264_slice_info { > */ > struct vdec_h264_slice_vsi { > /* LAT dec addr */ > - u64 wdma_err_addr; > - u64 wdma_start_addr; > - u64 wdma_end_addr; > - u64 slice_bc_start_addr; > - u64 slice_bc_end_addr; > - u64 row_info_start_addr; > - u64 row_info_end_addr; > - u64 trans_start; > - u64 trans_end; > - u64 wdma_end_addr_offset; > + struct vdec_h264_slice_mem bs; > + struct vdec_h264_slice_fb fb; > > - u64 mv_buf_dma[H264_MAX_MV_NUM]; > + struct vdec_h264_slice_mem ube; > + struct vdec_h264_slice_mem trans; > + struct vdec_h264_slice_mem row_info; > + struct vdec_h264_slice_mem err_map; > + struct vdec_h264_slice_mem slice_bc; > + > + struct vdec_h264_slice_mem mv_buf_dma[H264_MAX_MV_NUM]; > struct vdec_h264_slice_info dec; > struct vdec_h264_slice_lat_dec_param h264_slice_params; > }; Hard NAK. You are changing the interface with the firmware without any backward compatibility. This breaks H.264 decoding on other platforms that use this code path, including MT8192, MT8195, and MT8186. You cannot just consider the current platform you are working on. This is already showing in our downstream test results for Asurada / MT8192 on v6.1, same branch as MT8188, which has these patches applied. The kernel needs to be able to run with older firmware. The firmware needs to signal that it wants the new layout either with a version number (which probably won't work with SCP here) or with capability flags, like with 4K or AV1 or HEVC support we had before. The kernel driver sees the capability flag and uses the new data structures. Or you make changes to the layout in some backward compatible way, like only expanding the data structure and keeping all the old fields, and duplicating fields for new structures you add. Regards ChenYu > @@ -392,6 +412,100 @@ static void vdec_h264_slice_get_crop_info(struct vd= ec_h264_slice_inst *inst, > cr->left, cr->top, cr->width, cr->height); > } > > +static void vdec_h264_slice_setup_lat_buffer(struct vdec_h264_slice_inst= *inst, > + struct mtk_vcodec_mem *bs, > + struct vdec_lat_buf *lat_buf= ) > +{ > + struct mtk_vcodec_mem *mem; > + int i; > + > + inst->vsi->bs.dma_addr =3D (u64)bs->dma_addr; > + inst->vsi->bs.size =3D bs->size; > + > + for (i =3D 0; i < H264_MAX_MV_NUM; i++) { > + mem =3D &inst->mv_buf[i]; > + inst->vsi->mv_buf_dma[i].dma_addr =3D mem->dma_addr; > + inst->vsi->mv_buf_dma[i].size =3D mem->size; > + } > + inst->vsi->ube.dma_addr =3D lat_buf->ctx->msg_queue.wdma_addr.dma= _addr; > + inst->vsi->ube.size =3D lat_buf->ctx->msg_queue.wdma_addr.size; > + > + inst->vsi->row_info.dma_addr =3D 0; > + inst->vsi->row_info.size =3D 0; > + > + inst->vsi->err_map.dma_addr =3D lat_buf->wdma_err_addr.dma_addr; > + inst->vsi->err_map.size =3D lat_buf->wdma_err_addr.size; > + > + inst->vsi->slice_bc.dma_addr =3D lat_buf->slice_bc_addr.dma_addr; > + inst->vsi->slice_bc.size =3D lat_buf->slice_bc_addr.size; > + > + inst->vsi->trans.dma_addr_end =3D inst->ctx->msg_queue.wdma_rptr_= addr; > + inst->vsi->trans.dma_addr =3D inst->ctx->msg_queue.wdma_wptr_addr= ; > +} > + > +static int vdec_h264_slice_setup_core_buffer(struct vdec_h264_slice_inst= *inst, > + struct vdec_h264_slice_share= _info *share_info, > + struct vdec_lat_buf *lat_buf= ) > +{ > + struct mtk_vcodec_mem *mem; > + struct mtk_vcodec_dec_ctx *ctx =3D inst->ctx; > + struct vb2_v4l2_buffer *vb2_v4l2; > + struct vdec_fb *fb; > + u64 y_fb_dma, c_fb_dma =3D 0; > + int i; > + > + fb =3D ctx->dev->vdec_pdata->get_cap_buffer(ctx); > + if (!fb) { > + mtk_vdec_err(ctx, "fb buffer is NULL"); > + return -EBUSY; > + } > + > + y_fb_dma =3D (u64)fb->base_y.dma_addr; > + if (!ctx->is_secure_playback) { > + if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes =3D=3D 1) > + c_fb_dma =3D > + y_fb_dma + inst->ctx->picinfo.buf_w * ins= t->ctx->picinfo.buf_h; > + else > + c_fb_dma =3D (u64)fb->base_c.dma_addr; > + } > + > + mtk_vdec_debug(ctx, "[h264-core] y/c addr =3D 0x%llx 0x%llx", y_f= b_dma, c_fb_dma); > + > + inst->vsi_core->fb.y.dma_addr =3D y_fb_dma; > + inst->vsi_core->fb.y.size =3D ctx->picinfo.fb_sz[0]; > + inst->vsi_core->fb.c.dma_addr =3D c_fb_dma; > + inst->vsi_core->fb.c.size =3D ctx->picinfo.fb_sz[1]; > + > + inst->vsi_core->dec.vdec_fb_va =3D (unsigned long)fb; > + inst->vsi_core->dec.nal_info =3D share_info->nal_info; > + > + inst->vsi_core->ube.dma_addr =3D lat_buf->ctx->msg_queue.wdma_add= r.dma_addr; > + inst->vsi_core->ube.size =3D lat_buf->ctx->msg_queue.wdma_addr.si= ze; > + > + inst->vsi_core->err_map.dma_addr =3D lat_buf->wdma_err_addr.dma_a= ddr; > + inst->vsi_core->err_map.size =3D lat_buf->wdma_err_addr.size; > + > + inst->vsi_core->slice_bc.dma_addr =3D lat_buf->slice_bc_addr.dma_= addr; > + inst->vsi_core->slice_bc.size =3D lat_buf->slice_bc_addr.size; > + > + inst->vsi_core->row_info.dma_addr =3D 0; > + inst->vsi_core->row_info.size =3D 0; > + > + inst->vsi_core->trans.dma_addr =3D share_info->trans_start; > + inst->vsi_core->trans.dma_addr_end =3D share_info->trans_end; > + > + for (i =3D 0; i < H264_MAX_MV_NUM; i++) { > + mem =3D &inst->mv_buf[i]; > + inst->vsi_core->mv_buf_dma[i].dma_addr =3D mem->dma_addr; > + inst->vsi_core->mv_buf_dma[i].size =3D mem->size; > + } > + > + vb2_v4l2 =3D v4l2_m2m_next_dst_buf(ctx->m2m_ctx); > + v4l2_m2m_buf_copy_metadata(&lat_buf->ts_info, vb2_v4l2, true); > + > + return 0; > +} > + > static int vdec_h264_slice_init(struct mtk_vcodec_dec_ctx *ctx) > { > struct vdec_h264_slice_inst *inst; > @@ -457,64 +571,22 @@ static void vdec_h264_slice_deinit(void *h_vdec) > > static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf) > { > - struct vdec_fb *fb; > - u64 vdec_fb_va; > - u64 y_fb_dma, c_fb_dma; > - int err, timeout, i; > + int err, timeout; > struct mtk_vcodec_dec_ctx *ctx =3D lat_buf->ctx; > struct vdec_h264_slice_inst *inst =3D ctx->drv_handle; > - struct vb2_v4l2_buffer *vb2_v4l2; > struct vdec_h264_slice_share_info *share_info =3D lat_buf->privat= e_data; > - struct mtk_vcodec_mem *mem; > struct vdec_vpu_inst *vpu =3D &inst->vpu; > > mtk_vdec_debug(ctx, "[h264-core] vdec_h264 core decode"); > memcpy(&inst->vsi_core->h264_slice_params, &share_info->h264_slic= e_params, > sizeof(share_info->h264_slice_params)); > > - fb =3D ctx->dev->vdec_pdata->get_cap_buffer(ctx); > - if (!fb) { > - err =3D -EBUSY; > - mtk_vdec_err(ctx, "fb buffer is NULL"); > + err =3D vdec_h264_slice_setup_core_buffer(inst, share_info, lat_b= uf); > + if (err) > goto vdec_dec_end; > - } > - > - vdec_fb_va =3D (unsigned long)fb; > - y_fb_dma =3D (u64)fb->base_y.dma_addr; > - if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes =3D=3D 1) > - c_fb_dma =3D > - y_fb_dma + inst->ctx->picinfo.buf_w * inst->ctx->= picinfo.buf_h; > - else > - c_fb_dma =3D (u64)fb->base_c.dma_addr; > - > - mtk_vdec_debug(ctx, "[h264-core] y/c addr =3D 0x%llx 0x%llx", y_f= b_dma, c_fb_dma); > - > - inst->vsi_core->dec.y_fb_dma =3D y_fb_dma; > - inst->vsi_core->dec.c_fb_dma =3D c_fb_dma; > - inst->vsi_core->dec.vdec_fb_va =3D vdec_fb_va; > - inst->vsi_core->dec.nal_info =3D share_info->nal_info; > - inst->vsi_core->wdma_start_addr =3D > - lat_buf->ctx->msg_queue.wdma_addr.dma_addr; > - inst->vsi_core->wdma_end_addr =3D > - lat_buf->ctx->msg_queue.wdma_addr.dma_addr + > - lat_buf->ctx->msg_queue.wdma_addr.size; > - inst->vsi_core->wdma_err_addr =3D lat_buf->wdma_err_addr.dma_addr= ; > - inst->vsi_core->slice_bc_start_addr =3D lat_buf->slice_bc_addr.dm= a_addr; > - inst->vsi_core->slice_bc_end_addr =3D lat_buf->slice_bc_addr.dma_= addr + > - lat_buf->slice_bc_addr.size; > - inst->vsi_core->trans_start =3D share_info->trans_start; > - inst->vsi_core->trans_end =3D share_info->trans_end; > - for (i =3D 0; i < H264_MAX_MV_NUM; i++) { > - mem =3D &inst->mv_buf[i]; > - inst->vsi_core->mv_buf_dma[i] =3D mem->dma_addr; > - } > - > - vb2_v4l2 =3D v4l2_m2m_next_dst_buf(ctx->m2m_ctx); > - v4l2_m2m_buf_copy_metadata(&lat_buf->ts_info, vb2_v4l2, true); > > vdec_h264_slice_fill_decode_reflist(inst, &inst->vsi_core->h264_s= lice_params, > share_info); > - > err =3D vpu_dec_core(vpu); > if (err) { > mtk_vdec_err(ctx, "core decode err=3D%d", err); > @@ -573,12 +645,11 @@ static int vdec_h264_slice_lat_decode(void *h_vdec,= struct mtk_vcodec_mem *bs, > struct vdec_h264_slice_inst *inst =3D h_vdec; > struct vdec_vpu_inst *vpu =3D &inst->vpu; > struct mtk_video_dec_buf *src_buf_info; > - int nal_start_idx, err, timeout =3D 0, i; > + int nal_start_idx, err, timeout =3D 0; > unsigned int data[2]; > struct vdec_lat_buf *lat_buf; > struct vdec_h264_slice_share_info *share_info; > unsigned char *buf; > - struct mtk_vcodec_mem *mem; > > if (vdec_msg_queue_init(&inst->ctx->msg_queue, inst->ctx, > vdec_h264_slice_core_decode, > @@ -617,11 +688,9 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, = struct mtk_vcodec_mem *bs, > if (err) > goto err_free_fb_out; > > - vdec_h264_insert_startcode(inst->ctx->dev, buf, &bs->size, > - &share_info->h264_slice_params.pps); > - > - inst->vsi->dec.bs_buf_addr =3D (uint64_t)bs->dma_addr; > - inst->vsi->dec.bs_buf_size =3D bs->size; > + if (!inst->ctx->is_secure_playback) > + vdec_h264_insert_startcode(inst->ctx->dev, buf, &bs->size= , > + &share_info->h264_slice_params= pps); > > *res_chg =3D inst->resolution_changed; > if (inst->resolution_changed) { > @@ -634,38 +703,27 @@ static int vdec_h264_slice_lat_decode(void *h_vdec,= struct mtk_vcodec_mem *bs, > } > inst->resolution_changed =3D false; > } > - for (i =3D 0; i < H264_MAX_MV_NUM; i++) { > - mem =3D &inst->mv_buf[i]; > - inst->vsi->mv_buf_dma[i] =3D mem->dma_addr; > - } > - inst->vsi->wdma_start_addr =3D lat_buf->ctx->msg_queue.wdma_addr.= dma_addr; > - inst->vsi->wdma_end_addr =3D lat_buf->ctx->msg_queue.wdma_addr.dm= a_addr + > - lat_buf->ctx->msg_queue.wdma_addr.size; > - inst->vsi->wdma_err_addr =3D lat_buf->wdma_err_addr.dma_addr; > - inst->vsi->slice_bc_start_addr =3D lat_buf->slice_bc_addr.dma_add= r; > - inst->vsi->slice_bc_end_addr =3D lat_buf->slice_bc_addr.dma_addr = + > - lat_buf->slice_bc_addr.size; > - > - inst->vsi->trans_end =3D inst->ctx->msg_queue.wdma_rptr_addr; > - inst->vsi->trans_start =3D inst->ctx->msg_queue.wdma_wptr_addr; > - mtk_vdec_debug(inst->ctx, "lat:trans(0x%llx 0x%llx) err:0x%llx", > - inst->vsi->wdma_start_addr, > - inst->vsi->wdma_end_addr, > - inst->vsi->wdma_err_addr); > - > - mtk_vdec_debug(inst->ctx, "slice(0x%llx 0x%llx) rprt((0x%llx 0x%l= lx))", > - inst->vsi->slice_bc_start_addr, > - inst->vsi->slice_bc_end_addr, > - inst->vsi->trans_start, > - inst->vsi->trans_end); > + > + vdec_h264_slice_setup_lat_buffer(inst, bs, lat_buf); > + mtk_vdec_debug(inst->ctx, "lat:trans(0x%llx 0x%lx) err:0x%llx", > + inst->vsi->ube.dma_addr, (unsigned long)inst->vsi-= >ube.size, > + inst->vsi->err_map.dma_addr); > + > + mtk_vdec_debug(inst->ctx, "slice(0x%llx 0x%lx) rprt((0x%llx 0x%ll= x))", > + inst->vsi->slice_bc.dma_addr, (unsigned long)inst-= >vsi->slice_bc.size, > + inst->vsi->trans.dma_addr, inst->vsi->trans.dma_ad= dr_end); > err =3D vpu_dec_start(vpu, data, 2); > if (err) { > mtk_vdec_debug(inst->ctx, "lat decode err: %d", err); > goto err_free_fb_out; > } > > - share_info->trans_end =3D inst->ctx->msg_queue.wdma_addr.dma_addr= + > - inst->vsi->wdma_end_addr_offset; > + if (inst->ctx->is_secure_playback) > + share_info->trans_end =3D inst->vsi->dec.wdma_end_addr_of= fset; > + else > + share_info->trans_end =3D inst->ctx->msg_queue.wdma_addr.= dma_addr + > + inst->vsi->dec.wdma_end_addr_offset; > + > share_info->trans_start =3D inst->ctx->msg_queue.wdma_wptr_addr; > share_info->nal_info =3D inst->vsi->dec.nal_info; > > @@ -691,8 +749,11 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, = struct mtk_vcodec_mem *bs, > return -EINVAL; > } > > - share_info->trans_end =3D inst->ctx->msg_queue.wdma_addr.dma_addr= + > - inst->vsi->wdma_end_addr_offset; > + if (inst->ctx->is_secure_playback) > + share_info->trans_end =3D inst->vsi->dec.wdma_end_addr_of= fset; > + else > + share_info->trans_end =3D inst->ctx->msg_queue.wdma_addr.= dma_addr + > + inst->vsi->dec.wdma_end_addr_offset; > vdec_msg_queue_update_ube_wptr(&lat_buf->ctx->msg_queue, share_in= fo->trans_end); > > if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability)) { > @@ -737,10 +798,10 @@ static int vdec_h264_slice_single_decode(void *h_vd= ec, struct mtk_vcodec_mem *bs > mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=3D%llx c_dma=3D%= llx", > inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma); > > - inst->vsi_ctx.dec.bs_buf_addr =3D (u64)bs->dma_addr; > - inst->vsi_ctx.dec.bs_buf_size =3D bs->size; > - inst->vsi_ctx.dec.y_fb_dma =3D y_fb_dma; > - inst->vsi_ctx.dec.c_fb_dma =3D c_fb_dma; > + inst->vsi_ctx.bs.dma_addr =3D (u64)bs->dma_addr; > + inst->vsi_ctx.bs.size =3D bs->size; > + inst->vsi_ctx.fb.y.dma_addr =3D y_fb_dma; > + inst->vsi_ctx.fb.c.dma_addr =3D c_fb_dma; > inst->vsi_ctx.dec.vdec_fb_va =3D (u64)(uintptr_t)fb; > > v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, > @@ -770,7 +831,7 @@ static int vdec_h264_slice_single_decode(void *h_vdec= , struct mtk_vcodec_mem *bs > > for (i =3D 0; i < H264_MAX_MV_NUM; i++) { > mem =3D &inst->mv_buf[i]; > - inst->vsi_ctx.mv_buf_dma[i] =3D mem->dma_addr; > + inst->vsi_ctx.mv_buf_dma[i].dma_addr =3D mem->dma= _addr; > } > } > > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_msg_queu= e.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec_msg_queue.c > index f283c4703dc6..c1310176ae05 100644 > --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_msg_queue.c > +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_msg_queue.c > @@ -308,8 +308,13 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_q= ueue, > msg_queue->wdma_addr.size =3D 0; > return -ENOMEM; > } > - msg_queue->wdma_rptr_addr =3D msg_queue->wdma_addr.dma_addr; > - msg_queue->wdma_wptr_addr =3D msg_queue->wdma_addr.dma_addr; > + if (ctx->is_secure_playback) { > + msg_queue->wdma_rptr_addr =3D 0; > + msg_queue->wdma_wptr_addr =3D 0; > + } else { > + msg_queue->wdma_rptr_addr =3D msg_queue->wdma_addr.dma_ad= dr; > + msg_queue->wdma_wptr_addr =3D msg_queue->wdma_addr.dma_ad= dr; > + } > > msg_queue->empty_lat_buf.ctx =3D ctx; > msg_queue->empty_lat_buf.core_decode =3D NULL; > -- > 2.25.1 >