From: Andrew Lunn <andrew@lunn.ch>
To: Tristram.Ha@microchip.com
Cc: Woojung.Huh@microchip.com, UNGLinuxDriver@microchip.com,
devicetree@vger.kernel.org, f.fainelli@gmail.com,
olteanv@gmail.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, marex@denx.de,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 3/4] net: dsa: microchip: handle most interrupts in KSZ9477/KSZ9893 switch families
Date: Wed, 14 Aug 2024 15:55:52 +0200 [thread overview]
Message-ID: <736f67be-a21a-40ba-9eeb-d94040d56dc2@lunn.ch> (raw)
In-Reply-To: <BYAPR11MB3558DD354E8162D02E1FCC21EC862@BYAPR11MB3558.namprd11.prod.outlook.com>
On Tue, Aug 13, 2024 at 10:24:52PM +0000, Tristram.Ha@microchip.com wrote:
> > > +static irqreturn_t ksz9477_handle_port_irq(struct ksz_device *dev, u8 port,
> > > + u8 *data)
> > > +{
> > > + struct dsa_switch *ds = dev->ds;
> > > + struct phy_device *phydev;
> > > + int cnt = 0;
> > > +
> > > + phydev = mdiobus_get_phy(ds->user_mii_bus, port);
> > > + if (*data & PORT_PHY_INT) {
> > > + /* Handle the interrupt if there is no PHY device or its
> > > + * interrupt is not registered yet.
> > > + */
> > > + if (!phydev || phydev->interrupts != PHY_INTERRUPT_ENABLED) {
> > > + u8 phy_status;
> > > +
> > > + ksz_pread8(dev, port, REG_PORT_PHY_INT_STATUS,
> > > + &phy_status);
> > > + if (phydev)
> > > + phy_trigger_machine(phydev);
> > > + ++cnt;
> > > + *data &= ~PORT_PHY_INT;
> > > + }
> > > + }
> >
> > This looks like a layering violation. Why is this needed? An interrupt
> > controller generally has no idea what the individual interrupt is
> > about. It just calls into the interrupt core to get the handler
> > called, and then clears the interrupt. Why does that not work here?
> >
> > What other DSA drivers do if they need to handle some of the
> > interrupts is just request the interrupt like any other driver:
> >
> > https://elixir.bootlin.com/linux/v6.10.3/source/drivers/net/dsa/mv88e6xxx/pcs-
> > 639x.c#L95
>
> The PHY and ACL interrupt handling can be removed, but the SGMII
> interrupt handling cannot as the SGMII port is simulated as having an
> internal PHY but the regular PHY interrupt processing will not clear the
> interrupt.
>
> Furthermore, there will be a situation where the SGMII interrupt is
> triggered before the PHY interrupt handling function is registered.
This is one of the reasons i suggested a PCS driver. Look at
drivers/net/dsa/mv88e6xxx/pcs-6185.c as an example, how it handles
interrupts from the PCS. And it is a similar setup, the switch has an
interrupt controller, and the PCS driver requests the interrupt. PCS
drivers do not need to be complex. pcs-6185.c has an empty AN restart
callback, pcs_config does nothing, etc.
Andrew
next prev parent reply other threads:[~2024-08-14 13:56 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 23:38 [PATCH net-next 0/4] net: dsa: microchip: add SGMII port support to KSZ9477 switch Tristram.Ha
2024-08-09 23:38 ` [PATCH net-next 1/4] dt-bindings: " Tristram.Ha
2024-08-10 0:20 ` Rob Herring (Arm)
2024-08-10 11:48 ` Krzysztof Kozlowski
2024-08-13 23:09 ` Tristram.Ha
2024-08-14 6:12 ` Krzysztof Kozlowski
2024-08-14 22:32 ` Tristram.Ha
2024-08-10 17:26 ` Andrew Lunn
2024-08-13 21:14 ` Tristram.Ha
2024-08-13 21:32 ` Andrew Lunn
2024-08-13 22:17 ` Tristram.Ha
2024-08-14 13:50 ` Andrew Lunn
2024-08-14 22:30 ` Tristram.Ha
2024-08-14 22:40 ` Andrew Lunn
2024-08-15 21:54 ` Tristram.Ha
2024-08-15 22:50 ` Andrew Lunn
2024-08-09 23:38 ` [PATCH net-next 2/4] net: dsa: microchip: support global switch interrupt in KSZ DSA driver Tristram.Ha
2024-08-09 23:38 ` [PATCH net-next 3/4] net: dsa: microchip: handle most interrupts in KSZ9477/KSZ9893 switch families Tristram.Ha
2024-08-10 17:43 ` Sai Krishna Gajula
2024-08-10 17:44 ` Andrew Lunn
2024-08-13 22:24 ` Tristram.Ha
2024-08-14 13:55 ` Andrew Lunn [this message]
2024-08-09 23:38 ` [PATCH net-next 4/4] net: dsa: microchip: add SGMII port support to KSZ9477 switch Tristram.Ha
2024-08-10 17:52 ` Andrew Lunn
2024-08-13 20:59 ` Tristram.Ha
2024-08-11 16:32 ` Andrew Lunn
2024-08-13 20:54 ` Tristram.Ha
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=736f67be-a21a-40ba-9eeb-d94040d56dc2@lunn.ch \
--to=andrew@lunn.ch \
--cc=Tristram.Ha@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marex@denx.de \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh@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
all inboxes | Powered by JetHome®