From: Ajit Kumar <Ajit.Kumar@amd.com>
To: <dev@dpdk.org>
Subject: [PATCH v2] net/axgbe: serialize PHY and link status access
Date: Tue, 17 Nov 2026 15:18:05 +0530 [thread overview]
Message-ID: <20261117094805.4134371-1-Ajit.Kumar@amd.com> (raw)
In-Reply-To: <20261112135611.2757325-1-Ajit.Kumar@amd.com>
From: Ajit Kumar <ajit.kumar@amd.com>
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 (-EAGAIN, -ENOTCONN, -ETIMEDOUT) and
incorrect link status reporting.
Add a driver-wide mutex taken before the per-port one, as the Linux
xgbe driver does (xgbe_phy_comm_lock), which this DPDK PMD lost when
its equivalent global lock became the per-port pdata->phy_mutex.
This fix applies to ports owned by a single process. If ports of the
same device are ever split across separate processes, or one port
stays with the kernel xgbe driver, the hardware mutex registers
remain the only arbitration between them; this is a pre-existing
limitation, not something this patch changes.
v2: dropped the per-port link_status_mutex and the retry-on-
-ENOTCONN/-ETIMEDOUT change from v1, per review (Stephen Hemminger):
- link_status_mutex only covered axgbe_dev_link_update() and not
axgbe_dev_interrupt_handler()'s AN ISR, which touches the same PHY/
link state without it, so it was incomplete protection for a race
that was never actually observed or validated, while the real,
validated cross-port race is already fully handled by the bus
mutex below. Removed, along with the struct member and its init.
- -ENOTCONN is an address NAK (IC_TX_ABRT_7B_ADDR_NOACK), not a bus-
contention symptom, and axgbe_i2c_xfer() already waits up to 1s
before returning -ETIMEDOUT, so retrying either while holding this
new driver-wide mutex can block every other port's link_update
behind it. Reverted axgbe_phy_i2c_read() to the existing -EAGAIN-
only retry; a separate fix for a different, non-contention I2C
failure mode will follow as its own patch with its own
justification and hardware validation.
Fixes: a5c7273771e8 ("net/axgbe: add phy programming APIs")
Cc: stable@dpdk.org
Signed-off-by: Ajit Kumar <ajit.kumar@amd.com>
---
drivers/net/axgbe/axgbe_phy_impl.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 4abf5fdea9..55d45bfb7b 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -605,9 +605,30 @@ static int axgbe_phy_sfp_get_mux(struct axgbe_port *pdata)
return axgbe_phy_i2c_xfer(pdata, &i2c_op);
}
+/*
+ * 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 reporting.
+ *
+ * Add a single, driver-wide mutex, taken before the per-port one and
+ * before the hardware XP_I2C_MUTEX/XP_MDIO_MUTEX acquire sequence, so
+ * that only one port in this process is ever inside that sequence at
+ * a time. This matches xgbe_phy_comm_lock in the Linux xgbe driver,
+ * which this DPDK PMD lost when its equivalent global lock became the
+ * per-port pdata->phy_mutex.
+ *
+ * This only arbitrates ports owned by this process. If ports of the
+ * same device are split across separate processes, or one port stays
+ * with the kernel xgbe driver, the hardware mutex registers remain
+ * the only arbitration between them.
+ */
+static pthread_mutex_t axgbe_i2c_mdio_bus_mutex = PTHREAD_MUTEX_INITIALIZER;
+
static void axgbe_phy_put_comm_ownership(struct axgbe_port *pdata)
{
pthread_mutex_unlock(&pdata->phy_mutex);
+ pthread_mutex_unlock(&axgbe_i2c_mdio_bus_mutex);
}
static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
@@ -616,6 +637,8 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
uint64_t timeout;
unsigned int mutex_id;
+ pthread_mutex_lock(&axgbe_i2c_mdio_bus_mutex);
+
/* The I2C and MDIO/GPIO bus is multiplexed between multiple devices,
* the driver needs to take the software mutex and then the hardware
* mutexes before being able to use the busses.
@@ -648,6 +671,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
}
pthread_mutex_unlock(&pdata->phy_mutex);
+ pthread_mutex_unlock(&axgbe_i2c_mdio_bus_mutex);
PMD_DRV_LOG_LINE(ERR, "unable to obtain hardware mutexes");
--
2.43.0
prev parent reply other threads:[~2026-11-18 9:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 13:56 [PATCH] net/axgbe: serialize PHY and link status access Ajit Kumar
2026-11-15 21:23 ` Stephen Hemminger
2026-11-17 9:48 ` Ajit Kumar [this message]
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=20261117094805.4134371-1-Ajit.Kumar@amd.com \
--to=ajit.kumar@amd.com \
--cc=dev@dpdk.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