From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30327C433DF for ; Fri, 9 Oct 2020 07:21:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E34D422264 for ; Fri, 9 Oct 2020 07:21:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731892AbgJIHV5 (ORCPT ); Fri, 9 Oct 2020 03:21:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbgJIHV4 (ORCPT ); Fri, 9 Oct 2020 03:21:56 -0400 Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D7CFC0613D2 for ; Fri, 9 Oct 2020 00:21:56 -0700 (PDT) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4C6zz40CLhz1sKj1; Fri, 9 Oct 2020 09:21:44 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4C6zyw4zdRz1qrgc; Fri, 9 Oct 2020 09:21:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id k_HpLOAIS43b; Fri, 9 Oct 2020 09:21:43 +0200 (CEST) X-Auth-Info: jV0RK6JVURhLTawQr16+gnEXCQEQGp+vs06xZxLcngU= Received: from [IPv6:::1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 9 Oct 2020 09:21:43 +0200 (CEST) Subject: Re: [PATCH] net: fec: Fix phy_device lookup for phy_reset_after_clk_enable() To: Jakub Kicinski Cc: Florian Fainelli , netdev@vger.kernel.org, Christoph Niedermaier , "David S . Miller" , NXP Linux Team , Richard Leitner , Shawn Guo , Andrew Lunn , Heiner Kallweit References: <20201006202029.254212-1-marex@denx.de> <110b63bb-9096-7ce0-530f-45dffed09077@gmail.com> <9f882603-2419-5931-fe8f-03c2a28ac785@denx.de> <20201008174619.282b3482@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Marek Vasut Message-ID: Date: Fri, 9 Oct 2020 09:20:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201008174619.282b3482@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 > >>>> 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.