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  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]
Date:   Mon, 13 Jan 2020 08:50:12 +0000
From:   <Claudiu.Beznea@...rochip.com>
To:     <mparab@...ence.com>, <Nicolas.Ferre@...rochip.com>,
        <jakub.kicinski@...ronome.com>, <andrew@...n.ch>,
        <antoine.tenart@...tlin.com>, <rmk+kernel@...linux.org.uk>
CC:     <f.fainelli@...il.com>, <davem@...emloft.net>,
        <netdev@...r.kernel.org>, <hkallweit1@...il.com>,
        <linux-kernel@...r.kernel.org>, <dkangude@...ence.com>,
        <a.fatoum@...gutronix.de>, <brad.mouring@...com>,
        <pthombar@...ence.com>
Subject: Re: [PATCH v3 net] net: macb: fix for fixed-link mode



On 13.01.2020 05:30, Milind Parab wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> This patch fix the issue with fixed link. With fixed-link
> device opening fails due to macb_phylink_connect not
> handling fixed-link mode, in which case no MAC-PHY connection
> is needed and phylink_connect return success (0), however
> in current driver attempt is made to search and connect to
> PHY even for fixed-link.
> 
> Fixes: 7897b071ac3b ("net: macb: convert to phylink")
> Signed-off-by: Milind Parab <mparab@...ence.com>

Reviewed-by: Claudiu Beznea <claudiu.beznea@...rochip.com>

> ---
> Changes in v2:
> 1. Code refactoring to remove extra if condition
> 
> Changes in v3:
> 1. Reverse christmas tree ordering of local variables
> ---
>  drivers/net/ethernet/cadence/macb_main.c | 30 ++++++++++++++----------
>  1 file changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 1c547ee0d444..7a2fe63d1136 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -650,21 +650,24 @@ static const struct phylink_mac_ops macb_phylink_ops = {
>         .mac_link_up = macb_mac_link_up,
>  };
> 
> +static bool macb_phy_handle_exists(struct device_node *dn)
> +{
> +       dn = of_parse_phandle(dn, "phy-handle", 0);
> +       of_node_put(dn);
> +       return dn != NULL;
> +}
> +
>  static int macb_phylink_connect(struct macb *bp)
>  {
> +       struct device_node *dn = bp->pdev->dev.of_node;
>         struct net_device *dev = bp->dev;
>         struct phy_device *phydev;
>         int ret;
> 
> -       if (bp->pdev->dev.of_node &&
> -           of_parse_phandle(bp->pdev->dev.of_node, "phy-handle", 0)) {
> -               ret = phylink_of_phy_connect(bp->phylink, bp->pdev->dev.of_node,
> -                                            0);
> -               if (ret) {
> -                       netdev_err(dev, "Could not attach PHY (%d)\n", ret);
> -                       return ret;
> -               }
> -       } else {
> +       if (dn)
> +               ret = phylink_of_phy_connect(bp->phylink, dn, 0);
> +
> +       if (!dn || (ret && !macb_phy_handle_exists(dn))) {
>                 phydev = phy_find_first(bp->mii_bus);
>                 if (!phydev) {
>                         netdev_err(dev, "no PHY found\n");
> @@ -673,10 +676,11 @@ static int macb_phylink_connect(struct macb *bp)
> 
>                 /* attach the mac to the phy */
>                 ret = phylink_connect_phy(bp->phylink, phydev);
> -               if (ret) {
> -                       netdev_err(dev, "Could not attach to PHY (%d)\n", ret);
> -                       return ret;
> -               }
> +       }
> +
> +       if (ret) {
> +               netdev_err(dev, "Could not attach PHY (%d)\n", ret);
> +               return ret;
>         }
> 
>         phylink_start(bp->phylink);
> --
> 2.17.1
> 
> 

Powered by blists - more mailing lists