All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
@ 2021-06-21 10:33 Jian-Hong Pan
  2021-06-21 13:09 ` Andrew Lunn
  0 siblings, 1 reply; 19+ messages in thread
From: Jian-Hong Pan @ 2021-06-21 10:33 UTC (permalink / raw)
  To: Doug Berger, Florian Fainelli, Stefan Wahren
  Cc: bcm-kernel-feedback-list, netdev, linux-kernel, linux,
	linux-rpi-kernel, Jian-Hong Pan

The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
PHY.

bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
...
could not attach to PHY
bcmgenet fd580000.ethernet eth0: failed to connect to PHY
uart-pl011 fe201000.serial: no DMA platform data
libphy: bcmgenet MII bus: probed
...
unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus

This patch makes GENET try to connect the PHY up to 3 times. Also, waits
a while between each time for mdio-bcm-unimac module's loading and
probing.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=213485
Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
---
 drivers/net/ethernet/broadcom/genet/bcmmii.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 5335244e4577..64f244471fd3 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -289,6 +289,7 @@ int bcmgenet_mii_probe(struct net_device *dev)
 	struct phy_device *phydev;
 	u32 phy_flags = 0;
 	int ret;
+	int i;
 
 	/* Communicate the integrated PHY revision */
 	if (priv->internal_phy)
@@ -301,8 +302,22 @@ int bcmgenet_mii_probe(struct net_device *dev)
 	priv->old_pause = -1;
 
 	if (dn) {
-		phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup,
-					phy_flags, priv->phy_interface);
+		/* Try to connect the PHY on UniMAC DMIO bus up to 3 times.
+		 * Wait a while between each time for mdio-bcm-unimac module's
+		 * loading and probing.
+		 */
+		phydev = NULL;
+		for (i = 1; i < 4 && !phydev; i++) {
+			netdev_info(dev,
+				    "connect %s on UniMAC MDIO bus %d time",
+				    priv->phy_dn->full_name, i);
+			phydev = of_phy_connect(dev, priv->phy_dn,
+						bcmgenet_mii_setup,
+						phy_flags, priv->phy_interface);
+			if (!phydev && i < 3)
+				msleep(500);
+		}
+
 		if (!phydev) {
 			pr_err("could not attach to PHY\n");
 			return -ENODEV;
-- 
2.32.0


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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-21 10:33 [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B Jian-Hong Pan
@ 2021-06-21 13:09 ` Andrew Lunn
  2021-06-21 16:37   ` Florian Fainelli
  0 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2021-06-21 13:09 UTC (permalink / raw)
  To: Jian-Hong Pan
  Cc: Doug Berger, Florian Fainelli, Stefan Wahren,
	bcm-kernel-feedback-list, netdev, linux-kernel, linux,
	linux-rpi-kernel

On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
> PHY.
> 
> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> ...
> could not attach to PHY
> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> uart-pl011 fe201000.serial: no DMA platform data
> libphy: bcmgenet MII bus: probed
> ...
> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> 
> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
> a while between each time for mdio-bcm-unimac module's loading and
> probing.

Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
driver again later, by which time, the MDIO bus driver should of
probed.

	Andrew

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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-21 13:09 ` Andrew Lunn
@ 2021-06-21 16:37   ` Florian Fainelli
  2021-06-21 16:47     ` Florian Fainelli
  2021-06-21 16:56     ` Peter Robinson
  0 siblings, 2 replies; 19+ messages in thread
From: Florian Fainelli @ 2021-06-21 16:37 UTC (permalink / raw)
  To: Andrew Lunn, Jian-Hong Pan
  Cc: Doug Berger, Stefan Wahren, bcm-kernel-feedback-list, netdev,
	linux-kernel, linux, linux-rpi-kernel

On 6/21/21 6:09 AM, Andrew Lunn wrote:
> On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
>> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
>> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
>> PHY.
>>
>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
>> ...
>> could not attach to PHY
>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
>> uart-pl011 fe201000.serial: no DMA platform data
>> libphy: bcmgenet MII bus: probed
>> ...
>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
>>
>> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
>> a while between each time for mdio-bcm-unimac module's loading and
>> probing.
> 
> Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
> driver again later, by which time, the MDIO bus driver should of
> probed.

This is unlikely to work because GENET register the mdio-bcm-unimac
platform device so we will likely run into a chicken and egg problem,
though surprisingly I have not seen this on STB platforms where GENET is
used, I will try building everything as a module like you do. Can you
see if the following helps:

diff --git a/drivers/net/mdio/mdio-bcm-unimac.c
b/drivers/net/mdio/mdio-bcm-unimac.c
index bfc9be23c973..d1844ef3724a 100644
--- a/drivers/net/mdio/mdio-bcm-unimac.c
+++ b/drivers/net/mdio/mdio-bcm-unimac.c
@@ -351,6 +351,7 @@ static struct platform_driver unimac_mdio_driver = {
                .pm = &unimac_mdio_pm_ops,
        },
        .probe  = unimac_mdio_probe,
+       .probe_type = PROBE_FORCE_SYNCHRONOUS,
        .remove = unimac_mdio_remove,
 };
 module_platform_driver(unimac_mdio_driver);
-- 
Florian

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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-21 16:37   ` Florian Fainelli
@ 2021-06-21 16:47     ` Florian Fainelli
  2021-06-21 16:56     ` Peter Robinson
  1 sibling, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2021-06-21 16:47 UTC (permalink / raw)
  To: Andrew Lunn, Jian-Hong Pan
  Cc: Doug Berger, Stefan Wahren, bcm-kernel-feedback-list, netdev,
	linux-kernel, linux, linux-rpi-kernel

