lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGVrzcY+3xeDzMAe1683+ypF59eMN9oTss6LC_rLShuEpmC4NA@mail.gmail.com>
Date:	Tue, 6 May 2014 17:55:30 -0700
From:	Florian Fainelli <f.fainelli@...il.com>
To:	Daniel Mack <zonque@...il.com>
Cc:	David Miller <davem@...emloft.net>,
	netdev <netdev@...r.kernel.org>,
	Grant Likely <grant.likely@...aro.org>,
	Rob Herring <robh+dt@...nel.org>
Subject: Re: [PATCH] net: mdio: of_mdio: check for already registered phy
 before creating new instances

Hi Daniel,

2014-05-06 8:21 GMT-07:00 Daniel Mack <zonque@...il.com>:
> In of_mdiobus_register_phy(), check if the phy with the given address is
> already registered within the mii bus before calling phy_device_create()
> or get_phy_device().

I am not exactly sure how you could be in that sort of situation.
of_mdiobus_register() handles two different cases at the moment:

1) PHY child nodes have a valid 'reg' property, and this property is
used to register the PHY at the given address
2) if a PHY child node does not have a valid 'reg' property, which
will trigger an auto-scan and then we iterate through all 32 addresses
of the bus, we skip over PHYs that are already registered

>
> This allows us to augment auto-probed phy devices with extra information
> via DT. Without this patch, a second instance of the phydev is created
> unnecessarily.

Which piece of code is doing the auto-probing in your case? One of the
very first things that of_mdiobus_register() does is set the PHY mask
to 0xffffffff to prevent the default PHY probing method to trigger,
since we are using information from the Device Tree right after that.

>
> Signed-off-by: Daniel Mack <zonque@...il.com>
> ---
>  drivers/of/of_mdio.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index 9a95831..264ea3f 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -72,10 +72,15 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi
>         is_c45 = of_device_is_compatible(child,
>                                          "ethernet-phy-ieee802.3-c45");
>
> -       if (!is_c45 && !of_get_phy_id(child, &phy_id))
> -               phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
> -       else
> -               phy = get_phy_device(mdio, addr, is_c45);
> +       /* Check if the phy we're looking for is already registered */
> +       phy = mdio->phy_map[addr];
> +       if (!phy) {
> +               if (!is_c45 && !of_get_phy_id(child, &phy_id))
> +                       phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
> +               else
> +                       phy = get_phy_device(mdio, addr, is_c45);
> +       }
> +
>         if (!phy || IS_ERR(phy))
>                 return 1;
>
> --
> 1.9.0
>



-- 
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