[PATCH net-next 3/9] ptp: ocp: hand the TMC bus back once on an acquire timeout

From: Sagi Maimon

Date: Tue Sep 22 2026 - 10:38:57 EST


adva_x1_mblaze_acquire() ran the hand-back itself before returning
-ETIMEDOUT, and adva_x1_bus_claim() then called adva_x1_bus_release() for
the same error, which runs it again.

Both write MBLAZE_RELEASE and poll for the grant to drop for up to
MBLAZE_RETRIES * MBLAZE_RETRY_US, and both run with the i2c root adapter
lock held, so a single failed claim could hold the shared controller for
half as long again and log "TMC bus still granted after release" twice for
one failure.

Leave it to the release path, which the claim already calls.

Fixes: 3b815e29966f ("ptp: ocp: add TAP CPLD access for ADVA TimeCard X1")
Signed-off-by: Sagi Maimon <maimon.sagi@xxxxxxxxx>
---
drivers/ptp/ptp_ocp.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 510083dc750a..feb61355078a 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -4526,10 +4526,6 @@ static int adva_x1_mblaze_acquire(struct ptp_ocp *bp)
return 0;
}

- /* Drop the request we gave up on. Any error from the hand-back is
- * subsumed by the -ETIMEDOUT we are already returning.
- */
- adva_x1_mblaze_release(bp);
return -ETIMEDOUT;
}

@@ -4647,6 +4643,12 @@ static int adva_x1_bus_claim(struct ptp_ocp *bp)
i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
bp->cpld_adap = adap;

+ /* adva_x1_bus_release() runs the hand-back, so the acquire path does
+ * not do it itself: both poll for the grant to drop for up to
+ * MBLAZE_RETRIES * MBLAZE_RETRY_US with the adapter lock held, and
+ * doing it twice only holds the shared controller for longer and
+ * logs the same failure twice.
+ */
ret = adva_x1_mblaze_acquire(bp);
if (ret) {
adva_x1_bus_release(bp); /* keeps the acquire error */
--
2.47.0