Re: [PATCH net-next 3/4] drivers/net/phy: Add driver for the onsemi NCN26000 10BASE-T1S PHY

From: Andrew Lunn
Date: Sun Dec 04 2022 - 13:02:00 EST


> On Sun, Dec 04, 2022 at 03:31:33AM +0100, Piergiorgio Beruto wrote:
> > +static irqreturn_t ncn26000_handle_interrupt(struct phy_device *phydev)
> > +{
> > + const struct ncn26000_priv *const priv = phydev->priv;
> > + u16 events;
> > + int ret;
> > +
> > + // read and aknowledge the IRQ status register
> > + ret = phy_read(phydev, NCN26000_REG_IRQ_STATUS);
> > +
> > + if (unlikely(ret < 0))
> > + return IRQ_NONE;
> > +
> > + events = (u16)ret & priv->enabled_irqs;
> > + if (events == 0)
> > + return IRQ_NONE;
> > +
> > + if (events & NCN26000_IRQ_LINKST_BIT) {
> > + ret = phy_read(phydev, MII_BMSR);
> > +
> > + if (unlikely(ret < 0)) {
> > + phydev_err(phydev,
> > + "error reading the status register (%d)\n",
> > + ret);
> > +
> > + return IRQ_NONE;
> > + }
> > +
> > + phydev->link = ((u16)ret & BMSR_ANEGCOMPLETE) ? 1 : 0;

Hi Piergiorgio

Interrupt handling in PHY don't follow the usual model. Historically,
PHYs were always polled once per second. The read_status() function
gets called to report the current status of the PHY. Interrupt are
just used to indicate that poll should happen now. All the handler
needs to do is clear the interrupt line so it can be safely reenabled
and not cause an interrupt storm, and call phy_trigger_machine() to
trigger the poll.

Andrew