[v4,1/5] dt-bindings: watchdog: mt7621-wdt: add phandle to access system controller registers

Message ID 20230211073357.755893-2-sergio.paracuellos@gmail.com
State New
Headers
Series watchdog: mt7621-wdt: avoid globals and arch dependencies |

Commit Message

Sergio Paracuellos Feb. 11, 2023, 7:33 a.m. UTC
  MT7621 SoC provides a system controller node for accessing to some registers.
Add a phandle in this node to avoid using MIPS related arch operations and
includes in watchdog driver code.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 .../devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml  | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Arınç ÜNAL Feb. 11, 2023, 9:10 a.m. UTC | #1
Is this mediatek,sysctl property required after your changes on the 
watchdog code?

Arınç

On 11.02.2023 10:33, Sergio Paracuellos wrote:
> MT7621 SoC provides a system controller node for accessing to some registers.
> Add a phandle in this node to avoid using MIPS related arch operations and
> includes in watchdog driver code.
> 
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
>   .../devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml  | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml b/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
> index b2b17fdf4..a668d0c2f 100644
> --- a/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
> +++ b/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
> @@ -19,6 +19,12 @@ properties:
>     reg:
>       maxItems: 1
>   
> +  mediatek,sysctl:
> +    $ref: /schemas/types.yaml#/definitions/phandle
> +    description:
> +      phandle to system controller 'sysc' syscon node which
> +      controls system registers
> +
>   required:
>     - compatible
>     - reg
> @@ -30,4 +36,5 @@ examples:
>       watchdog@100 {
>         compatible = "mediatek,mt7621-wdt";
>         reg = <0x100 0x100>;
> +      mediatek,sysctl = <&sysc>;
>       };
  
Sergio Paracuellos Feb. 11, 2023, 10:41 a.m. UTC | #2
On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>
> Is this mediatek,sysctl property required after your changes on the
> watchdog code?

I don't really understand the question :-) Yes, it is. Since we have
introduced a new phandle in the watchdog node to be able to access the
reset status register through the 'sysc' syscon node.
We need the bindings to be aligned with the mt7621.dtsi file and we
are getting the syscon regmap handler via
'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.

Thanks,
    Sergio Paracuellos
>
> Arınç
>
> On 11.02.2023 10:33, Sergio Paracuellos wrote:
> > MT7621 SoC provides a system controller node for accessing to some registers.
> > Add a phandle in this node to avoid using MIPS related arch operations and
> > includes in watchdog driver code.
> >
> > Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> > ---
> >   .../devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml  | 7 +++++++
> >   1 file changed, 7 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml b/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
> > index b2b17fdf4..a668d0c2f 100644
> > --- a/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
> > +++ b/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
> > @@ -19,6 +19,12 @@ properties:
> >     reg:
> >       maxItems: 1
> >
> > +  mediatek,sysctl:
> > +    $ref: /schemas/types.yaml#/definitions/phandle
> > +    description:
> > +      phandle to system controller 'sysc' syscon node which
> > +      controls system registers
> > +
> >   required:
> >     - compatible
> >     - reg
> > @@ -30,4 +36,5 @@ examples:
> >       watchdog@100 {
> >         compatible = "mediatek,mt7621-wdt";
> >         reg = <0x100 0x100>;
> > +      mediatek,sysctl = <&sysc>;
> >       };
  
Arınç ÜNAL Feb. 11, 2023, 10:46 a.m. UTC | #3
On 11.02.2023 13:41, Sergio Paracuellos wrote:
> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>
>> Is this mediatek,sysctl property required after your changes on the
>> watchdog code?
> 
> I don't really understand the question :-) Yes, it is. Since we have
> introduced a new phandle in the watchdog node to be able to access the
> reset status register through the 'sysc' syscon node.
> We need the bindings to be aligned with the mt7621.dtsi file and we
> are getting the syscon regmap handler via
> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.

I believe you need to put mediatek,sysctl under "required:".

Arınç
  
Sergio Paracuellos Feb. 11, 2023, 11:01 a.m. UTC | #4
On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>
> On 11.02.2023 13:41, Sergio Paracuellos wrote:
> > On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> >>
> >> Is this mediatek,sysctl property required after your changes on the
> >> watchdog code?
> >
> > I don't really understand the question :-) Yes, it is. Since we have
> > introduced a new phandle in the watchdog node to be able to access the
> > reset status register through the 'sysc' syscon node.
> > We need the bindings to be aligned with the mt7621.dtsi file and we
> > are getting the syscon regmap handler via
> > 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
>
> I believe you need to put mediatek,sysctl under "required:".

Ah, I understood your question now :-). You meant 'required' property.
I need more coffee, I guess :-). I am not sure if you can add
properties as required after bindings are already mainlined for
compatibility issues. The problem with this SoC is that drivers become
mainlined before the device tree was so if things are properly fixed
now this kind of issues appear.  Let's see Krzysztof and Rob comments
for this.

