[1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask
Message ID | 20230323083810.21912-1-yunfei.dong@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2794274wrt; Thu, 23 Mar 2023 01:53:46 -0700 (PDT) X-Google-Smtp-Source: AK7set/josDFVSGoIXPon0dgtNGv7gKGrizOM5WNvHnpSlDuRX7QKN2KofiIv97lCZs7Fob5deO3 X-Received: by 2002:a05:6402:1384:b0:4fa:8aa2:4170 with SMTP id b4-20020a056402138400b004fa8aa24170mr9289978edv.27.1679561626387; Thu, 23 Mar 2023 01:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679561626; cv=none; d=google.com; s=arc-20160816; b=higtly1piBhBDO9Wf6Z3/zowc7owk9y+SWzbt+XBy8dJ75q/NQTgnndD7U/UoT7Vta qPsih94NSyHW4wqyxoTRrBnW0VTVH4hMA0HY9Ux6aw8A7T3UlKk36xsVMoFvC1NzIaBT X+sBLfja3H9TCiaF4rpX032BxaQGoEzhL38NwZFtV7LCZMCeCkrywcOObrN2CCMcvcfx cXjoSo/aKp1KW2TpVFvKki0g/N1q4ZLdM/nqesjKe2nWLkPZqwz/V4OUf7jAq+I57mWZ 4qrbf50UMKP7TYORe/l3PxZlxG/YGSVZxrj52rvHgOuZCu+BPV6Q57unH8nVJmJZeM1c BJtQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=02p1XoxXrLuMUBe0CjfZAi7psUBwCDsTusscQOeN2kU=; b=vldhcxb0dqCfhdjRBGFKQChC6QXTre4lij4WTBs3NgXnBMHF34N2qt0WbDvqPQBbpw YTVbc5S39imd11PQQ/uBfCE4bK/1fyEsKBGT9f37gN1116fBDxIfJ5NEPvzB7D7TWRAx 3/QB3i+VIwUzvGb25ondhJTDVIEbgV4Zzm3XKepltzMiOZQ7PIcU+HkDnhBNbxPLXt4W 08lLX6IDYY1mL1SYX/StQZI5jadoiPBcd+vlsrPHPxST1PdDflLL/PyWr5Mfy1aiF8OT +yge2+LUB0CNPD3CPhwN1VpIH1lTgOYoCFgFX3cCwLiqNj/3T+uQORc27POX47aEj5Tm 9ogQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=f7OnHpUT; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wf4-20020a170907d68400b0093339446f35si14333525ejc.129.2023.03.23.01.53.22; Thu, 23 Mar 2023 01:53:45 -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=f7OnHpUT; 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 S231473AbjCWIkF (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Thu, 23 Mar 2023 04:40:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231142AbjCWIjm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 23 Mar 2023 04:39:42 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96B19199D0; Thu, 23 Mar 2023 01:38:17 -0700 (PDT) X-UUID: 0cb96ec6c95611eda9a90f0bb45854f4-20230323 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:Message-ID:Date:Subject:CC:To:From; bh=02p1XoxXrLuMUBe0CjfZAi7psUBwCDsTusscQOeN2kU=; b=f7OnHpUTpnNP2fcPBRIzEyK+L9PK3z9SuDMmPWX+fP5JRvjL5ooT4NXfnR5KMCo65A82uTp3zJUS0djdFwCkl3irZ5Ny5n6wUMai7egSB5h+ItPSPZY/KEaTZDi1fe1o5bNVZMTfL02IrkXgMezR81uPLRtr2zpnZrijoflHnP4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:200f4d0d-4c03-434f-adf7-4c937266cde6,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:120426c,CLOUDID:dcde21b4-beed-4dfc-bd9c-e1b22fa6ccc4,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 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 0cb96ec6c95611eda9a90f0bb45854f4-20230323 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from <yunfei.dong@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1510370815; Thu, 23 Mar 2023 16:38:13 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Thu, 23 Mar 2023 16:38:12 +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.25 via Frontend Transport; Thu, 23 Mar 2023 16:38:11 +0800 From: Yunfei Dong <yunfei.dong@mediatek.com> To: Yunfei Dong <yunfei.dong@mediatek.com>, Chen-Yu Tsai <wenst@chromium.org>, Yong Wu <yong.wu@mediatek.org>, Nicolas Dufresne <nicolas@ndufresne.ca>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Benjamin Gaignard <benjamin.gaignard@collabora.com>, =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= <nfraprado@collabora.com> CC: Matthias Brugger <matthias.bgg@gmail.com>, Hsin-Yi Wang <hsinyi@chromium.org>, Fritz Koenig <frkoenig@chromium.org>, Daniel Vetter <daniel@ffwll.ch>, Steve Cho <stevecho@chromium.org>, <linux-media@vger.kernel.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 1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask Date: Thu, 23 Mar 2023 16:38:09 +0800 Message-ID: <20230323083810.21912-1-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761148011904117438?= X-GMAIL-MSGID: =?utf-8?q?1761148011904117438?= |
Series |
[1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask
|
|
Commit Message
Yunfei Dong (董云飞)
March 23, 2023, 8:38 a.m. UTC
After commit f1ad5338a4d5("of: Fix "dma-ranges" handling for bus controllers"),
the dma-ranges is not allowed in decoder dts node. But the driver still need
to set dma mask, remove "dma-ranges" condition in prob function.
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
Reference series:
[1]: v5 of this series is present by Yong Wu.
20230307023507.13306-1-yong.wu@mediatek.com
---
.../mediatek/vcodec/mtk_vcodec_dec_drv.c | 24 +++++++++++++------
1 file changed, 17 insertions(+), 7 deletions(-)
Comments
Il 23/03/23 09:38, Yunfei Dong ha scritto: > After commit f1ad5338a4d5("of: Fix "dma-ranges" handling for bus controllers"), > the dma-ranges is not allowed in decoder dts node. But the driver still need > to set dma mask, remove "dma-ranges" condition in prob function. > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > --- > Reference series: > [1]: v5 of this series is present by Yong Wu. > 20230307023507.13306-1-yong.wu@mediatek.com > --- > .../mediatek/vcodec/mtk_vcodec_dec_drv.c | 24 +++++++++++++------ > 1 file changed, 17 insertions(+), 7 deletions(-) > > 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 bba7b932f4fa..2c3a4c2cdaee 100644 > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c > @@ -137,6 +137,20 @@ static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev *dev) > return 0; > } > > +static int mtk_vcodec_dec_set_dma_mask(struct device *dev) > +{ > + int ret = 0; > + > + return !(of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-dec") || > + of_device_is_compatible(dev->of_node, "mediatek,mt8183-vcodec-dec")); Like that, you're never reaching the code below... Anyway, at a first glance, it looked like you were sending the same commit twice, but then I noticed... so... I would propose to change the commit title(s) to follow this format: media: mediatek: vcodec: enc: Set DMA mask only for MT8173 and MT8183 (but then, why mt8173/83 and not the others? this deserves an explanation...) Regards, Angelo
On Thu, 2023-03-23 at 09:50 +0100, AngeloGioacchino Del Regno wrote: > Il 23/03/23 09:38, Yunfei Dong ha scritto: > > After commit f1ad5338a4d5("of: Fix "dma-ranges" handling for bus > > controllers"), > > the dma-ranges is not allowed in decoder dts node. But the driver > > still need > > to set dma mask, remove "dma-ranges" condition in prob function. > > > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > > --- > > Reference series: > > [1]: v5 of this series is present by Yong Wu. > > 20230307023507.13306-1-yong.wu@mediatek.com > > --- > > .../mediatek/vcodec/mtk_vcodec_dec_drv.c | 24 +++++++++++++- > > ----- > > 1 file changed, 17 insertions(+), 7 deletions(-) > > > > 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 bba7b932f4fa..2c3a4c2cdaee 100644 > > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c > > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c > > @@ -137,6 +137,20 @@ static int > > mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev *dev) > > return 0; > > } > > > > +static int mtk_vcodec_dec_set_dma_mask(struct device *dev) > > +{ > > + int ret = 0; > > + > > + return !(of_device_is_compatible(dev->of_node, > > "mediatek,mt8173-vcodec-dec") || > > + of_device_is_compatible(dev->of_node, > > "mediatek,mt8183-vcodec-dec")); > > Like that, you're never reaching the code below... > > Anyway, at a first glance, it looked like you were sending the same > commit twice, > but then I noticed... so... I would propose to change the commit > title(s) to follow > this format: > > media: mediatek: vcodec: enc: Set DMA mask only for MT8173 and MT8183 > > (but then, why mt8173/83 and not the others? this deserves an > explanation...) This should be mt8173/83 don't need this. After confirming with yunfei, I will fix the "return" above and contain this two patches and a jpeg fix patch into the patchset of "Adjust the dma-ranges for MTK IOMMU". This issue was introduced by that one since I removed "dma-ranges" for them. they should be a topic. > > > Regards, > Angelo > >
On Thu, 2023-03-23 at 17:13 +0800, YongWu wrote: > On Thu, 2023-03-23 at 09:50 +0100, AngeloGioacchino Del Regno wrote: > > Il 23/03/23 09:38, Yunfei Dong ha scritto: > > > After commit f1ad5338a4d5("of: Fix "dma-ranges" handling for bus > > > controllers"), > > > the dma-ranges is not allowed in decoder dts node. But the driver > > > still need > > > to set dma mask, remove "dma-ranges" condition in prob function. > > > > > > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> > > > --- > > > Reference series: > > > [1]: v5 of this series is present by Yong Wu. > > > 20230307023507.13306-1-yong.wu@mediatek.com > > > --- > > > .../mediatek/vcodec/mtk_vcodec_dec_drv.c | 24 > > > +++++++++++++- > > > ----- > > > 1 file changed, 17 insertions(+), 7 deletions(-) > > > > > > 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 bba7b932f4fa..2c3a4c2cdaee 100644 > > > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c > > > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c > > > @@ -137,6 +137,20 @@ static int > > > mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev *dev) > > > return 0; > > > } > > > > > > +static int mtk_vcodec_dec_set_dma_mask(struct device *dev) > > > +{ > > > + int ret = 0; > > > + > > > + return !(of_device_is_compatible(dev->of_node, > > > "mediatek,mt8173-vcodec-dec") || > > > + of_device_is_compatible(dev->of_node, > > > "mediatek,mt8183-vcodec-dec")); > > > > Like that, you're never reaching the code below... > > > > Anyway, at a first glance, it looked like you were sending the same > > commit twice, > > but then I noticed... so... I would propose to change the commit > > title(s) to follow > > this format: > > > > media: mediatek: vcodec: enc: Set DMA mask only for MT8173 and > > MT8183 > > > > (but then, why mt8173/83 and not the others? this deserves an > > explanation...) > > This should be mt8173/83 don't need this. After confirming with > yunfei, > I will fix the "return" above and contain this two patches and a jpeg > fix patch into the patchset of "Adjust the dma-ranges for MTK IOMMU". > This issue was introduced by that one since I removed "dma-ranges" > for > them. they should be a topic. Hi Angelo, We meet a problem when changing this for jpeg. JPEG[1] uses "mediatek,mtk-jpgenc" for mt2701, mt8183, mt8186 and mt8188. But only mt8186/mt8188 need this "dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34))". It can not distinguish the different SoC. Then does it need a different compatible string for mt8186/mt8188? Alternatively, A more simple way, MTK iommu knows whether the jpeg need set dma_mask, it could help this. But I'm not sure if this is a right way. The master devices don't know if it need set dma_mask and its dma_mask is set by the other drivers, is this right? Thanks very much:) [1] https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/media/mediatek-jpeg-encoder.yaml#L23 > > > > > > > Regards, > > Angelo > > > >
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 bba7b932f4fa..2c3a4c2cdaee 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c @@ -137,6 +137,20 @@ static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev *dev) return 0; } +static int mtk_vcodec_dec_set_dma_mask(struct device *dev) +{ + int ret = 0; + + return !(of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-dec") || + of_device_is_compatible(dev->of_node, "mediatek,mt8183-vcodec-dec")); + + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(34)); + if (ret) + mtk_v4l2_err("Failed to set dec mask"); + + return ret; +} + static int fops_vcodec_open(struct file *file) { struct mtk_vcodec_dev *dev = video_drvdata(file); @@ -323,13 +337,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev) } } - if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL)) { - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34)); - if (ret) { - mtk_v4l2_err("Failed to set mask"); - goto err_core_workq; - } - } + ret = mtk_vcodec_dec_set_dma_mask(&pdev->dev); + if (ret) + goto err_core_workq; for (i = 0; i < MTK_VDEC_HW_MAX; i++) mutex_init(&dev->dec_mutex[i]);