[PATCH] watchdog: mtk_wdt: Move mt6589-wdt fallback compatible to end of list

AngeloGioacchino Del Regno angelogioacchino.delregno at collabora.com
Tue Jul 26 01:37:50 PDT 2022


Il 26/07/22 08:20, Chen-Yu Tsai ha scritto:
> The watchdog facility in the MediaTek SoCs are all the same, but the
> hardware block also contains a reset controller, which differs in the
> number of resets used between different SoCs. This difference is
> supported with of_device_get_match_data() supplying the number of reset
> lines for the newer compatible strings. The original mt6589-wdt only
> covers the watchdog facility.
> 
> of_device_is_compatible(), and by extension of_device_get_match_data(),
> works by going through the given list of compatible strings sequentially,
> and checks if any of the device node's compatible strings match.
> 
> To avoid early matching on the "mediatek,mt6589-wdt" fallback compatible,
> which only provides watchdog functionality and no reset controller, move
> the fallback entry to the end of the list, so that other, more specific
> compatible strings have a chance at getting matched.
> 
> Fixes: c254e103082b ("watchdog: mtk_wdt: mt8183: Add reset controller")
> Fixes: adc318a34066 ("watchdog: mt8192: add wdt support")
> Fixes: 8c6b5ea6ac68 ("watchdog: mediatek: mt8195: add wdt support")
> Fixes: 4dbabc4d9e8c ("watchdog: mediatek: mt8186: add wdt support")
> Fixes: 711a5b25bac9 ("watchdog: mtk_wdt: mt7986: Add toprgu reset controller support")
> Signed-off-by: Chen-Yu Tsai <wenst at chromium.org>

Uhm, I don't think that this is an issue?

Ordering precedence is given to the list that you specify in devicetree, that's why
"the second one" is a fallback, meaning: ("impossible" example below)

compatible = "mediatek,mt8195-wdt", "mediatek,mt8183-wdt", "mediatek,mt6589-wdt";

This gets walked as per the order in which you wrote the compatibles, so:
* Check match for mt8195-wdt, does not exist?
  * Check match for mt8183-wdt, exists!
  * Put everything into dev->of_node (having mediatek,mt8183-wdt only!)

__of_device_is_compatible() gets dev->of_node and compares that to all of the
possible matches.

struct device_node for this device hence does *not* contain any of the other
compatibles that we specified in devicetree, so it does *not* contain any of
"mediatek,mt8195-wdt", or "mediatek,mt6589-wdt", because we have previously
successfully matches 8183.

I don't think that I've misinterpreted this flow, but if I have, let's pull
in devicetree people and check with them?

Cheers,
Angelo

> ---
> 
> This change complements the removal of the fallback compatible from the
> bindings and DTSI files [1].
> 
> [1] https://lore.kernel.org/linux-mediatek/20220721014845.19044-1-allen-kh.cheng@mediatek.com/
> 
>   drivers/watchdog/mtk_wdt.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
> index e97787536792..3d5a239b93ba 100644
> --- a/drivers/watchdog/mtk_wdt.c
> +++ b/drivers/watchdog/mtk_wdt.c
> @@ -425,12 +425,13 @@ static int mtk_wdt_resume(struct device *dev)
>   
>   static const struct of_device_id mtk_wdt_dt_ids[] = {
>   	{ .compatible = "mediatek,mt2712-wdt", .data = &mt2712_data },
> -	{ .compatible = "mediatek,mt6589-wdt" },
>   	{ .compatible = "mediatek,mt7986-wdt", .data = &mt7986_data },
>   	{ .compatible = "mediatek,mt8183-wdt", .data = &mt8183_data },
>   	{ .compatible = "mediatek,mt8186-wdt", .data = &mt8186_data },
>   	{ .compatible = "mediatek,mt8192-wdt", .data = &mt8192_data },
>   	{ .compatible = "mediatek,mt8195-wdt", .data = &mt8195_data },
> +	/* Fallback compatible string must be last entry */
> +	{ .compatible = "mediatek,mt6589-wdt" },
>   	{ /* sentinel */ }
>   };
>   MODULE_DEVICE_TABLE(of, mtk_wdt_dt_ids);


-- 



More information about the Linux-mediatek mailing list