Thanks,
    Sergio Paracuellos
>
> Arınç
  
Krzysztof Kozlowski Feb. 11, 2023, 11:42 a.m. UTC | #5
On 11/02/2023 12:01, Sergio Paracuellos wrote:
> On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>
>> On 11.02.2023 13:41, Sergio Paracuellos wrote:
>>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>>>
>>>> Is this mediatek,sysctl property required after your changes on the
>>>> watchdog code?
>>>
>>> I don't really understand the question :-) Yes, it is. Since we have
>>> introduced a new phandle in the watchdog node to be able to access the
>>> reset status register through the 'sysc' syscon node.
>>> We need the bindings to be aligned with the mt7621.dtsi file and we
>>> are getting the syscon regmap handler via
>>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
>>
>> I believe you need to put mediatek,sysctl under "required:".
> 
> Ah, I understood your question now :-). You meant 'required' property.
> I need more coffee, I guess :-). I am not sure if you can add
> properties as required after bindings are already mainlined for
> compatibility issues. The problem with this SoC is that drivers become
> mainlined before the device tree was so if things are properly fixed
> now this kind of issues appear.  Let's see Krzysztof and Rob comments
> for this.

If your driver fails to probe without mediatek,sysctl, you already made
it required (thus broke the ABI) regardless what dt-binding is saying.
In such case you should update dt-binding to reflect reality.

Now ABI break is different case. Usually you should not break it without
valid reasons (e.g. it was never working before). Your commit msg
suggests that you only improve the code, thus ABI break is not really
justified. In such case - binding is correct, driver should be reworked
to accept DTS without the new property.

Best regards,
Krzysztof
  
Krzysztof Kozlowski Feb. 11, 2023, 11:42 a.m. UTC | #6
On 11/02/2023 08:33, Sergio Paracuellos wrote:
> MT7621 SoC provides a system controller node for accessing to some registers.
> Add a phandle in this node to avoid using MIPS related arch operations and
> includes in watchdog driver code.
> 
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof
  
Sergio Paracuellos Feb. 12, 2023, 8:13 a.m. UTC | #7
On Sat, Feb 11, 2023 at 12:42 PM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
>
> On 11/02/2023 12:01, Sergio Paracuellos wrote:
> > On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> >>
> >> On 11.02.2023 13:41, Sergio Paracuellos wrote:
> >>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> >>>>
> >>>> Is this mediatek,sysctl property required after your changes on the
> >>>> watchdog code?
> >>>
> >>> I don't really understand the question :-) Yes, it is. Since we have
> >>> introduced a new phandle in the watchdog node to be able to access the
> >>> reset status register through the 'sysc' syscon node.
> >>> We need the bindings to be aligned with the mt7621.dtsi file and we
> >>> are getting the syscon regmap handler via
> >>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
> >>
> >> I believe you need to put mediatek,sysctl under "required:".
> >
> > Ah, I understood your question now :-). You meant 'required' property.
> > I need more coffee, I guess :-). I am not sure if you can add
> > properties as required after bindings are already mainlined for
> > compatibility issues. The problem with this SoC is that drivers become
> > mainlined before the device tree was so if things are properly fixed
> > now this kind of issues appear.  Let's see Krzysztof and Rob comments
> > for this.
>
> If your driver fails to probe without mediatek,sysctl, you already made
> it required (thus broke the ABI) regardless what dt-binding is saying.
> In such case you should update dt-binding to reflect reality.
>
> Now ABI break is different case. Usually you should not break it without
> valid reasons (e.g. it was never working before). Your commit msg
> suggests that you only improve the code, thus ABI break is not really
> justified. In such case - binding is correct, driver should be reworked
> to accept DTS without the new property.

Thanks for clarification, Krzysztof. Ok, so if this is the case I need
to add this property required (as Arinc was properly pointing out in
previous mail) since without it the driver is going to fail on probe
(PATCH 5 of the series). I understand the "it was never working
before" argument reason for ABI breaks. What happens if the old driver
code was not ideal and totally dependent on architecture specific
operations when this could be totally avoided and properly make arch
independent agnostic drivers? This driver was added in 2016 [0]. There
was not a device tree file in the kernel for this SoC mainlined until
2022 [1]. I also personally migrated this watchdog binding in 2022
from text to YAML and maintained it without changes [2]. When this was
mainlined not all drivers were properly reviewed and the current code
was just maintained as it is. Most users of this SoC are in the
openWRT community where the dtsi of the mainline is not used yet and
they maintain their own mt7621.dtsi files. Also, when a new version of
the openWRT selected kernel is added they also modify and align with
its mt7621.dtsi file without maintaining previous dtb's. If "make the
driver arch independent to be able to be compile tested" and this kind
of arguments are not valid at all I need to know because I have
started to review driver code for this SoC and other drivers also have
the same arch dependency that ideally should be avoided in the same
way. This at the end means to break the ABI again in the future for
those drivers / bindings. So I can just let them be as it is and not
provide any change at all and continue without being compile tested
and other beneficial features to detect future driver breakage.

