Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2174532pxb; Thu, 11 Feb 2021 06:19:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyeUnQX9y7QRabsNmM+hP9wtq/picqb+r8ZLyQqeSEPjqppX/gmpjGPPoZCpCuoooTrR/GU X-Received: by 2002:a17:907:210e:: with SMTP id qn14mr9014035ejb.237.1613053155649; Thu, 11 Feb 2021 06:19:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613053155; cv=none; d=google.com; s=arc-20160816; b=jAH1YTcsNsJEyQAqtCVUP4xEwO1gLg6oyMSVyK5KgdggmyxKrPTNaGPRd9WlzeKTZa hA07A/dPVgsDB1KRXpxOenoPtbjC/TwhDCdIXKxid7G19Y/fAqPkCNPOiz6Rrdhd/241 kpgY8xQMW4MLNGiB+DL9sHfamPz5WqyE63nDAWcm6j6fFBBBKEJI9frrUH80DVEnRbWu NWe4+s0lpyV0bA1fwEI8Kc5Wu1rQLaSq0lvikdCGtHtTjnwrFakxmKWsq3ZU9rfGdFdD 1LR/ACSyy6mXILeURgqlZe2yz0Dzu9MPRmJUjlBiQw+Wm3+T9wx3YDXUw5UAvBdbZep3 B5Hg== 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; bh=tw8qzXuGMspUzyym/Zb7HKEdZkwo6inYW0Zp+KV5Rr8=; b=pwQaAKAqyACuRAeMnOPjduejNAPqQ/q7BJ2vpvPftSjNj5diWtUuijXmMBYIk+10P7 2whQrm/Us7Uld5tbcYwltiNK5nm2gy4/tNxNCdAtkymjQVNH6jhd2uC+ctnkcoMKYJKq FwZ/J7uC3fBlbHU1xQwyRRhXEJ8oUxbbOZgLb5zFnDYNM7ki8fjepGTwpmO2czcj03UW P3Uwb/OzwPzdIOvsBwoOQz13ZWTQr8/ncrKIam0q7z/v2S/5HP1YNwx5eFlzshTRywdC HVvas6XYJ7WKV149+LOcAAHZkExHsWAi6sjR5Ao/8cITe2KHPzfCP9qpSQclYdNNEfh8 q6eg== ARC-Authentication-Results: i=1; mx.google.com; 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 c20si3759916edy.427.2021.02.11.06.18.34; Thu, 11 Feb 2021 06:19:15 -0800 (PST) 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; 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 S231912AbhBKOQo (ORCPT + 99 others); Thu, 11 Feb 2021 09:16:44 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:34866 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbhBKN6P (ORCPT ); Thu, 11 Feb 2021 08:58:15 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lACT7-005aPt-7q; Thu, 11 Feb 2021 14:57:17 +0100 Date: Thu, 11 Feb 2021 14:57:17 +0100 From: Andrew Lunn To: Saravana Kannan Cc: Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Android Kernel Team , netdev , LKML , Jon Hunter Subject: Re: phy_attach_direct()'s use of device_bind_driver() Message-ID: References: <4f0086ad-1258-063d-0ace-fe4c6c114991@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Yeah, I plan to fix this. So I have a few more questions. In the > example I gave, what should happen if the gpios listed in the phy's DT > node aren't ready yet? There are four different use cases for GPIO. 1) The GPIO is used to reset all devices on the MDIO bus. When the bus is registered with the core, the core will try to get this GPIO. If we get EPROBE_DEFER, the registration of the bus is deferred and tried again later. If the MAC driver tries to get the PHY device before the MDIO bus is enumerated, it should also get EPROBE_DEFER, and in the end everything should work. 2) The GPIO is for a specific PHY. Here we have an oddity in the code. If the PHY responds to bus enumeration, before we start doing anything with the reset GPIO, it will be discovered on the bus. At this point, we try to get the GPIO. If that fails with EPROBE_DEFER, all the PHYs on the bus are unregistered, and the bus registration process fails with EPROBE_DEFER. 3) The GPIO is for a specific PHY. However, the device does not respond to enumeration, because it is held in reset. You can get around this by placing the ID values into device tree. The bus is first enumerated in the normal way. And then devices which are listed in DT, but have not been found, and have ID registers are registered to the bus. This follows pretty much the same path as for a device which is discovered. Before the device is registered with the device core, we get the GPIOs, and handle the EPROBE_DEFER, unwinding everything. 4) The GPIO does not use the normal name in DT. Or the PHY has some other resource, which phylib does nothing with. The driver specific to the hardware has code to handle the resource. It should try to get those resources during probe. If probe returns EPROBE_DEFER, the probe will be retried later. And when the MAC driver tries to find the PHY, it should also get EPROBE_DEFER. In case 4, the fallback driver has no idea about these PHY devices specific properties. They are not part of 802.3 clause 22. So it will ignore them. Probably the PHY will not work, because it is missing a reset, or a clock, or a regulator. But we don't really care about that. In order that the DT was accepted into the kernel, there must be a device specific driver which uses those properties. So the kernel installation is broken, that hardware specific driver is missing. Andrew