All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Parthiban.Veerasooran@microchip.com>
To: <netdev-bot+sashiko@kernel.org>
Cc: <andrew+netdev@lunn.ch>, <davem@davemloft.net>,
	<edumazet@kernel.org>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<hkallweit1@gmail.com>, <linux@armlinux.org.uk>,
	<netdev@vger.kernel.org>, <UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH net-next RESEND v4 3/4] microchip: lan865x: enable PHY interrupt via virtual IRQ
Date: Tue, 1 Dec 2026 13:55:34 +0000	[thread overview]
Message-ID: <b3162a47-e6ab-4dd6-b02b-1a2b9730097f@microchip.com> (raw)
In-Reply-To: <179561192833.3135.495365531706227788@kernel.org>

On 25/11/26 6:35 pm, netdev-bot+sashiko@kernel.org wrote:
> This patch makes lan865x_probe() pass the OA_TC6_PHY_INT quirk flag to
> oa_tc6_init(), which turns on the oa_tc6 virtual IRQ for the internal
> PHY. phylib then runs in interrupt mode. As a result, CDEN follows PLCA
> transitions through lan86xx_config_intr() and lan86xx_handle_interrupt()
> instead of the polling-based resync.
> 
>> CDEN is synchronized to the live PLCA status when lan86xx_config_intr()
>> runs during phy_enable_interrupts(), then tracked on each subsequent
>> PLCA transition via lan86xx_handle_interrupt(). This PHY interrupt path
>> is critical for keeping CDEN correct across PLCA transitions.
>>
>> Fixes: 78341049fbcd ("net: phy: microchip_t1s: configure collision detection based on PLCA mode")
> 
> [Severity: Low]
> 
> Can this patch be backported on its own? It uses OA_TC6_PHY_INT, but at
> the baseline include/linux/oa_tc6.h only defines OA_TC6_BROKEN_PHY. The
> new flag comes from the prerequisite "net: ethernet: oa_tc6: deliver the
> PHY interrupt to phylib", together with the irq_chip, irq_domain and
> phy_irq_work code.
> 
> That prerequisite has no Fixes: tag and no "Cc: stable # dependency"
> annotation. It only says "Prerequisite for ..." in prose.
> 
> 78341049fbcd is from October 2024 and is in current stable branches.
> Stable tooling that picks Fixes: tagged commits could take this patch
> without its dependency. lan865x_probe() would then fail to build with
> OA_TC6_PHY_INT undeclared.
> 
> Would it make sense to either tag the prerequisite as a stable dependency
> or drop the Fixes: tag here?
> 
> Is the "critical" wording accurate? The earlier commit "net: phy:
> microchip_t1s: fix collision detection on PLCA status change" already
> added a polling resync for the LAN865X Rev.B entry:
> 
> drivers/net/phy/microchip_t1s.c:lan86xx_read_status() {
>      ...
>          /* When no PHY interrupt is available, phylib polls read_status().
>           * Use the PLCA status from that poll to resync CDEN.
>           */
>          mutex_lock(&priv->cden_lock);
>          ret = lan86xx_update_cden(phydev);
>      ...
> }
> 
> So this patch seems to cut the resync delay from about one phylib poll
> interval down to interrupt latency. It does not appear to close a
> correctness hole by itself. Could the wording be toned down?

Agreed. I will add a stable dependency annotation to the Patch 2 commit 
message:

   Cc: stable@vger.kernel.org # Prerequisite for LAN865X CDEN fix

This ensures stable tooling picks Patch 2 alongside Patch 3 and avoids
the OA_TC6_PHY_INT build failure you describe.

On the wording: agreed. The polling resync in lan86xx_read_status() from
Patch 1 already keeps CDEN correct. I will replace the "critical" 
sentence with:

"This reduces the CDEN resync latency from the phylib poll interval to 
interrupt latency, ensuring CDEN is updated promptly on each PLCA 
transition rather than waiting for the next read_status() poll."

>> @@ -348,7 +349,8 @@ static int lan865x_probe(struct spi_device *spi)
>>
>>        netdev->netdev_ops = &lan865x_netdev_ops;
>>
>> -     priv->tc6 = oa_tc6_init(spi, netdev, NULL);
>> +     tc6_quirks.quirk_flags = OA_TC6_PHY_INT;
>> +     priv->tc6 = oa_tc6_init(spi, netdev, &tc6_quirks);
> 
> [Severity: Medium]
> 
> With OA_TC6_PHY_INT set, phydev->irq becomes valid and phy_polling_mode()
> returns false. The periodic CDEN resync in lan86xx_read_status() then
> stops. From that point, does CDEN depend on every PHY interrupt getting
> through the oa_tc6 virtual IRQ path?
> 
> Two error branches in that path are not recovered. The first is in
> oa_tc6_phy_irq_work():
> 
> drivers/net/ethernet/oa_tc6.c:oa_tc6_phy_irq_work() {
>      ...
>          handle_nested_irq(tc6->phy_virq);
> 
>          ret = oa_tc6_phy_irq_unmask_hw(tc6);
>          if (ret)
>                  dev_err(&tc6->spi->dev, "Failed to unmask PHY interrupt: %d\n",
>                          ret);
> }
> 
> The INT_MASK0 read or write here can fail, for example with an SPI
> transfer error or -EPROTO from oa_tc6_check_ctrl_read_reply() or
> oa_tc6_check_ctrl_write_reply(). PHYINTM then stays set in hardware while
> the phy_irq_masked shadow says unmasked.
> 
> The second is in oa_tc6_process_extended_status():
> 
> drivers/net/ethernet/oa_tc6.c:oa_tc6_process_extended_status() {
>      ...
>          if (tc6->phy_virq && FIELD_GET(OA_TC6_STATUS0_PHY_INT, value)) {
>                  ret = oa_tc6_phy_irq_mask_hw(tc6);
>                  if (ret)
>                          dev_err(&tc6->spi->dev,
>                                  "Failed to mask PHY interrupt: %d\n", ret);
>                  else
>                          schedule_work(&tc6->phy_irq_work);
>          }
>      ...
> }
> 
> oa_tc6_phy_irq_mask_hw() can report an error even though its write
> reached the device. In that case the worker that would unmask is never
> scheduled.
> 
> In both cases, unmask_hw only runs again after a PHYINT is delivered.
> bus_sync_unlock only runs on genirq enable, disable or request.
> 
> Would PSTC interrupts then stop for good, with phylib no longer polling?
> lan86xx_update_cden() would not run again until the driver is rebound.
> 
> Before this patch, a transient SPI control error only delayed the resync
> until the next poll.