Thanks in advance for clarification.

Best regards,
    Sergio Paracuellos

[0]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/watchdog/mt7621_wdt.c?id=ab3f09fe16d158cb4f84e558c61ec5d6d601f2e0
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/mips/boot/dts/ralink/mt7621.dtsi?id=7a6ee0bbab2551d7189ce0f5e625fef4d612ebea
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml?id=9023e05b7a5809593a7ea09896eee0bbb6ae1685

>
> Best regards,
> Krzysztof
>
  
Guenter Roeck Feb. 12, 2023, 3:27 p.m. UTC | #8
On 2/12/23 00:13, Sergio Paracuellos wrote:
> On Sat, Feb 11, 2023 at 12:42 PM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
>>
>> On 11/02/2023 12:01, Sergio Paracuellos wrote:
>>> On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>>>
>>>> On 11.02.2023 13:41, Sergio Paracuellos wrote:
>>>>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>>>>>
>>>>>> Is this mediatek,sysctl property required after your changes on the
>>>>>> watchdog code?
>>>>>
>>>>> I don't really understand the question :-) Yes, it is. Since we have
>>>>> introduced a new phandle in the watchdog node to be able to access the
>>>>> reset status register through the 'sysc' syscon node.
>>>>> We need the bindings to be aligned with the mt7621.dtsi file and we
>>>>> are getting the syscon regmap handler via
>>>>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
>>>>
>>>> I believe you need to put mediatek,sysctl under "required:".
>>>
>>> Ah, I understood your question now :-). You meant 'required' property.
>>> I need more coffee, I guess :-). I am not sure if you can add
>>> properties as required after bindings are already mainlined for
>>> compatibility issues. The problem with this SoC is that drivers become
>>> mainlined before the device tree was so if things are properly fixed
>>> now this kind of issues appear.  Let's see Krzysztof and Rob comments
>>> for this.
>>
>> If your driver fails to probe without mediatek,sysctl, you already made
>> it required (thus broke the ABI) regardless what dt-binding is saying.
>> In such case you should update dt-binding to reflect reality.
>>
>> Now ABI break is different case. Usually you should not break it without
>> valid reasons (e.g. it was never working before). Your commit msg
>> suggests that you only improve the code, thus ABI break is not really
>> justified. In such case - binding is correct, driver should be reworked
>> to accept DTS without the new property.
> 
> Thanks for clarification, Krzysztof. Ok, so if this is the case I need
> to add this property required (as Arinc was properly pointing out in
> previous mail) since without it the driver is going to fail on probe
> (PATCH 5 of the series). I understand the "it was never working
> before" argument reason for ABI breaks. What happens if the old driver
> code was not ideal and totally dependent on architecture specific
> operations when this could be totally avoided and properly make arch
> independent agnostic drivers? This driver was added in 2016 [0]. There
> was not a device tree file in the kernel for this SoC mainlined until
> 2022 [1]. I also personally migrated this watchdog binding in 2022
> from text to YAML and maintained it without changes [2]. When this was
> mainlined not all drivers were properly reviewed and the current code
> was just maintained as it is. Most users of this SoC are in the
> openWRT community where the dtsi of the mainline is not used yet and
> they maintain their own mt7621.dtsi files. Also, when a new version of
> the openWRT selected kernel is added they also modify and align with
> its mt7621.dtsi file without maintaining previous dtb's. If "make the
> driver arch independent to be able to be compile tested" and this kind
> of arguments are not valid at all I need to know because I have
> started to review driver code for this SoC and other drivers also have
> the same arch dependency that ideally should be avoided in the same
> way. This at the end means to break the ABI again in the future for
> those drivers / bindings. So I can just let them be as it is and not
> provide any change at all and continue without being compile tested
> and other beneficial features to detect future driver breakage.
> 

Problem is that there are (presumably) shipped systems out there with
the old devicetree file. The watchdog driver would no longer instantiate
on those systems.

Guenter
  
