Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp718025pxb; Thu, 2 Sep 2021 13:26:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjwHdEdr6Cjz4KEXghqqOZ03agwH3l6SdrqvrW0lb6wOOKeIkYkQQBrfJ4IeOU1fGXOIR5 X-Received: by 2002:a05:6e02:1bc8:: with SMTP id x8mr18905ilv.138.1630614377292; Thu, 02 Sep 2021 13:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630614377; cv=none; d=google.com; s=arc-20160816; b=pM4+79aqm9HRqf9vY4Lga9/KIBwtpzraQ6OHIX7xpVt47GaYNyinDBNkqLV3aEseXZ B5ILKy8gKCTdCmKp9xThSfAjUrnMux9QS9j7qTH0TXNWYFaMKZnR+yNenn4nPsiE7Pv7 XM4VM2Ffhb04n90LhhoxH39IGpDz3luI/y/uC0nK8Kgcg+yZ7MeGqA5pG7VKAHfoFS6W oPThwmmm5PHbh3oeRRqerJPIpFjIRTZ6MF6uPoBCVvNL1b7xYrWFksZx3pzqBGoZpEDl Fq9HUPsD0UaKTwDLkMk4VDNHagrJMtKbY+8qfTufW+3mSfLF5LOkyirm4d7SUtT0Lksy YJyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xOucIOQ6UtzBW3tM9Wea+AQXnKYvu/HSHmo7sZLlgbo=; b=pDLxITSD8lFGdNNk/d3yisFckEnPWexnFDACIBOaTpDVLHsiSkMdB0UMsYFJZ7pxTz g16mBwQikODy7Kl8SECJlgpOM1xJ368qQqPnWPVdbyx9leZDtaqCAKmgWAkRWZC6jBMS bY6OtNWGy+P728G8VTq33x/Wwet/OH9izrpw1fahE+Do4JBRzHRg+GwzX4342H0pehdH 3sEV/DLT8wKDyhFGgpX6DP1UWzHQsAwxe2D8sJVs7sndFAPTqvo6bSukjyqL/Za3IiZj 4Y2SpudiPruC+JHfj8a0ER9m/pIuPJt8m/CaOtmlIjN8j9EHNZKPVvS8u2l6ezHqIMmj DIcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=4+6aumT0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si2873830ile.129.2021.09.02.13.26.04; Thu, 02 Sep 2021 13:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=4+6aumT0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347422AbhIBTwy (ORCPT + 99 others); Thu, 2 Sep 2021 15:52:54 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:54030 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbhIBTwx (ORCPT ); Thu, 2 Sep 2021 15:52:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=xOucIOQ6UtzBW3tM9Wea+AQXnKYvu/HSHmo7sZLlgbo=; b=4+6aumT0YXZ4ccr6LAogodGa/K ewLzJRNRHlJaihgAp3V972EpohUYUNbLe10SY/+ZUEaLf12MJVUckbz77lw3iXztzT+IYCvg+3FDj mPQFqqhmAfVlzw2PjzkRWCHezSO275WTVt1w/0lxZMGRQn/g/48jfYp89FCCDv8pl/Y4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1mLskP-0052nI-2o; Thu, 02 Sep 2021 21:51:41 +0200 Date: Thu, 2 Sep 2021 21:51:41 +0200 From: Andrew Lunn To: "Russell King (Oracle)" Cc: Vladimir Oltean , netdev@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Heiner Kallweit , "David S. Miller" , Jakub Kicinski , Vivien Didelot , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Linus Walleij , Alvin =?utf-8?Q?=C5=A0ipraga?= , ACPI Devel Maling List , kernel-team , Len Brown Subject: Re: [RFC PATCH net-next 1/3] net: phy: don't bind genphy in phy_attach_direct if the specific driver defers probe Message-ID: References: <20210901225053.1205571-1-vladimir.oltean@nxp.com> <20210901225053.1205571-2-vladimir.oltean@nxp.com> <20210902185016.GL22278@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210902185016.GL22278@shell.armlinux.org.uk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 02, 2021 at 07:50:16PM +0100, Russell King (Oracle) wrote: > On Thu, Sep 02, 2021 at 01:50:51AM +0300, Vladimir Oltean wrote: > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > > index 52310df121de..2c22a32f0a1c 100644 > > --- a/drivers/net/phy/phy_device.c > > +++ b/drivers/net/phy/phy_device.c > > @@ -1386,8 +1386,16 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, > > > > /* Assume that if there is no driver, that it doesn't > > * exist, and we should use the genphy driver. > > + * The exception is during probing, when the PHY driver might have > > + * attempted a probe but has requested deferral. Since there might be > > + * MAC drivers which also attach to the PHY during probe time, try > > + * harder to bind the specific PHY driver, and defer the MAC driver's > > + * probing until then. > > */ > > if (!d->driver) { > > + if (device_pending_probe(d)) > > + return -EPROBE_DEFER; > > Something else that concerns me here. > > As noted, many network drivers attempt to attach their PHY when the > device is brought up, and not during their probe function. Yes, this is going to be a problem. I agree it is too late to return -EPROBE_DEFER. Maybe phy_attach_direct() needs to wait around, if the device is still on the deferred list, otherwise use genphy. And maybe a timeout and return -ENODEV, which is not 100% correct, we know the device exists, we just cannot drive it. Can we tell we are in the context of a driver probe? Or do we need to add a parameter to the various phy_attach API calls to let the core know if this is probe or open? This is more likely to be a problem with NFS root, with the kernel bringing up an interface as soon as its registered. userspace bringing up interfaces is generally much later, and udev tends to wait around until there are no more driver load requests before the boot continues. Andrew