linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 14/15] net: phy: add PHY regulator support
       [not found]           ` <20200623095646.GT1551@shell.armlinux.org.uk>
@ 2020-06-23 16:27             ` Bartosz Golaszewski
  2020-06-24 16:57               ` Russell King - ARM Linux admin
  0 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2020-06-23 16:27 UTC (permalink / raw)
  To: Russell King - ARM Linux admin
  Cc: Andrew Lunn, Alexandre Belloni, Tom Lendacky, Vladimir Oltean,
	Liam Girdwood, Fabien Parent, Iyappan Subramanian, Quan Nguyen,
	Frank Rowand, Florian Fainelli, Bartosz Golaszewski,
	Jakub Kicinski, Vivien Didelot, devicetree, Philipp Zabel,
	Stephane Le Provost, Keyur Chudgar, Jassi Brar, Claudiu Manoil,
	Mark Brown, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, netdev, Ilias Apalodimas,
	Linux Kernel Mailing List, Rob Herring, Andrew Perepech,
	Pedro Tsai, David S . Miller, Heiner Kallweit

wt., 23 cze 2020 o 11:56 Russell King - ARM Linux admin
<linux@armlinux.org.uk> napisał(a):
>
> On Tue, Jun 23, 2020 at 11:46:15AM +0200, Bartosz Golaszewski wrote:
> > wt., 23 cze 2020 o 11:43 Russell King - ARM Linux admin
> > <linux@armlinux.org.uk> napisał(a):
> > >
> > > On Tue, Jun 23, 2020 at 11:41:11AM +0200, Bartosz Golaszewski wrote:
> > > > pon., 22 cze 2020 o 15:29 Russell King - ARM Linux admin
> > > > <linux@armlinux.org.uk> napisał(a):
> > > > >
> > > >
> > > > [snip!]
> > > >
> > > > >
> > > > > This is likely to cause issues for some PHY drivers.  Note that we have
> > > > > some PHY drivers which register a temperature sensor in the probe
> > > > > function, which means they can be accessed independently of the lifetime
> > > > > of the PHY bound to the network driver (which may only be while the
> > > > > network device is "up".)  We certainly do not want hwmon failing just
> > > > > because the network device is down.
> > > > >
> > > > > That's kind of worked around for the reset stuff, because there are two
> > > > > layers to that: the mdio device layer reset support which knows nothing
> > > > > of the PHY binding state to the network driver, and the phylib reset
> > > > > support, but it is not nice.
> > > > >
> > > >
> > > > Regulators are reference counted so if the hwmon driver enables it
> > > > using mdio_device_power_on() it will stay on even after the PHY driver
> > > > calls phy_device_power_off(), right? Am I missing something?
> > >
> > > If that is true, you will need to audit the PHY drivers to add that.
> > >
> >
> > This change doesn't have any effect on devices which don't have a
> > regulator assigned in DT though. The one I'm adding in the last patch
> > is the first to use this.
>
> It's quality of implementation.
>
> Should we wait for someone else to make use of the new regulator
> support that has been added with a PHY that uses hwmon, and they
> don't realise that it breaks hwmon on it, and several kernel versions
> go by without it being noticed.  It will only be a noticable issue
> when the associated network device is down, and that network device
> driver detaches from the PHY, so _is_ likely not to be noticed.
>
> Or should we do a small amount of work now to properly implement
> regulator support, which includes a trivial grep for "hwmon" amongst
> the PHY drivers, and add the necessary call to avoid the regulator
> being shut off.
>

I'm not sure what the correct approach is here. Provide some helper
that, when called, would increase the regulator's reference count even
more to keep it enabled from the moment hwmon is registered to when
the driver is detached?

Bart

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 01/15] net: phy: arrange headers in mdio_bus.c alphabetically
       [not found] ` <20200622093744.13685-2-brgl@bgdev.pl>
@ 2020-06-23 18:54   ` Florian Fainelli
  0 siblings, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2020-06-23 18:54 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, Rob Herring, Matthias Brugger,
	Microchip Linux Driver Support, Vladimir Oltean, Claudiu Manoil,
	Alexandre Belloni, Vivien Didelot, Tom Lendacky, Yisen Zhuang,
	Salil Mehta, Jassi Brar, Ilias Apalodimas, Iyappan Subramanian,
	Keyur Chudgar, Quan Nguyen, Frank Rowand, Philipp Zabel,
	Liam Girdwood, Mark Brown
  Cc: devicetree, Stephane Le Provost, Bartosz Golaszewski, netdev,
	linux-kernel, Fabien Parent, linux-mediatek, Andrew Perepech,
	Pedro Tsai, linux-arm-kernel

On 6/22/20 2:37 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Keeping the headers in alphabetical order is better for readability and
> allows to easily see if given header is already included.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 02/15] net: phy: arrange headers in mdio_device.c alphabetically
       [not found] ` <20200622093744.13685-3-brgl@bgdev.pl>
@ 2020-06-23 18:56   ` Florian Fainelli
  0 siblings, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2020-06-23 18:56 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, Rob Herring, Matthias Brugger,
	Microchip Linux Driver Support, Vladimir Oltean, Claudiu Manoil,
	Alexandre Belloni, Vivien Didelot, Tom Lendacky, Yisen Zhuang,
	Salil Mehta, Jassi Brar, Ilias Apalodimas, Iyappan Subramanian,
	Keyur Chudgar, Quan Nguyen, Frank Rowand, Philipp Zabel,
	Liam Girdwood, Mark Brown
  Cc: devicetree, Stephane Le Provost, Bartosz Golaszewski, netdev,
	linux-kernel, Fabien Parent, linux-mediatek, Andrew Perepech,
	Pedro Tsai, linux-arm-kernel

On 6/22/20 2:37 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Keeping the headers in alphabetical order is better for readability and
> allows to easily see if given header is already included.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 03/15] net: phy: arrange headers in phy_device.c alphabetically
       [not found] ` <20200622093744.13685-4-brgl@bgdev.pl>
