devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Xu Liang <lxu@maxlinear.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v1 4/4] net: phy: mxl-gpy: disable interrupts on GPY215 by default
Date: Tue, 20 Dec 2022 22:39:15 +0100	[thread overview]
Message-ID: <28c24c43a758fcbc0a648f676a6d7524@walle.cc> (raw)
In-Reply-To: <Y6G5phSGSPk+7Dgj@lunn.ch>

Am 2022-12-20 14:33, schrieb Andrew Lunn:
>> > > > I think a better place for this test is in gpy_config_intr(), return
>> > > > -EOPNOTSUPP. phy_enable_interrupts() failing should then cause
>> > > > phy_request_interrupt() to use polling.
>> > >
>> > > Which will then print a warning, which might be misleading.
>> > > Or we disable the warning if -EOPNOTSUPP is returned?
>> >
>> > Disabling the warning is the right thing to do.
>> 
>> There is more to this. .config_intr() is also used in
>> phy_init_hw() and phy_drv_supports_irq(). The latter would
>> still return true in our case. I'm not sure that is correct.
>> 
>> After trying your suggestion, I'm still in favor of somehow
>> tell the phy core to force polling mode during probe() of the
>> driver.
> 
> The problem is that the MAC can set the interrupt number after the PHY
> probe has been called. e.g.
> 
> https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c#L524
> 
> The interrupt needs to be set by the time the PHY is connected to the
> MAC, which is often in the MAC open method, much later than the PHY
> probe.

Ok, then phydev->irq should be updated within the phy_attach_direct().
Something like the following:

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e865be3d7f01..c6c5830f5214 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1537,6 +1537,14 @@ int phy_attach_direct(struct net_device *dev, 
struct phy_device *phydev,

         phydev->interrupts = PHY_INTERRUPT_DISABLED;

+       /* PHYs can request to use poll mode even though they have an
+        * associated interrupt line. This could be the case if they
+        * detect a broken interrupt handling.
+        */
+       if (phydev->drv->force_polling_mode &&
+           phydev->drv->force_polling_mode(phydev))
+               phydev->irq = PHY_POLL;
+
         /* Port is set to PORT_TP by default and the actual PHY driver 
will set
          * it to different value depending on the PHY configuration. If 
we have
          * the generic PHY driver we can't figure it out, thus set the 
old

That callback could be too specifc, I don't know. We could also have
phydev->drv->pre_attach() which then can update the phydev->irq itself.

Btw. the phy_attached_info() in the stmmac seems to be a leftover
from before the phylink conversion. phylink will print a similar info
but when the PHY is actually attached.

-michael

  reply	other threads:[~2022-12-20 21:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02 15:12 [PATCH net-next v1 0/4] net: phy: mxl-gpy: broken interrupt fixes Michael Walle
2022-12-02 15:12 ` [PATCH net-next v1 1/4] net: phy: mxl-gpy: add MDINT workaround Michael Walle
2022-12-02 18:23   ` Andrew Lunn
2022-12-02 22:53     ` Michael Walle
2022-12-02 15:12 ` [PATCH net-next v1 2/4] dt-bindings: vendor-prefixes: add MaxLinear Michael Walle
2022-12-02 15:28   ` Krzysztof Kozlowski
2022-12-02 15:12 ` [PATCH net-next v1 3/4] dt-bindings: net: phy: add MaxLinear GPY2xx bindings Michael Walle
2022-12-02 18:31   ` Andrew Lunn
2022-12-02 22:50     ` Michael Walle
2022-12-05 21:29   ` Rob Herring
2022-12-05 21:53     ` Michael Walle
2022-12-06  8:29       ` Michael Walle
2022-12-06  8:38         ` Krzysztof Kozlowski
2022-12-06  9:44           ` Michael Walle
2022-12-16  9:03             ` Michael Walle
2022-12-20 13:21               ` Andrew Lunn
2022-12-28 15:00     ` Michael Walle
2022-12-02 15:12 ` [PATCH net-next v1 4/4] net: phy: mxl-gpy: disable interrupts on GPY215 by default Michael Walle
2022-12-02 18:42   ` Andrew Lunn
2022-12-02 23:09     ` Michael Walle
2022-12-03 20:36       ` Andrew Lunn
2022-12-16  9:46         ` Michael Walle
2022-12-20 13:33           ` Andrew Lunn
2022-12-20 21:39             ` Michael Walle [this message]
2022-12-03 20:41 ` [PATCH net-next v1 0/4] net: phy: mxl-gpy: broken interrupt fixes 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=28c24c43a758fcbc0a648f676a6d7524@walle.cc \
    --to=michael@walle.cc \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lxu@maxlinear.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    /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 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).