[SRU][Q:linux-gcp][PATCH 3/6] RDMA/irdma: Remove fixed 1 ms delay during AH wait loop
Ian Whitfield
ian.whitfield at canonical.com
Wed Mar 25 23:21:46 UTC 2026
From: Jacob Moroni <jmoroni at google.com>
BugLink: https://bugs.launchpad.net/bugs/2146168
The AH CQP command wait loop executes in an atomic context and was
using a fixed 1 ms delay. Since many AH create commands can complete
much faster than 1 ms, use poll_timeout_us_atomic with a 1 us delay.
Also, use the timeout value indicated during the capability exchange
rather than a hard-coded value.
Signed-off-by: Jacob Moroni <jmoroni at google.com>
Link: https://patch.msgid.link/20260105180550.2907858-1-jmoroni@google.com
Signed-off-by: Leon Romanovsky <leon at kernel.org>
(cherry picked from commit 5c3f795d17dc57a58a1fc1c1b449812e26ad85a3)
Signed-off-by: Ian Whitfield <ian.whitfield at canonical.com>
---
drivers/infiniband/hw/irdma/main.h | 2 ++
drivers/infiniband/hw/irdma/utils.c | 2 +-
drivers/infiniband/hw/irdma/verbs.c | 16 ++++++++--------
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/infiniband/hw/irdma/main.h b/drivers/infiniband/hw/irdma/main.h
index 65ce4924dbfa..c5336b26e730 100644
--- a/drivers/infiniband/hw/irdma/main.h
+++ b/drivers/infiniband/hw/irdma/main.h
@@ -23,6 +23,7 @@
#include <linux/workqueue.h>
#include <linux/slab.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/crc32c.h>
#include <linux/kthread.h>
#ifndef CONFIG_64BIT
@@ -528,6 +529,7 @@ void irdma_cq_wq_destroy(struct irdma_pci_f *rf, struct irdma_sc_cq *cq);
void irdma_srq_event(struct irdma_sc_srq *srq);
void irdma_srq_wq_destroy(struct irdma_pci_f *rf, struct irdma_sc_srq *srq);
void irdma_cleanup_pending_cqp_op(struct irdma_pci_f *rf);
+int irdma_get_timeout_threshold(struct irdma_sc_dev *dev);
int irdma_hw_modify_qp(struct irdma_device *iwdev, struct irdma_qp *iwqp,
struct irdma_modify_qp_info *info, bool wait);
int irdma_qp_suspend_resume(struct irdma_sc_qp *qp, bool suspend);
diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c
index b6c4ccf38eb7..a1d9ebe4f731 100644
--- a/drivers/infiniband/hw/irdma/utils.c
+++ b/drivers/infiniband/hw/irdma/utils.c
@@ -572,7 +572,7 @@ void irdma_cleanup_pending_cqp_op(struct irdma_pci_f *rf)
}
}
-static int irdma_get_timeout_threshold(struct irdma_sc_dev *dev)
+int irdma_get_timeout_threshold(struct irdma_sc_dev *dev)
{
u16 time_s = dev->vc_caps.cqp_timeout_s;
diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index 6c3e1e8cea94..5e098215d1c0 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -5019,15 +5019,15 @@ static int irdma_create_hw_ah(struct irdma_device *iwdev, struct irdma_ah *ah, b
}
if (!sleep) {
- int cnt = CQP_COMPL_WAIT_TIME_MS * CQP_TIMEOUT_THRESHOLD;
+ const u64 tmout_ms = irdma_get_timeout_threshold(&rf->sc_dev) *
+ CQP_COMPL_WAIT_TIME_MS;
- do {
- irdma_cqp_ce_handler(rf, &rf->ccq.sc_cq);
- mdelay(1);
- } while (!ah->sc_ah.ah_info.ah_valid && --cnt);
-
- if (!cnt) {
- ibdev_dbg(&iwdev->ibdev, "VERBS: CQP create AH timed out");
+ if (poll_timeout_us_atomic(irdma_cqp_ce_handler(rf,
+ &rf->ccq.sc_cq),
+ ah->sc_ah.ah_info.ah_valid, 1,
+ tmout_ms * USEC_PER_MSEC, false)) {
+ ibdev_dbg(&iwdev->ibdev,
+ "VERBS: CQP create AH timed out");
err = -ETIMEDOUT;
goto err_ah_create;
}
--
2.43.0
More information about the kernel-team
mailing list