@ 2020-06-23 18:57   ` Florian Fainelli
  0 siblings, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2020-06-23 18:57 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, Rob Herring, Matthias Brugger,
	Microchip Linux Driver Support, Vladimir Oltean, Claudiu Manoil,
	Alexandre Belloni, Vivien Didelot, Tom Lendacky, Yisen Zhuang,
	Salil Mehta, Jassi Brar, Ilias Apalodimas, Iyappan Subramanian,
	Keyur Chudgar, Quan Nguyen, Frank Rowand, Philipp Zabel,
	Liam Girdwood, Mark Brown
  Cc: devicetree, Stephane Le Provost, Bartosz Golaszewski, netdev,
	linux-kernel, Fabien Parent, linux-mediatek, Andrew Perepech,
	Pedro Tsai, linux-arm-kernel

On 6/22/20 2:37 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Keeping the headers in alphabetical order is better for readability and
> allows to easily see if given header is already included.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 04/15] net: mdio: add a forward declaration for reset_control to mdio.h
       [not found] ` <20200622093744.13685-5-brgl@bgdev.pl>
@ 2020-06-23 18:59   ` Florian Fainelli
  0 siblings, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2020-06-23 18:59 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, Rob Herring, Matthias Brugger,
	Microchip Linux Driver Support, Vladimir Oltean, Claudiu Manoil,
	Alexandre Belloni, Vivien Didelot, Tom Lendacky, Yisen Zhuang,
	Salil Mehta, Jassi Brar, Ilias Apalodimas, Iyappan Subramanian,
	Keyur Chudgar, Quan Nguyen, Frank Rowand, Philipp Zabel,
	Liam Girdwood, Mark Brown
  Cc: devicetree, Stephane Le Provost, Bartosz Golaszewski, netdev,
	linux-kernel, Fabien Parent, linux-mediatek, Andrew Perepech,
	Pedro Tsai, linux-arm-kernel

On 6/22/20 2:37 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> This header refers to struct reset_control but doesn't include any reset
> header. The structure definition is probably somehow indirectly pulled in
> since no warnings are reported but for the sake of correctness add the
> forward declaration for struct reset_control.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  include/linux/mdio.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/mdio.h b/include/linux/mdio.h
> index 36d2e0673d03..9ac5e7ff6156 100644
> --- a/include/linux/mdio.h
> +++ b/include/linux/mdio.h
> @@ -17,6 +17,7 @@
>  #define MII_REGADDR_C45_MASK	GENMASK(15, 0)
>  
>  struct gpio_desc;
> +struct reset_control;
>  struct mii_bus;

You wrote 3 patches to sort the headers alphabetically, do you mind
doing the same thing for forward declarations as well?
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 05/15] net: phy: reset the PHY even if probe() is not implemented
       [not found] ` <20200622093744.13685-6-brgl@bgdev.pl>
@ 2020-06-23 19:14   ` Florian Fainelli
  2020-06-24 16:22     ` Bartosz Golaszewski
  0 siblings, 1 reply; 18+ messages in thread
From: Florian Fainelli @ 2020-06-23 19:14 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, Rob Herring, Matthias Brugger,
	Microchip Linux Driver Support, Vladimir Oltean, Claudiu Manoil,
	Alexandre Belloni, Vivien Didelot, Tom Lendacky, Yisen Zhuang,
	Salil Mehta, Jassi Brar, Ilias Apalodimas, Iyappan Subramanian,
	Keyur Chudgar, Quan Nguyen, Frank Rowand, Philipp Zabel,
	Liam Girdwood, Mark Brown
  Cc: devicetree, Stephane Le Provost, Bartosz Golaszewski, netdev,
	linux-kernel, Fabien Parent, linux-mediatek, Andrew Perepech,
	Pedro Tsai, linux-arm-kernel

On 6/22/20 2:37 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Currently we only call phy_device_reset() if the PHY driver implements
> the probe() callback. This is not mandatory and many drivers (e.g.
> realtek) don't need probe() for most devices but still can have reset
> GPIOs defined. There's no reason to depend on the presence of probe()
> here so pull the reset code out of the if clause.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

OK, but now let's imagine that a PHY device has two or more reset lines,
one of them is going to be managed by the core PHY library and the rest
is going to be under the responsibility of the PHY driver, that does not
sound intuitive or convenient at all. This is a hypothetical case, but
it could conceivable happen, so how about adding a flag to the driver
that says "let me manage it a all"?
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 06/15] net: phy: mdio: reset MDIO devices even if probe() is not implemented
       [not found] ` <20200622093744.13685-7-brgl@bgdev.pl>
@ 2020-06-23 19:16   ` Florian Fainelli
  0 siblings, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2020-06-23 19:16 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, Rob Herring, Matthias Brugger,
	Microchip Linux Driver Support, Vladimir Oltean, Claudiu Manoil,
	Alexandre Belloni, Vivien Didelot, Tom Lendacky, Yisen Zhuang,
	Salil Mehta, Jassi Brar, Ilias Apalodimas, Iyappan Subramanian,
	Keyur Chudgar, Quan Nguyen, Frank Rowand, Philipp Zabel,
	Liam Girdwood, Mark Brown
  Cc: devicetree, Stephane Le Provost, Bartosz Golaszewski, netdev,
	linux-kernel, Fabien Parent, linux-mediatek, Andrew Perepech,
	Pedro Tsai, linux-arm-kernel

On 6/22/20 2:37 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Similarily to PHY drivers - there's no reason to require probe() to be
> implemented in order to call mdio_device_reset(). MDIO devices can have
> resets defined without needing to do anything in probe().
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Same comment as patch #5, I would prefer that we seek a solution that
allows MDIO drivers to manage multiple reset lines (would that exist) on
their own instead of this one size fits all approach. Thank you.
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 12/15] dt-bindings: mdio: add phy-supply property to ethernet phy node
       [not found] ` <20200622093744.13685-13-brgl@bgdev.pl>
@ 2020-06-23 19:39   ` Florian Fainelli
  0 siblings, 0 replies; 18+ messages in thread
From: Florian Fainelli @ 2020-06-23 19:39 UTC (permalink / raw)
  To: Bartosz Golaszewski, Andrew Lunn, Heiner Kallweit, Russell King,
	David S . Miller, Jakub Kicinski, Rob Herring, Matthias Brugger,
	Microchip Linux Driver Support, Vladimir Oltean, Claudiu Manoil,
	Alexandre Belloni, Vivien Didelot, Tom Lendacky, Yisen Zhuang,
	Salil Mehta, Jassi Brar, Ilias Apalodimas, Iyappan Subramanian,
	Keyur Chudgar, Quan Nguyen, Frank Rowand, Philipp Zabel,
	Liam Girdwood, Mark Brown
  Cc: devicetree, Stephane Le Provost, Bartosz Golaszewski, netdev,
	linux-kernel, Fabien Parent, linux-mediatek, Andrew Perepech,
	Pedro Tsai, linux-arm-kernel