Krzysztof Kozlowski Feb. 13, 2023, 8:38 a.m. UTC | #9
On 12/02/2023 09:13, Sergio Paracuellos wrote:
> On Sat, Feb 11, 2023 at 12:42 PM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
>>
>> On 11/02/2023 12:01, Sergio Paracuellos wrote:
>>> On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>>>
>>>> On 11.02.2023 13:41, Sergio Paracuellos wrote:
>>>>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>>>>>
>>>>>> Is this mediatek,sysctl property required after your changes on the
>>>>>> watchdog code?
>>>>>
>>>>> I don't really understand the question :-) Yes, it is. Since we have
>>>>> introduced a new phandle in the watchdog node to be able to access the
>>>>> reset status register through the 'sysc' syscon node.
>>>>> We need the bindings to be aligned with the mt7621.dtsi file and we
>>>>> are getting the syscon regmap handler via
>>>>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
>>>>
>>>> I believe you need to put mediatek,sysctl under "required:".
>>>
>>> Ah, I understood your question now :-). You meant 'required' property.
>>> I need more coffee, I guess :-). I am not sure if you can add
>>> properties as required after bindings are already mainlined for
>>> compatibility issues. The problem with this SoC is that drivers become
>>> mainlined before the device tree was so if things are properly fixed
>>> now this kind of issues appear.  Let's see Krzysztof and Rob comments
>>> for this.
>>
>> If your driver fails to probe without mediatek,sysctl, you already made
>> it required (thus broke the ABI) regardless what dt-binding is saying.
>> In such case you should update dt-binding to reflect reality.
>>
>> Now ABI break is different case. Usually you should not break it without
>> valid reasons (e.g. it was never working before). Your commit msg
>> suggests that you only improve the code, thus ABI break is not really
>> justified. In such case - binding is correct, driver should be reworked
>> to accept DTS without the new property.
> 
> Thanks for clarification, Krzysztof. Ok, so if this is the case I need
> to add this property required (as Arinc was properly pointing out in
> previous mail) since without it the driver is going to fail on probe
> (PATCH 5 of the series). I understand the "it was never working
> before" argument reason for ABI breaks. What happens if the old driver
> code was not ideal and totally dependent on architecture specific
> operations when this could be totally avoided and properly make arch
> independent agnostic drivers?

It's just an improvement and improvements should be incremental and not
break ABI.

> This driver was added in 2016 [0]. There
> was not a device tree file in the kernel for this SoC mainlined until
> 2022 [1]. 

2022 march was almost a year ago, so there were kernel releases with
this ABI.

Also, what about all out of tree DTS? What about other operating
systems, bootloaders, firmwares etc?


Best regards,
Krzysztof
  
Sergio Paracuellos Feb. 13, 2023, 8:58 a.m. UTC | #10
On Mon, Feb 13, 2023 at 9:38 AM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
>
> On 12/02/2023 09:13, Sergio Paracuellos wrote:
> > On Sat, Feb 11, 2023 at 12:42 PM Krzysztof Kozlowski
> > <krzysztof.kozlowski@linaro.org> wrote:
> >>
> >> On 11/02/2023 12:01, Sergio Paracuellos wrote:
> >>> On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> >>>>
> >>>> On 11.02.2023 13:41, Sergio Paracuellos wrote:
> >>>>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> >>>>>>
> >>>>>> Is this mediatek,sysctl property required after your changes on the
> >>>>>> watchdog code?
> >>>>>
> >>>>> I don't really understand the question :-) Yes, it is. Since we have
> >>>>> introduced a new phandle in the watchdog node to be able to access the
> >>>>> reset status register through the 'sysc' syscon node.
> >>>>> We need the bindings to be aligned with the mt7621.dtsi file and we
> >>>>> are getting the syscon regmap handler via
> >>>>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
> >>>>
> >>>> I believe you need to put mediatek,sysctl under "required:".
> >>>
> >>> Ah, I understood your question now :-). You meant 'required' property.
> >>> I need more coffee, I guess :-). I am not sure if you can add
> >>> properties as required after bindings are already mainlined for
> >>> compatibility issues. The problem with this SoC is that drivers become
> >>> mainlined before the device tree was so if things are properly fixed
> >>> now this kind of issues appear.  Let's see Krzysztof and Rob comments
> >>> for this.
> >>
> >> If your driver fails to probe without mediatek,sysctl, you already made
> >> it required (thus broke the ABI) regardless what dt-binding is saying.
> >> In such case you should update dt-binding to reflect reality.
> >>
> >> Now ABI break is different case. Usually you should not break it without
> >> valid reasons (e.g. it was never working before). Your commit msg
> >> suggests that you only improve the code, thus ABI break is not really
> >> justified. In such case - binding is correct, driver should be reworked
> >> to accept DTS without the new property.
> >
> > Thanks for clarification, Krzysztof. Ok, so if this is the case I need
> > to add this property required (as Arinc was properly pointing out in
> > previous mail) since without it the driver is going to fail on probe
> > (PATCH 5 of the series). I understand the "it was never working
> > before" argument reason for ABI breaks. What happens if the old driver
> > code was not ideal and totally dependent on architecture specific
> > operations when this could be totally avoided and properly make arch
> > independent agnostic drivers?
>
> It's just an improvement and improvements should be incremental and not
> break ABI.

Understood.

>
> > This driver was added in 2016 [0]. There
> > was not a device tree file in the kernel for this SoC mainlined until
> > 2022 [1].
>
> 2022 march was almost a year ago, so there were kernel releases with
> this ABI.
>
> Also, what about all out of tree DTS? What about other operating
> systems, bootloaders, firmwares etc?

