diff mbox series

[net-next,v7,04/16] of: mdio: Refactor of_phy_find_device()

Message ID 20210311062011.8054-5-calvin.johnson@oss.nxp.com
State Accepted
Commit 2d7b8bf1fa7afab77f106b67ec6e3d524e3745ca
Headers show
Series ACPI support for dpaa2 driver | expand

Commit Message

Calvin Johnson March 11, 2021, 6:19 a.m. UTC
Refactor of_phy_find_device() to use fwnode_phy_find_device().

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/mdio/of_mdio.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

Daniel Thompson March 16, 2021, 7:17 p.m. UTC | #1
On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:
> Refactor of_phy_find_device() to use fwnode_phy_find_device().
> 
> Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>

This patch series is provoking depmod dependency cycles for me and
it bisected down to this patch (although I think later patches in
the series add further cycles).

The problems emerge when running modules_install either directly or
indirectly via packaging rules such as bindeb-pkg.

~~~
make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install
...
  INSTALL sound/usb/misc/snd-ua101.ko
  INSTALL sound/usb/snd-usb-audio.ko
  INSTALL sound/usb/snd-usbmidi-lib.ko
  INSTALL sound/xen/snd_xen_front.ko
  DEPMOD  5.12.0-rc3-00009-g1fda33bf463d
depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio
depmod: ERROR: Found 2 modules in dependency cycles!
~~~

Kconfig can be found here:
https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474

This Kconfig file is for a highly modular kernel derived from the Debian
5.10 arm64 kernel config. I was not able to reproduce using the defconfig
kernel for arm64.


Daniel.


> ---
> 
> Changes in v7: None
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  drivers/net/mdio/of_mdio.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
> index d5e0970b2561..b5e0b5b22f1a 100644
> --- a/drivers/net/mdio/of_mdio.c
> +++ b/drivers/net/mdio/of_mdio.c
> @@ -360,18 +360,7 @@ EXPORT_SYMBOL(of_mdio_find_device);
>   */
>  struct phy_device *of_phy_find_device(struct device_node *phy_np)
>  {
> -	struct mdio_device *mdiodev;
> -
> -	mdiodev = of_mdio_find_device(phy_np);
> -	if (!mdiodev)
> -		return NULL;
> -
> -	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
> -		return to_phy_device(&mdiodev->dev);
> -
> -	put_device(&mdiodev->dev);
> -
> -	return NULL;
> +	return fwnode_phy_find_device(of_fwnode_handle(phy_np));
>  }
>  EXPORT_SYMBOL(of_phy_find_device);
>
Daniel Thompson March 19, 2021, 11:21 a.m. UTC | #2
On Wed, Mar 17, 2021 at 02:15:20PM +0530, Calvin Johnson wrote:
> Hi Daniel,

> 

> On Tue, Mar 16, 2021 at 07:17:19PM +0000, Daniel Thompson wrote:

> > On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:

> > > Refactor of_phy_find_device() to use fwnode_phy_find_device().

> > > 

> > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>

> > 

> > This patch series is provoking depmod dependency cycles for me and

> > it bisected down to this patch (although I think later patches in

> > the series add further cycles).

> > 

> > The problems emerge when running modules_install either directly or

> > indirectly via packaging rules such as bindeb-pkg.

> > 

> > ~~~

> > make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install

> > ...

> >   INSTALL sound/usb/misc/snd-ua101.ko

> >   INSTALL sound/usb/snd-usb-audio.ko

> >   INSTALL sound/usb/snd-usbmidi-lib.ko

> >   INSTALL sound/xen/snd_xen_front.ko

> >   DEPMOD  5.12.0-rc3-00009-g1fda33bf463d

> > depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio

> > depmod: ERROR: Found 2 modules in dependency cycles!

> > ~~~

> > 

> > Kconfig can be found here:

> > https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474

> > 

> > This Kconfig file is for a highly modular kernel derived from the Debian

> > 5.10 arm64 kernel config. I was not able to reproduce using the defconfig

> > kernel for arm64.

> > 

> Thanks for catching this. I'm able to reproduce the issue and will fix it.

