[PATCH rdma-next 09/13] RDMA/hfi1: Remove redundant NULL checks in create_workqueues()

From: Leon Romanovsky

Date: Wed Jul 08 2026 - 06:49:23 EST


From: Leon Romanovsky <leonro@xxxxxxxxxx>

create_workqueues() is called only from init_one(), immediately after
hfi1_alloc_devdata() returns a zero-initialized hfi1_devdata. As a
result, the per-port hfi1_wq and link_wq pointers are always NULL on
entry, and nothing modifies them between allocation and this call.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
---
drivers/infiniband/hw/hfi1/init.c | 56 ++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 33 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
index 0545180b5a11..ae30f6dd944c 100644
--- a/drivers/infiniband/hw/hfi1/init.c
+++ b/drivers/infiniband/hw/hfi1/init.c
@@ -738,31 +738,27 @@ static int create_workqueues(struct hfi1_devdata *dd)

for (pidx = 0; pidx < dd->num_pports; ++pidx) {
ppd = dd->pport + pidx;
- if (!ppd->hfi1_wq) {
- ppd->hfi1_wq =
- alloc_workqueue(
- "hfi%d_%d",
- WQ_SYSFS | WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM |
- WQ_PERCPU,
- HFI1_MAX_ACTIVE_WORKQUEUE_ENTRIES,
- dd->unit, pidx);
- if (!ppd->hfi1_wq)
- goto wq_error;
- }
- if (!ppd->link_wq) {
- /*
- * Make the link workqueue single-threaded to enforce
- * serialization.
- */
- ppd->link_wq =
- alloc_workqueue(
- "hfi_link_%d_%d",
- WQ_SYSFS | WQ_MEM_RECLAIM | WQ_UNBOUND,
- 1, /* max_active */
- dd->unit, pidx);
- if (!ppd->link_wq)
- goto wq_error;
- }
+ ppd->hfi1_wq =
+ alloc_workqueue(
+ "hfi%d_%d",
+ WQ_SYSFS | WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM |
+ WQ_PERCPU,
+ HFI1_MAX_ACTIVE_WORKQUEUE_ENTRIES,
+ dd->unit, pidx);
+ if (!ppd->hfi1_wq)
+ goto wq_error;
+ /*
+ * Make the link workqueue single-threaded to enforce
+ * serialization.
+ */
+ ppd->link_wq =
+ alloc_workqueue(
+ "hfi_link_%d_%d",
+ WQ_SYSFS | WQ_MEM_RECLAIM | WQ_UNBOUND,
+ 1, /* max_active */
+ dd->unit, pidx);
+ if (!ppd->link_wq)
+ goto wq_error;
}
return 0;
wq_error:
@@ -1658,14 +1654,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
for (pidx = 0; pidx < dd->num_pports; ++pidx) {
hfi1_quiet_serdes(dd->pport + pidx);
ppd = dd->pport + pidx;
- if (ppd->hfi1_wq) {
- destroy_workqueue(ppd->hfi1_wq);
- ppd->hfi1_wq = NULL;
- }
- if (ppd->link_wq) {
- destroy_workqueue(ppd->link_wq);
- ppd->link_wq = NULL;
- }
+ destroy_workqueue(ppd->hfi1_wq);
+ destroy_workqueue(ppd->link_wq);
}
if (!j)
hfi1_device_remove(dd);

--
2.54.0