[PATCH 0/9] RDMA/hfi2: Sync with upstream hfi1 fixes and cleanups

Dennis Dalessandro <[email protected]> Mon, 03 Aug 2026 12:10:52 -0400
Newsgroups org.kernel.vger.linux-rdma
Message-ID <178577337105.1793053.12662894969464495064.stgit@awdrv-04>
This series ports relevant upstream fixes from hfi1 to the new hfi2 driver.
Since the original hfi2 submission, several fixes and cleanups have landed
upstream for hfi1, primarily focused on PCI probe error unwinding and
resource management.

This patch series adapts the applicable fixes for the hfi2 architecture.
The modifications in this series are based on the following upstream hfi1
commits:

1. 091c6162c022 ("RDMA/hfi1: Propagate sdma_txinit_ahg() errors")
2. 2e3809ad8911 ("RDMA/hfi1: Preserve unit 0 on allocation failure")
3. d43b1c17f9e1 ("RDMA/hfi1: Stop flushing the global IB workqueue")
4. 22113f3f55a1 ("RDMA/hfi1: Remove redundant NULL checks in create_workqueues()")
5. 76b48a70b16b ("IB/hfi1: Fix potential use-after-free in PIO and SDMA map teardown")
6. b9cb5e81f7d9 ("RDMA/hfi1: Pass PCI device to hfi1_pcie_init()")
7. 4ebd241071af ("RDMA/hfi1: Drop device data from hfi1_validate_rcvhdrcnt()")
8. 9f674ba674a0 ("RDMA/hfi1: Allocate device data after PCI initialization")
9. bb18740b302f ("RDMA/hfi1: Initialize debugfs after probe completes")
10. e26c48cf23a4 ("RDMA/hfi1: Align probe error unwinding with device removal")
11. adc09d7fbbb9 ("RDMA: Remove outdated comments referencing hfi1_destroy_qp()")

We performed a deep-dive analysis of Leon Romanovsky's 12-commit "clean
init one hfi1" series to determine applicability to hfi2. Commits 6-10
above are the members of that series that apply to hfi2's
probe/error-unwind path; because they interlock (each depends on the
pdev-based signatures and reordering introduced by the others), they are
folded into a single "Align probe error unwinding with device removal"
patch in this series rather than being split 1:1.

The following upstream hfi1 commits from that same series were analyzed and
deemed NOT APPLICABLE for hfi2:
- af9117d02f50 ("RDMA/hfi1: Remove redundant PCI device ID validation"):
  Not applicable. The check is not redundant in hfi2 as it does chip_params
  dispatch mapping between wfr_params/jkr_params.
  - 0d5618c1b2fc ("RDMA/hfi1: Create workqueues before device
  initialization"): Moot. hfi2 already implements this correct ordering.
- 8e17e101e04a ("RDMA/hfi1: Free RX data on late probe failure"): Moot.
  hfi2 already frees RX data transitively via cleanup_device_data().
- 9bab31776ae6 ("RDMA/hfi1: Defer device creation until probe succeeds"):
  Not applicable. hfi2 has no legacy char-device creation to defer; it uses
  standard IB core device registration only.
- 297b5b747a0a ("RDMA/hfi1: Remove unused non-user-accessible device
  class"): Not applicable. hfi2 does not contain the device.c/device.h
  files or any class/cdev registration of this kind.

We also evaluated 56521f587704 ("IB/hfi1: kzalloc to kzalloc_flex") for
applicability. In hfi1 this combines a struct's separate psets kcalloc
allocation into a single kzalloc_flex() call using a trailing flexible
array member. In hfi2, struct tid_user_buf is embedded as a non-trailing
member of larger per-backend wrapper structs (e.g. struct
system_tid_user_buf in tid_system.c), so a trailing flexible array member
cannot be added to tid_user_buf itself without a broader multi-backend
restructuring. We are treating this as not applicable to hfi2's current
architecture rather than porting it as-is.

---

Dennis Dalessandro (9):
      RDMA/hfi2: Propagate sdma_txinit_ahg() errors in user_sdma.c
      RDMA/hfi2: Preserve unit 0 on allocation failure
      RDMA/hfi2: Stop flushing global IB workqueue
      RDMA/hfi2: Remove redundant NULL checks in create_workqueues()
      RDMA/hfi2: Fix use-after-free in PIO and SDMA map teardown
      RDMA/hfi2: Pass PCI device to hfi2_pcie_init()
      RDMA/hfi2: Drop device data from hfi2_validate_rcvhdrcnt()
      RDMA/hfi2: Align probe error unwinding with device removal
      RDMA/hfi2: Remove stale hfi2_destroy_qp() comment


 drivers/infiniband/hw/hfi2/chip.c      |  14 +-
 drivers/infiniband/hw/hfi2/chip.h      |   2 +-
 drivers/infiniband/hw/hfi2/hfi2.h      |   3 +-
 drivers/infiniband/hw/hfi2/init.c      | 183 +++++++++++--------------
 drivers/infiniband/hw/hfi2/pcie.c      |  22 +--
 drivers/infiniband/hw/hfi2/pio.c       |   4 +-
 drivers/infiniband/hw/hfi2/qp.c        |   1 -
 drivers/infiniband/hw/hfi2/sdma.c      |   4 +-
 drivers/infiniband/hw/hfi2/user_sdma.c |   8 +-
 9 files changed, 114 insertions(+), 127 deletions(-)

--
-Denny