Skip to contentSkip to conversation

RDMA/cxgb4: Unmap BAR2 when c4iw_rdev_open() fails

PATCH In review Serhat Kumral 3 participants 3 messages Nov 22 – Nov 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/cxgb4: Unmap BAR2 when c4iw_rdev_open() fails

c4iw_alloc() maps BAR2 on T5/T6 devices or its on-chip queue region on T4 devices. If c4iw_rdev_open() fails, c4iw_alloc() releases the IB device but leaves the mapping in place.

Unmap the mapped region before releasing the IB device.

Fixes c6d7b26791a2 ("RDMA/cxgb4: Support on-chip SQs")
Fixes fa658a98a2d0 ("RDMA/cxgb4: Use the BAR2/WC path for kernel QPs and T5 devices")
---
 drivers/infiniband/hw/cxgb4/device.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/infiniband/hw/cxgb4/device.c +4 -0
index 24ac9871ce67..35dacf379294 100644
@@ -1046,6 +1046,10 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop)
 	ret = c4iw_rdev_open(&devp->rdev);
 	if (ret) {
 		pr_err("Unable to open CXIO rdev err %d\n", ret);
+		if (devp->rdev.bar2_kva)
+			iounmap(devp->rdev.bar2_kva);
+		if (devp->rdev.oc_mw_kva)
+			iounmap(devp->rdev.oc_mw_kva);
 		ib_dealloc_device(&devp->ibdev);
 		return ERR_PTR(ret);
 	}
Signature · 1 line
2.53.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

c4iw_alloc() maps BAR2 on T5/T6 devices or its on-chip queue region on T4 devices. If c4iw_rdev_open() fails, c4iw_alloc() releases the IB device but leaves the mapping in place.

Unmap the mapped region before releasing the IB device.

Fixes c6d7b26791a2 ("RDMA/cxgb4: Support on-chip SQs")
Fixes fa658a98a2d0 ("RDMA/cxgb4: Use the BAR2/WC path for kernel QPs and T5 devices")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Serhat Kumral
Quoted 18 lines · Serhat Kumral

c4iw_alloc() maps BAR2 on T5/T6 devices or its on-chip queue region on T4 devices. If c4iw_rdev_open() fails, c4iw_alloc() releases the IB device but leaves the mapping in place.

Unmap the mapped region before releasing the IB device.

Fixes c6d7b26791a2 ("RDMA/cxgb4: Support on-chip SQs")
Fixes fa658a98a2d0 ("RDMA/cxgb4: Use the BAR2/WC path for kernel QPs and T5 devices")
---
 drivers/infiniband/hw/cxgb4/device.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/infiniband/hw/cxgb4/device.c +0 -0
index 24ac9871ce67..35dacf379294 100644

drivers/infiniband/hw/cxgb4/device.c static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop) · line 1054

Quoted 9 lines
drivers/infiniband/hw/cxgb4/device.c +4 -0
@@ -1046,6 +1046,10 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop)
 	ret = c4iw_rdev_open(&devp->rdev);
 	if (ret) {
 		pr_err("Unable to open CXIO rdev err %d\n", ret);
+		if (devp->rdev.bar2_kva)
+			iounmap(devp->rdev.bar2_kva);
+		if (devp->rdev.oc_mw_kva)
+			iounmap(devp->rdev.oc_mw_kva);
 		ib_dealloc_device(&devp->ibdev);
 		return ERR_PTR(ret);

You should refactor things so c4iw uses the

		device->ops.dealloc_driver(device);

Call and puts stuff like this in there

Existing c4iw_dealloc() is possibly close to what should be in the op.

Jason