Message ID | 20231206081538.17056-21-yunfei.dong@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3957904vqy; Wed, 6 Dec 2023 00:18:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsh39AucMTva1SwRiZYOZ0LEa31H6i+zEskm5yoYVtcUIBSr48i8JvllStumaC/V+3eg6i X-Received: by 2002:a17:903:187:b0:1cf:d2c5:ae87 with SMTP id z7-20020a170903018700b001cfd2c5ae87mr387276plg.11.1701850697141; Wed, 06 Dec 2023 00:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701850697; cv=none; d=google.com; s=arc-20160816; b=Tadco5D8yRT0SqYRwb33rg2EKGh9IrJb+DOzwakfKR22Qpoya16/jd6/7/k5ydtw0f Fp1ly+sU1NvIZoEbVzQrMq0+CJdmx1j9uJHBgJHlCH+KK8i/hTGNcxPEBjDxyJtIyCU3 4f7M7JKQihb+5FxcwgRVqid1lPw8V/q788s+W+zUJx0lqjKAP2h12TGGtKAj7RQCXwqH GaKHm1IrYrsxwR/FP/57VnVnP6cBmdnxm3lyTZ4g+C9H1Mvf90Vhc+E3pSAbsoITwNfC jZblmnmYjYlQsU/+jLge+huL3jrpxGjcNsGe0yOxf31TeP4ywzPUAAOrhZHX1fQgQq4x eSrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kC7KzWLgDHvbqhzMWnc/8P0WK0I0J12Fa3NbbNqI088=; fh=wcqrfUTA4c9nkJHA4kqbuH5WL/x/W2/AFDhttE+DJkw=; b=G8FukdDoAHEptDA6a05m9PDYnQTHMx1ZZfp+ml57xl23/9Z64GmlOPsZtLd3ElMGwJ sJf/6nWZsl8M7p41D3DZDcyUuxqjTkrS1Ta5AGl1E1Es7vxx6INIjEk2p2ovd7m1quRr L/Nk6KO29h+foofWUDs+cpfSAisuMQH740T0OtesaG+QwwLu8RSxGnvTlv/MWTR3rOz9 VwqkBKMn2xBeVoMIfSvZbcvx48txaz82wXPvkh5OmgZwOl1StwFJJiERCx2sMW5VIgic 05asCQ6D5AkMYndLQ+lGW2tQHI1WgluKYniWvHR7667jKkKAz6R72P4BHk/dg4ct3OiZ uBIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=DRgY0xCz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l16-20020a170903245000b001d044978d7esi5130029pls.598.2023.12.06.00.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 00:18:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=DRgY0xCz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C09D380BD525; Wed, 6 Dec 2023 00:18:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377361AbjLFIRZ (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Wed, 6 Dec 2023 03:17:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377315AbjLFIQr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 6 Dec 2023 03:16:47 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5576E199E; Wed, 6 Dec 2023 00:16:16 -0800 (PST) X-UUID: b4edff10940f11ee8051498923ad61e6-20231206 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=kC7KzWLgDHvbqhzMWnc/8P0WK0I0J12Fa3NbbNqI088=; b=DRgY0xCz2XKjDEUTrQLh5nBlVtY87KqKA/vZ1ToLL9WmUItuVnxQpasK9nM0ldv7Y/kkWe5z8ag7jL/1fjbHBBqG3P3bIhs3ng3zEoSWUoWC6qXg8HVJ9JFvqzplyKrOTg5L7QrdC6tBAnpXG4WiegqyYhI5kXm7S9pGqrZhUzc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.34,REQID:0b6040a7-3dbc-4ac0-bb21-ed69f2d0860c,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:abefa75,CLOUDID:bf863596-10ce-4e4b-85c2-c9b5229ff92b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: b4edff10940f11ee8051498923ad61e6-20231206 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw02.mediatek.com (envelope-from <yunfei.dong@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 991676486; Wed, 06 Dec 2023 16:16:07 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 6 Dec 2023 16:16:06 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 6 Dec 2023 16:16:05 +0800 From: Yunfei Dong <yunfei.dong@mediatek.com> To: Jeffrey Kardatzke <jkardatzke@google.com>, =?utf-8?q?N=C3=ADcolas_F_=2E_?= =?utf-8?q?R_=2E_A_=2E_Prado?= <nfraprado@collabora.com>, Nicolas Dufresne <nicolas.dufresne@collabora.com>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Nathan Hebert <nhebert@chromium.org> CC: Chen-Yu Tsai <wenst@chromium.org>, Yong Wu <yong.wu@mediatek.com>, "Hsin-Yi Wang" <hsinyi@chromium.org>, Fritz Koenig <frkoenig@chromium.org>, "Daniel Vetter" <daniel@ffwll.ch>, Steve Cho <stevecho@chromium.org>, Yunfei Dong <yunfei.dong@mediatek.com>, Sumit Semwal <sumit.semwal@linaro.org>, "Brian Starkey" <Brian.Starkey@arm.com>, John Stultz <jstultz@google.com>, "T . J . Mercier" <tjmercier@google.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, Matthias Brugger <matthias.bgg@gmail.com>, <dri-devel@lists.freedesktop.org>, <linaro-mm-sig@lists.linaro.org>, <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-mediatek@lists.infradead.org>, <Project_Global_Chrome_Upstream_Group@mediatek.com> Subject: [PATCH v3,20/21] media: medkatek: vcodec: support tee decoder Date: Wed, 6 Dec 2023 16:15:37 +0800 Message-ID: <20231206081538.17056-21-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231206081538.17056-1-yunfei.dong@mediatek.com> References: <20231206081538.17056-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10-3.006200-8.000000 X-TMASE-MatchedRID: WVKpczY/zoTtAxjyNphE0new7fOv9rv4Kx5ICGp/WtF6unVYJJS8BvlY oV6p/cSxF8u8dQXnFzmAbmfpXu2gQmUlOh2o2oTOFYJUGv4DL3yt4laWdJbsDBL6MU7t349bW9o SzMAtdLLi8zVgXoAltsIJ+4gwXrEtwrbXMGDYqV+HuSUEBMGDjCgTieNKzl0v+c+7T33Au3DNuA ezS6+buStXMlZOFFSrjrE02BmFeIfvcrH62iIKGAXWfB7vcPOFv+VreHCTJr8xLORmmfnUyqMnT JRI0XInfXwUEm1ouDzLDYxFC1/7rjCBQDy1BJSc7ndUHUMmXu5+3BndfXUhXQ== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10-3.006200-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 2E252DE02EC8D4257050ACF60994A700FF1332821D343220C9073F792B30A9112000:8 X-MTK: N X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 00:18:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784519796396534889 X-GMAIL-MSGID: 1784519796396534889 |
Series |
add driver to support secure video decoder
|
|
Commit Message
Yunfei Dong (董云飞)
Dec. 6, 2023, 8:15 a.m. UTC
Initialize tee private data to support secure decoder.
Release tee related information for each instance when decoder
done.
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
.../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 8 ++++++++
1 file changed, 8 insertions(+)
Comments
Hi Yunfei, kernel test robot noticed the following build errors: [auto build test ERROR on media-tree/master] [also build test ERROR on linus/master v6.7-rc4 next-20231206] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Yunfei-Dong/media-medkatek-vcodec-support-tee-decoder/20231206-201843 base: git://linuxtv.org/media_tree.git master patch link: https://lore.kernel.org/r/20231206081538.17056-21-yunfei.dong%40mediatek.com patch subject: [PATCH] media: medkatek: vcodec: support tee decoder config: arm64-defconfig (https://download.01.org/0day-ci/archive/20231207/202312070717.a86rODYn-lkp@intel.com/config) compiler: aarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231207/202312070717.a86rODYn-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312070717.a86rODYn-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c: In function 'fops_vcodec_release': >> drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:313:16: error: 'struct mtk_vcodec_dec_ctx' has no member named 'is_secure_playback' 313 | if (ctx->is_secure_playback) | ^~ >> drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:314:17: error: implicit declaration of function 'mtk_vcodec_dec_optee_release'; did you mean 'mtk_vcodec_dec_release'? [-Werror=implicit-function-declaration] 314 | mtk_vcodec_dec_optee_release(dev->optee_private); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | mtk_vcodec_dec_release >> drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:314:49: error: 'struct mtk_vcodec_dec_dev' has no member named 'optee_private' 314 | mtk_vcodec_dec_optee_release(dev->optee_private); | ^~ drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c: In function 'mtk_vcodec_probe': >> drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:472:15: error: implicit declaration of function 'mtk_vcodec_dec_optee_private_init'; did you mean 'mtk_vcodec_dec_queue_init'? [-Werror=implicit-function-declaration] 472 | ret = mtk_vcodec_dec_optee_private_init(dev); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | mtk_vcodec_dec_queue_init cc1: some warnings being treated as errors vim +313 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c 291 292 static int fops_vcodec_release(struct file *file) 293 { 294 struct mtk_vcodec_dec_dev *dev = video_drvdata(file); 295 struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(file->private_data); 296 297 mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id); 298 mutex_lock(&dev->dev_mutex); 299 300 /* 301 * Call v4l2_m2m_ctx_release before mtk_vcodec_dec_release. First, it 302 * makes sure the worker thread is not running after vdec_if_deinit. 303 * Second, the decoder will be flushed and all the buffers will be 304 * returned in stop_streaming. 305 */ 306 v4l2_m2m_ctx_release(ctx->m2m_ctx); 307 mtk_vcodec_dec_release(ctx); 308 309 v4l2_fh_del(&ctx->fh); 310 v4l2_fh_exit(&ctx->fh); 311 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); 312 > 313 if (ctx->is_secure_playback) > 314 mtk_vcodec_dec_optee_release(dev->optee_private); 315 316 mtk_vcodec_dbgfs_remove(dev, ctx->id); 317 list_del_init(&ctx->list); 318 kfree(ctx); 319 mutex_unlock(&dev->dev_mutex); 320 return 0; 321 } 322 323 static const struct v4l2_file_operations mtk_vcodec_fops = { 324 .owner = THIS_MODULE, 325 .open = fops_vcodec_open, 326 .release = fops_vcodec_release, 327 .poll = v4l2_m2m_fop_poll, 328 .unlocked_ioctl = video_ioctl2, 329 .mmap = v4l2_m2m_fop_mmap, 330 }; 331 332 static void mtk_vcodec_dec_get_chip_name(struct mtk_vcodec_dec_dev *vdec_dev) 333 { 334 struct device *dev = &vdec_dev->plat_dev->dev; 335 336 if (of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-dec")) 337 vdec_dev->chip_name = MTK_VDEC_MT8173; 338 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8183-vcodec-dec")) 339 vdec_dev->chip_name = MTK_VDEC_MT8183; 340 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8192-vcodec-dec")) 341 vdec_dev->chip_name = MTK_VDEC_MT8192; 342 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8195-vcodec-dec")) 343 vdec_dev->chip_name = MTK_VDEC_MT8195; 344 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8186-vcodec-dec")) 345 vdec_dev->chip_name = MTK_VDEC_MT8186; 346 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8188-vcodec-dec")) 347 vdec_dev->chip_name = MTK_VDEC_MT8188; 348 else 349 vdec_dev->chip_name = MTK_VDEC_INVAL; 350 } 351 352 static int mtk_vcodec_probe(struct platform_device *pdev) 353 { 354 struct mtk_vcodec_dec_dev *dev; 355 struct video_device *vfd_dec; 356 phandle rproc_phandle; 357 enum mtk_vcodec_fw_type fw_type; 358 int i, ret; 359 360 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); 361 if (!dev) 362 return -ENOMEM; 363 364 INIT_LIST_HEAD(&dev->ctx_list); 365 dev->plat_dev = pdev; 366 367 mtk_vcodec_dec_get_chip_name(dev); 368 if (dev->chip_name == MTK_VDEC_INVAL) { 369 dev_err(&pdev->dev, "Failed to get decoder chip name"); 370 return -EINVAL; 371 } 372 373 dev->vdec_pdata = of_device_get_match_data(&pdev->dev); 374 if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu", 375 &rproc_phandle)) { 376 fw_type = VPU; 377 } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp", 378 &rproc_phandle)) { 379 fw_type = SCP; 380 } else { 381 dev_dbg(&pdev->dev, "Could not get vdec IPI device"); 382 return -ENODEV; 383 } 384 dma_set_max_seg_size(&pdev->dev, UINT_MAX); 385 386 dev->fw_handler = mtk_vcodec_fw_select(dev, fw_type, DECODER); 387 if (IS_ERR(dev->fw_handler)) 388 return PTR_ERR(dev->fw_handler); 389 390 ret = mtk_vcodec_init_dec_resources(dev); 391 if (ret) { 392 dev_err(&pdev->dev, "Failed to init dec resources"); 393 goto err_dec_pm; 394 } 395 396 if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch)) { 397 dev->core_workqueue = 398 alloc_ordered_workqueue("core-decoder", 399 WQ_MEM_RECLAIM | WQ_FREEZABLE); 400 if (!dev->core_workqueue) { 401 dev_dbg(&pdev->dev, "Failed to create core workqueue"); 402 ret = -EINVAL; 403 goto err_res; 404 } 405 } 406 407 for (i = 0; i < MTK_VDEC_HW_MAX; i++) 408 mutex_init(&dev->dec_mutex[i]); 409 mutex_init(&dev->dev_mutex); 410 spin_lock_init(&dev->irqlock); 411 412 snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s", 413 "[/MTK_V4L2_VDEC]"); 414 415 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); 416 if (ret) { 417 dev_err(&pdev->dev, "v4l2_device_register err=%d", ret); 418 goto err_core_workq; 419 } 420 421 vfd_dec = video_device_alloc(); 422 if (!vfd_dec) { 423 dev_err(&pdev->dev, "Failed to allocate video device"); 424 ret = -ENOMEM; 425 goto err_dec_alloc; 426 } 427 vfd_dec->fops = &mtk_vcodec_fops; 428 vfd_dec->ioctl_ops = &mtk_vdec_ioctl_ops; 429 vfd_dec->release = video_device_release; 430 vfd_dec->lock = &dev->dev_mutex; 431 vfd_dec->v4l2_dev = &dev->v4l2_dev; 432 vfd_dec->vfl_dir = VFL_DIR_M2M; 433 vfd_dec->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | 434 V4L2_CAP_STREAMING; 435 436 snprintf(vfd_dec->name, sizeof(vfd_dec->name), "%s", 437 MTK_VCODEC_DEC_NAME); 438 video_set_drvdata(vfd_dec, dev); 439 dev->vfd_dec = vfd_dec; 440 platform_set_drvdata(pdev, dev); 441 442 dev->m2m_dev_dec = v4l2_m2m_init(&mtk_vdec_m2m_ops); 443 if (IS_ERR((__force void *)dev->m2m_dev_dec)) { 444 dev_err(&pdev->dev, "Failed to init mem2mem dec device"); 445 ret = PTR_ERR((__force void *)dev->m2m_dev_dec); 446 goto err_dec_alloc; 447 } 448 449 dev->decode_workqueue = 450 alloc_ordered_workqueue(MTK_VCODEC_DEC_NAME, 451 WQ_MEM_RECLAIM | WQ_FREEZABLE); 452 if (!dev->decode_workqueue) { 453 dev_err(&pdev->dev, "Failed to create decode workqueue"); 454 ret = -EINVAL; 455 goto err_event_workq; 456 } 457 458 if (dev->vdec_pdata->is_subdev_supported) { 459 ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, 460 &pdev->dev); 461 if (ret) { 462 dev_err(&pdev->dev, "Main device of_platform_populate failed."); 463 goto err_reg_cont; 464 } 465 } else { 466 set_bit(MTK_VDEC_CORE, dev->subdev_bitmap); 467 } 468 469 atomic_set(&dev->dec_active_cnt, 0); 470 memset(dev->vdec_racing_info, 0, sizeof(dev->vdec_racing_info)); 471 mutex_init(&dev->dec_racing_info_mutex); > 472 ret = mtk_vcodec_dec_optee_private_init(dev); 473 if (ret) { 474 dev_err(&pdev->dev, "Failed to init svp private."); 475 goto err_reg_cont; 476 } 477 478 ret = video_register_device(vfd_dec, VFL_TYPE_VIDEO, -1); 479 if (ret) { 480 dev_err(&pdev->dev, "Failed to register video device"); 481 goto err_reg_cont; 482 } 483 484 if (dev->vdec_pdata->uses_stateless_api) { 485 v4l2_disable_ioctl(vfd_dec, VIDIOC_DECODER_CMD); 486 v4l2_disable_ioctl(vfd_dec, VIDIOC_TRY_DECODER_CMD); 487 488 dev->mdev_dec.dev = &pdev->dev; 489 strscpy(dev->mdev_dec.model, MTK_VCODEC_DEC_NAME, 490 sizeof(dev->mdev_dec.model)); 491 492 media_device_init(&dev->mdev_dec); 493 dev->mdev_dec.ops = &mtk_vcodec_media_ops; 494 dev->v4l2_dev.mdev = &dev->mdev_dec; 495 496 ret = v4l2_m2m_register_media_controller(dev->m2m_dev_dec, dev->vfd_dec, 497 MEDIA_ENT_F_PROC_VIDEO_DECODER); 498 if (ret) { 499 dev_err(&pdev->dev, "Failed to register media controller"); 500 goto err_dec_mem_init; 501 } 502 503 ret = media_device_register(&dev->mdev_dec); 504 if (ret) { 505 dev_err(&pdev->dev, "Failed to register media device"); 506 goto err_media_reg; 507 } 508 509 dev_dbg(&pdev->dev, "media registered as /dev/media%d", vfd_dec->minor); 510 } 511 512 mtk_vcodec_dbgfs_init(dev, false); 513 dev_dbg(&pdev->dev, "decoder registered as /dev/video%d", vfd_dec->minor); 514 515 return 0; 516 517 err_media_reg: 518 v4l2_m2m_unregister_media_controller(dev->m2m_dev_dec); 519 err_dec_mem_init: 520 video_unregister_device(vfd_dec); 521 err_reg_cont: 522 if (dev->vdec_pdata->uses_stateless_api) 523 media_device_cleanup(&dev->mdev_dec); 524 destroy_workqueue(dev->decode_workqueue); 525 err_event_workq: 526 v4l2_m2m_release(dev->m2m_dev_dec); 527 err_dec_alloc: 528 v4l2_device_unregister(&dev->v4l2_dev); 529 err_core_workq: 530 if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch)) 531 destroy_workqueue(dev->core_workqueue); 532 err_res: 533 if (!dev->vdec_pdata->is_subdev_supported) 534 pm_runtime_disable(dev->pm.dev); 535 err_dec_pm: 536 mtk_vcodec_fw_release(dev->fw_handler); 537 return ret; 538 } 539
Hi Yunfei, kernel test robot noticed the following build errors: [auto build test ERROR on media-tree/master] [also build test ERROR on linus/master v6.7-rc4 next-20231206] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Yunfei-Dong/media-medkatek-vcodec-support-tee-decoder/20231206-201843 base: git://linuxtv.org/media_tree.git master patch link: https://lore.kernel.org/r/20231206081538.17056-21-yunfei.dong%40mediatek.com patch subject: [PATCH] media: medkatek: vcodec: support tee decoder config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20231207/202312070723.APrpMLj9-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231207/202312070723.APrpMLj9-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312070723.APrpMLj9-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:313:11: error: no member named 'is_secure_playback' in 'struct mtk_vcodec_dec_ctx' 313 | if (ctx->is_secure_playback) | ~~~ ^ >> drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:314:3: error: call to undeclared function 'mtk_vcodec_dec_optee_release'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 314 | mtk_vcodec_dec_optee_release(dev->optee_private); | ^ drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:314:3: note: did you mean 'mtk_vcodec_dec_release'? drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h:88:6: note: 'mtk_vcodec_dec_release' declared here 88 | void mtk_vcodec_dec_release(struct mtk_vcodec_dec_ctx *ctx); | ^ >> drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:314:37: error: no member named 'optee_private' in 'struct mtk_vcodec_dec_dev' 314 | mtk_vcodec_dec_optee_release(dev->optee_private); | ~~~ ^ >> drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:472:8: error: call to undeclared function 'mtk_vcodec_dec_optee_private_init'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 472 | ret = mtk_vcodec_dec_optee_private_init(dev); | ^ drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c:472:8: note: did you mean 'mtk_vcodec_dec_queue_init'? drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h:85:5: note: 'mtk_vcodec_dec_queue_init' declared here 85 | int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq, | ^ 4 errors generated. vim +313 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c 291 292 static int fops_vcodec_release(struct file *file) 293 { 294 struct mtk_vcodec_dec_dev *dev = video_drvdata(file); 295 struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(file->private_data); 296 297 mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id); 298 mutex_lock(&dev->dev_mutex); 299 300 /* 301 * Call v4l2_m2m_ctx_release before mtk_vcodec_dec_release. First, it 302 * makes sure the worker thread is not running after vdec_if_deinit. 303 * Second, the decoder will be flushed and all the buffers will be 304 * returned in stop_streaming. 305 */ 306 v4l2_m2m_ctx_release(ctx->m2m_ctx); 307 mtk_vcodec_dec_release(ctx); 308 309 v4l2_fh_del(&ctx->fh); 310 v4l2_fh_exit(&ctx->fh); 311 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); 312 > 313 if (ctx->is_secure_playback) > 314 mtk_vcodec_dec_optee_release(dev->optee_private); 315 316 mtk_vcodec_dbgfs_remove(dev, ctx->id); 317 list_del_init(&ctx->list); 318 kfree(ctx); 319 mutex_unlock(&dev->dev_mutex); 320 return 0; 321 } 322 323 static const struct v4l2_file_operations mtk_vcodec_fops = { 324 .owner = THIS_MODULE, 325 .open = fops_vcodec_open, 326 .release = fops_vcodec_release, 327 .poll = v4l2_m2m_fop_poll, 328 .unlocked_ioctl = video_ioctl2, 329 .mmap = v4l2_m2m_fop_mmap, 330 }; 331 332 static void mtk_vcodec_dec_get_chip_name(struct mtk_vcodec_dec_dev *vdec_dev) 333 { 334 struct device *dev = &vdec_dev->plat_dev->dev; 335 336 if (of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-dec")) 337 vdec_dev->chip_name = MTK_VDEC_MT8173; 338 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8183-vcodec-dec")) 339 vdec_dev->chip_name = MTK_VDEC_MT8183; 340 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8192-vcodec-dec")) 341 vdec_dev->chip_name = MTK_VDEC_MT8192; 342 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8195-vcodec-dec")) 343 vdec_dev->chip_name = MTK_VDEC_MT8195; 344 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8186-vcodec-dec")) 345 vdec_dev->chip_name = MTK_VDEC_MT8186; 346 else if (of_device_is_compatible(dev->of_node, "mediatek,mt8188-vcodec-dec")) 347 vdec_dev->chip_name = MTK_VDEC_MT8188; 348 else 349 vdec_dev->chip_name = MTK_VDEC_INVAL; 350 } 351 352 static int mtk_vcodec_probe(struct platform_device *pdev) 353 { 354 struct mtk_vcodec_dec_dev *dev; 355 struct video_device *vfd_dec; 356 phandle rproc_phandle; 357 enum mtk_vcodec_fw_type fw_type; 358 int i, ret; 359 360 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); 361 if (!dev) 362 return -ENOMEM; 363 364 INIT_LIST_HEAD(&dev->ctx_list); 365 dev->plat_dev = pdev; 366 367 mtk_vcodec_dec_get_chip_name(dev); 368 if (dev->chip_name == MTK_VDEC_INVAL) { 369 dev_err(&pdev->dev, "Failed to get decoder chip name"); 370 return -EINVAL; 371 } 372 373 dev->vdec_pdata = of_device_get_match_data(&pdev->dev); 374 if (!of_property_read_u32(pdev->dev.of_node, "mediatek,vpu", 375 &rproc_phandle)) { 376 fw_type = VPU; 377 } else if (!of_property_read_u32(pdev->dev.of_node, "mediatek,scp", 378 &rproc_phandle)) { 379 fw_type = SCP; 380 } else { 381 dev_dbg(&pdev->dev, "Could not get vdec IPI device"); 382 return -ENODEV; 383 } 384 dma_set_max_seg_size(&pdev->dev, UINT_MAX); 385 386 dev->fw_handler = mtk_vcodec_fw_select(dev, fw_type, DECODER); 387 if (IS_ERR(dev->fw_handler)) 388 return PTR_ERR(dev->fw_handler); 389 390 ret = mtk_vcodec_init_dec_resources(dev); 391 if (ret) { 392 dev_err(&pdev->dev, "Failed to init dec resources"); 393 goto err_dec_pm; 394 } 395 396 if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch)) { 397 dev->core_workqueue = 398 alloc_ordered_workqueue("core-decoder", 399 WQ_MEM_RECLAIM | WQ_FREEZABLE); 400 if (!dev->core_workqueue) { 401 dev_dbg(&pdev->dev, "Failed to create core workqueue"); 402 ret = -EINVAL; 403 goto err_res; 404 } 405 } 406 407 for (i = 0; i < MTK_VDEC_HW_MAX; i++) 408 mutex_init(&dev->dec_mutex[i]); 409 mutex_init(&dev->dev_mutex); 410 spin_lock_init(&dev->irqlock); 411 412 snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s", 413 "[/MTK_V4L2_VDEC]"); 414 415 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); 416 if (ret) { 417 dev_err(&pdev->dev, "v4l2_device_register err=%d", ret); 418 goto err_core_workq; 419 } 420 421 vfd_dec = video_device_alloc(); 422 if (!vfd_dec) { 423 dev_err(&pdev->dev, "Failed to allocate video device"); 424 ret = -ENOMEM; 425 goto err_dec_alloc; 426 } 427 vfd_dec->fops = &mtk_vcodec_fops; 428 vfd_dec->ioctl_ops = &mtk_vdec_ioctl_ops; 429 vfd_dec->release = video_device_release; 430 vfd_dec->lock = &dev->dev_mutex; 431 vfd_dec->v4l2_dev = &dev->v4l2_dev; 432 vfd_dec->vfl_dir = VFL_DIR_M2M; 433 vfd_dec->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | 434 V4L2_CAP_STREAMING; 435 436 snprintf(vfd_dec->name, sizeof(vfd_dec->name), "%s", 437 MTK_VCODEC_DEC_NAME); 438 video_set_drvdata(vfd_dec, dev); 439 dev->vfd_dec = vfd_dec; 440 platform_set_drvdata(pdev, dev); 441 442 dev->m2m_dev_dec = v4l2_m2m_init(&mtk_vdec_m2m_ops); 443 if (IS_ERR((__force void *)dev->m2m_dev_dec)) { 444 dev_err(&pdev->dev, "Failed to init mem2mem dec device"); 445 ret = PTR_ERR((__force void *)dev->m2m_dev_dec); 446 goto err_dec_alloc; 447 } 448 449 dev->decode_workqueue = 450 alloc_ordered_workqueue(MTK_VCODEC_DEC_NAME, 451 WQ_MEM_RECLAIM | WQ_FREEZABLE); 452 if (!dev->decode_workqueue) { 453 dev_err(&pdev->dev, "Failed to create decode workqueue"); 454 ret = -EINVAL; 455 goto err_event_workq; 456 } 457 458 if (dev->vdec_pdata->is_subdev_supported) { 459 ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, 460 &pdev->dev); 461 if (ret) { 462 dev_err(&pdev->dev, "Main device of_platform_populate failed."); 463 goto err_reg_cont; 464 } 465 } else { 466 set_bit(MTK_VDEC_CORE, dev->subdev_bitmap); 467 } 468 469 atomic_set(&dev->dec_active_cnt, 0); 470 memset(dev->vdec_racing_info, 0, sizeof(dev->vdec_racing_info)); 471 mutex_init(&dev->dec_racing_info_mutex); > 472 ret = mtk_vcodec_dec_optee_private_init(dev); 473 if (ret) { 474 dev_err(&pdev->dev, "Failed to init svp private."); 475 goto err_reg_cont; 476 } 477 478 ret = video_register_device(vfd_dec, VFL_TYPE_VIDEO, -1); 479 if (ret) { 480 dev_err(&pdev->dev, "Failed to register video device"); 481 goto err_reg_cont; 482 } 483 484 if (dev->vdec_pdata->uses_stateless_api) { 485 v4l2_disable_ioctl(vfd_dec, VIDIOC_DECODER_CMD); 486 v4l2_disable_ioctl(vfd_dec, VIDIOC_TRY_DECODER_CMD); 487 488 dev->mdev_dec.dev = &pdev->dev; 489 strscpy(dev->mdev_dec.model, MTK_VCODEC_DEC_NAME, 490 sizeof(dev->mdev_dec.model)); 491 492 media_device_init(&dev->mdev_dec); 493 dev->mdev_dec.ops = &mtk_vcodec_media_ops; 494 dev->v4l2_dev.mdev = &dev->mdev_dec; 495 496 ret = v4l2_m2m_register_media_controller(dev->m2m_dev_dec, dev->vfd_dec, 497 MEDIA_ENT_F_PROC_VIDEO_DECODER); 498 if (ret) { 499 dev_err(&pdev->dev, "Failed to register media controller"); 500 goto err_dec_mem_init; 501 } 502 503 ret = media_device_register(&dev->mdev_dec); 504 if (ret) { 505 dev_err(&pdev->dev, "Failed to register media device"); 506 goto err_media_reg; 507 } 508 509 dev_dbg(&pdev->dev, "media registered as /dev/media%d", vfd_dec->minor); 510 } 511 512 mtk_vcodec_dbgfs_init(dev, false); 513 dev_dbg(&pdev->dev, "decoder registered as /dev/video%d", vfd_dec->minor); 514 515 return 0; 516 517 err_media_reg: 518 v4l2_m2m_unregister_media_controller(dev->m2m_dev_dec); 519 err_dec_mem_init: 520 video_unregister_device(vfd_dec); 521 err_reg_cont: 522 if (dev->vdec_pdata->uses_stateless_api) 523 media_device_cleanup(&dev->mdev_dec); 524 destroy_workqueue(dev->decode_workqueue); 525 err_event_workq: 526 v4l2_m2m_release(dev->m2m_dev_dec); 527 err_dec_alloc: 528 v4l2_device_unregister(&dev->v4l2_dev); 529 err_core_workq: 530 if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch)) 531 destroy_workqueue(dev->core_workqueue); 532 err_res: 533 if (!dev->vdec_pdata->is_subdev_supported) 534 pm_runtime_disable(dev->pm.dev); 535 err_dec_pm: 536 mtk_vcodec_fw_release(dev->fw_handler); 537 return ret; 538 } 539
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c index f47c98faf068..08e7d250487b 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c @@ -310,6 +310,9 @@ static int fops_vcodec_release(struct file *file) v4l2_fh_exit(&ctx->fh); v4l2_ctrl_handler_free(&ctx->ctrl_hdl); + if (ctx->is_secure_playback) + mtk_vcodec_dec_optee_release(dev->optee_private); + mtk_vcodec_dbgfs_remove(dev, ctx->id); list_del_init(&ctx->list); kfree(ctx); @@ -466,6 +469,11 @@ static int mtk_vcodec_probe(struct platform_device *pdev) atomic_set(&dev->dec_active_cnt, 0); memset(dev->vdec_racing_info, 0, sizeof(dev->vdec_racing_info)); mutex_init(&dev->dec_racing_info_mutex); + ret = mtk_vcodec_dec_optee_private_init(dev); + if (ret) { + dev_err(&pdev->dev, "Failed to init svp private."); + goto err_reg_cont; + } ret = video_register_device(vfd_dec, VFL_TYPE_VIDEO, -1); if (ret) {