On 6/21/21 9:37 AM, Florian Fainelli wrote:
> On 6/21/21 6:09 AM, Andrew Lunn wrote:
>> On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
>>> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
>>> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
>>> PHY.
>>>
>>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
>>> ...
>>> could not attach to PHY
>>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
>>> uart-pl011 fe201000.serial: no DMA platform data
>>> libphy: bcmgenet MII bus: probed
>>> ...
>>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
>>>
>>> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
>>> a while between each time for mdio-bcm-unimac module's loading and
>>> probing.
>>
>> Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
>> driver again later, by which time, the MDIO bus driver should of
>> probed.
> 
> This is unlikely to work because GENET register the mdio-bcm-unimac
> platform device so we will likely run into a chicken and egg problem,
> though surprisingly I have not seen this on STB platforms where GENET is
> used, I will try building everything as a module like you do. Can you
> see if the following helps:
> 
> diff --git a/drivers/net/mdio/mdio-bcm-unimac.c
> b/drivers/net/mdio/mdio-bcm-unimac.c
> index bfc9be23c973..d1844ef3724a 100644
> --- a/drivers/net/mdio/mdio-bcm-unimac.c
> +++ b/drivers/net/mdio/mdio-bcm-unimac.c
> @@ -351,6 +351,7 @@ static struct platform_driver unimac_mdio_driver = {
>                 .pm = &unimac_mdio_pm_ops,
>         },
>         .probe  = unimac_mdio_probe,
> +       .probe_type = PROBE_FORCE_SYNCHRONOUS,
>         .remove = unimac_mdio_remove,
>  };
>  module_platform_driver(unimac_mdio_driver);

This won't build try this instead:

diff --git a/drivers/net/mdio/mdio-bcm-unimac.c
b/drivers/net/mdio/mdio-bcm-unimac.c
index bfc9be23c973..53fecb53cd65 100644
--- a/drivers/net/mdio/mdio-bcm-unimac.c
+++ b/drivers/net/mdio/mdio-bcm-unimac.c
@@ -349,6 +349,7 @@ static struct platform_driver unimac_mdio_driver = {
                .name = UNIMAC_MDIO_DRV_NAME,
                .of_match_table = unimac_mdio_ids,
                .pm = &unimac_mdio_pm_ops,
+               .probe_type = PROBE_FORCE_SYNCHRONOUS,
        },
        .probe  = unimac_mdio_probe,
        .remove = unimac_mdio_remove,
-- 
Florian

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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-21 16:37   ` Florian Fainelli
  2021-06-21 16:47     ` Florian Fainelli
@ 2021-06-21 16:56     ` Peter Robinson
  2021-06-21 20:15       ` Stefan Wahren
  1 sibling, 1 reply; 19+ messages in thread
From: Peter Robinson @ 2021-06-21 16:56 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Andrew Lunn, Jian-Hong Pan, Doug Berger, netdev, linux-kernel,
	linux, bcm-kernel-feedback-list, linux-rpi-kernel

On Mon, Jun 21, 2021 at 5:39 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> On 6/21/21 6:09 AM, Andrew Lunn wrote:
> > On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
> >> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
> >> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
> >> PHY.
> >>
> >> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> >> ...
> >> could not attach to PHY
> >> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> >> uart-pl011 fe201000.serial: no DMA platform data
> >> libphy: bcmgenet MII bus: probed
> >> ...
> >> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> >>
> >> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
> >> a while between each time for mdio-bcm-unimac module's loading and
> >> probing.
> >
> > Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
> > driver again later, by which time, the MDIO bus driver should of
> > probed.
>
> This is unlikely to work because GENET register the mdio-bcm-unimac
> platform device so we will likely run into a chicken and egg problem,
> though surprisingly I have not seen this on STB platforms where GENET is
> used, I will try building everything as a module like you do. Can you
> see if the following helps:

For reference we have mdio_bcm_unimac/genet both built as modules in
Fedora and I've not seen this issue reported using vanilla upstream
kernels if that's a useful reference point.

Regards,
Peter

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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-21 16:56     ` Peter Robinson
@ 2021-06-21 20:15       ` Stefan Wahren
  2021-06-21 21:47         ` Florian Fainelli
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Wahren @ 2021-06-21 20:15 UTC (permalink / raw)
  To: Peter Robinson, Florian Fainelli
  Cc: Andrew Lunn, Jian-Hong Pan, Doug Berger, netdev, linux-kernel,
	linux, bcm-kernel-feedback-list, linux-rpi-kernel

Am 21.06.21 um 18:56 schrieb Peter Robinson:
> On Mon, Jun 21, 2021 at 5:39 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
>> On 6/21/21 6:09 AM, Andrew Lunn wrote:
>>> On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
>>>> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
>>>> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
>>>> PHY.
>>>>
>>>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
>>>> ...
>>>> could not attach to PHY
>>>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
>>>> uart-pl011 fe201000.serial: no DMA platform data
>>>> libphy: bcmgenet MII bus: probed
>>>> ...
>>>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
>>>>
>>>> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
>>>> a while between each time for mdio-bcm-unimac module's loading and
>>>> probing.
>>> Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
>>> driver again later, by which time, the MDIO bus driver should of
>>> probed.
>> This is unlikely to work because GENET register the mdio-bcm-unimac
>> platform device so we will likely run into a chicken and egg problem,
>> though surprisingly I have not seen this on STB platforms where GENET is
>> used, I will try building everything as a module like you do. Can you
>> see if the following helps:
> For reference we have mdio_bcm_unimac/genet both built as modules in
> Fedora and I've not seen this issue reported using vanilla upstream
> kernels if that's a useful reference point.

I was also unable to reproduce this issue, but it seems to be a known
issue [1], [2].

Jian-Hong opened an issue in my Github repo [3], but before the issue
was narrowed down, he decided to send this workaround.

Best regards

[1] -
https://github.com/raspberrypi/linux/issues/3108#issuecomment-723550749
[2] - https://archlinuxarm.org/forum/viewtopic.php?f=67&t=14806
[3] - https://github.com/lategoodbye/rpi-zero/issues/51

>
> Regards,
> Peter
>
> _______________________________________________
> linux-rpi-kernel mailing list
> linux-rpi-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel


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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-21 20:15       ` Stefan Wahren
@ 2021-06-21 21:47         ` Florian Fainelli
  2021-06-22  6:29           ` Jian-Hong Pan
  0 siblings, 1 reply; 19+ messages in thread
From: Florian Fainelli @ 2021-06-21 21:47 UTC (permalink / raw)
  To: Stefan Wahren, Peter Robinson, Florian Fainelli
  Cc: Andrew Lunn, Jian-Hong Pan, Doug Berger, netdev, linux-kernel,
	linux, bcm-kernel-feedback-list, linux-rpi-kernel

On 6/21/21 1:15 PM, Stefan Wahren wrote:
> Am 21.06.21 um 18:56 schrieb Peter Robinson:
>> On Mon, Jun 21, 2021 at 5:39 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
>>> On 6/21/21 6:09 AM, Andrew Lunn wrote:
>>>> On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
>>>>> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
>>>>> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
>>>>> PHY.
>>>>>
>>>>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
>>>>> ...
>>>>> could not attach to PHY
>>>>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
>>>>> uart-pl011 fe201000.serial: no DMA platform data
>>>>> libphy: bcmgenet MII bus: probed
>>>>> ...
>>>>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
>>>>>
>>>>> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
>>>>> a while between each time for mdio-bcm-unimac module's loading and
>>>>> probing.
>>>> Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
>>>> driver again later, by which time, the MDIO bus driver should of
>>>> probed.
>>> This is unlikely to work because GENET register the mdio-bcm-unimac
>>> platform device so we will likely run into a chicken and egg problem,
>>> though surprisingly I have not seen this on STB platforms where GENET is
>>> used, I will try building everything as a module like you do. Can you
>>> see if the following helps:
>> For reference we have mdio_bcm_unimac/genet both built as modules in
>> Fedora and I've not seen this issue reported using vanilla upstream
>> kernels if that's a useful reference point.
> 
> I was also unable to reproduce this issue, but it seems to be a known
> issue [1], [2].
> 
> Jian-Hong opened an issue in my Github repo [3], but before the issue
> was narrowed down, he decided to send this workaround.

The comment about changing the phy-mode property is not quite making
sense to me, except if that means that in one case the Broadcom PHY
driver is used and in the other case the Generic PHY driver is used.

What is not clear to me from the debugging that has been done so far is
whether the mdio-bcm-unimac MDIO controller was not loaded at the time
of_phy_connect() was trying to identify the PHY device.
--
Florian

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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-21 21:47         ` Florian Fainelli
@ 2021-06-22  6:29           ` Jian-Hong Pan
  2021-06-22  6:50             ` Heiner Kallweit
  0 siblings, 1 reply; 19+ messages in thread
From: Jian-Hong Pan @ 2021-06-22  6:29 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Stefan Wahren, Peter Robinson, Andrew Lunn, Doug Berger,
	Linux Netdev List, Linux Kernel, linux, bcm-kernel-feedback-list,
	linux-rpi-kernel

Florian Fainelli <f.fainelli@gmail.com> 於 2021年6月22日 週二 上午5:47寫道:
>
> On 6/21/21 1:15 PM, Stefan Wahren wrote:
> > Am 21.06.21 um 18:56 schrieb Peter Robinson:
> >> On Mon, Jun 21, 2021 at 5:39 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
> >>> On 6/21/21 6:09 AM, Andrew Lunn wrote:
> >>>> On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
> >>>>> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
> >>>>> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
> >>>>> PHY.
> >>>>>
> >>>>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> >>>>> ...
> >>>>> could not attach to PHY
> >>>>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> >>>>> uart-pl011 fe201000.serial: no DMA platform data
> >>>>> libphy: bcmgenet MII bus: probed
> >>>>> ...
> >>>>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> >>>>>
> >>>>> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
> >>>>> a while between each time for mdio-bcm-unimac module's loading and
> >>>>> probing.
> >>>> Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
> >>>> driver again later, by which time, the MDIO bus driver should of
> >>>> probed.
> >>> This is unlikely to work because GENET register the mdio-bcm-unimac
> >>> platform device so we will likely run into a chicken and egg problem,
> >>> though surprisingly I have not seen this on STB platforms where GENET is
> >>> used, I will try building everything as a module like you do. Can you
> >>> see if the following helps:
> >> For reference we have mdio_bcm_unimac/genet both built as modules in
> >> Fedora and I've not seen this issue reported using vanilla upstream
> >> kernels if that's a useful reference point.
> >
> > I was also unable to reproduce this issue, but it seems to be a known
> > issue [1], [2].
> >
> > Jian-Hong opened an issue in my Github repo [3], but before the issue
> > was narrowed down, he decided to send this workaround.
>
> The comment about changing the phy-mode property is not quite making
> sense to me, except if that means that in one case the Broadcom PHY
> driver is used and in the other case the Generic PHY driver is used.
>
> What is not clear to me from the debugging that has been done so far is
> whether the mdio-bcm-unimac MDIO controller was not loaded at the time
> of_phy_connect() was trying to identify the PHY device.

MODULE_SOFTDEP("pre: mdio-bcm-unimac")  mentioned in the comment [1]
solves this issue.

Tracing the code by following the debug message in comment #2 [2], I
learned the path bcmgenet_mii_probe()'s of_phy_connect() ->
of_phy_find_device() -> of_mdio_find_device() ->
bus_find_device_by_of_node().  And, bus_find_device_by_of_node()
cannot find the device on the mdio bus.

So, I traced bcm2711-rpi-4-b's device tree to find out which one is
the mdio device and why it has not been prepared ready on the mdio bus
for genet.
Then, I found out it is mdio-bcm-unimac module as mentioned in comment
#4 [3].  Also, noticed "unimac-mdio unimac-mdio.-19: Broadcom UniMAC
MDIO bus" comes after "bcmgenet fd580000.ethernet eth0: failed to
connect to PHY" in the log.

With these findings, I try to re-modprobe genet module again.  The
ethernet on RPi 4B works correctly!  Also, noticed mdio-bcm-unimac
module is loaded before I re-modprobe genet module.
Therefore, I try to make mdio-bcm-unimac built in kernel image,
instead of a module.  Then, genet always can find the mdio device on
the bus and the ethernet works as well.

Consequently, the idea, loading mdio-bcm-unimac module earlier than
genet module comes in my head!  However, I don't know the key word
"MODULE_SOFTDEP" until Florian's guide.  That is why I have a loop to
connect the PHY in the original patch.  But, I understand
MODULE_SOFTDEP is a better solution now!

I think this is like the module loading order situation mentioned in
commit 11287b693d03 ("r8169: load Realtek PHY driver module before
r8169") [4].

[1] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c6
[2] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c2
[3] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c4
[4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=11287b693d03830010356339e4ceddf47dee34fa

Jian-Hong Pan

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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-22  6:29           ` Jian-Hong Pan
@ 2021-06-22  6:50             ` Heiner Kallweit
  2021-06-22  7:46               ` Jian-Hong Pan
  0 siblings, 1 reply; 19+ messages in thread
From: Heiner Kallweit @ 2021-06-22  6:50 UTC (permalink / raw)
  To: Jian-Hong Pan, Florian Fainelli
  Cc: Stefan Wahren, Peter Robinson, Andrew Lunn, Doug Berger,
	Linux Netdev List, Linux Kernel, linux, bcm-kernel-feedback-list,
	linux-rpi-kernel

On 22.06.2021 08:29, Jian-Hong Pan wrote:
> Florian Fainelli <f.fainelli@gmail.com> 於 2021年6月22日 週二 上午5:47寫道:
>>
>> On 6/21/21 1:15 PM, Stefan Wahren wrote:
>>> Am 21.06.21 um 18:56 schrieb Peter Robinson:
>>>> On Mon, Jun 21, 2021 at 5:39 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
>>>>> On 6/21/21 6:09 AM, Andrew Lunn wrote:
>>>>>> On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
>>>>>>> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
>>>>>>> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
>>>>>>> PHY.
>>>>>>>
>>>>>>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
>>>>>>> ...
>>>>>>> could not attach to PHY
>>>>>>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
>>>>>>> uart-pl011 fe201000.serial: no DMA platform data
>>>>>>> libphy: bcmgenet MII bus: probed
>>>>>>> ...
>>>>>>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
>>>>>>>
>>>>>>> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
>>>>>>> a while between each time for mdio-bcm-unimac module's loading and
>>>>>>> probing.
>>>>>> Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
>>>>>> driver again later, by which time, the MDIO bus driver should of
>>>>>> probed.
>>>>> This is unlikely to work because GENET register the mdio-bcm-unimac
>>>>> platform device so we will likely run into a chicken and egg problem,
>>>>> though surprisingly I have not seen this on STB platforms where GENET is
>>>>> used, I will try building everything as a module like you do. Can you
>>>>> see if the following helps:
>>>> For reference we have mdio_bcm_unimac/genet both built as modules in
>>>> Fedora and I've not seen this issue reported using vanilla upstream
>>>> kernels if that's a useful reference point.
>>>
>>> I was also unable to reproduce this issue, but it seems to be a known
>>> issue [1], [2].
>>>
>>> Jian-Hong opened an issue in my Github repo [3], but before the issue
>>> was narrowed down, he decided to send this workaround.
>>
>> The comment about changing the phy-mode property is not quite making
>> sense to me, except if that means that in one case the Broadcom PHY
>> driver is used and in the other case the Generic PHY driver is used.
>>
>> What is not clear to me from the debugging that has been done so far is
>> whether the mdio-bcm-unimac MDIO controller was not loaded at the time
>> of_phy_connect() was trying to identify the PHY device.
> 
> MODULE_SOFTDEP("pre: mdio-bcm-unimac")  mentioned in the comment [1]
> solves this issue.
> 
> Tracing the code by following the debug message in comment #2 [2], I
> learned the path bcmgenet_mii_probe()'s of_phy_connect() ->
> of_phy_find_device() -> of_mdio_find_device() ->
> bus_find_device_by_of_node().  And, bus_find_device_by_of_node()
> cannot find the device on the mdio bus.
> 
> So, I traced bcm2711-rpi-4-b's device tree to find out which one is
> the mdio device and why it has not been prepared ready on the mdio bus
> for genet.
> Then, I found out it is mdio-bcm-unimac module as mentioned in comment
> #4 [3].  Also, noticed "unimac-mdio unimac-mdio.-19: Broadcom UniMAC
> MDIO bus" comes after "bcmgenet fd580000.ethernet eth0: failed to
> connect to PHY" in the log.
> 
> With these findings, I try to re-modprobe genet module again.  The
> ethernet on RPi 4B works correctly!  Also, noticed mdio-bcm-unimac
> module is loaded before I re-modprobe genet module.
> Therefore, I try to make mdio-bcm-unimac built in kernel image,
> instead of a module.  Then, genet always can find the mdio device on
> the bus and the ethernet works as well.
> 
> Consequently, the idea, loading mdio-bcm-unimac module earlier than
> genet module comes in my head!  However, I don't know the key word
> "MODULE_SOFTDEP" until Florian's guide.  That is why I have a loop to
> connect the PHY in the original patch.  But, I understand
> MODULE_SOFTDEP is a better solution now!
> 
> I think this is like the module loading order situation mentioned in
> commit 11287b693d03 ("r8169: load Realtek PHY driver module before
> r8169") [4].
> 
The reason in r8169 is different. When people add r8169 module to
initramfs but not the Realtek PHY driver module then loading
r8169 will fail. The MODULE_SOFTDEP is a hint to tools building
initramfs.

> [1] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c6
> [2] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c2
> [3] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c4
> [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=11287b693d03830010356339e4ceddf47dee34fa
> 
> Jian-Hong Pan
> 


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

* Re: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-22  6:50             ` Heiner Kallweit
@ 2021-06-22  7:46               ` Jian-Hong Pan
  2021-06-23  3:28                 ` [PATCH v2] " Jian-Hong Pan
  0 siblings, 1 reply; 19+ messages in thread
From: Jian-Hong Pan @ 2021-06-22  7:46 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Florian Fainelli, Stefan Wahren, Peter Robinson, Andrew Lunn,
	Doug Berger, Linux Netdev List, Linux Kernel, linux,
	bcm-kernel-feedback-list, linux-rpi-kernel

Heiner Kallweit <hkallweit1@gmail.com> 於 2021年6月22日 週二 下午2:50寫道:
>
> On 22.06.2021 08:29, Jian-Hong Pan wrote:
> > Florian Fainelli <f.fainelli@gmail.com> 於 2021年6月22日 週二 上午5:47寫道:
> >>
> >> On 6/21/21 1:15 PM, Stefan Wahren wrote:
> >>> Am 21.06.21 um 18:56 schrieb Peter Robinson:
> >>>> On Mon, Jun 21, 2021 at 5:39 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
> >>>>> On 6/21/21 6:09 AM, Andrew Lunn wrote:
> >>>>>> On Mon, Jun 21, 2021 at 06:33:11PM +0800, Jian-Hong Pan wrote:
> >>>>>>> The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the
> >>>>>>> ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the
> >>>>>>> PHY.
> >>>>>>>
> >>>>>>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> >>>>>>> ...
> >>>>>>> could not attach to PHY
> >>>>>>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> >>>>>>> uart-pl011 fe201000.serial: no DMA platform data
> >>>>>>> libphy: bcmgenet MII bus: probed
> >>>>>>> ...
> >>>>>>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> >>>>>>>
> >>>>>>> This patch makes GENET try to connect the PHY up to 3 times. Also, waits
> >>>>>>> a while between each time for mdio-bcm-unimac module's loading and
> >>>>>>> probing.
> >>>>>> Don't loop. Return -EPROBE_DEFER. The driver core will then probed the
> >>>>>> driver again later, by which time, the MDIO bus driver should of
> >>>>>> probed.
> >>>>> This is unlikely to work because GENET register the mdio-bcm-unimac
> >>>>> platform device so we will likely run into a chicken and egg problem,
> >>>>> though surprisingly I have not seen this on STB platforms where GENET is
> >>>>> used, I will try building everything as a module like you do. Can you
> >>>>> see if the following helps:
> >>>> For reference we have mdio_bcm_unimac/genet both built as modules in
> >>>> Fedora and I've not seen this issue reported using vanilla upstream
> >>>> kernels if that's a useful reference point.
> >>>
> >>> I was also unable to reproduce this issue, but it seems to be a known
> >>> issue [1], [2].
> >>>
> >>> Jian-Hong opened an issue in my Github repo [3], but before the issue
> >>> was narrowed down, he decided to send this workaround.
> >>
> >> The comment about changing the phy-mode property is not quite making
> >> sense to me, except if that means that in one case the Broadcom PHY
> >> driver is used and in the other case the Generic PHY driver is used.
> >>
> >> What is not clear to me from the debugging that has been done so far is
> >> whether the mdio-bcm-unimac MDIO controller was not loaded at the time
> >> of_phy_connect() was trying to identify the PHY device.
> >
> > MODULE_SOFTDEP("pre: mdio-bcm-unimac")  mentioned in the comment [1]
> > solves this issue.
> >
> > Tracing the code by following the debug message in comment #2 [2], I
> > learned the path bcmgenet_mii_probe()'s of_phy_connect() ->
> > of_phy_find_device() -> of_mdio_find_device() ->
> > bus_find_device_by_of_node().  And, bus_find_device_by_of_node()
> > cannot find the device on the mdio bus.
> >
> > So, I traced bcm2711-rpi-4-b's device tree to find out which one is
> > the mdio device and why it has not been prepared ready on the mdio bus
> > for genet.
> > Then, I found out it is mdio-bcm-unimac module as mentioned in comment
> > #4 [3].  Also, noticed "unimac-mdio unimac-mdio.-19: Broadcom UniMAC
> > MDIO bus" comes after "bcmgenet fd580000.ethernet eth0: failed to
> > connect to PHY" in the log.
> >
> > With these findings, I try to re-modprobe genet module again.  The
> > ethernet on RPi 4B works correctly!  Also, noticed mdio-bcm-unimac
> > module is loaded before I re-modprobe genet module.
> > Therefore, I try to make mdio-bcm-unimac built in kernel image,
> > instead of a module.  Then, genet always can find the mdio device on
> > the bus and the ethernet works as well.
> >
> > Consequently, the idea, loading mdio-bcm-unimac module earlier than
> > genet module comes in my head!  However, I don't know the key word
> > "MODULE_SOFTDEP" until Florian's guide.  That is why I have a loop to
> > connect the PHY in the original patch.  But, I understand
> > MODULE_SOFTDEP is a better solution now!

Forgot to place some reference as note:

* MODULE_SOFTDEP is defined in include/linux/module.h [1]

* modprobe.d has an example: [2]
  Assume "softdep c pre: a b post: d e" is provided in
  the configuration. Running "modprobe c" is now equivalent to
  "modprobe a b c d e" without the softdep.

[1] https://elixir.bootlin.com/linux/v5.13-rc7/source/include/linux/module.h#L170
[2] https://man7.org/linux/man-pages/man5/modprobe.d.5.html

> > I think this is like the module loading order situation mentioned in
> > commit 11287b693d03 ("r8169: load Realtek PHY driver module before
> > r8169") [4].
> >
> The reason in r8169 is different. When people add r8169 module to
> initramfs but not the Realtek PHY driver module then loading
> r8169 will fail. The MODULE_SOFTDEP is a hint to tools building
> initramfs.

Thanks for Heiner's quick clarification.
Maybe I missed some background of the commit ("r8169: load Realtek PHY
driver module before r8169").

Jian-Hong Pan

> > [1] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c6
> > [2] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c2
> > [3] https://bugzilla.kernel.org/show_bug.cgi?id=213485#c4
> > [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=11287b693d03830010356339e4ceddf47dee34fa
> >
> > Jian-Hong Pan
> >
>

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

* [PATCH v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-22  7:46               ` Jian-Hong Pan
@ 2021-06-23  3:28                 ` Jian-Hong Pan
  2021-06-23  4:00                   ` Florian Fainelli
  2021-06-23 20:50                   ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 19+ messages in thread
From: Jian-Hong Pan @ 2021-06-23  3:28 UTC (permalink / raw)
  To: Florian Fainelli, Stefan Wahren, Doug Berger
  Cc: Andrew Lunn, bcm-kernel-feedback-list, netdev, linux-kernel,
	linux, linux-rpi-kernel, Jian-Hong Pan

The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.
So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
GENET fail to attach the PHY as following log:

bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
...
could not attach to PHY
bcmgenet fd580000.ethernet eth0: failed to connect to PHY
uart-pl011 fe201000.serial: no DMA platform data
libphy: bcmgenet MII bus: probed
...
unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus

This patch adds the soft dependency to load mdio-bcm-unimac module
before genet module to avoid the issue.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=213485
Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
---
v2: Load mdio-bcm-unimac before genet module instead of trying to
    connect the PHY in a loop.

 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index fcca023f22e5..41f7f078cd27 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -4296,3 +4296,4 @@ MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom GENET Ethernet controller driver");
 MODULE_ALIAS("platform:bcmgenet");
 MODULE_LICENSE("GPL");
+MODULE_SOFTDEP("pre: mdio-bcm-unimac");
-- 
2.32.0


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

* Re: [PATCH v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-23  3:28                 ` [PATCH v2] " Jian-Hong Pan
@ 2021-06-23  4:00                   ` Florian Fainelli
  2021-06-23 20:50                   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2021-06-23  4:00 UTC (permalink / raw)
  To: Jian-Hong Pan, Florian Fainelli, Stefan Wahren, Doug Berger
  Cc: Andrew Lunn, bcm-kernel-feedback-list, netdev, linux-kernel,
	linux, linux-rpi-kernel

The subject should be fixed s/PYH/PHY/ and also probably reworded to be:

net: bcmgenet: Add mdio-bcm-unimac soft dependency

On 6/22/2021 8:28 PM, Jian-Hong Pan wrote:
> The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.

It is not just coming too late, there is also no way for the module 
loader to figure out the dependency between GENET and its MDIO bus 
driver unless we provide this MODULE_SOFTDEP hint.

> So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
> GENET fail to attach the PHY as following log:
> 
> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> ...
> could not attach to PHY
> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> uart-pl011 fe201000.serial: no DMA platform data
> libphy: bcmgenet MII bus: probed
> ...
> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> 
> This patch adds the soft dependency to load mdio-bcm-unimac module
> before genet module to avoid the issue.
> 
> Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=213485
> Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Fixes: 9a4e79697009 ("net: bcmgenet: utilize generic Broadcom UniMAC 
MDIO controller driver")

> ---
> v2: Load mdio-bcm-unimac before genet module instead of trying to
>      connect the PHY in a loop.
> 
>   drivers/net/ethernet/broadcom/genet/bcmgenet.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index fcca023f22e5..41f7f078cd27 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -4296,3 +4296,4 @@ MODULE_AUTHOR("Broadcom Corporation");
>   MODULE_DESCRIPTION("Broadcom GENET Ethernet controller driver");
>   MODULE_ALIAS("platform:bcmgenet");
>   MODULE_LICENSE("GPL");
> +MODULE_SOFTDEP("pre: mdio-bcm-unimac");
> 

-- 
Florian

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

* Re: [PATCH v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-23  3:28                 ` [PATCH v2] " Jian-Hong Pan
  2021-06-23  4:00                   ` Florian Fainelli
@ 2021-06-23 20:50                   ` patchwork-bot+netdevbpf
  2021-06-23 21:19                     ` Florian Fainelli
  1 sibling, 1 reply; 19+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-23 20:50 UTC (permalink / raw)
  To: Jian-Hong Pan
  Cc: f.fainelli, stefan.wahren, opendmb, andrew,
	bcm-kernel-feedback-list, netdev, linux-kernel, linux,
	linux-rpi-kernel

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Wed, 23 Jun 2021 11:28:03 +0800 you wrote:
> The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.
> So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
> GENET fail to attach the PHY as following log:
> 
> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> ...
> could not attach to PHY
> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> uart-pl011 fe201000.serial: no DMA platform data
> libphy: bcmgenet MII bus: probed
> ...
> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> 
> [...]

Here is the summary with links:
  - [v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
    https://git.kernel.org/netdev/net/c/b2ac9800cfe0

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-23 20:50                   ` patchwork-bot+netdevbpf
@ 2021-06-23 21:19                     ` Florian Fainelli
  2021-06-24  2:47                       ` Jian-Hong Pan
  2021-06-24  3:22                       ` [PATCH v3] net: bcmgenet: Add mdio-bcm-unimac soft dependency Jian-Hong Pan
  0 siblings, 2 replies; 19+ messages in thread
From: Florian Fainelli @ 2021-06-23 21:19 UTC (permalink / raw)
  To: patchwork-bot+netdevbpf, Jian-Hong Pan
  Cc: f.fainelli, stefan.wahren, opendmb, andrew,
	bcm-kernel-feedback-list, netdev, linux-kernel, linux,
	linux-rpi-kernel

On 6/23/21 1:50 PM, patchwork-bot+netdevbpf@kernel.org wrote:
> Hello:
> 
> This patch was applied to netdev/net.git (refs/heads/master):
> 
> On Wed, 23 Jun 2021 11:28:03 +0800 you wrote:
>> The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.
>> So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
>> GENET fail to attach the PHY as following log:
>>
>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
>> ...
>> could not attach to PHY
>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
>> uart-pl011 fe201000.serial: no DMA platform data
>> libphy: bcmgenet MII bus: probed
>> ...
>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
>>
>> [...]
> 
> Here is the summary with links:
>   - [v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
>     https://git.kernel.org/netdev/net/c/b2ac9800cfe0

There was feedback given that could have deserved a v3, if nothing else
to fix the typo in the subject, I suppose that would do though.
-- 
Florian

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

* Re: [PATCH v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-23 21:19                     ` Florian Fainelli
@ 2021-06-24  2:47                       ` Jian-Hong Pan
  2021-06-24  3:27                         ` Florian Fainelli
  2021-06-24  3:22                       ` [PATCH v3] net: bcmgenet: Add mdio-bcm-unimac soft dependency Jian-Hong Pan
  1 sibling, 1 reply; 19+ messages in thread
From: Jian-Hong Pan @ 2021-06-24  2:47 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: patchwork-bot+netdevbpf, Stefan Wahren, Doug Berger, Andrew Lunn,
	bcm-kernel-feedback-list, Linux Netdev List, Linux Kernel, linux,
	linux-rpi-kernel

Florian Fainelli <f.fainelli@gmail.com> 於 2021年6月24日 週四 上午5:19寫道:
>
> On 6/23/21 1:50 PM, patchwork-bot+netdevbpf@kernel.org wrote:
> > Hello:
> >
> > This patch was applied to netdev/net.git (refs/heads/master):
> >
> > On Wed, 23 Jun 2021 11:28:03 +0800 you wrote:
> >> The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.
> >> So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
> >> GENET fail to attach the PHY as following log:
> >>
> >> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> >> ...
> >> could not attach to PHY
> >> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> >> uart-pl011 fe201000.serial: no DMA platform data
> >> libphy: bcmgenet MII bus: probed
> >> ...
> >> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> >>
> >> [...]
> >
> > Here is the summary with links:
> >   - [v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
> >     https://git.kernel.org/netdev/net/c/b2ac9800cfe0

This bot is interesting!!!  Good feature! :)

> There was feedback given that could have deserved a v3, if nothing else
> to fix the typo in the subject, I suppose that would do though.

I can prepare the v3 patch with Florian's suggestion!

Jian-Hong Pan

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

* [PATCH v3] net: bcmgenet: Add mdio-bcm-unimac soft dependency
  2021-06-23 21:19                     ` Florian Fainelli
  2021-06-24  2:47                       ` Jian-Hong Pan
@ 2021-06-24  3:22                       ` Jian-Hong Pan
  2021-06-24 23:00                         ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 19+ messages in thread
From: Jian-Hong Pan @ 2021-06-24  3:22 UTC (permalink / raw)
  To: Florian Fainelli, Stefan Wahren, Doug Berger
  Cc: Andrew Lunn, bcm-kernel-feedback-list, netdev, linux-kernel,
	linux, linux-rpi-kernel, Jian-Hong Pan

The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.
So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
GENET fail to attach the PHY as following log:

bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
...
could not attach to PHY
bcmgenet fd580000.ethernet eth0: failed to connect to PHY
uart-pl011 fe201000.serial: no DMA platform data
libphy: bcmgenet MII bus: probed
...
unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus

It is not just coming too late, there is also no way for the module
loader to figure out the dependency between GENET and its MDIO bus
driver unless we provide this MODULE_SOFTDEP hint.

This patch adds the soft dependency to load mdio-bcm-unimac module
before genet module to fix this issue.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=213485
Fixes: 9a4e79697009 ("net: bcmgenet: utilize generic Broadcom UniMAC MDIO controller driver")
Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
v3: Modified the subject and added some more description in the commit
    message by Florian's suggestion.

v2: Load mdio-bcm-unimac before genet module instead of trying to
    connect the PHY in a loop.

 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index fcca023f22e5..41f7f078cd27 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -4296,3 +4296,4 @@ MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom GENET Ethernet controller driver");
 MODULE_ALIAS("platform:bcmgenet");
 MODULE_LICENSE("GPL");
+MODULE_SOFTDEP("pre: mdio-bcm-unimac");
-- 
2.32.0


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

* Re: [PATCH v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-24  2:47                       ` Jian-Hong Pan
@ 2021-06-24  3:27                         ` Florian Fainelli
  2021-06-24  3:28                           ` Jian-Hong Pan
  0 siblings, 1 reply; 19+ messages in thread
From: Florian Fainelli @ 2021-06-24  3:27 UTC (permalink / raw)
  To: Jian-Hong Pan
  Cc: patchwork-bot+netdevbpf, Stefan Wahren, Doug Berger, Andrew Lunn,
	bcm-kernel-feedback-list, Linux Netdev List, Linux Kernel, linux,
	linux-rpi-kernel



On 6/23/2021 7:47 PM, Jian-Hong Pan wrote:
> Florian Fainelli <f.fainelli@gmail.com> 於 2021年6月24日 週四 上午5:19寫道:
>>
>> On 6/23/21 1:50 PM, patchwork-bot+netdevbpf@kernel.org wrote:
>>> Hello:
>>>
>>> This patch was applied to netdev/net.git (refs/heads/master):
>>>
>>> On Wed, 23 Jun 2021 11:28:03 +0800 you wrote:
>>>> The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.
>>>> So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
>>>> GENET fail to attach the PHY as following log:
>>>>
>>>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
>>>> ...
>>>> could not attach to PHY
>>>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
>>>> uart-pl011 fe201000.serial: no DMA platform data
>>>> libphy: bcmgenet MII bus: probed
>>>> ...
>>>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
>>>>
>>>> [...]
>>>
>>> Here is the summary with links:
>>>    - [v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
>>>      https://git.kernel.org/netdev/net/c/b2ac9800cfe0
> 
> This bot is interesting!!!  Good feature! :)
> 
>> There was feedback given that could have deserved a v3, if nothing else
>> to fix the typo in the subject, I suppose that would do though.
> 
> I can prepare the v3 patch with Florian's suggestion!

Too late, once it's merged only fixups can be accepted, and that does 
not include commit messages, it's alright.
-- 
Florian

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

* Re: [PATCH v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
  2021-06-24  3:27                         ` Florian Fainelli
@ 2021-06-24  3:28                           ` Jian-Hong Pan
  0 siblings, 0 replies; 19+ messages in thread
From: Jian-Hong Pan @ 2021-06-24  3:28 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: patchwork-bot+netdevbpf, Stefan Wahren, Doug Berger, Andrew Lunn,
	bcm-kernel-feedback-list, Linux Netdev List, Linux Kernel, linux,
	linux-rpi-kernel

Ok, thanks!

Florian Fainelli <f.fainelli@gmail.com> 於 2021年6月24日 週四 上午11:27寫道:
>
>
>
> On 6/23/2021 7:47 PM, Jian-Hong Pan wrote:
> > Florian Fainelli <f.fainelli@gmail.com> 於 2021年6月24日 週四 上午5:19寫道:
> >>
> >> On 6/23/21 1:50 PM, patchwork-bot+netdevbpf@kernel.org wrote:
> >>> Hello:
> >>>
> >>> This patch was applied to netdev/net.git (refs/heads/master):
> >>>
> >>> On Wed, 23 Jun 2021 11:28:03 +0800 you wrote:
> >>>> The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.
> >>>> So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
> >>>> GENET fail to attach the PHY as following log:
> >>>>
> >>>> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> >>>> ...
> >>>> could not attach to PHY
> >>>> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> >>>> uart-pl011 fe201000.serial: no DMA platform data
> >>>> libphy: bcmgenet MII bus: probed
> >>>> ...
> >>>> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> >>>>
> >>>> [...]
> >>>
> >>> Here is the summary with links:
> >>>    - [v2] net: bcmgenet: Fix attaching to PYH failed on RPi 4B
> >>>      https://git.kernel.org/netdev/net/c/b2ac9800cfe0
> >
> > This bot is interesting!!!  Good feature! :)
> >
> >> There was feedback given that could have deserved a v3, if nothing else
> >> to fix the typo in the subject, I suppose that would do though.
> >
> > I can prepare the v3 patch with Florian's suggestion!
>
> Too late, once it's merged only fixups can be accepted, and that does
> not include commit messages, it's alright.
> --
> Florian

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

* Re: [PATCH v3] net: bcmgenet: Add mdio-bcm-unimac soft dependency
  2021-06-24  3:22                       ` [PATCH v3] net: bcmgenet: Add mdio-bcm-unimac soft dependency Jian-Hong Pan
@ 2021-06-24 23:00                         ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 19+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-24 23:00 UTC (permalink / raw)
  To: Jian-Hong Pan
  Cc: f.fainelli, stefan.wahren, opendmb, andrew,
	bcm-kernel-feedback-list, netdev, linux-kernel, linux,
	linux-rpi-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Thu, 24 Jun 2021 11:22:41 +0800 you wrote:
> The Broadcom UniMAC MDIO bus from mdio-bcm-unimac module comes too late.
> So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads
> GENET fail to attach the PHY as following log:
> 
> bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000
> ...
> could not attach to PHY
> bcmgenet fd580000.ethernet eth0: failed to connect to PHY
> uart-pl011 fe201000.serial: no DMA platform data
> libphy: bcmgenet MII bus: probed
> ...
> unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus
> 
> [...]

Here is the summary with links:
  - [v3] net: bcmgenet: Add mdio-bcm-unimac soft dependency
    https://git.kernel.org/netdev/net-next/c/19938bafa7ae

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

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

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 10:33 [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B Jian-Hong Pan
2021-06-21 13:09 ` Andrew Lunn
2021-06-21 16:37   ` Florian Fainelli
2021-06-21 16:47     ` Florian Fainelli
2021-06-21 16:56     ` Peter Robinson
2021-06-21 20:15       ` Stefan Wahren
2021-06-21 21:47         ` Florian Fainelli
2021-06-22  6:29           ` Jian-Hong Pan
2021-06-22  6:50             ` Heiner Kallweit
2021-06-22  7:46               ` Jian-Hong Pan
2021-06-23  3:28                 ` [PATCH v2] " Jian-Hong Pan
2021-06-23  4:00                   ` Florian Fainelli
2021-06-23 20:50                   ` patchwork-bot+netdevbpf
2021-06-23 21:19                     ` Florian Fainelli
2021-06-24  2:47                       ` Jian-Hong Pan
2021-06-24  3:27                         ` Florian Fainelli
2021-06-24  3:28                           ` Jian-Hong Pan
2021-06-24  3:22                       ` [PATCH v3] net: bcmgenet: Add mdio-bcm-unimac soft dependency Jian-Hong Pan
2021-06-24 23:00                         ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.