* [PATCH 1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask
@ 2023-03-23 8:38 Yunfei Dong
2023-03-23 8:38 ` [PATCH 2/2] media: mediatek: vcodec: Remove encoder " Yunfei Dong
2023-03-23 8:50 ` [PATCH 1/2] media: mediatek: vcodec: Remove decoder " AngeloGioacchino Del Regno
0 siblings, 2 replies; 5+ messages in thread
From: Yunfei Dong @ 2023-03-23 8:38 UTC (permalink / raw)
To: Yunfei Dong, Chen-Yu Tsai, Yong Wu, Nicolas Dufresne,
Hans Verkuil, AngeloGioacchino Del Regno, Benjamin Gaignard,
Nícolas F . R . A . Prado
Cc: Matthias Brugger, Hsin-Yi Wang, Fritz Koenig, Daniel Vetter,
Steve Cho, linux-media, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek,
Project_Global_Chrome_Upstream_Group
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"));
+
+ 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]);
--
2.18.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/2] media: mediatek: vcodec: Remove encoder 'dma-ranges' conditon when set dma mask 2023-03-23 8:38 [PATCH 1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask Yunfei Dong @ 2023-03-23 8:38 ` Yunfei Dong 2023-03-23 8:50 ` [PATCH 1/2] media: mediatek: vcodec: Remove decoder " AngeloGioacchino Del Regno 1 sibling, 0 replies; 5+ messages in thread From: Yunfei Dong @ 2023-03-23 8:38 UTC (permalink / raw) To: Yunfei Dong, Chen-Yu Tsai, Yong Wu, Nicolas Dufresne, Hans Verkuil, AngeloGioacchino Del Regno, Benjamin Gaignard, Nícolas F . R . A . Prado Cc: Matthias Brugger, Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Project_Global_Chrome_Upstream_Group After commit f1ad5338a4d5("of: Fix "dma-ranges" handling for bus controllers"), the dma-ranges is not allowed in encoder 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_enc_drv.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c index 6961f66b5693..dda669d04c05 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c @@ -83,6 +83,21 @@ static void clean_irq_status(unsigned int irq_status, void __iomem *addr) writel(MTK_VENC_IRQ_STATUS_FRM, addr); } + +static int mtk_vcodec_enc_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 enc mask"); + + return ret; +} + static irqreturn_t mtk_vcodec_enc_irq_handler(int irq, void *priv) { struct mtk_vcodec_dev *dev = priv; @@ -344,8 +359,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev) goto err_event_workq; } - if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL)) - dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34)); + ret = mtk_vcodec_enc_set_dma_mask(&pdev->dev); + if (ret) + goto err_event_workq; ret = video_register_device(vfd_enc, VFL_TYPE_VIDEO, -1); if (ret) { -- 2.18.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask 2023-03-23 8:38 [PATCH 1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask Yunfei Dong 2023-03-23 8:38 ` [PATCH 2/2] media: mediatek: vcodec: Remove encoder " Yunfei Dong @ 2023-03-23 8:50 ` AngeloGioacchino Del Regno 2023-03-23 9:13 ` Yong Wu (吴勇) 1 sibling, 1 reply; 5+ messages in thread From: AngeloGioacchino Del Regno @ 2023-03-23 8:50 UTC (permalink / raw) To: Yunfei Dong, Chen-Yu Tsai, Yong Wu, Nicolas Dufresne, Hans Verkuil, Benjamin Gaignard, Nícolas F . R . A . Prado Cc: Matthias Brugger, Hsin-Yi Wang, Fritz Koenig, Daniel Vetter, Steve Cho, linux-media, devicetree, linux-kernel, linux-arm-kernel, linux-mediatek, Project_Global_Chrome_Upstream_Group 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask 2023-03-23 8:50 ` [PATCH 1/2] media: mediatek: vcodec: Remove decoder " AngeloGioacchino Del Regno @ 2023-03-23 9:13 ` Yong Wu (吴勇) 2023-03-24 9:19 ` Yong Wu (吴勇) 0 siblings, 1 reply; 5+ messages in thread From: Yong Wu (吴勇) @ 2023-03-23 9:13 UTC (permalink / raw) To: nicolas, yong.wu, wenst, Yunfei Dong (董云飞), benjamin.gaignard, hverkuil-cisco, angelogioacchino.delregno, nfraprado Cc: linux-kernel, linux-mediatek, frkoenig, stevecho, linux-media, devicetree, daniel, Project_Global_Chrome_Upstream_Group, hsinyi, linux-arm-kernel, matthias.bgg 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 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask 2023-03-23 9:13 ` Yong Wu (吴勇) @ 2023-03-24 9:19 ` Yong Wu (吴勇) 0 siblings, 0 replies; 5+ messages in thread From: Yong Wu (吴勇) @ 2023-03-24 9:19 UTC (permalink / raw) To: Kyrie Wu (吴晗), angelogioacchino.delregno, Yunfei Dong (董云飞) Cc: linux-kernel, linux-mediatek, frkoenig, stevecho, wenst, linux-media, nicolas, yong.wu, daniel, Project_Global_Chrome_Upstream_Group, hsinyi, linux-arm-kernel, hverkuil-cisco, matthias.bgg, benjamin.gaignard, nfraprado, Jianhua Lin (林建华) 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 > > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-24 9:19 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-23 8:38 [PATCH 1/2] media: mediatek: vcodec: Remove decoder 'dma-ranges' conditon when set dma mask Yunfei Dong 2023-03-23 8:38 ` [PATCH 2/2] media: mediatek: vcodec: Remove encoder " Yunfei Dong 2023-03-23 8:50 ` [PATCH 1/2] media: mediatek: vcodec: Remove decoder " AngeloGioacchino Del Regno 2023-03-23 9:13 ` Yong Wu (吴勇) 2023-03-24 9:19 ` Yong Wu (吴勇)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®