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: <da024643-e7bc-3470-64ad-96277655f494@denx.de>
Date:   Fri, 9 Oct 2020 09:20:30 +0200
From:   Marek Vasut <marex@...x.de>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     Florian Fainelli <f.fainelli@...il.com>, netdev@...r.kernel.org,
        Christoph Niedermaier <cniedermaier@...electronics.com>,
        "David S . Miller" <davem@...emloft.net>,
        NXP Linux Team <linux-imx@....com>,
        Richard Leitner <richard.leitner@...data.com>,
        Shawn Guo <shawnguo@...nel.org>, Andrew Lunn <andrew@...n.ch>,
        Heiner Kallweit <hkallweit1@...il.com>
Subject: Re: [PATCH] net: fec: Fix phy_device lookup for
 phy_reset_after_clk_enable()

On 10/9/20 2:46 AM, Jakub Kicinski wrote:
> On Wed, 7 Oct 2020 00:02:42 +0200 Marek Vasut wrote:
>> On 10/6/20 11:09 PM, Florian Fainelli wrote:
>>> On 10/6/2020 1:20 PM, Marek Vasut wrote:  
>>>> The phy_reset_after_clk_enable() is always called with ndev->phydev,
>>>> however that pointer may be NULL even though the PHY device instance
>>>> already exists and is sufficient to perform the PHY reset.
>>>>
>>>> If the PHY still is not bound to the MAC, but there is OF PHY node
>>>> and a matching PHY device instance already, use the OF PHY node to
>>>> obtain the PHY device instance, and then use that PHY device instance
>>>> when triggering the PHY reset.
>>>>
>>>> Fixes: 1b0a83ac04e3 ("net: fec: add phy_reset_after_clk_enable()
>>>> support")
>>>> Signed-off-by: Marek Vasut <marex@...x.de>
> 
>>>> diff --git a/drivers/net/ethernet/freescale/fec_main.c
>>>> b/drivers/net/ethernet/freescale/fec_main.c
>>>> index 2d5433301843..5a4b20941aeb 100644
>>>> --- a/drivers/net/ethernet/freescale/fec_main.c
>>>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>>>> @@ -1912,6 +1912,24 @@ static int fec_enet_mdio_write(struct mii_bus
>>>> *bus, int mii_id, int regnum,
>>>>       return ret;
>>>>   }
>>>>   +static void fec_enet_phy_reset_after_clk_enable(struct net_device
>>>> *ndev)
>>>> +{
>>>> +    struct fec_enet_private *fep = netdev_priv(ndev);
>>>> +    struct phy_device *phy_dev = ndev->phydev;
>>>> +
>>>> +    /*
>>>> +     * If the PHY still is not bound to the MAC, but there is
>>>> +     * OF PHY node and a matching PHY device instance already,
>>>> +     * use the OF PHY node to obtain the PHY device instance,
>>>> +     * and then use that PHY device instance when triggering
>>>> +     * the PHY reset.
>>>> +     */
>>>> +    if (!phy_dev && fep->phy_node)
>>>> +        phy_dev = of_phy_find_device(fep->phy_node);  
>>>
>>> Don't you need to put the phy_dev reference at some point?  
>>
>> Probably, yes.
>>
>> But first, does this approach and this patch even make sense ?
>> I mean, it fixes my problem, but is this right ?
> 
> Can you describe your problem in detail?

Yes, I tried to do that in the commit message and the extra detailed
comment above the code. What exactly do you not understand from that?

> To an untrained eye this looks pretty weird.

I see, I'm not quite sure how to address this comment.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