Pretty clear, thanks. So I guess I have to drop all the changes that
are breaking ABI and just maintain those that make no real changes in
bindings.

>
>
> Best regards,
> Krzysztof

Thanks,
    Sergio Paracuellos
>
  
Sergio Paracuellos Feb. 13, 2023, 8:59 a.m. UTC | #11
On Sun, Feb 12, 2023 at 4:27 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 2/12/23 00:13, Sergio Paracuellos wrote:
> > On Sat, Feb 11, 2023 at 12:42 PM Krzysztof Kozlowski
> > <krzysztof.kozlowski@linaro.org> wrote:
> >>
> >> On 11/02/2023 12:01, Sergio Paracuellos wrote:
> >>> On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> >>>>
> >>>> On 11.02.2023 13:41, Sergio Paracuellos wrote:
> >>>>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> >>>>>>
> >>>>>> Is this mediatek,sysctl property required after your changes on the
> >>>>>> watchdog code?
> >>>>>
> >>>>> I don't really understand the question :-) Yes, it is. Since we have
> >>>>> introduced a new phandle in the watchdog node to be able to access the
> >>>>> reset status register through the 'sysc' syscon node.
> >>>>> We need the bindings to be aligned with the mt7621.dtsi file and we
> >>>>> are getting the syscon regmap handler via
> >>>>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
> >>>>
> >>>> I believe you need to put mediatek,sysctl under "required:".
> >>>
> >>> Ah, I understood your question now :-). You meant 'required' property.
> >>> I need more coffee, I guess :-). I am not sure if you can add
> >>> properties as required after bindings are already mainlined for
> >>> compatibility issues. The problem with this SoC is that drivers become
> >>> mainlined before the device tree was so if things are properly fixed
> >>> now this kind of issues appear.  Let's see Krzysztof and Rob comments
> >>> for this.
> >>
> >> If your driver fails to probe without mediatek,sysctl, you already made
> >> it required (thus broke the ABI) regardless what dt-binding is saying.
> >> In such case you should update dt-binding to reflect reality.
> >>
> >> Now ABI break is different case. Usually you should not break it without
> >> valid reasons (e.g. it was never working before). Your commit msg
> >> suggests that you only improve the code, thus ABI break is not really
> >> justified. In such case - binding is correct, driver should be reworked
> >> to accept DTS without the new property.
> >
> > Thanks for clarification, Krzysztof. Ok, so if this is the case I need
> > to add this property required (as Arinc was properly pointing out in
> > previous mail) since without it the driver is going to fail on probe
> > (PATCH 5 of the series). I understand the "it was never working
> > before" argument reason for ABI breaks. What happens if the old driver
> > code was not ideal and totally dependent on architecture specific
> > operations when this could be totally avoided and properly make arch
> > independent agnostic drivers? This driver was added in 2016 [0]. There
> > was not a device tree file in the kernel for this SoC mainlined until
> > 2022 [1]. I also personally migrated this watchdog binding in 2022
> > from text to YAML and maintained it without changes [2]. When this was
> > mainlined not all drivers were properly reviewed and the current code
> > was just maintained as it is. Most users of this SoC are in the
> > openWRT community where the dtsi of the mainline is not used yet and
> > they maintain their own mt7621.dtsi files. Also, when a new version of
> > the openWRT selected kernel is added they also modify and align with
> > its mt7621.dtsi file without maintaining previous dtb's. If "make the
> > driver arch independent to be able to be compile tested" and this kind
> > of arguments are not valid at all I need to know because I have
> > started to review driver code for this SoC and other drivers also have
> > the same arch dependency that ideally should be avoided in the same
> > way. This at the end means to break the ABI again in the future for
> > those drivers / bindings. So I can just let them be as it is and not
> > provide any change at all and continue without being compile tested
> > and other beneficial features to detect future driver breakage.
> >
>
> Problem is that there are (presumably) shipped systems out there with
> the old devicetree file. The watchdog driver would no longer instantiate
> on those systems.

Ok, I will maintain only the PATCH that changes the driver to not use
globals and send v5.

>
> Guenter
>

Thanks,
    Sergio Paracuellos
  
