From: Robin Murphy <robin.murphy@arm.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
yong.wu@mediatek.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
iommu@lists.linux-foundation.org, robh+dt@kernel.org,
linux-mediatek@lists.infradead.org,
krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com,
will@kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/8] iommu: mtk_iommu: Lookup phandle to retrieve syscon to infracfg
Date: Tue, 17 May 2022 15:12:16 +0100 [thread overview]
Message-ID: <16fb07d9-28d8-5c73-1eb5-ec13544d22e5@arm.com> (raw)
In-Reply-To: <20220517132107.195932-3-angelogioacchino.delregno@collabora.com>
On 2022-05-17 14:21, AngeloGioacchino Del Regno wrote:
> This driver will get support for more SoCs and the list of infracfg
> compatibles is expected to grow: in order to prevent getting this
> situation out of control and see a long list of compatible strings,
> add support to retrieve a handle to infracfg's regmap through a
> new "mediatek,infracfg" phandle.
>
> In order to keep retrocompatibility with older devicetrees, the old
> way is kept in place, but also a dev_warn() was added to advertise
> this change in hope that the user will see it and eventually update
> the devicetree if this is possible.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> drivers/iommu/mtk_iommu.c | 40 +++++++++++++++++++++++++--------------
> 1 file changed, 26 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 71b2ace74cd6..cfaaa98d2b50 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -1134,22 +1134,34 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> data->protect_base = ALIGN(virt_to_phys(protect), MTK_PROTECT_PA_ALIGN);
>
> if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_4GB_MODE)) {
> - switch (data->plat_data->m4u_plat) {
> - case M4U_MT2712:
> - p = "mediatek,mt2712-infracfg";
> - break;
> - case M4U_MT8173:
> - p = "mediatek,mt8173-infracfg";
> - break;
> - default:
> - p = NULL;
> + infracfg = syscon_regmap_lookup_by_phandle(dev->of_node, "mediatek,infracfg");
> + if (IS_ERR(infracfg)) {
> + dev_warn(dev, "Cannot find phandle to mediatek,infracfg:"
> + " Please update your devicetree.\n");
Is this really a dev_warn-level problem? There's no functional impact,
given that we can't stop supporting the original binding any time soon,
if ever, so I suspect this is more likely to just annoy users and CI
systems than effect any significant change.
> + /*
> + * Legacy devicetrees will not specify a phandle to
> + * mediatek,infracfg: in that case, we use the older
> + * way to retrieve a syscon to infra.
> + *
> + * This is for retrocompatibility purposes only, hence
> + * no more compatibles shall be added to this.
> + */
> + switch (data->plat_data->m4u_plat) {
> + case M4U_MT2712:
> + p = "mediatek,mt2712-infracfg";
> + break;
> + case M4U_MT8173:
> + p = "mediatek,mt8173-infracfg";
> + break;
> + default:
> + p = NULL;
> + }
> +
> + infracfg = syscon_regmap_lookup_by_compatible(p);
Would it not make sense to punt this over to the same mechanism as for
pericfg, such that it simplifies down to something like:
if (IS_ERR(infracfg) && plat_data->infracfg) {
infracfg = syscon_regmap_lookup_by_compatible(plat_data->infracfg);
...
}
?
TBH if we're still going to have a load of per-SoC data in the driver
anyway then I don't see that we really gain much by delegating one
aspect of it to DT, but meh. I would note that with the phandle
approach, you still need some *other* flag in the driver to know whether
a phandle is expected to be present or not, whereas a NULL vs. non-NULL
string is at least neatly self-describing.
Robin.
> + if (IS_ERR(infracfg))
> + return PTR_ERR(infracfg);
> }
>
> - infracfg = syscon_regmap_lookup_by_compatible(p);
> -
> - if (IS_ERR(infracfg))
> - return PTR_ERR(infracfg);
> -
> ret = regmap_read(infracfg, REG_INFRA_MISC, &val);
> if (ret)
> return ret;
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-05-17 14:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-17 13:20 [PATCH 0/8] mtk_iommu: Specify phandles to infracfg and pericfg AngeloGioacchino Del Regno
2022-05-17 13:21 ` [PATCH 1/8] dt-bindings: iommu: mediatek: Add mediatek, infracfg phandle AngeloGioacchino Del Regno
2022-05-17 14:23 ` [PATCH 1/8] dt-bindings: iommu: mediatek: Add mediatek,infracfg phandle Krzysztof Kozlowski
2022-05-18 9:16 ` Matthias Brugger
2022-05-17 13:21 ` [PATCH 2/8] iommu: mtk_iommu: Lookup phandle to retrieve syscon to infracfg AngeloGioacchino Del Regno
2022-05-17 14:12 ` Robin Murphy [this message]
2022-05-18 8:29 ` AngeloGioacchino Del Regno
2022-05-18 11:07 ` Robin Murphy
2022-05-18 18:46 ` Rob Herring
2022-05-17 13:21 ` [PATCH 3/8] dt-bindings: iommu: mediatek: Add mediatek, pericfg phandle AngeloGioacchino Del Regno
2022-05-17 14:23 ` [PATCH 3/8] dt-bindings: iommu: mediatek: Add mediatek,pericfg phandle Krzysztof Kozlowski
2022-05-17 13:21 ` [PATCH 4/8] iommu: mtk_iommu: Lookup phandle to retrieve syscon to pericfg AngeloGioacchino Del Regno
2022-05-18 10:17 ` Matthias Brugger
2022-05-17 13:21 ` [PATCH 5/8] arm64: dts: mediatek: mt8173: Add mediatek, infracfg phandle for IOMMU AngeloGioacchino Del Regno
2022-05-17 13:21 ` [PATCH 6/8] arm64: dts: mediatek: mt2712e: " AngeloGioacchino Del Regno
2022-05-17 13:21 ` [PATCH 7/8] dt-bindings: iommu: mediatek: Require mediatek, infracfg for mt2712/8173 AngeloGioacchino Del Regno
2022-05-18 1:41 ` [PATCH 7/8] dt-bindings: iommu: mediatek: Require mediatek,infracfg " Rob Herring
2022-05-18 8:14 ` AngeloGioacchino Del Regno
2022-05-18 18:43 ` Rob Herring
2022-05-17 13:21 ` [PATCH 8/8] dt-bindings: iommu: mediatek: Require mediatek, pericfg for mt8195-infra AngeloGioacchino Del Regno
2022-05-18 1:42 ` [PATCH 8/8] dt-bindings: iommu: mediatek: Require mediatek,pericfg " Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16fb07d9-28d8-5c73-1eb5-ec13544d22e5@arm.com \
--to=robin.murphy@arm.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=iommu@lists.linux-foundation.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=will@kernel.org \
--cc=yong.wu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox