All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel González Cabanelas" <dgcbueu@gmail.com>
To: Heiner Kallweit <hkallweit1@gmail.com>, Andrew Lunn <andrew@lunn.ch>
Cc: "Florian Fainelli" <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	gregkh@linuxfoundation.org, netdev@vger.kernel.org,
	"Álvaro Fernández Rojas" <noltari@gmail.com>
Subject: Re: [PATCH v2] bcm63xx_enet: fix internal phy IRQ assignment
Date: Thu, 25 Feb 2021 17:36:37 +0100	[thread overview]
Message-ID: <CABwr4_s6Y8OoeGNiPK8XpnduMsv3Sv3_mx_UcoGq=9vza6L2Ew@mail.gmail.com> (raw)
In-Reply-To: <0e75a5c3-f6bd-6039-3cfd-8708da963d20@gmail.com>

El jue, 25 feb 2021 a las 8:22, Heiner Kallweit
(<hkallweit1@gmail.com>) escribió:
>
> On 25.02.2021 00:54, Daniel González Cabanelas wrote:
> > El mié, 24 feb 2021 a las 23:01, Florian Fainelli
> > (<f.fainelli@gmail.com>) escribió:
> >>
> >>
> >>
> >> On 2/24/2021 1:44 PM, Heiner Kallweit wrote:
> >>> On 24.02.2021 16:44, Daniel González Cabanelas wrote:
> >>>> The current bcm63xx_enet driver doesn't asign the internal phy IRQ. As a
> >>>> result of this it works in polling mode.
> >>>>
> >>>> Fix it using the phy_device structure to assign the platform IRQ.
> >>>>
> >>>> Tested under a BCM6348 board. Kernel dmesg before the patch:
> >>>>    Broadcom BCM63XX (1) bcm63xx_enet-0:01: attached PHY driver [Broadcom
> >>>>               BCM63XX (1)] (mii_bus:phy_addr=bcm63xx_enet-0:01, irq=POLL)
> >>>>
> >>>> After the patch:
> >>>>    Broadcom BCM63XX (1) bcm63xx_enet-0:01: attached PHY driver [Broadcom
> >>>>               BCM63XX (1)] (mii_bus:phy_addr=bcm63xx_enet-0:01, irq=17)
> >>>>
> >>>> Pluging and uplugging the ethernet cable now generates interrupts and the
> >>>> PHY goes up and down as expected.
> >>>>
> >>>> Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
> >>>> ---
> >>>> changes in V2:
> >>>>   - snippet moved after the mdiobus registration
> >>>>   - added missing brackets
> >>>>
> >>>>  drivers/net/ethernet/broadcom/bcm63xx_enet.c | 13 +++++++++++--
> >>>>  1 file changed, 11 insertions(+), 2 deletions(-)
> >>>>
> >>>> diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> >>>> index fd876721316..dd218722560 100644
> >>>> --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> >>>> +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> >>>> @@ -1818,10 +1818,19 @@ static int bcm_enet_probe(struct platform_device *pdev)
> >>>>               * if a slave is not present on hw */
> >>>>              bus->phy_mask = ~(1 << priv->phy_id);
> >>>>
> >>>> -            if (priv->has_phy_interrupt)
> >>>> +            ret = mdiobus_register(bus);
> >>>> +
> >>>> +            if (priv->has_phy_interrupt) {
> >>>> +                    phydev = mdiobus_get_phy(bus, priv->phy_id);
> >>>> +                    if (!phydev) {
> >>>> +                            dev_err(&dev->dev, "no PHY found\n");
> >>>> +                            goto out_unregister_mdio;
> >>>> +                    }
> >>>> +
> >>>>                      bus->irq[priv->phy_id] = priv->phy_interrupt;
> >>>> +                    phydev->irq = priv->phy_interrupt;
> >>>> +            }
> >>>>
> >>>> -            ret = mdiobus_register(bus);
> >>>
> >>> You shouldn't have to set phydev->irq, this is done by phy_device_create().
> >>> For this to work bus->irq[] needs to be set before calling mdiobus_register().
> >>
> >> Yes good point, and that is what the unchanged code does actually.
> >> Daniel, any idea why that is not working?
> >
> > Hi Florian, I don't know. bus->irq[] has no effect, only assigning the
> > IRQ through phydev->irq works.
> >
> > I can resend the patch  without the bus->irq[] line since it's
> > pointless in this scenario.
> >
>
> It's still an ugly workaround and a proper root cause analysis should be done
> first. I can only imagine that phydev->irq is overwritten in phy_probe()
> because phy_drv_supports_irq() is false. Can you please check whether
> phydev->irq is properly set in phy_device_create(), and if yes, whether
> it's reset to PHY_POLL in phy_probe()?.
>

Hi Heiner, I added some kernel prints:

[    2.712519] libphy: Fixed MDIO Bus: probed
[    2.721969] =======phy_device_create===========
[    2.726841] phy_device_create: dev->irq = 17
[    2.726841]
[    2.832620] =======phy_probe===========
[    2.836846] phy_probe: phydev->irq = 17
[    2.840950] phy_probe: phy_drv_supports_irq = 0, phy_interrupt_is_valid = 1
[    2.848267] phy_probe: phydev->irq = -1
[    2.848267]
[    2.854059] =======phy_probe===========
[    2.858174] phy_probe: phydev->irq = -1
[    2.862253] phy_probe: phydev->irq = -1
[    2.862253]
[    2.868121] libphy: bcm63xx_enet MII bus: probed
[    2.873320] Broadcom BCM63XX (1) bcm63xx_enet-0:01: attached PHY
driver [Broadcom BCM63XX (1)] (mii_bus:phy_addr=bcm63xx_enet-0:01,
irq=POLL)

Currently using kernel 5.4.99. I still have no idea what's going on.

> On which kernel version do you face this problem?
>
The kernel version 4.4 works ok. The minimum version where I found the
problem were the kernel 4.9.111, now using 5.4. And 5.10 also tested.

Regards
Daniel

> > Regards
> >> --
> >> Florian
>

  reply	other threads:[~2021-02-25 16:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24 15:44 [PATCH v2] bcm63xx_enet: fix internal phy IRQ assignment Daniel González Cabanelas
2021-02-24 21:44 ` Heiner Kallweit
2021-02-24 22:01   ` Florian Fainelli
2021-02-24 23:54     ` Daniel González Cabanelas
2021-02-25  7:22       ` Heiner Kallweit
2021-02-25 16:36         ` Daniel González Cabanelas [this message]
2021-02-25 20:05           ` Heiner Kallweit
2021-02-25 22:28             ` Daniel González Cabanelas
2021-02-25 22:56               ` Heiner Kallweit
2021-02-26  4:12                 ` Florian Fainelli
2021-02-26  7:13               ` Heiner Kallweit
2021-02-26  9:10                 ` Daniel González Cabanelas
2021-02-26  9:32                   ` Heiner Kallweit
2021-02-26  9:38                     ` Heiner Kallweit
2021-02-26  9:49                     ` Daniel González Cabanelas
2021-02-26 10:08                       ` Heiner Kallweit
2021-02-26 10:19                         ` Daniel González Cabanelas
2021-02-26 14:16                           ` Andrew Lunn
2021-02-26 14:28                             ` Heiner Kallweit
2021-02-26 16:14                               ` Daniel González Cabanelas
2021-02-26 16:55                                 ` Florian Fainelli
2021-02-25 13:53 ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABwr4_s6Y8OoeGNiPK8XpnduMsv3Sv3_mx_UcoGq=9vza6L2Ew@mail.gmail.com' \
    --to=dgcbueu@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=noltari@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.