Guenter Roeck Feb. 13, 2023, 7:36 p.m. UTC | #12
On Mon, Feb 13, 2023 at 09:59:35AM +0100, Sergio Paracuellos wrote:
> On Sun, Feb 12, 2023 at 4:27 PM Guenter Roeck <linux@roeck-us.net> wrote:
> >
> > On 2/12/23 00:13, Sergio Paracuellos wrote:
> > > On Sat, Feb 11, 2023 at 12:42 PM Krzysztof Kozlowski
> > > <krzysztof.kozlowski@linaro.org> wrote:
> > >>
> > >> On 11/02/2023 12:01, Sergio Paracuellos wrote:
> > >>> On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> > >>>>
> > >>>> On 11.02.2023 13:41, Sergio Paracuellos wrote:
> > >>>>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> > >>>>>>
> > >>>>>> Is this mediatek,sysctl property required after your changes on the
> > >>>>>> watchdog code?
> > >>>>>
> > >>>>> I don't really understand the question :-) Yes, it is. Since we have
> > >>>>> introduced a new phandle in the watchdog node to be able to access the
> > >>>>> reset status register through the 'sysc' syscon node.
> > >>>>> We need the bindings to be aligned with the mt7621.dtsi file and we
> > >>>>> are getting the syscon regmap handler via
> > >>>>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
> > >>>>
> > >>>> I believe you need to put mediatek,sysctl under "required:".
> > >>>
> > >>> Ah, I understood your question now :-). You meant 'required' property.
> > >>> I need more coffee, I guess :-). I am not sure if you can add
> > >>> properties as required after bindings are already mainlined for
> > >>> compatibility issues. The problem with this SoC is that drivers become
> > >>> mainlined before the device tree was so if things are properly fixed
> > >>> now this kind of issues appear.  Let's see Krzysztof and Rob comments
> > >>> for this.
> > >>
> > >> If your driver fails to probe without mediatek,sysctl, you already made
> > >> it required (thus broke the ABI) regardless what dt-binding is saying.
> > >> In such case you should update dt-binding to reflect reality.
> > >>
> > >> Now ABI break is different case. Usually you should not break it without
> > >> valid reasons (e.g. it was never working before). Your commit msg
> > >> suggests that you only improve the code, thus ABI break is not really
> > >> justified. In such case - binding is correct, driver should be reworked
> > >> to accept DTS without the new property.
> > >
> > > Thanks for clarification, Krzysztof. Ok, so if this is the case I need
> > > to add this property required (as Arinc was properly pointing out in
> > > previous mail) since without it the driver is going to fail on probe
> > > (PATCH 5 of the series). I understand the "it was never working
> > > before" argument reason for ABI breaks. What happens if the old driver
> > > code was not ideal and totally dependent on architecture specific
> > > operations when this could be totally avoided and properly make arch
> > > independent agnostic drivers? This driver was added in 2016 [0]. There
> > > was not a device tree file in the kernel for this SoC mainlined until
> > > 2022 [1]. I also personally migrated this watchdog binding in 2022
> > > from text to YAML and maintained it without changes [2]. When this was
> > > mainlined not all drivers were properly reviewed and the current code
> > > was just maintained as it is. Most users of this SoC are in the
> > > openWRT community where the dtsi of the mainline is not used yet and
> > > they maintain their own mt7621.dtsi files. Also, when a new version of
> > > the openWRT selected kernel is added they also modify and align with
> > > its mt7621.dtsi file without maintaining previous dtb's. If "make the
> > > driver arch independent to be able to be compile tested" and this kind
> > > of arguments are not valid at all I need to know because I have
> > > started to review driver code for this SoC and other drivers also have
> > > the same arch dependency that ideally should be avoided in the same
> > > way. This at the end means to break the ABI again in the future for
> > > those drivers / bindings. So I can just let them be as it is and not
> > > provide any change at all and continue without being compile tested
> > > and other beneficial features to detect future driver breakage.
> > >
> >
> > Problem is that there are (presumably) shipped systems out there with
> > the old devicetree file. The watchdog driver would no longer instantiate
> > on those systems.
> 
> Ok, I will maintain only the PATCH that changes the driver to not use
> globals and send v5.
> 

Other options might be to search for the "syscon" node name or to search
for the "mediatek,mt7621-sysc" compatible.

Guenter

> >
> > Guenter
> >
> 
> Thanks,
>     Sergio Paracuellos
  