Both unrecovered paths are addressed by fixes in Patch 2:

1. unmask_hw() failure in oa_tc6_phy_irq_work(): the worker now calls 
schedule_work() on error, retrying until the SPI bus recovers. 
phy_irq_dispatched is cleared before the reschedule so the gate in 
oa_tc6_process_extended_status() can re-arm on the next SPI chunk if needed.

2. mask_hw() failure in oa_tc6_process_extended_status(): 
phy_irq_dispatched is cleared on mask_hw() failure, allowing the next 
SPI chunk to retry the full dispatch sequence (set flag -> mask_hw() -> 
schedule_work()).

Together these ensure the interrupt path self-recovers from transient
SPI errors without requiring a driver rebind or suspend/resume.

> 
>>        if (IS_ERR(priv->tc6)) {
>>                ret = PTR_ERR(priv->tc6);
>>                goto free_netdev;
> 
> [Severity: High]
> 
> This isn't a bug introduced by this patch, but there is a problem in the
> same driver. lan865x_remove() cancels the multicast work before it
> unregisters the netdev:
> 
> drivers/net/ethernet/microchip/lan865x/lan865x.c:lan865x_remove() {
>          ...
>          cancel_work_sync(&priv->multicast_work);
>          unregister_netdev(priv->netdev);
>          oa_tc6_exit(priv->tc6);
>          free_netdev(priv->netdev);
> }
> 
> At that point the netdev is still registered and may still be IFF_UP.
> lan865x uses the legacy rx-mode path, so __dev_set_rx_mode() calls
> ndo_set_rx_mode() synchronously:
> 
> __dev_set_rx_mode()
>      lan865x_set_multicast_list()
>          schedule_work(&priv->multicast_work);
> 
> Can a concurrent multicast join or promisc change re-queue the work in
> the window between cancel_work_sync() and unregister_netdev() clearing
> IFF_UP?
> 
> Nothing cancels the work a second time. oa_tc6_exit() frees tc6 and
> free_netdev() frees priv. lan865x_multicast_work_handler() would then
> dereference priv->netdev and priv->tc6 in freed memory.
> 
> remove() runs under device_lock rather than rtnl, so nothing serialises
> the two paths. Would moving cancel_work_sync() after unregister_netdev()
> close this window?

Yes. I will add a separate patch to fix this pre-existing issue:

   unregister_netdev(priv->netdev);
   cancel_work_sync(&priv->multicast_work);
   oa_tc6_exit(priv->tc6);
   free_netdev(priv->netdev);

unregister_netdev() clears IFF_UP, which prevents any further 
ndo_set_rx_mode() calls from re-queuing multicast_work. The subsequent
cancel_work_sync() then safely drains any work queued before IFF_UP was 
cleared.

Thanks,
Parthiban V

  reply	other threads:[~2026-12-01 13:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 12:49 [PATCH net-next RESEND v4 0/4] net: microchip_t1s: fix collision detection on PLCA status change Parthiban Veerasooran
2026-11-24 12:49 ` [PATCH net-next RESEND v4 1/4] net: phy: " Parthiban Veerasooran
2026-11-25 13:05   ` netdev-bot+sashiko
2026-11-27  5:23     ` Parthiban.Veerasooran
2026-12-01 13:55     ` Parthiban.Veerasooran
2026-11-24 12:49 ` [PATCH net-next RESEND v4 2/4] net: ethernet: oa_tc6: deliver the PHY interrupt to phylib Parthiban Veerasooran
2026-11-25 13:05   ` netdev-bot+sashiko
2026-12-01 13:55     ` Parthiban.Veerasooran
2026-11-24 12:49 ` [PATCH net-next RESEND v4 3/4] microchip: lan865x: enable PHY interrupt via virtual IRQ Parthiban Veerasooran
2026-11-25 13:05   ` netdev-bot+sashiko
2026-12-01 13:55     ` Parthiban.Veerasooran [this message]
2026-11-24 12:49 ` [PATCH net-next RESEND v4 4/4] net: phy: microchip_t1s: fix collision detection for LAN867X Rev.D0 Parthiban Veerasooran
2026-11-25 13:05   ` netdev-bot+sashiko
2026-12-01 13:55     ` Parthiban.Veerasooran
2026-11-24 12:52 ` [PATCH net-next RESEND v4 0/4] net: microchip_t1s: fix collision detection on PLCA status change netdev-bot+sinfo
2026-11-25  3:28   ` Parthiban.Veerasooran

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=b3162a47-e6ab-4dd6-b02b-1a2b9730097f@microchip.com \
    --to=parthiban.veerasooran@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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.