Blame SOURCES/0001-ibacm-Do-not-open-non-InfiniBand-device.patch

dd836b
From 9ecb459f5bb442174189f25e9ce6c59d66b5b943 Mon Sep 17 00:00:00 2001
dd836b
From: Honggang Li <honli@redhat.com>
dd836b
Date: Tue, 4 Feb 2020 09:01:11 +0800
dd836b
Subject: [PATCH] ibacm: Do not open non InfiniBand device
dd836b
dd836b
For dual port HCA, which has an InfiniBand port and an Ethernet port,
dd836b
only open InfiniBand port will introduce segment fault issues.
dd836b
dd836b
Because the Ethernet port did not open yet, segment fault when active
dd836b
the Ethernet port. The second segment fault issue happens when there
dd836b
is asyn event on the Ethernet port.
dd836b
dd836b
We should skip pure iWARP or RoCE devices, but not device which has at
dd836b
least one InfiniBand port.
dd836b
dd836b
Signed-off-by: Honggang Li <honli@redhat.com>
dd836b
---
dd836b
 ibacm/src/acm.c | 22 ++++++++++++++++++++++
dd836b
 1 file changed, 22 insertions(+)
dd836b
dd836b
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
dd836b
index 1aa08f4b..77828d8c 100644
dd836b
--- a/ibacm/src/acm.c
dd836b
+++ b/ibacm/src/acm.c
dd836b
@@ -2600,9 +2600,11 @@ static void acm_open_dev(struct ibv_device *ibdev)
dd836b
 {
dd836b
 	struct acmc_device *dev;
dd836b
 	struct ibv_device_attr attr;
dd836b
+	struct ibv_port_attr port_attr;
dd836b
 	struct ibv_context *verbs;
dd836b
 	size_t size;
dd836b
 	int i, ret;
dd836b
+	bool has_ib_port = false;
dd836b
 
dd836b
 	acm_log(1, "%s\n", ibdev->name);
dd836b
 	verbs = ibv_open_device(ibdev);
dd836b
@@ -2617,6 +2619,26 @@ static void acm_open_dev(struct ibv_device *ibdev)
dd836b
 		goto err1;
dd836b
 	}
dd836b
 
dd836b
+	for (i = 0; i < attr.phys_port_cnt; i++) {
dd836b
+		ret = ibv_query_port(verbs, i + 1, &port_attr);
dd836b
+		if (ret) {
dd836b
+			acm_log(0, "ERROR - ibv_query_port (%s, %d) return (%d)\n",
dd836b
+				ibdev->name, i + 1, ret);
dd836b
+			continue;
dd836b
+		}
dd836b
+
dd836b
+		if (port_attr.link_layer == IBV_LINK_LAYER_INFINIBAND) {
dd836b
+			acm_log(1, "%s port %d is an InfiniBand port\n", ibdev->name, i);
dd836b
+			has_ib_port = true;
dd836b
+		} else
dd836b
+			acm_log(1, "%s port %d is not an InfiniBand port\n", ibdev->name, i);
dd836b
+	}
dd836b
+
dd836b
+	if (!has_ib_port) {
dd836b
+		acm_log(1, "%s does not support InfiniBand.\n", ibdev->name);
dd836b
+		goto err1;
dd836b
+	}
dd836b
+
dd836b
 	size = sizeof(*dev) + sizeof(struct acmc_port) * attr.phys_port_cnt;
dd836b
 	dev = (struct acmc_device *) calloc(1, size);
dd836b
 	if (!dev)
dd836b
-- 
dd836b
2.24.1
dd836b