dt-bindings: net: mdio: Add negative patten match for child node
Subsystems (5)
Frank Li
maintainerPATCH 1/1 dt-bindings: net: mdio: Add negative patten match for child node
mdio.yaml wrong parser mdio controller's address instead phy's address when mdio-mux exist.
For example:
mdio-mux-emi1@54 {
compatible = "mdio-mux-mmioreg", "mdio-mux";
mdio@20 {
reg = <0x20>;
^^^ This is mdio controller register
ethernet-phy@2 {
reg = <0x2>;
^^^ This phy's address
};
};
};Only phy's address is limited to 31 because MDIO bus defination.
But CHECK_DTBS report below warning:
arch/arm64/boot/dts/freescale/fsl-ls1043a-qds.dtb: mdio-mux-emi1@54:
mdio@20:reg:0:0: 32 is greater than the maximum of 31
The reason is that "mdio@20" match "patternProperties: '@[0-9a-f]+$'" in mdio.yaml.
Change to '^(?!mdio@).*@[0-9a-f]+$' to avoid match parent's mdio controller's address.
--- Documentation/devicetree/bindings/net/mdio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/net/mdio.yaml +1 -1
@@ -59,7 +59,7 @@ properties: type: boolean patternProperties: - '@[0-9a-f]+$': + '^(?!mdio@).*@[0-9a-f]+$': type: object properties:
Signature · 1 line
2.34.1
Simon Horman
reviewerQuoted 18 lines · Frank Li
mdio.yamlwrong parser mdio controller's address instead phy's address when mdio-mux exist.For example:
mdio-mux-emi1@54 { compatible = "mdio-mux-mmioreg", "mdio-mux"; mdio@20 { reg = <0x20>; ^^^ This is mdio controller register ethernet-phy@2 { reg = <0x2>; ^^^ This phy's address }; }; };
Quoted 1 line
Only phy's address is limited to 31 because MDIO bus defination.
nit: definition
Also, in subject: patten -> pattern
Flagged by checkpatch.pl --codespell
Quoted 12 lines
But
CHECK_DTBSreport below warning:
arch/arm64/boot/dts/freescale/fsl-ls1043a-qds.dtb: mdio-mux-emi1@54:
mdio@20:reg:0:0: 32 is greater than the maximum of 31The reason is that "mdio@20" match "patternProperties: '@[0-9a-f]+$'" in
mdio.yaml.Change to '^(?!mdio@).*@[0-9a-f]+$' to avoid match parent's mdio controller's address.
Signed-off-by Frank Li <[email protected]>
...
Quoted 4 lines · Frank Li
mdio.yamlwrong parser mdio controller's address instead phy's address when mdio-mux exist.For example:
Quoted 13 lines
mdio-mux-emi1@54 {
compatible = "mdio-mux-mmioreg", "mdio-mux";
mdio@20 {
reg = <0x20>;
^^^ This is mdio controller register
ethernet-phy@2 {
reg = <0x2>;
^^^ This phy's address
};
};
};I don't understand MDIO well enough to know the answer - does this actually solve the problem? It seems to me that the problem is that mdio.yaml is applied to the mdio-mux node because it matches the pattern "^mdio(@.*)?" that applies the binding based on node-names. If the properties in mdio.yaml do not apply to mdio muxes, then the binding should not be applied and the patch here is only treating a symptom rather than the actual problem.
From a quick check, I don't see any of the mdio-mux-mmioreg nodes using the properties from mdio.yaml, so should the binding be applied to them at all?
Cheers,
Conor.
FWIW, adding a $ after the ? in the pattern I linked would stop the binding being applied to the mdio-mux nodes, but if something like that were done, all mdio nodes would need to be checked to ensure they match the new pattern...
Quoted 35 lines
Only phy's address is limited to 31 because MDIO bus defination.
But
CHECK_DTBSreport below warning:
arch/arm64/boot/dts/freescale/fsl-ls1043a-qds.dtb: mdio-mux-emi1@54:
mdio@20:reg:0:0: 32 is greater than the maximum of 31The reason is that "mdio@20" match "patternProperties: '@[0-9a-f]+$'" in
mdio.yaml.Change to '^(?!mdio@).*@[0-9a-f]+$' to avoid match parent's mdio controller's address.
Signed-off-by Frank Li <[email protected]>--- Documentation/devicetree/bindings/net/mdio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/net/mdio.yaml +1
-1@@ -59,7 +59,7 @@ properties: type: boolean patternProperties: - '@[0-9a-f]+$': + '^(?!mdio@).*@[0-9a-f]+$': type: object properties:Signature · 1 line
2.34.1
Frank Li
maintainerQuoted 19 lines · Conor Dooley
Quoted 4 lines · Frank Li
mdio.yamlwrong parser mdio controller's address instead phy's address when mdio-mux exist.For example:
Quoted 13 lines
mdio-mux-emi1@54 { compatible = "mdio-mux-mmioreg", "mdio-mux"; mdio@20 { reg = <0x20>; ^^^ This is mdio controller register ethernet-phy@2 { reg = <0x2>; ^^^ This phy's address }; }; };
Quoted 7 lines
I don't understand MDIO well enough to know the answer - does this actually solve the problem? It seems to me that the problem is that
mdio.yamlis applied to the mdio-mux node because it matches the pattern "^mdio(@.*)?" that applies the binding based on node-names. If the properties inmdio.yamldo not apply to mdio muxes, then the binding should not be applied and the patch here is only treating a symptom rather than the actual problem.
after I change above example 0x2 to 0x22, mdio.yaml can report exceed 31.
Only issue should be only when "ethernet-phy" use node name "mdio".
Quoted 4 lines
From a quick check, I don't see any of the mdio-mux-mmioreg nodes using the properties from
mdio.yaml, so should the binding be applied to them at all?
in mdio-mux-mmioreg.yaml line 18:
allOf:
- $ref: /schemas/net/mdio-mux.yaml#
in mdio-mux.yaml
patternProperties:
'^mdio@[0-9a-f]+$': -> A
$ref: mdio.yaml#In mdio.yaml
properties:
$nodename:
pattern: "^mdio(@.*)?
^^^^^ mdio@20 Match condition A, it should correct.
patternProperties:
'@[0-9a-f]+$':
^^^^ mdio@20 also match this one. but I suppose it should
search mdio@20's child node, such as ethernet-phy@2, but not.
Frank
Quoted 46 lines
Cheers,
Conor.FWIW, adding a $ after the ? in the pattern I linked would stop the binding being applied to the mdio-mux nodes, but if something like that were done, all mdio nodes would need to be checked to ensure they match the new pattern...
Quoted 35 lines
Only phy's address is limited to 31 because MDIO bus defination.
But
CHECK_DTBSreport below warning:
arch/arm64/boot/dts/freescale/fsl-ls1043a-qds.dtb: mdio-mux-emi1@54:
mdio@20:reg:0:0: 32 is greater than the maximum of 31The reason is that "mdio@20" match "patternProperties: '@[0-9a-f]+$'" in
mdio.yaml.Change to '^(?!mdio@).*@[0-9a-f]+$' to avoid match parent's mdio controller's address.
Signed-off-by Frank Li <[email protected]>--- Documentation/devicetree/bindings/net/mdio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/net/mdio.yaml +1
-2@@ -59,7 +59,7 @@ properties: type: boolean patternProperties: - '@[0-9a-f]+$': + '^(?!mdio@).*@[0-9a-f]+$': type: object properties: --2.34.1
Rob Herring
maintainerQuoted 41 lines · Frank Li
mdio.yamlwrong parser mdio controller's address instead phy's address when mdio-mux exist.For example:
mdio-mux-emi1@54 { compatible = "mdio-mux-mmioreg", "mdio-mux"; mdio@20 { reg = <0x20>; ^^^ This is mdio controller register ethernet-phy@2 { reg = <0x2>; ^^^ This phy's address }; }; };Only phy's address is limited to 31 because MDIO bus defination.
But
CHECK_DTBSreport below warning:
arch/arm64/boot/dts/freescale/fsl-ls1043a-qds.dtb: mdio-mux-emi1@54:
mdio@20:reg:0:0: 32 is greater than the maximum of 31The reason is that "mdio@20" match "patternProperties: '@[0-9a-f]+$'" in
mdio.yaml.Change to '^(?!mdio@).*@[0-9a-f]+$' to avoid match parent's mdio controller's address.
Signed-off-by Frank Li <[email protected]>--- Documentation/devicetree/bindings/net/mdio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/net/mdio.yaml +0
-0
Documentation/devicetree/bindings/net/mdio.yaml properties: · line 62
Quoted 5 lines
Documentation/devicetree/bindings/net/mdio.yaml +1
-1@@ -59,7 +59,7 @@ properties: type: boolean patternProperties: - '@[0-9a-f]+$': + '^(?!mdio@).*@[0-9a-f]+$':
This is at the wrong spot. The problem is up a level where the $nodename matched mdio-mux-emi1@54.
I think what we want for the $nodename pattern is:
'^mdio(-(bus|external))?(@.+|-([0-9]+))$'
There's lots of pinctrl nodes named 'mdio...' we need to avoid and we aren't currently.
I'd prefer not to support 'mdio-external', but there's already 1 documented case. I think the only node name fix we'd need with this is 'mdio-gpio' which should be just 'mdio' or 'mdio-N' like all other bitbanged implementations.
Rob
Frank Li
maintainerQuoted 55 lines · Rob Herring
Quoted 41 lines · Frank Li
mdio.yamlwrong parser mdio controller's address instead phy's address when mdio-mux exist.For example:
mdio-mux-emi1@54 { compatible = "mdio-mux-mmioreg", "mdio-mux"; mdio@20 { reg = <0x20>; ^^^ This is mdio controller register ethernet-phy@2 { reg = <0x2>; ^^^ This phy's address }; }; };Only phy's address is limited to 31 because MDIO bus defination.
But
CHECK_DTBSreport below warning:
arch/arm64/boot/dts/freescale/fsl-ls1043a-qds.dtb: mdio-mux-emi1@54:
mdio@20:reg:0:0: 32 is greater than the maximum of 31The reason is that "mdio@20" match "patternProperties: '@[0-9a-f]+$'" in
mdio.yaml.Change to '^(?!mdio@).*@[0-9a-f]+$' to avoid match parent's mdio controller's address.
Signed-off-by Frank Li <[email protected]>--- Documentation/devicetree/bindings/net/mdio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/net/mdio.yaml +0
-0Documentation/devicetree/bindings/net/mdio.yaml properties: · line 62
Quoted 5 lines
Documentation/devicetree/bindings/net/mdio.yaml +1
-1@@ -59,7 +59,7 @@ properties: type: boolean patternProperties: - '@[0-9a-f]+$': + '^(?!mdio@).*@[0-9a-f]+$':This is at the wrong spot. The problem is up a level where the $nodename matched mdio-mux-emi1@54.
I think what we want for the $nodename pattern is:
'^mdio(-(bus|external))?(@.+|-([0-9]+))$'
Quoted 7 lines
There's lots of pinctrl nodes named 'mdio...' we need to avoid and we aren't currently.
I'd prefer not to support 'mdio-external', but there's already 1 documented case. I think the only node name fix we'd need with this is 'mdio-gpio' which should be just 'mdio' or 'mdio-N' like all other bitbanged implementations.
Documentation/devicetree/bindings/net/mdio.yaml +1 -1
@@ -19,7 +19,7 @@ description: properties: $nodename: - pattern: "^mdio(@.*)?" + pattern: '^mdio(-(bus|external))?(@.+|-([0-9]+))$'
You are right. Above patch can work.
Frank
Quoted 2 lines
Rob