On 6/22/20 2:37 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> The phy-supply property is often added to MAC nodes but this is wrong
> conceptually. These supplies should be part of the PHY node on the
> MDIO bus. Add phy-supply property at PHY level to mdio.yaml.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  Documentation/devicetree/bindings/net/mdio.yaml | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/mdio.yaml b/Documentation/devicetree/bindings/net/mdio.yaml
> index d6a3bf8550eb..9c10012c2093 100644
> --- a/Documentation/devicetree/bindings/net/mdio.yaml
> +++ b/Documentation/devicetree/bindings/net/mdio.yaml
> @@ -90,6 +90,10 @@ patternProperties:
>            Delay after the reset was deasserted in microseconds. If
>            this property is missing the delay will be skipped.
>  
> +      phy-supply:
> +        description:
> +          Phandle to the regulator that provides the supply voltage to the PHY.

I do not see how you can come up with a generic name here, there could
be PHYs supporting different voltages (3.3V, 1.8V, 1.5V) depending on
their operation mode/strapping, there can also be different parts of the
PHY being powered by different regulators, the analog part could be on
an always-on island such that Wake-on-LAN from the PHY could be done,
and the digital part could be on a complete different island.
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration
       [not found]     ` <20200622135106.GK4560@sirena.org.uk>
@ 2020-06-23 19:49       ` Florian Fainelli
  2020-06-24  9:43         ` Mark Brown
  0 siblings, 1 reply; 18+ messages in thread
From: Florian Fainelli @ 2020-06-23 19:49 UTC (permalink / raw)
  To: Mark Brown, Andrew Lunn
  Cc: Alexandre Belloni, devicetree, Vladimir Oltean, linux-kernel,
	Fabien Parent, Iyappan Subramanian, Quan Nguyen, Frank Rowand,
	Bartosz Golaszewski, Russell King, Bartosz Golaszewski,
	Jakub Kicinski, Yisen Zhuang, Vivien Didelot, Tom Lendacky,
	Andrew Perepech, Stephane Le Provost, Keyur Chudgar, Jassi Brar,
	Claudiu Manoil, Rob Herring, linux-mediatek, Matthias Brugger,
	linux-arm-kernel, Salil Mehta, netdev, Ilias Apalodimas,
	Liam Girdwood, Microchip Linux Driver Support, Philipp Zabel,
	Pedro Tsai, David S . Miller, Heiner Kallweit

On 6/22/20 6:51 AM, Mark Brown wrote:
> On Mon, Jun 22, 2020 at 03:39:40PM +0200, Andrew Lunn wrote:
> 
>> The PHY subsystem cannot be the first to run into this problem, that
>> you need a device structure to make use of the regulator API, but you
>> need the regulator API to probe the device. How do other subsystems
>> work around this?
> 
> If the bus includes power management for the devices on the bus the
> controller is generally responsible for that rather than the devices,
> the devices access this via facilities provided by the bus if needed.
> If the device is enumerated by firmware prior to being physically
> enumerable then the bus will generally instantiate the device model
> device and then arrange to wait for the physical device to appear and
> get joined up with the device model device, typically in such situations
> the physical device might appear and disappear dynamically at runtime
> based on what the driver is doing anyway.

In premise there is nothing that prevents the MDIO bus from taking care
of the regulators, resets, prior to probing the PHY driver, what is
complicated here is that we do need to issue a read of the actual PHY to
know its 32-bit unique identifier and match it with an appropriate
driver. The way that we have worked around this with if you do not wish
such a hardware access to be made, is to provide an Ethernet PHY node
compatible string that encodes that 32-bit OUI directly. In premise the
same challenges exist with PCI devices/endpoints as well as USB, would
they have reset or regulator typically attached to them.

> 
>> Maybe it is time to add a lower level API to the regulator framework?
> 
> I don't see any need for that here, this is far from the only thing
> that's keyed off a struct device and having the device appear and
> disappear at runtime can make things like runtime PM look really messy
> to userspace.
> 
> We could use a pre-probe stage in the device model for hotpluggable
> buses in embedded contexts where you might need to bring things out of
> reset or power them up before they'll appear on the bus for enumeration
> but buses have mostly handled that at their level.
> 

That sounds like a better solution, are there any subsystems currently
implementing that, or would this be a generic Linux device driver model
addition that needs to be done?
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration
  2020-06-23 19:49       ` [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration Florian Fainelli
@ 2020-06-24  9:43         ` Mark Brown
  2020-06-24 13:48           ` Bartosz Golaszewski
  0 siblings, 1 reply; 18+ messages in thread
From: Mark Brown @ 2020-06-24  9:43 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Andrew Lunn, Alexandre Belloni, devicetree, Vladimir Oltean,
	linux-kernel, Fabien Parent, Iyappan Subramanian, Quan Nguyen,
	Frank Rowand, Bartosz Golaszewski, Russell King,
	Bartosz Golaszewski, Jakub Kicinski, Yisen Zhuang,
	Vivien Didelot, Tom Lendacky, Andrew Perepech,
	Stephane Le Provost, Keyur Chudgar, Jassi Brar, Claudiu Manoil,
	Rob Herring, linux-mediatek, Matthias Brugger, linux-arm-kernel,
	Salil Mehta, netdev, Ilias Apalodimas, Liam Girdwood,
	Microchip Linux Driver Support, Philipp Zabel, Pedro Tsai,
	David S . Miller, Heiner Kallweit


[-- Attachment #1.1: Type: text/plain, Size: 1982 bytes --]

On Tue, Jun 23, 2020 at 12:49:15PM -0700, Florian Fainelli wrote:
> On 6/22/20 6:51 AM, Mark Brown wrote:

> > If the bus includes power management for the devices on the bus the
> > controller is generally responsible for that rather than the devices,
> > the devices access this via facilities provided by the bus if needed.
> > If the device is enumerated by firmware prior to being physically
> > enumerable then the bus will generally instantiate the device model
> > device and then arrange to wait for the physical device to appear and
> > get joined up with the device model device, typically in such situations
> > the physical device might appear and disappear dynamically at runtime
> > based on what the driver is doing anyway.

> In premise there is nothing that prevents the MDIO bus from taking care
> of the regulators, resets, prior to probing the PHY driver, what is
> complicated here is that we do need to issue a read of the actual PHY to
> know its 32-bit unique identifier and match it with an appropriate
> driver. The way that we have worked around this with if you do not wish
> such a hardware access to be made, is to provide an Ethernet PHY node
> compatible string that encodes that 32-bit OUI directly. In premise the
> same challenges exist with PCI devices/endpoints as well as USB, would
> they have reset or regulator typically attached to them.

That all sounds very normal and is covered by both cases I describe?

> > We could use a pre-probe stage in the device model for hotpluggable
> > buses in embedded contexts where you might need to bring things out of
> > reset or power them up before they'll appear on the bus for enumeration
> > but buses have mostly handled that at their level.

> That sounds like a better solution, are there any subsystems currently
> implementing that, or would this be a generic Linux device driver model
> addition that needs to be done?

Like I say I'm suggesting doing something at the device model level.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration
  2020-06-24  9:43         ` Mark Brown
@ 2020-06-24 13:48           ` Bartosz Golaszewski
  2020-06-24 16:06             ` Florian Fainelli
  0 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2020-06-24 13:48 UTC (permalink / raw)
  To: Mark Brown
  Cc: Andrew Lunn, Alexandre Belloni, devicetree, Vladimir Oltean,
	Linux Kernel Mailing List, Fabien Parent, Iyappan Subramanian,
	Quan Nguyen, Frank Rowand, Florian Fainelli, Russell King,
	Bartosz Golaszewski, Jakub Kicinski, Yisen Zhuang,
	Vivien Didelot, Tom Lendacky, Andrew Perepech,
	Stephane Le Provost, Keyur Chudgar, Jassi Brar, Claudiu Manoil,
	Rob Herring, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, Salil Mehta, netdev,
	Ilias Apalodimas, Liam Girdwood, Microchip Linux Driver Support,
	Philipp Zabel, Pedro Tsai, David S . Miller, Heiner Kallweit

śr., 24 cze 2020 o 11:43 Mark Brown <broonie@kernel.org> napisał(a):
>
> On Tue, Jun 23, 2020 at 12:49:15PM -0700, Florian Fainelli wrote:
> > On 6/22/20 6:51 AM, Mark Brown wrote:
>
> > > If the bus includes power management for the devices on the bus the
> > > controller is generally responsible for that rather than the devices,
> > > the devices access this via facilities provided by the bus if needed.
> > > If the device is enumerated by firmware prior to being physically
> > > enumerable then the bus will generally instantiate the device model
> > > device and then arrange to wait for the physical device to appear and
> > > get joined up with the device model device, typically in such situations
> > > the physical device might appear and disappear dynamically at runtime
> > > based on what the driver is doing anyway.
>
> > In premise there is nothing that prevents the MDIO bus from taking care
> > of the regulators, resets, prior to probing the PHY driver, what is
> > complicated here is that we do need to issue a read of the actual PHY to
> > know its 32-bit unique identifier and match it with an appropriate
> > driver. The way that we have worked around this with if you do not wish
> > such a hardware access to be made, is to provide an Ethernet PHY node
> > compatible string that encodes that 32-bit OUI directly. In premise the
> > same challenges exist with PCI devices/endpoints as well as USB, would
> > they have reset or regulator typically attached to them.
>
> That all sounds very normal and is covered by both cases I describe?
>
> > > We could use a pre-probe stage in the device model for hotpluggable
> > > buses in embedded contexts where you might need to bring things out of
> > > reset or power them up before they'll appear on the bus for enumeration
> > > but buses have mostly handled that at their level.
>
> > That sounds like a better solution, are there any subsystems currently
> > implementing that, or would this be a generic Linux device driver model
> > addition that needs to be done?
>
> Like I say I'm suggesting doing something at the device model level.

I didn't expect to open such a can of worms...

This has evolved into several new concepts being proposed vs my
use-case which is relatively simple. The former will probably take
several months of development, reviews and discussions and it will
block supporting the phy supply on pumpkin boards upstream. I would
prefer not to redo what other MAC drivers do (phy-supply property on
the MAC node, controlling it from the MAC driver itself) if we've
already established it's wrong.

Is there any compromise we could reach to add support for a basic,
common use-case of a single regulator supplying a PHY that needs
enabling before reading its ID short-term (just like we currently
support a single reset or reset-gpios property for PHYs) and
introducing a whole new concept to the device model for more advanced
(but currently mostly hypothetical) cases long-term?

Bart

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration
  2020-06-24 13:48           ` Bartosz Golaszewski
@ 2020-06-24 16:06             ` Florian Fainelli
  2020-06-24 16:35               ` Bartosz Golaszewski
  2020-06-24 16:50               ` Russell King - ARM Linux admin
  0 siblings, 2 replies; 18+ messages in thread
From: Florian Fainelli @ 2020-06-24 16:06 UTC (permalink / raw)
  To: Bartosz Golaszewski, Mark Brown
  Cc: Andrew Lunn, Alexandre Belloni, devicetree, Vladimir Oltean,
	Linux Kernel Mailing List, Fabien Parent, Iyappan Subramanian,
	Quan Nguyen, Frank Rowand, Russell King, Bartosz Golaszewski,
	Jakub Kicinski, Yisen Zhuang, Vivien Didelot, Tom Lendacky,
	Andrew Perepech, Stephane Le Provost, Keyur Chudgar, Jassi Brar,
	Claudiu Manoil, Rob Herring, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, Salil Mehta, netdev,
	Ilias Apalodimas, Liam Girdwood, Microchip Linux Driver Support,
	Philipp Zabel, Pedro Tsai, David S . Miller, Heiner Kallweit



On 6/24/2020 6:48 AM, Bartosz Golaszewski wrote:
> śr., 24 cze 2020 o 11:43 Mark Brown <broonie@kernel.org> napisał(a):
>>
>> On Tue, Jun 23, 2020 at 12:49:15PM -0700, Florian Fainelli wrote:
>>> On 6/22/20 6:51 AM, Mark Brown wrote:
>>
>>>> If the bus includes power management for the devices on the bus the
>>>> controller is generally responsible for that rather than the devices,
>>>> the devices access this via facilities provided by the bus if needed.
>>>> If the device is enumerated by firmware prior to being physically
>>>> enumerable then the bus will generally instantiate the device model
>>>> device and then arrange to wait for the physical device to appear and
>>>> get joined up with the device model device, typically in such situations
>>>> the physical device might appear and disappear dynamically at runtime
>>>> based on what the driver is doing anyway.
>>
>>> In premise there is nothing that prevents the MDIO bus from taking care
>>> of the regulators, resets, prior to probing the PHY driver, what is
>>> complicated here is that we do need to issue a read of the actual PHY to
>>> know its 32-bit unique identifier and match it with an appropriate
>>> driver. The way that we have worked around this with if you do not wish
>>> such a hardware access to be made, is to provide an Ethernet PHY node
>>> compatible string that encodes that 32-bit OUI directly. In premise the
>>> same challenges exist with PCI devices/endpoints as well as USB, would
>>> they have reset or regulator typically attached to them.
>>
>> That all sounds very normal and is covered by both cases I describe?
>>
>>>> We could use a pre-probe stage in the device model for hotpluggable
>>>> buses in embedded contexts where you might need to bring things out of
>>>> reset or power them up before they'll appear on the bus for enumeration
>>>> but buses have mostly handled that at their level.
>>
>>> That sounds like a better solution, are there any subsystems currently
>>> implementing that, or would this be a generic Linux device driver model
>>> addition that needs to be done?
>>
>> Like I say I'm suggesting doing something at the device model level.
> 
> I didn't expect to open such a can of worms...
> 
> This has evolved into several new concepts being proposed vs my
> use-case which is relatively simple. The former will probably take
> several months of development, reviews and discussions and it will
> block supporting the phy supply on pumpkin boards upstream. I would
> prefer not to redo what other MAC drivers do (phy-supply property on
> the MAC node, controlling it from the MAC driver itself) if we've
> already established it's wrong.

You are not new to Linux development, so none of this should come as a
surprise to you. Your proposed solution has clearly short comings and is
a hack, especially around the PHY_ID_NONE business to get a phy_device
only then to have the real PHY device ID. You should also now that "I
need it now because my product deliverable depends on it" has never been
received as a valid argument to coerce people into accepting a solution
for which there are at review time known deficiencies to the proposed
approach.

> 
> Is there any compromise we could reach to add support for a basic,
> common use-case of a single regulator supplying a PHY that needs
> enabling before reading its ID short-term (just like we currently
> support a single reset or reset-gpios property for PHYs) and
> introducing a whole new concept to the device model for more advanced
> (but currently mostly hypothetical) cases long-term?

The pre-probe use case is absolutely not hypothetical, and I would need
it for pcie-brcmstb.c at some point which is a PCIe root complex driver
with multiple regulators that need to be turned on *prior* to
enumerating the PCIe bus and creating pci_device instances. It is
literally the same thing as what you are trying to do, just in a
different subsystem, therefore I am happy to test and review your patches.
-- 
Florian

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 05/15] net: phy: reset the PHY even if probe() is not implemented
  2020-06-23 19:14   ` [PATCH 05/15] net: phy: reset the PHY even if probe() is not implemented Florian Fainelli
@ 2020-06-24 16:22     ` Bartosz Golaszewski
  0 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2020-06-24 16:22 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Andrew Lunn, Alexandre Belloni, devicetree, Vladimir Oltean,
	Linux Kernel Mailing List, Fabien Parent, Iyappan Subramanian,
	Quan Nguyen, Frank Rowand, Russell King, Bartosz Golaszewski,
	Jakub Kicinski, Yisen Zhuang, Vivien Didelot, Tom Lendacky,
	Andrew Perepech, Stephane Le Provost, Keyur Chudgar, Jassi Brar,
	Claudiu Manoil, Rob Herring, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, Salil Mehta, netdev,
	Ilias Apalodimas, Liam Girdwood, Microchip Linux Driver Support,
	Mark Brown, Philipp Zabel, Pedro Tsai, David S . Miller,
	Heiner Kallweit

wt., 23 cze 2020 o 21:14 Florian Fainelli <f.fainelli@gmail.com> napisał(a):
>
> On 6/22/20 2:37 AM, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Currently we only call phy_device_reset() if the PHY driver implements
> > the probe() callback. This is not mandatory and many drivers (e.g.
> > realtek) don't need probe() for most devices but still can have reset
> > GPIOs defined. There's no reason to depend on the presence of probe()
> > here so pull the reset code out of the if clause.
> >
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> OK, but now let's imagine that a PHY device has two or more reset lines,
> one of them is going to be managed by the core PHY library and the rest
> is going to be under the responsibility of the PHY driver, that does not
> sound intuitive or convenient at all. This is a hypothetical case, but
> it could conceivable happen, so how about adding a flag to the driver
> that says "let me manage it a all"?

This sounds good as a new feature idea but doesn't seem to be related
to what this patch is trying to do. The only thing it does is improve
the current behavior. I'll note your point for the future work on the
pre-probe stage.

Bartosz

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration
  2020-06-24 16:06             ` Florian Fainelli
@ 2020-06-24 16:35               ` Bartosz Golaszewski
  2020-06-24 16:50               ` Russell King - ARM Linux admin
  1 sibling, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2020-06-24 16:35 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Andrew Lunn, Alexandre Belloni, devicetree, Vladimir Oltean,
	Linux Kernel Mailing List, Fabien Parent, Iyappan Subramanian,
	Quan Nguyen, Frank Rowand, Russell King, Bartosz Golaszewski,
	Jakub Kicinski, Vivien Didelot, Tom Lendacky, Andrew Perepech,
	Stephane Le Provost, Keyur Chudgar, Jassi Brar, Claudiu Manoil,
	Rob Herring, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, netdev, Ilias Apalodimas,
	Liam Girdwood, Microchip Linux Driver Support, Mark Brown,
	Philipp Zabel, Pedro Tsai, David S . Miller, Heiner Kallweit

On Wed, Jun 24, 2020 at 6:06 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
>

[snip!]

> >
> > This has evolved into several new concepts being proposed vs my
> > use-case which is relatively simple. The former will probably take
> > several months of development, reviews and discussions and it will
> > block supporting the phy supply on pumpkin boards upstream. I would
> > prefer not to redo what other MAC drivers do (phy-supply property on
> > the MAC node, controlling it from the MAC driver itself) if we've
> > already established it's wrong.
>
> You are not new to Linux development, so none of this should come as a
> surprise to you. Your proposed solution has clearly short comings and is
> a hack, especially around the PHY_ID_NONE business to get a phy_device
> only then to have the real PHY device ID. You should also now that "I
> need it now because my product deliverable depends on it" has never been
> received as a valid argument to coerce people into accepting a solution
> for which there are at review time known deficiencies to the proposed
> approach.
>

Don't get me wrong, I understand that full well. On the other hand a
couple years ago I put a significant amount of work into the concept
of early platform device drivers for linux clocksource, clock and
interrupt drivers. Every reviewer had his own preferred approach and
after something like three completely different submissions and
several conversations at conferences I simply gave up due to all the
bikeshedding. It just wasn't moving forward and frankly: I expect any
changes to the core driver model to follow a similar path of most
resistance.

I will give it a shot but at some point getting the job done is better
than not getting it done just because the solution isn't perfect. IMO
this approach is still slightly more correct than controlling the
PHY's supply from the MAC driver.

Bartosz

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration
  2020-06-24 16:06             ` Florian Fainelli
  2020-06-24 16:35               ` Bartosz Golaszewski
@ 2020-06-24 16:50               ` Russell King - ARM Linux admin
  2020-06-24 18:59                 ` Robin Murphy
  1 sibling, 1 reply; 18+ messages in thread
From: Russell King - ARM Linux admin @ 2020-06-24 16:50 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Andrew Lunn, Alexandre Belloni, devicetree, Vladimir Oltean,
	Linux Kernel Mailing List, Fabien Parent, Iyappan Subramanian,
	Quan Nguyen, Frank Rowand, Bartosz Golaszewski,
	Bartosz Golaszewski, Jakub Kicinski, Yisen Zhuang,
	Vivien Didelot, Tom Lendacky, Andrew Perepech,
	Stephane Le Provost, Keyur Chudgar, Jassi Brar, Claudiu Manoil,
	Rob Herring, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, Salil Mehta, netdev,
	Ilias Apalodimas, Liam Girdwood, Microchip Linux Driver Support,
	Mark Brown, Philipp Zabel, Pedro Tsai, David S . Miller,
	Heiner Kallweit

On Wed, Jun 24, 2020 at 09:06:28AM -0700, Florian Fainelli wrote:
> On 6/24/2020 6:48 AM, Bartosz Golaszewski wrote:
> > I didn't expect to open such a can of worms...
> > 
> > This has evolved into several new concepts being proposed vs my
> > use-case which is relatively simple. The former will probably take
> > several months of development, reviews and discussions and it will
> > block supporting the phy supply on pumpkin boards upstream. I would
> > prefer not to redo what other MAC drivers do (phy-supply property on
> > the MAC node, controlling it from the MAC driver itself) if we've
> > already established it's wrong.
> 
> You are not new to Linux development, so none of this should come as a
> surprise to you. Your proposed solution has clearly short comings and is
> a hack, especially around the PHY_ID_NONE business to get a phy_device
> only then to have the real PHY device ID. You should also now that "I
> need it now because my product deliverable depends on it" has never been
> received as a valid argument to coerce people into accepting a solution
> for which there are at review time known deficiencies to the proposed
> approach.

It /is/ a generic issue.  The same problem exists for AMBA Primecell
devices, and that code has an internal deferred device list that it
manages.  See drivers/amba/bus.c, amba_deferred_retry_func(),
amba_device_try_add(), and amba_device_add().

As we see more devices gain this property, it needs to be addressed
in a generic way, rather than coming up with multiple bus specific
implementations.

Maybe struct bus_type needs a method to do the preparation to add
a device (such as reading IDs etc), which is called by device_add().
If that method returns -EPROBE_DEFER, the device gets added to a
deferred list, which gets retried when drivers are successfully
probed.  Possible maybe?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 14/15] net: phy: add PHY regulator support
  2020-06-23 16:27             ` [PATCH 14/15] net: phy: add PHY regulator support Bartosz Golaszewski
@ 2020-06-24 16:57               ` Russell King - ARM Linux admin
  2020-06-24 18:12                 ` Russell King - ARM Linux admin
  0 siblings, 1 reply; 18+ messages in thread
From: Russell King - ARM Linux admin @ 2020-06-24 16:57 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andrew Lunn, Alexandre Belloni, Tom Lendacky, Vladimir Oltean,
	Liam Girdwood, Fabien Parent, Iyappan Subramanian, Quan Nguyen,
	Frank Rowand, Florian Fainelli, Bartosz Golaszewski,
	Jakub Kicinski, Vivien Didelot, devicetree, Philipp Zabel,
	Stephane Le Provost, Keyur Chudgar, Jassi Brar, Claudiu Manoil,
	Mark Brown, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, netdev, Ilias Apalodimas,
	Linux Kernel Mailing List, Rob Herring, Andrew Perepech,
	Pedro Tsai, David S . Miller, Heiner Kallweit

On Tue, Jun 23, 2020 at 06:27:06PM +0200, Bartosz Golaszewski wrote:
> wt., 23 cze 2020 o 11:56 Russell King - ARM Linux admin
> <linux@armlinux.org.uk> napisał(a):
> >
> > On Tue, Jun 23, 2020 at 11:46:15AM +0200, Bartosz Golaszewski wrote:
> > > wt., 23 cze 2020 o 11:43 Russell King - ARM Linux admin
> > > <linux@armlinux.org.uk> napisał(a):
> > > >
> > > > On Tue, Jun 23, 2020 at 11:41:11AM +0200, Bartosz Golaszewski wrote:
> > > > > pon., 22 cze 2020 o 15:29 Russell King - ARM Linux admin
> > > > > <linux@armlinux.org.uk> napisał(a):
> > > > > >
> > > > >
> > > > > [snip!]
> > > > >
> > > > > >
> > > > > > This is likely to cause issues for some PHY drivers.  Note that we have
> > > > > > some PHY drivers which register a temperature sensor in the probe
> > > > > > function, which means they can be accessed independently of the lifetime
> > > > > > of the PHY bound to the network driver (which may only be while the
> > > > > > network device is "up".)  We certainly do not want hwmon failing just
> > > > > > because the network device is down.
> > > > > >
> > > > > > That's kind of worked around for the reset stuff, because there are two
> > > > > > layers to that: the mdio device layer reset support which knows nothing
> > > > > > of the PHY binding state to the network driver, and the phylib reset
> > > > > > support, but it is not nice.
> > > > > >
> > > > >
> > > > > Regulators are reference counted so if the hwmon driver enables it
> > > > > using mdio_device_power_on() it will stay on even after the PHY driver
> > > > > calls phy_device_power_off(), right? Am I missing something?
> > > >
> > > > If that is true, you will need to audit the PHY drivers to add that.
> > > >
> > >
> > > This change doesn't have any effect on devices which don't have a
> > > regulator assigned in DT though. The one I'm adding in the last patch
> > > is the first to use this.
> >
> > It's quality of implementation.
> >
> > Should we wait for someone else to make use of the new regulator
> > support that has been added with a PHY that uses hwmon, and they
> > don't realise that it breaks hwmon on it, and several kernel versions
> > go by without it being noticed.  It will only be a noticable issue
> > when the associated network device is down, and that network device
> > driver detaches from the PHY, so _is_ likely not to be noticed.
> >
> > Or should we do a small amount of work now to properly implement
> > regulator support, which includes a trivial grep for "hwmon" amongst
> > the PHY drivers, and add the necessary call to avoid the regulator
> > being shut off.
> >
> 
> I'm not sure what the correct approach is here. Provide some helper
> that, when called, would increase the regulator's reference count even
> more to keep it enabled from the moment hwmon is registered to when
> the driver is detached?

I think a PHY driver needs the utility to control this.  We need to be
careful here with naming, because phylib is not the only code in the
kernel that uses the phy_ prefix.

If we had runtime PM support for PHYs, with regulator support hooked
into runtime PM, then we already have standard interfaces that drivers
can use to control whether the device gets powered down.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 14/15] net: phy: add PHY regulator support
  2020-06-24 16:57               ` Russell King - ARM Linux admin
@ 2020-06-24 18:12                 ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 18+ messages in thread
From: Russell King - ARM Linux admin @ 2020-06-24 18:12 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andrew Lunn, Alexandre Belloni, devicetree, Vladimir Oltean,
	Linux Kernel Mailing List, Fabien Parent, Iyappan Subramanian,
	Quan Nguyen, Frank Rowand, Florian Fainelli, Bartosz Golaszewski,
	Jakub Kicinski, Vivien Didelot, Tom Lendacky, Andrew Perepech,
	Stephane Le Provost, Keyur Chudgar, Jassi Brar, Claudiu Manoil,
	Mark Brown, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, netdev, Ilias Apalodimas,
	Liam Girdwood, Rob Herring, Philipp Zabel, Pedro Tsai,
	David S . Miller, Heiner Kallweit

On Wed, Jun 24, 2020 at 05:57:19PM +0100, Russell King - ARM Linux admin wrote:
> On Tue, Jun 23, 2020 at 06:27:06PM +0200, Bartosz Golaszewski wrote:
> > wt., 23 cze 2020 o 11:56 Russell King - ARM Linux admin
> > <linux@armlinux.org.uk> napisał(a):
> > >
> > > On Tue, Jun 23, 2020 at 11:46:15AM +0200, Bartosz Golaszewski wrote:
> > > > wt., 23 cze 2020 o 11:43 Russell King - ARM Linux admin
> > > > <linux@armlinux.org.uk> napisał(a):
> > > > >
> > > > > On Tue, Jun 23, 2020 at 11:41:11AM +0200, Bartosz Golaszewski wrote:
> > > > > > pon., 22 cze 2020 o 15:29 Russell King - ARM Linux admin
> > > > > > <linux@armlinux.org.uk> napisał(a):
> > > > > > >
> > > > > >
> > > > > > [snip!]
> > > > > >
> > > > > > >
> > > > > > > This is likely to cause issues for some PHY drivers.  Note that we have
> > > > > > > some PHY drivers which register a temperature sensor in the probe
> > > > > > > function, which means they can be accessed independently of the lifetime
> > > > > > > of the PHY bound to the network driver (which may only be while the
> > > > > > > network device is "up".)  We certainly do not want hwmon failing just
> > > > > > > because the network device is down.
> > > > > > >
> > > > > > > That's kind of worked around for the reset stuff, because there are two
> > > > > > > layers to that: the mdio device layer reset support which knows nothing
> > > > > > > of the PHY binding state to the network driver, and the phylib reset
> > > > > > > support, but it is not nice.
> > > > > > >
> > > > > >
> > > > > > Regulators are reference counted so if the hwmon driver enables it
> > > > > > using mdio_device_power_on() it will stay on even after the PHY driver
> > > > > > calls phy_device_power_off(), right? Am I missing something?
> > > > >
> > > > > If that is true, you will need to audit the PHY drivers to add that.
> > > > >
> > > >
> > > > This change doesn't have any effect on devices which don't have a
> > > > regulator assigned in DT though. The one I'm adding in the last patch
> > > > is the first to use this.
> > >
> > > It's quality of implementation.
> > >
> > > Should we wait for someone else to make use of the new regulator
> > > support that has been added with a PHY that uses hwmon, and they
> > > don't realise that it breaks hwmon on it, and several kernel versions
> > > go by without it being noticed.  It will only be a noticable issue
> > > when the associated network device is down, and that network device
> > > driver detaches from the PHY, so _is_ likely not to be noticed.
> > >
> > > Or should we do a small amount of work now to properly implement
> > > regulator support, which includes a trivial grep for "hwmon" amongst
> > > the PHY drivers, and add the necessary call to avoid the regulator
> > > being shut off.
> > >
> > 
> > I'm not sure what the correct approach is here. Provide some helper
> > that, when called, would increase the regulator's reference count even
> > more to keep it enabled from the moment hwmon is registered to when
> > the driver is detached?
> 
> I think a PHY driver needs the utility to control this.  We need to be
> careful here with naming, because phylib is not the only code in the
> kernel that uses the phy_ prefix.
> 
> If we had runtime PM support for PHYs, with regulator support hooked
> into runtime PM, then we already have standard interfaces that drivers
> can use to control whether the device gets powered down.

Other ideas:

- using genpd outside of the SoC to provide power domain management.
  This is already hooked into runtime PM, but would need their
  agreement, a genpd provider written, and runtime PM added to phylib.

- if we're going for some core driver model approach, then the driver
  model only knows when devices are bound and unbound to their driver,
  it knows nothing of phylib's attach/detach from the network
  interface.  If we want to shut off power when a PHY is not attached,
  we would likely need some kind of interface to do that.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration
  2020-06-24 16:50               ` Russell King - ARM Linux admin
@ 2020-06-24 18:59                 ` Robin Murphy
  0 siblings, 0 replies; 18+ messages in thread
From: Robin Murphy @ 2020-06-24 18:59 UTC (permalink / raw)
  To: Russell King - ARM Linux admin, Florian Fainelli
  Cc: Andrew Lunn, Alexandre Belloni, Tom Lendacky, Vladimir Oltean,
	Liam Girdwood, Fabien Parent, Iyappan Subramanian, Quan Nguyen,
	Frank Rowand, Bartosz Golaszewski, Bartosz Golaszewski,
	Jakub Kicinski, Yisen Zhuang, Vivien Didelot, devicetree,
	Philipp Zabel, Stephane Le Provost, Keyur Chudgar, Jassi Brar,
	Claudiu Manoil, Rob Herring, moderated list:ARM/Mediatek SoC...,
	Matthias Brugger, Linux ARM, Salil Mehta, netdev,
	Ilias Apalodimas, Linux Kernel Mailing List,
	Microchip Linux Driver Support, Mark Brown, Andrew Perepech,
	Pedro Tsai, David S . Miller, Heiner Kallweit

On 2020-06-24 17:50, Russell King - ARM Linux admin wrote:
> On Wed, Jun 24, 2020 at 09:06:28AM -0700, Florian Fainelli wrote:
>> On 6/24/2020 6:48 AM, Bartosz Golaszewski wrote:
>>> I didn't expect to open such a can of worms...
>>>
>>> This has evolved into several new concepts being proposed vs my
>>> use-case which is relatively simple. The former will probably take
>>> several months of development, reviews and discussions and it will
>>> block supporting the phy supply on pumpkin boards upstream. I would
>>> prefer not to redo what other MAC drivers do (phy-supply property on
>>> the MAC node, controlling it from the MAC driver itself) if we've
>>> already established it's wrong.
>>
>> You are not new to Linux development, so none of this should come as a
>> surprise to you. Your proposed solution has clearly short comings and is
>> a hack, especially around the PHY_ID_NONE business to get a phy_device
>> only then to have the real PHY device ID. You should also now that "I
>> need it now because my product deliverable depends on it" has never been
>> received as a valid argument to coerce people into accepting a solution
>> for which there are at review time known deficiencies to the proposed
>> approach.
> 
> It /is/ a generic issue.  The same problem exists for AMBA Primecell
> devices, and that code has an internal deferred device list that it
> manages.  See drivers/amba/bus.c, amba_deferred_retry_func(),
> amba_device_try_add(), and amba_device_add().
> 
> As we see more devices gain this property, it needs to be addressed
> in a generic way, rather than coming up with multiple bus specific
> implementations.
> 
> Maybe struct bus_type needs a method to do the preparation to add
> a device (such as reading IDs etc), which is called by device_add().
> If that method returns -EPROBE_DEFER, the device gets added to a
> deferred list, which gets retried when drivers are successfully
> probed.  Possible maybe?

FWIW that would be ideal for solving an ordering a problem we have in 
the IOMMU subsystem too (which we currently sort-of-handle by deferring 
driver probe from dma_configure(), but it really needs to be done 
earlier and not depend on drivers being present at all).

Robin.

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-06-24 19:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200622093744.13685-1-brgl@bgdev.pl>
     [not found] ` <20200622093744.13685-15-brgl@bgdev.pl>
     [not found]   ` <20200622132921.GI1551@shell.armlinux.org.uk>
     [not found]     ` <CAMRc=Me1r3Mzfg3-gTsGk4rEtvB=P9ESkn9q=c7z0Q=YQDsw2A@mail.gmail.com>
     [not found]       ` <20200623094252.GS1551@shell.armlinux.org.uk>
     [not found]         ` <CAMpxmJVP9db-4-AA4e1JkEfrajvJ4s0T6zo5+oFzpJHRBcuSsg@mail.gmail.com>
     [not found]           ` <20200623095646.GT1551@shell.armlinux.org.uk>
2020-06-23 16:27             ` [PATCH 14/15] net: phy: add PHY regulator support Bartosz Golaszewski
2020-06-24 16:57               ` Russell King - ARM Linux admin
2020-06-24 18:12                 ` Russell King - ARM Linux admin
     [not found] ` <20200622093744.13685-2-brgl@bgdev.pl>
2020-06-23 18:54   ` [PATCH 01/15] net: phy: arrange headers in mdio_bus.c alphabetically Florian Fainelli
     [not found] ` <20200622093744.13685-3-brgl@bgdev.pl>
2020-06-23 18:56   ` [PATCH 02/15] net: phy: arrange headers in mdio_device.c alphabetically Florian Fainelli
     [not found] ` <20200622093744.13685-4-brgl@bgdev.pl>
2020-06-23 18:57   ` [PATCH 03/15] net: phy: arrange headers in phy_device.c alphabetically Florian Fainelli
     [not found] ` <20200622093744.13685-5-brgl@bgdev.pl>
2020-06-23 18:59   ` [PATCH 04/15] net: mdio: add a forward declaration for reset_control to mdio.h Florian Fainelli
     [not found] ` <20200622093744.13685-6-brgl@bgdev.pl>
2020-06-23 19:14   ` [PATCH 05/15] net: phy: reset the PHY even if probe() is not implemented Florian Fainelli
2020-06-24 16:22     ` Bartosz Golaszewski
     [not found] ` <20200622093744.13685-7-brgl@bgdev.pl>
2020-06-23 19:16   ` [PATCH 06/15] net: phy: mdio: reset MDIO devices " Florian Fainelli
     [not found] ` <20200622093744.13685-13-brgl@bgdev.pl>
2020-06-23 19:39   ` [PATCH 12/15] dt-bindings: mdio: add phy-supply property to ethernet phy node Florian Fainelli
     [not found] ` <20200622093744.13685-10-brgl@bgdev.pl>
     [not found]   ` <20200622133940.GL338481@lunn.ch>
     [not found]     ` <20200622135106.GK4560@sirena.org.uk>
2020-06-23 19:49       ` [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration Florian Fainelli
2020-06-24  9:43         ` Mark Brown
2020-06-24 13:48           ` Bartosz Golaszewski
2020-06-24 16:06             ` Florian Fainelli
2020-06-24 16:35               ` Bartosz Golaszewski
2020-06-24 16:50               ` Russell King - ARM Linux admin
2020-06-24 18:59                 ` Robin Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).