diff mbox

IB/srpt: Support HCAs with more than two ports

Message ID 20180626222448.11411-1-bart.vanassche@wdc.com (mailing list archive)
State Superseded
Headers show

Commit Message

Bart Van Assche June 26, 2018, 10:24 p.m. UTC
Since there are adapters that have four ports, increase the size of
the srpt_device.port[] array. This patch avoids that the following
warning is hit with quad port Chelsio adapters:

    WARN_ON(sdev->device->phys_port_cnt > ARRAY_SIZE(sdev->port));

Reported-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Steve Wise <swise@opengridcomputing.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: <stable@vger.kernel.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 6 +++---
 drivers/infiniband/ulp/srpt/ib_srpt.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Steve Wise June 26, 2018, 11:10 p.m. UTC | #1
> Subject: [PATCH] IB/srpt: Support HCAs with more than two ports
> 
> Since there are adapters that have four ports, increase the size of
> the srpt_device.port[] array. This patch avoids that the following
> warning is hit with quad port Chelsio adapters:
> 
>     WARN_ON(sdev->device->phys_port_cnt > ARRAY_SIZE(sdev->port));
> 
> Reported-by: Steve Wise <swise@opengridcomputing.com>
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Steve Wise <swise@opengridcomputing.com>
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: <stable@vger.kernel.org>

Looks good.

Reviewed-by: Steve Wise <swise@opengridcomputing.com>



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 3081c629a7f7..50f4f9806ac6 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2969,10 +2969,12 @@  static void srpt_add_one(struct ib_device *device)
 
 	pr_debug("device = %p\n", device);
 
-	sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
+	sdev = kzalloc(sizeof(*sdev) + device->phys_port_cnt *
+		       sizeof(*sdev->port), GFP_KERNEL);
 	if (!sdev)
 		goto err;
 
+	sdev->port = (void *)(sdev + 1);
 	sdev->device = device;
 	mutex_init(&sdev->sdev_mutex);
 
@@ -3023,8 +3025,6 @@  static void srpt_add_one(struct ib_device *device)
 			      srpt_event_handler);
 	ib_register_event_handler(&sdev->event_handler);
 
-	WARN_ON(sdev->device->phys_port_cnt > ARRAY_SIZE(sdev->port));
-
 	for (i = 1; i <= sdev->device->phys_port_cnt; i++) {
 		sport = &sdev->port[i - 1];
 		INIT_LIST_HEAD(&sport->nexus_list);
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h
index 2361483476a0..b20ad6dbf966 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -410,7 +410,7 @@  struct srpt_device {
 	struct mutex		sdev_mutex;
 	bool			use_srq;
 	struct srpt_recv_ioctx	**ioctx_ring;
-	struct srpt_port	port[2];
+	struct srpt_port	*port;
 	struct ib_event_handler	event_handler;
 	struct list_head	list;
 };