linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: mtk_wdt: Move mt6589-wdt fallback compatible to end of list
@ 2022-07-26  6:20 Chen-Yu Tsai
  2022-07-26  8:37 ` AngeloGioacchino Del Regno
  0 siblings, 1 reply; 4+ messages in thread
From: Chen-Yu Tsai @ 2022-07-26  6:20 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Matthias Brugger, Philipp Zabel
  Cc: AngeloGioacchino Del Regno, Chen-Yu Tsai, linux-watchdog,
	linux-arm-kernel, linux-mediatek, linux-kernel

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@chromium.org>
---

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);
-- 
2.37.1.359.gd136c6c3e2-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] watchdog: mtk_wdt: Move mt6589-wdt fallback compatible to end of list
  2022-07-26  6:20 [PATCH] watchdog: mtk_wdt: Move mt6589-wdt fallback compatible to end of list Chen-Yu Tsai
@ 2022-07-26  8:37 ` AngeloGioacchino Del Regno
  2022-07-26 13:25   ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-07-26  8:37 UTC (permalink / raw)
  To: Chen-Yu Tsai, Wim Van Sebroeck, Guenter Roeck, Matthias Brugger,
	Philipp Zabel
  Cc: linux-watchdog, linux-arm-kernel, linux-mediatek, linux-kernel

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@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);


-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] watchdog: mtk_wdt: Move mt6589-wdt fallback compatible to end of list
  2022-07-26  8:37 ` AngeloGioacchino Del Regno
@ 2022-07-26 13:25   ` Guenter Roeck
  2022-08-01  9:31     ` Chen-Yu Tsai
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2022-07-26 13:25 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Chen-Yu Tsai, Wim Van Sebroeck,
	Matthias Brugger, Philipp Zabel
  Cc: linux-watchdog, linux-arm-kernel, linux-mediatek, linux-kernel

On 7/26/22 01:37, AngeloGioacchino Del Regno wrote:
> 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@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?
> 

I don't see the problem either. The fallback needs to be listed last in the
compatible property. If it isn't, having it last in struct of_device_id
won't help either.

> Cheers,
> Angelo
> 
>> ---
>>
>> This change complements the removal of the fallback compatible from the
>> bindings and DTSI files [1].
>>

If the fallback isn't listed in the dtsi files, it won't match at all,
no matter where it is located in struct of_device_id.

Guenter

>> [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);
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] watchdog: mtk_wdt: Move mt6589-wdt fallback compatible to end of list
  2022-07-26 13:25   ` Guenter Roeck
@ 2022-08-01  9:31     ` Chen-Yu Tsai
  0 siblings, 0 replies; 4+ messages in thread
From: Chen-Yu Tsai @ 2022-08-01  9:31 UTC (permalink / raw)
  To: Guenter Roeck, Wim Van Sebroeck
  Cc: AngeloGioacchino Del Regno, Matthias Brugger, Philipp Zabel,
	linux-watchdog, linux-arm-kernel, linux-mediatek, linux-kernel

On Tue, Jul 26, 2022 at 9:25 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 7/26/22 01:37, AngeloGioacchino Del Regno wrote:
> > 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@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?
> >
>
> I don't see the problem either. The fallback needs to be listed last in the
> compatible property. If it isn't, having it last in struct of_device_id
> won't help either.

I was probably reading something that wasn't there in the watchdog patch
series I mentioned. I've replied over there. Please ignore this one for
now.

ChenYu

> > Cheers,
> > Angelo
> >
> >> ---
> >>
> >> This change complements the removal of the fallback compatible from the
> >> bindings and DTSI files [1].
> >>
>
> If the fallback isn't listed in the dtsi files, it won't match at all,
> no matter where it is located in struct of_device_id.
>
> Guenter
>
> >> [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);
> >
> >
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-01  9:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26  6:20 [PATCH] watchdog: mtk_wdt: Move mt6589-wdt fallback compatible to end of list Chen-Yu Tsai
2022-07-26  8:37 ` AngeloGioacchino Del Regno
2022-07-26 13:25   ` Guenter Roeck
2022-08-01  9:31     ` Chen-Yu Tsai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).