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