On Thu, 12 Nov 2026 19:26:11 +0530 Ajit Kumar <[email protected]> wrote:
> From: Ajit Kumar <[email protected]> > > Concurrent link status polling and PHY access can result in > simultaneous I2C/MDIO bus transactions. On systems with multiple > AXGBE ports this may lead to I2C transfer failures such as > -EAGAIN, -ENOTCONN, or -ETIMEDOUT and can cause incorrect link > status reporting. > > Serialize access to shared PHY communication resources by > protecting PHY status updates and introducing a mutex around > I2C/MDIO ownership acquisition. Also add retry delays for > recoverable I2C transfer failures. > > Signed-off-by: Ajit Kumar <[email protected]> > --- AI found some issues that still need addressing before merge Subject: Re: [PATCH] net/axgbe: serialize PHY and link status access The global axgbe_i2c_mdio_bus_mutex is the right fix; it matches xgbe_phy_comm_lock in the Linux xgbe driver, which DPDK lost when the global lock became the per-port pdata->phy_mutex. The other two changes do not belong with it as written. Warning 1. link_status_mutex does nothing useful. It is per-port and only taken in axgbe_dev_link_update(). It cannot serialize bus access between ports (the problem in the commit message); the new bus mutex already does that inside axgbe_phy_get_comm_ownership(). It is also not taken by axgbe_dev_interrupt_handler() -> an_isr, the only other path touching PHY/AN state. Two concurrent link_update calls on the same port are control-vs-control, which ethdev does not promise to make safe. If they can happen, the lock must cover the ISR too; if not, there is no point in it. Drop the mutex, the struct member and the init. 2. Retrying -ETIMEDOUT and -ENOTCONN. axgbe_i2c_xfer() already waits up to 1 s before returning -ETIMEDOUT. One retry doubles that per phase, and it now happens with the global bus mutex held, so every other port's link_update blocks behind it. -ENOTCONN is an address NAK (IC_TX_ABRT_7B_ADDR_NOACK), meaning nothing answered at that target, not bus contention. If the bus mutex fixes the concurrent access, these errors should not occur any more, and retrying them hides a different fault. Keep the -EAGAIN (arbitration lost) retry only, or explain in the commit message what still causes the other two after serialization. In the second hunk "ret &&" is redundant, and the closing brace in the first hunk is indented one level too shallow: if (ret) { if (ret == -EAGAIN && retry--) { rte_delay_ms(AXGBE_I2C_RETRY_DELAY_MS); goto again1; } return ret; } ... if (ret == -EAGAIN && retry--) { rte_delay_ms(AXGBE_I2C_RETRY_DELAY_MS); goto again2; } 3. Missing Fixes and stable tags. The per-port lock dates from the initial PHY code: Fixes: a5c7273771e8 ("net/axgbe: add phy programming APIs") Cc: [email protected] Info 4. The static mutex only covers ports in one process. When ports of the same device belong to different DPDK processes, or one port stays with the kernel xgbe driver, the only arbitration is the hardware mutex. axgbe_phy_get_comm_ownership() writes AXGBE_MUTEX_RELEASE to XP_I2C_MUTEX/XP_MDIO_MUTEX unconditionally before acquiring, which can take ownership away from the other agent. This bug is older than the patch, but the commit message should say the fix applies to ports in a single process. 5. Suggested commit message body, once 1 and 2 are addressed: The I2C and MDIO buses are shared by all ports on the device. axgbe_phy_get_comm_ownership() takes the per-port phy_mutex, which does not stop two ports in the same process from using the bus at once, causing I2C failures and wrong link status. Add a driver-wide mutex taken before the per-port one, as the Linux xgbe driver does.

