Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp327381rwd; Wed, 24 May 2023 19:14:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6meG+QsXTD2rrXJbliv6inZ+GSg8ZeGDu3HLlG4A8DW4U6RgAsXQWZWusn34X6HhgLS35n X-Received: by 2002:a17:90a:d485:b0:250:69de:7157 with SMTP id s5-20020a17090ad48500b0025069de7157mr91977pju.2.1684980847916; Wed, 24 May 2023 19:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684980847; cv=none; d=google.com; s=arc-20160816; b=q7yaZqLFyMLURWCHOL1x73tvoxo44gnwp+3B9v+6ECTrTnd2RquSSs5l5uC4tVPK09 Jy76WqrG/K6+jmJcJuHHm1ePFkNMtaIcqIfZ/NW305mXPYxsEPbM20ULW8jfbG1uY8r1 uhfqueIJWHv40ZDXgawTm638+wLLyWCSy+3CLl98KOPNMPRMIJTUYSW+vd8vn8QPlKfL XxAfbBgPVEM6T5QbFDvUpTOZd8/pFL76kTYTn2sNn6eb1jwbstiST2WteLOQT7IiQyyc uKpKad+xsibmCLzhB4TLo/WJuCbWd7k8zGUb8AVj7a+wSkExF/870pgMmNvmpV0erM0d t8cA== 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=HX31f4v0C+Tr2QZizHSm9mjBbzR4uVoRPkleeD3PY4Q=; b=UCkua2ObRWdQe//S837pUMdfmnOV3zwz7GTSaA4EiiM+Wb+ZJ3lt1RytqCtUcUcr03 7rPmbX/xnicB4S0IKvdsYKGwYAJdzjJMBpLh8+GbrUaqU+YUs8A/igHgjqSGjJCqoQRz 7ViXPq/3HI5haxNHsj7064+rNBcXllIbUkD1JggaNF+EP8H+DoGgZaB31CpMzNNNJw0/ 5llpxEsDSuwesyQ8j3kzGiCC3+gEQDQZCgn9zg+9kakBj8ItFXvkGUsORA1B5UuRkxmW 9bSuodw+KY6bBqdoIAF6cv5R4LvUn9QJcZ5OE9QbYoQVxr/v28b2FpvyA9U3bhleQgO6 4K6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="e/BGUNYD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz21-20020a17090b0ed500b0024e140702efsi1341208pjb.118.2023.05.24.19.13.53; Wed, 24 May 2023 19:14:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="e/BGUNYD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235497AbjEYCMk (ORCPT + 99 others); Wed, 24 May 2023 22:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjEYCMg (ORCPT ); Wed, 24 May 2023 22:12:36 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EE3212B; Wed, 24 May 2023 19:12:30 -0700 (PDT) X-UUID: 95faed64faa111ed9cb5633481061a41-20230525 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=HX31f4v0C+Tr2QZizHSm9mjBbzR4uVoRPkleeD3PY4Q=; b=e/BGUNYDNOPOipJJj6/K4GVAcquQmi0ZFvuSkD5jIHjcS7YoWtI/wLe1xvf6EE0lBnZeZLbckTdCAhQsTFdhHLt4jMq2etpDfrBfUrdQcY03hY4B4o5l4zuuITGAir3ipdbWXhRaooS7PHcLogvjSRMl5xOLBUVlJyM4M7NXRx4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.25,REQID:16c461a3-73ad-4741-977e-3d7ed12cfa1c,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:d5b0ae3,CLOUDID:1f2c473c-de1e-4348-bc35-c96f92f1dcbb,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 95faed64faa111ed9cb5633481061a41-20230525 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 310332476; Thu, 25 May 2023 10:12:23 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 25 May 2023 10:12:21 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 25 May 2023 10:12:20 +0800 From: Yunfei Dong To: Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= , Nathan Hebert CC: Yunfei Dong , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v5,1/8] media: mediatek: vcodec: Add debugfs interface to get debug information Date: Thu, 25 May 2023 10:12:12 +0800 Message-ID: <20230525021219.23638-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230525021219.23638-1-yunfei.dong@mediatek.com> References: <20230525021219.23638-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be useful when debugging specific issues related to kernel in running status. Signed-off-by: Yunfei Dong Reviewed-by: AngeloGioacchino Del Regno --- .../media/platform/mediatek/vcodec/Makefile | 6 ++++ .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 33 +++++++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dbgfs.h | 32 ++++++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 ++ .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 4 +++ 5 files changed, 77 insertions(+) create mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c create mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h diff --git a/drivers/media/platform/mediatek/vcodec/Makefile b/drivers/media/platform/mediatek/vcodec/Makefile index d24b452d0fb3..d9979d0259c1 100644 --- a/drivers/media/platform/mediatek/vcodec/Makefile +++ b/drivers/media/platform/mediatek/vcodec/Makefile @@ -45,3 +45,9 @@ endif ifneq ($(CONFIG_VIDEO_MEDIATEK_VCODEC_SCP),) mtk-vcodec-common-y += mtk_vcodec_fw_scp.o endif + +ifneq ($(CONFIG_DEBUG_FS),) +obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dbgfs.o + +mtk-vcodec-dbgfs-y := mtk_vcodec_dbgfs.o +endif \ No newline at end of file diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c new file mode 100644 index 000000000000..fb9edd379af5 --- /dev/null +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2023 MediaTek Inc. + * Author: Yunfei Dong + */ + +#include + +#include "mtk_vcodec_dbgfs.h" +#include "mtk_vcodec_drv.h" +#include "mtk_vcodec_util.h" + +void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) +{ + struct dentry *vcodec_root; + + vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL); + if (IS_ERR(vcodec_dev->dbgfs.vcodec_root)) + dev_err(&vcodec_dev->plat_dev->dev, "create vcodec dir err:%d\n", + IS_ERR(vcodec_dev->dbgfs.vcodec_root)); + + vcodec_root = vcodec_dev->dbgfs.vcodec_root; +} +EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_init); + +void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev) +{ + debugfs_remove_recursive(vcodec_dev->dbgfs.vcodec_root); +} +EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_deinit); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Mediatek video codec driver"); diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h new file mode 100644 index 000000000000..5eec2211cbbe --- /dev/null +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2023 MediaTek Inc. + * Author: Yunfei Dong + */ + +#ifndef __MTK_VCODEC_DBGFS_H__ +#define __MTK_VCODEC_DBGFS_H__ + +struct mtk_vcodec_dev; + +/** + * struct mtk_vcodec_dbgfs - dbgfs information + * @vcodec_root: vcodec dbgfs entry + */ +struct mtk_vcodec_dbgfs { + struct dentry *vcodec_root; +}; + +#if defined(CONFIG_DEBUG_FS) +void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev); +void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev); +#else +static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) +{ +} + +static inline void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev) +{ +} +#endif +#endif diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c index 7bd300341cf0..51a9af193f92 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c @@ -422,6 +422,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) mtk_v4l2_debug(0, "media registered as /dev/media%d", vfd_dec->minor); } + mtk_vcodec_dbgfs_init(dev); mtk_v4l2_debug(0, "decoder registered as /dev/video%d", vfd_dec->minor); return 0; @@ -497,6 +498,7 @@ static void mtk_vcodec_dec_remove(struct platform_device *pdev) if (dev->vfd_dec) video_unregister_device(dev->vfd_dec); + mtk_vcodec_dbgfs_deinit(dev); v4l2_device_unregister(&dev->v4l2_dev); if (!dev->vdec_pdata->is_subdev_supported) pm_runtime_disable(dev->pm.dev); diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h index 1f4c5774ec47..3ec027ec8192 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h @@ -16,6 +16,7 @@ #include #include +#include "mtk_vcodec_dbgfs.h" #include "mtk_vcodec_util.h" #include "vdec_msg_queue.h" @@ -470,6 +471,7 @@ struct mtk_vcodec_enc_pdata { * @dec_active_cnt: used to mark whether need to record register value * @vdec_racing_info: record register value * @dec_racing_info_mutex: mutex lock used for inner racing mode + * @dbgfs: debug log related information */ struct mtk_vcodec_dev { struct v4l2_device v4l2_dev; @@ -519,6 +521,8 @@ struct mtk_vcodec_dev { u32 vdec_racing_info[132]; /* Protects access to vdec_racing_info data */ struct mutex dec_racing_info_mutex; + + struct mtk_vcodec_dbgfs dbgfs; }; static inline struct mtk_vcodec_ctx *fh_to_ctx(struct v4l2_fh *fh) -- 2.25.1