> 

> By the way, is there any integration tool/mechanism out there to which I can

> submit the patch series and build for various possible configs like these?


Not sure which autotester would be most likely to pick this up.

This issue is slightly unusual because it broke the install rather then
the build... and lots of people (including me) primarily run build
tests ;-) .

Anyhow, I guess the best way to pick up module problems like this is
going to be an `allmodconfig` build followed up with `rm -rf modtest;
make modules_install INSTALL_MOD_PATH=$PWD/modtest`.


Daniel.
Calvin Johnson March 23, 2021, 5:27 a.m. UTC | #3
On Fri, Mar 19, 2021 at 11:21:15AM +0000, Daniel Thompson wrote:
> On Wed, Mar 17, 2021 at 02:15:20PM +0530, Calvin Johnson wrote:

> > Hi Daniel,

> > 

> > On Tue, Mar 16, 2021 at 07:17:19PM +0000, Daniel Thompson wrote:

> > > On Thu, Mar 11, 2021 at 11:49:59AM +0530, Calvin Johnson wrote:

> > > > Refactor of_phy_find_device() to use fwnode_phy_find_device().

> > > > 

> > > > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>

> > > 

> > > This patch series is provoking depmod dependency cycles for me and

> > > it bisected down to this patch (although I think later patches in

> > > the series add further cycles).

> > > 

> > > The problems emerge when running modules_install either directly or

> > > indirectly via packaging rules such as bindeb-pkg.

> > > 

> > > ~~~

> > > make -j16 INSTALL_MOD_PATH=$PWD/modules modules_install

> > > ...

> > >   INSTALL sound/usb/misc/snd-ua101.ko

> > >   INSTALL sound/usb/snd-usb-audio.ko

> > >   INSTALL sound/usb/snd-usbmidi-lib.ko

> > >   INSTALL sound/xen/snd_xen_front.ko

> > >   DEPMOD  5.12.0-rc3-00009-g1fda33bf463d

> > > depmod: ERROR: Cycle detected: fwnode_mdio -> of_mdio -> fwnode_mdio

> > > depmod: ERROR: Found 2 modules in dependency cycles!

> > > ~~~

> > > 

> > > Kconfig can be found here:

> > > https://gist.github.com/daniel-thompson/6a7d224f3d3950ffa3f63f979b636474

> > > 

> > > This Kconfig file is for a highly modular kernel derived from the Debian

> > > 5.10 arm64 kernel config. I was not able to reproduce using the defconfig

> > > kernel for arm64.

> > > 

> > Thanks for catching this. I'm able to reproduce the issue and will fix it.

> > 

> > By the way, is there any integration tool/mechanism out there to which I can

> > submit the patch series and build for various possible configs like these?

> 

> Not sure which autotester would be most likely to pick this up.

> 

> This issue is slightly unusual because it broke the install rather then

> the build... and lots of people (including me) primarily run build

> tests ;-) .

> 

> Anyhow, I guess the best way to pick up module problems like this is

> going to be an `allmodconfig` build followed up with `rm -rf modtest;

> make modules_install INSTALL_MOD_PATH=$PWD/modtest`.


Thanks Daniel for the info.

To resolve this issue, I need to add more fwnode MDIO functions.
I'm working on these. Meanwhile, will separately send out two patches
that got Reviewed-by tag.

Regards
Calvin
diff mbox series

Patch

diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index d5e0970b2561..b5e0b5b22f1a 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -360,18 +360,7 @@  EXPORT_SYMBOL(of_mdio_find_device);
  */
 struct phy_device *of_phy_find_device(struct device_node *phy_np)
 {
-	struct mdio_device *mdiodev;
-
-	mdiodev = of_mdio_find_device(phy_np);
-	if (!mdiodev)
-		return NULL;
-
-	if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
-		return to_phy_device(&mdiodev->dev);
-
-	put_device(&mdiodev->dev);
-
-	return NULL;
+	return fwnode_phy_find_device(of_fwnode_handle(phy_np));
 }
 EXPORT_SYMBOL(of_phy_find_device);