diff mbox series

[v2,16/29] iommu/mediatek: Adjust device link when it is sub-common

Message ID 20210813065324.29220-17-yong.wu@mediatek.com
State New
Headers show
Series MT8195 IOMMU SUPPORT | expand

Commit Message

Yong Wu (吴勇) Aug. 13, 2021, 6:53 a.m. UTC
For MM IOMMU, We always add device link between smi-common and IOMMU HW.
In mt8195, we add smi-sub-common. Thus, if the node is sub-common, we still
need find again to get smi-common, then do device link.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
 drivers/iommu/mtk_iommu.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Hsin-Yi Wang Aug. 24, 2021, 7:35 a.m. UTC | #1
On Fri, Aug 13, 2021 at 3:03 PM Yong Wu <yong.wu@mediatek.com> wrote:
>

> For MM IOMMU, We always add device link between smi-common and IOMMU HW.

> In mt8195, we add smi-sub-common. Thus, if the node is sub-common, we still

> need find again to get smi-common, then do device link.

>

> Signed-off-by: Yong Wu <yong.wu@mediatek.com>

> ---

>  drivers/iommu/mtk_iommu.c | 11 +++++++++++

>  1 file changed, 11 insertions(+)

>

> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c

> index a4479916ad33..a72241724adb 100644

> --- a/drivers/iommu/mtk_iommu.c

> +++ b/drivers/iommu/mtk_iommu.c

> @@ -845,6 +845,17 @@ static int mtk_iommu_mm_dts_parse(struct device *dev,

>         if (!smicomm_node)

>                 return -EINVAL;

>

> +       /* Find smi-common again if this is smi-sub-common */

> +       if (of_property_read_bool(smicomm_node, "mediatek,smi_sub_common")) {

> +               of_node_put(smicomm_node); /* put the sub common */

> +

> +               smicomm_node = of_parse_phandle(smicomm_node, "mediatek,smi", 0);


This only checks 1 level here, and does not check if the mediatek,smi
of a sub-common node is not another sub-common node.
So maybe add a check that the updated node here doesn't have
mediatek,smi_sub_common property.

> +               if (!smicomm_node) {

> +                       dev_err(dev, "sub-comm has no common.\n");

> +                       return -EINVAL;

> +               }

> +       }

> +

>         plarbdev = of_find_device_by_node(smicomm_node);

>         of_node_put(smicomm_node);

>         data->smicomm_dev = &plarbdev->dev;

> --

> 2.18.0

> _______________________________________________

> Linux-mediatek mailing list

> Linux-mediatek@lists.infradead.org

> http://lists.infradead.org/mailman/listinfo/linux-mediatek
Yong Wu (吴勇) Sept. 1, 2021, 12:01 p.m. UTC | #2
On Tue, 2021-08-24 at 15:35 +0800, Hsin-Yi Wang wrote:
> On Fri, Aug 13, 2021 at 3:03 PM Yong Wu <yong.wu@mediatek.com> wrote:

> > 

> > For MM IOMMU, We always add device link between smi-common and

> > IOMMU HW.

> > In mt8195, we add smi-sub-common. Thus, if the node is sub-common,

> > we still

> > need find again to get smi-common, then do device link.

> > 

> > Signed-off-by: Yong Wu <yong.wu@mediatek.com>

> > ---

> >  drivers/iommu/mtk_iommu.c | 11 +++++++++++

> >  1 file changed, 11 insertions(+)

> > 

> > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c

> > index a4479916ad33..a72241724adb 100644

> > --- a/drivers/iommu/mtk_iommu.c

> > +++ b/drivers/iommu/mtk_iommu.c

> > @@ -845,6 +845,17 @@ static int mtk_iommu_mm_dts_parse(struct

> > device *dev,

> >         if (!smicomm_node)

> >                 return -EINVAL;

> > 

> > +       /* Find smi-common again if this is smi-sub-common */

> > +       if (of_property_read_bool(smicomm_node,

> > "mediatek,smi_sub_common")) {

> > +               of_node_put(smicomm_node); /* put the sub common */

> > +

> > +               smicomm_node = of_parse_phandle(smicomm_node,

> > "mediatek,smi", 0);

> 

> This only checks 1 level here, and does not check if the mediatek,smi

> of a sub-common node is not another sub-common node.

> So maybe add a check that the updated node here doesn't have

> mediatek,smi_sub_common property.


Yes. Currently there are only 2 levels. we could confirm if it is sub-
common from if it has "mediatek,smi", then "mediatek,smi_sub_common" is
unnecessary.

Will fix in the next version.

> 

> > +               if (!smicomm_node) {

> > +                       dev_err(dev, "sub-comm has no common.\n");

> > +                       return -EINVAL;

> > +               }

> > +       }

> > +

> >         plarbdev = of_find_device_by_node(smicomm_node);

> >         of_node_put(smicomm_node);

> >         data->smicomm_dev = &plarbdev->dev;

> > --

> > 2.18.0

> > _______________________________________________

> > Linux-mediatek mailing list

> > Linux-mediatek@lists.infradead.org

> > http://lists.infradead.org/mailman/listinfo/linux-mediatek
diff mbox series

Patch

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index a4479916ad33..a72241724adb 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -845,6 +845,17 @@  static int mtk_iommu_mm_dts_parse(struct device *dev,
 	if (!smicomm_node)
 		return -EINVAL;
 
+	/* Find smi-common again if this is smi-sub-common */
+	if (of_property_read_bool(smicomm_node, "mediatek,smi_sub_common")) {
+		of_node_put(smicomm_node); /* put the sub common */
+
+		smicomm_node = of_parse_phandle(smicomm_node, "mediatek,smi", 0);
+		if (!smicomm_node) {
+			dev_err(dev, "sub-comm has no common.\n");
+			return -EINVAL;
+		}
+	}
+
 	plarbdev = of_find_device_by_node(smicomm_node);
 	of_node_put(smicomm_node);
 	data->smicomm_dev = &plarbdev->dev;