Sergio Paracuellos Feb. 13, 2023, 7:57 p.m. UTC | #13
On Mon, Feb 13, 2023 at 8:36 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On Mon, Feb 13, 2023 at 09:59:35AM +0100, Sergio Paracuellos wrote:
> > On Sun, Feb 12, 2023 at 4:27 PM Guenter Roeck <linux@roeck-us.net> wrote:
> > >
> > > On 2/12/23 00:13, Sergio Paracuellos wrote:
> > > > On Sat, Feb 11, 2023 at 12:42 PM Krzysztof Kozlowski
> > > > <krzysztof.kozlowski@linaro.org> wrote:
> > > >>
> > > >> On 11/02/2023 12:01, Sergio Paracuellos wrote:
> > > >>> On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> > > >>>>
> > > >>>> On 11.02.2023 13:41, Sergio Paracuellos wrote:
> > > >>>>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
> > > >>>>>>
> > > >>>>>> Is this mediatek,sysctl property required after your changes on the
> > > >>>>>> watchdog code?
> > > >>>>>
> > > >>>>> I don't really understand the question :-) Yes, it is. Since we have
> > > >>>>> introduced a new phandle in the watchdog node to be able to access the
> > > >>>>> reset status register through the 'sysc' syscon node.
> > > >>>>> We need the bindings to be aligned with the mt7621.dtsi file and we
> > > >>>>> are getting the syscon regmap handler via
> > > >>>>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
> > > >>>>
> > > >>>> I believe you need to put mediatek,sysctl under "required:".
> > > >>>
> > > >>> Ah, I understood your question now :-). You meant 'required' property.
> > > >>> I need more coffee, I guess :-). I am not sure if you can add
> > > >>> properties as required after bindings are already mainlined for
> > > >>> compatibility issues. The problem with this SoC is that drivers become
> > > >>> mainlined before the device tree was so if things are properly fixed
> > > >>> now this kind of issues appear.  Let's see Krzysztof and Rob comments
> > > >>> for this.
> > > >>
> > > >> If your driver fails to probe without mediatek,sysctl, you already made
> > > >> it required (thus broke the ABI) regardless what dt-binding is saying.
> > > >> In such case you should update dt-binding to reflect reality.
> > > >>
> > > >> Now ABI break is different case. Usually you should not break it without
> > > >> valid reasons (e.g. it was never working before). Your commit msg
> > > >> suggests that you only improve the code, thus ABI break is not really
> > > >> justified. In such case - binding is correct, driver should be reworked
> > > >> to accept DTS without the new property.
> > > >
> > > > Thanks for clarification, Krzysztof. Ok, so if this is the case I need
> > > > to add this property required (as Arinc was properly pointing out in
> > > > previous mail) since without it the driver is going to fail on probe
> > > > (PATCH 5 of the series). I understand the "it was never working
> > > > before" argument reason for ABI breaks. What happens if the old driver
> > > > code was not ideal and totally dependent on architecture specific
> > > > operations when this could be totally avoided and properly make arch
> > > > independent agnostic drivers? This driver was added in 2016 [0]. There
> > > > was not a device tree file in the kernel for this SoC mainlined until
> > > > 2022 [1]. I also personally migrated this watchdog binding in 2022
> > > > from text to YAML and maintained it without changes [2]. When this was
> > > > mainlined not all drivers were properly reviewed and the current code
> > > > was just maintained as it is. Most users of this SoC are in the
> > > > openWRT community where the dtsi of the mainline is not used yet and
> > > > they maintain their own mt7621.dtsi files. Also, when a new version of
> > > > the openWRT selected kernel is added they also modify and align with
> > > > its mt7621.dtsi file without maintaining previous dtb's. If "make the
> > > > driver arch independent to be able to be compile tested" and this kind
> > > > of arguments are not valid at all I need to know because I have
> > > > started to review driver code for this SoC and other drivers also have
> > > > the same arch dependency that ideally should be avoided in the same
> > > > way. This at the end means to break the ABI again in the future for
> > > > those drivers / bindings. So I can just let them be as it is and not
> > > > provide any change at all and continue without being compile tested
> > > > and other beneficial features to detect future driver breakage.
> > > >
> > >
> > > Problem is that there are (presumably) shipped systems out there with
> > > the old devicetree file. The watchdog driver would no longer instantiate
> > > on those systems.
> >
> > Ok, I will maintain only the PATCH that changes the driver to not use
> > globals and send v5.
> >
>
> Other options might be to search for the "syscon" node name or to search
> for the "mediatek,mt7621-sysc" compatible.

Thanks for the hint. I didn't know about
'syscon_regmap_lookup_by_compatible()'. I will use this to avoid DTB
ABI breakage and allow the driver to be selected for COMPILE_TEST..

Thanks, Guenter.

Best regards,
    Sergio Paracuellos

>
> Guenter
>
> > >
> > > Guenter
> > >
> >
> > Thanks,
> >     Sergio Paracuellos
  
