|
|
764884 |
From 2f6e9cb2087508d29bf525f652136ea23a007bc6 Mon Sep 17 00:00:00 2001
|
|
|
764884 |
From: Honggang Li <honli@redhat.com>
|
|
|
764884 |
Date: Fri, 7 Feb 2020 10:25:31 +0800
|
|
|
764884 |
Subject: [PATCH] ibacm: Do not open non InfiniBand device
|
|
|
764884 |
|
|
|
764884 |
For dual port HCA, which has an InfiniBand port and an Ethernet port,
|
|
|
764884 |
only open InfiniBand port will introduce segment fault issues.
|
|
|
764884 |
|
|
|
764884 |
Because the Ethernet port did not open yet, segment fault when active
|
|
|
764884 |
the Ethernet port. The second segment fault issue happens when there
|
|
|
764884 |
is asyn event on the Ethernet port.
|
|
|
764884 |
|
|
|
764884 |
We should skip pure iWARP or RoCE devices, but not device which has at
|
|
|
764884 |
least one InfiniBand port.
|
|
|
764884 |
|
|
|
764884 |
Fixes: e9ffc0b3b940 ("ibacm: only open InfiniBand port")
|
|
|
764884 |
Signed-off-by: Honggang Li <honli@redhat.com>
|
|
|
764884 |
---
|
|
|
764884 |
ibacm/src/acm.c | 47 ++++++++++++++++++++++++++---------------------
|
|
|
764884 |
1 file changed, 26 insertions(+), 21 deletions(-)
|
|
|
764884 |
|
|
|
764884 |
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
|
|
|
764884 |
index ad313075c7bb..283620338c9d 100644
|
|
|
764884 |
--- a/ibacm/src/acm.c
|
|
|
764884 |
+++ b/ibacm/src/acm.c
|
|
|
764884 |
@@ -2604,7 +2604,7 @@ static void acm_open_dev(struct ibv_device *ibdev)
|
|
|
764884 |
struct ibv_context *verbs;
|
|
|
764884 |
size_t size;
|
|
|
764884 |
int i, ret;
|
|
|
764884 |
- unsigned int opened_ib_port_cnt = 0;
|
|
|
764884 |
+ bool has_ib_port = false;
|
|
|
764884 |
|
|
|
764884 |
acm_log(1, "%s\n", ibdev->name);
|
|
|
764884 |
verbs = ibv_open_device(ibdev);
|
|
|
764884 |
@@ -2619,6 +2619,27 @@ static void acm_open_dev(struct ibv_device *ibdev)
|
|
|
764884 |
goto err1;
|
|
|
764884 |
}
|
|
|
764884 |
|
|
|
764884 |
+ for (i = 0; i < attr.phys_port_cnt; i++) {
|
|
|
764884 |
+ ret = ibv_query_port(verbs, i + 1, &port_attr);
|
|
|
764884 |
+ if (ret) {
|
|
|
764884 |
+ acm_log(0, "ERROR - ibv_query_port (%s, %d) return (%d)\n",
|
|
|
764884 |
+ ibdev->name, i + 1, ret);
|
|
|
764884 |
+ continue;
|
|
|
764884 |
+ }
|
|
|
764884 |
+
|
|
|
764884 |
+ if (port_attr.link_layer == IBV_LINK_LAYER_INFINIBAND) {
|
|
|
764884 |
+ acm_log(1, "%s port %d is an InfiniBand port\n", ibdev->name, i + 1);
|
|
|
764884 |
+ has_ib_port = true;
|
|
|
764884 |
+ } else {
|
|
|
764884 |
+ acm_log(1, "%s port %d is not an InfiniBand port\n", ibdev->name, i + 1);
|
|
|
764884 |
+ }
|
|
|
764884 |
+ }
|
|
|
764884 |
+
|
|
|
764884 |
+ if (!has_ib_port) {
|
|
|
764884 |
+ acm_log(1, "%s does not support InfiniBand.\n", ibdev->name);
|
|
|
764884 |
+ goto err1;
|
|
|
764884 |
+ }
|
|
|
764884 |
+
|
|
|
764884 |
size = sizeof(*dev) + sizeof(struct acmc_port) * attr.phys_port_cnt;
|
|
|
764884 |
dev = (struct acmc_device *) calloc(1, size);
|
|
|
764884 |
if (!dev)
|
|
|
764884 |
@@ -2630,29 +2651,13 @@ static void acm_open_dev(struct ibv_device *ibdev)
|
|
|
764884 |
list_head_init(&dev->prov_dev_context_list);
|
|
|
764884 |
|
|
|
764884 |
for (i = 0; i < dev->port_cnt; i++) {
|
|
|
764884 |
- acm_log(1, "%s port %d\n", ibdev->name, i + 1);
|
|
|
764884 |
- ret = ibv_query_port(dev->device.verbs, i + 1, &port_attr);
|
|
|
764884 |
- if (ret) {
|
|
|
764884 |
- acm_log(0, "ERROR - ibv_query_port (%d)\n", ret);
|
|
|
764884 |
- continue;
|
|
|
764884 |
- }
|
|
|
764884 |
- if (port_attr.link_layer != IBV_LINK_LAYER_INFINIBAND) {
|
|
|
764884 |
- acm_log(1, "not an InfiniBand port\n");
|
|
|
764884 |
- continue;
|
|
|
764884 |
- }
|
|
|
764884 |
-
|
|
|
764884 |
acm_open_port(&dev->port[i], dev, i + 1);
|
|
|
764884 |
- opened_ib_port_cnt++;
|
|
|
764884 |
}
|
|
|
764884 |
|
|
|
764884 |
- if (opened_ib_port_cnt) {
|
|
|
764884 |
- list_add(&dev_list, &dev->entry);
|
|
|
764884 |
- acm_log(1, "%d InfiniBand %s opened for %s\n",
|
|
|
764884 |
- opened_ib_port_cnt,
|
|
|
764884 |
- opened_ib_port_cnt == 1 ? "port" : "ports",
|
|
|
764884 |
- ibdev->name);
|
|
|
764884 |
- return;
|
|
|
764884 |
- }
|
|
|
764884 |
+ list_add(&dev_list, &dev->entry);
|
|
|
764884 |
+
|
|
|
764884 |
+ acm_log(1, "%s opened\n", ibdev->name);
|
|
|
764884 |
+ return;
|
|
|
764884 |
|
|
|
764884 |
err1:
|
|
|
764884 |
ibv_close_device(verbs);
|
|
|
764884 |
--
|
|
|
764884 |
2.24.1
|
|
|
764884 |
|