Re: [PATCH 1/1] dt-bindings: net: mdio: Add negative patten match for child node

From: Conor Dooley
Date: Mon Aug 12 2024 - 12:45:09 EST


On Sun, Aug 11, 2024 at 11:11:14PM -0400, Frank Li wrote:
> 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
> };
> };
> };

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...


>
> 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.
>
> Signed-off-by: Frank Li <Frank.Li@xxxxxxx>
> ---
> Documentation/devicetree/bindings/net/mdio.yaml | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/net/mdio.yaml b/Documentation/devicetree/bindings/net/mdio.yaml
> index a266ade918ca7..a7def3eb4674d 100644
> --- a/Documentation/devicetree/bindings/net/mdio.yaml
> +++ b/Documentation/devicetree/bindings/net/mdio.yaml
> @@ -59,7 +59,7 @@ properties:
> type: boolean
>
> patternProperties:
> - '@[0-9a-f]+$':
> + '^(?!mdio@).*@[0-9a-f]+$':
> type: object
>
> properties:
> --
> 2.34.1
>

Attachment: signature.asc
Description: PGP signature