Guenter Roeck Feb. 13, 2023, 8:09 p.m. UTC | #14
On 2/13/23 11:57, Sergio Paracuellos wrote:
> On Mon, Feb 13, 2023 at 8:36 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> On Mon, Feb 13, 2023 at 09:59:35AM +0100, Sergio Paracuellos wrote:
>>> On Sun, Feb 12, 2023 at 4:27 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>>>
>>>> On 2/12/23 00:13, Sergio Paracuellos wrote:
>>>>> On Sat, Feb 11, 2023 at 12:42 PM Krzysztof Kozlowski
>>>>> <krzysztof.kozlowski@linaro.org> wrote:
>>>>>>
>>>>>> On 11/02/2023 12:01, Sergio Paracuellos wrote:
>>>>>>> On Sat, Feb 11, 2023 at 11:47 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>>>>>>>
>>>>>>>> On 11.02.2023 13:41, Sergio Paracuellos wrote:
>>>>>>>>> On Sat, Feb 11, 2023 at 10:10 AM Arınç ÜNAL <arinc.unal@arinc9.com> wrote:
>>>>>>>>>>
>>>>>>>>>> Is this mediatek,sysctl property required after your changes on the
>>>>>>>>>> watchdog code?
>>>>>>>>>
>>>>>>>>> I don't really understand the question :-) Yes, it is. Since we have
>>>>>>>>> introduced a new phandle in the watchdog node to be able to access the
>>>>>>>>> reset status register through the 'sysc' syscon node.
>>>>>>>>> We need the bindings to be aligned with the mt7621.dtsi file and we
>>>>>>>>> are getting the syscon regmap handler via
>>>>>>>>> 'syscon_regmap_lookup_by_phandle()'. See PATCH 5 of the series, Arınç.
>>>>>>>>
>>>>>>>> I believe you need to put mediatek,sysctl under "required:".
>>>>>>>
>>>>>>> Ah, I understood your question now :-). You meant 'required' property.
>>>>>>> I need more coffee, I guess :-). I am not sure if you can add
>>>>>>> properties as required after bindings are already mainlined for
>>>>>>> compatibility issues. The problem with this SoC is that drivers become
>>>>>>> mainlined before the device tree was so if things are properly fixed
>>>>>>> now this kind of issues appear.  Let's see Krzysztof and Rob comments
>>>>>>> for this.
>>>>>>
>>>>>> If your driver fails to probe without mediatek,sysctl, you already made
>>>>>> it required (thus broke the ABI) regardless what dt-binding is saying.
>>>>>> In such case you should update dt-binding to reflect reality.
>>>>>>
>>>>>> Now ABI break is different case. Usually you should not break it without
>>>>>> valid reasons (e.g. it was never working before). Your commit msg
>>>>>> suggests that you only improve the code, thus ABI break is not really
>>>>>> justified. In such case - binding is correct, driver should be reworked
>>>>>> to accept DTS without the new property.
>>>>>
>>>>> Thanks for clarification, Krzysztof. Ok, so if this is the case I need
>>>>> to add this property required (as Arinc was properly pointing out in
>>>>> previous mail) since without it the driver is going to fail on probe
>>>>> (PATCH 5 of the series). I understand the "it was never working
>>>>> before" argument reason for ABI breaks. What happens if the old driver
>>>>> code was not ideal and totally dependent on architecture specific
>>>>> operations when this could be totally avoided and properly make arch
>>>>> independent agnostic drivers? This driver was added in 2016 [0]. There
>>>>> was not a device tree file in the kernel for this SoC mainlined until
>>>>> 2022 [1]. I also personally migrated this watchdog binding in 2022
>>>>> from text to YAML and maintained it without changes [2]. When this was
>>>>> mainlined not all drivers were properly reviewed and the current code
>>>>> was just maintained as it is. Most users of this SoC are in the
>>>>> openWRT community where the dtsi of the mainline is not used yet and
>>>>> they maintain their own mt7621.dtsi files. Also, when a new version of
>>>>> the openWRT selected kernel is added they also modify and align with
>>>>> its mt7621.dtsi file without maintaining previous dtb's. If "make the
>>>>> driver arch independent to be able to be compile tested" and this kind
>>>>> of arguments are not valid at all I need to know because I have
>>>>> started to review driver code for this SoC and other drivers also have
>>>>> the same arch dependency that ideally should be avoided in the same
>>>>> way. This at the end means to break the ABI again in the future for
>>>>> those drivers / bindings. So I can just let them be as it is and not
>>>>> provide any change at all and continue without being compile tested
>>>>> and other beneficial features to detect future driver breakage.
>>>>>
>>>>
>>>> Problem is that there are (presumably) shipped systems out there with
>>>> the old devicetree file. The watchdog driver would no longer instantiate
>>>> on those systems.
>>>
>>> Ok, I will maintain only the PATCH that changes the driver to not use
>>> globals and send v5.
>>>
>>
>> Other options might be to search for the "syscon" node name or to search
>> for the "mediatek,mt7621-sysc" compatible.
> 
> Thanks for the hint. I didn't know about
> 'syscon_regmap_lookup_by_compatible()'. I will use this to avoid DTB
> ABI breakage and allow the driver to be selected for COMPILE_TEST..
> 

I didn't know about that one either. I thought about of_find_compatible_node()
or of_find_node_by_name(). syscon_regmap_lookup_by_compatible() is widely used,
though, so it seems to be a much better option.

Thanks,
Guenter
  

Patch

diff --git a/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml b/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
index b2b17fdf4..a668d0c2f 100644
--- a/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/mediatek,mt7621-wdt.yaml
@@ -19,6 +19,12 @@  properties:
   reg:
     maxItems: 1
 
+  mediatek,sysctl:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      phandle to system controller 'sysc' syscon node which
+      controls system registers
+
 required:
   - compatible
   - reg
@@ -30,4 +36,5 @@  examples:
     watchdog@100 {
       compatible = "mediatek,mt7621-wdt";
       reg = <0x100 0x100>;
+      mediatek,sysctl = <&sysc>;
     };