* [PATCH] IB/srpt: Support HCAs with more than two ports
@ 2018-06-26 22:24 Bart Van Assche
2018-06-26 23:10 ` Steve Wise
2018-06-29 16:20 ` Jason Gunthorpe
0 siblings, 2 replies; 6+ messages in thread
From: Bart Van Assche @ 2018-06-26 22:24 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Doug Ledford, linux-rdma, Bart Van Assche, Steve Wise,
Christoph Hellwig, stable
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(-)
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;
};
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH] IB/srpt: Support HCAs with more than two ports
2018-06-26 22:24 [PATCH] IB/srpt: Support HCAs with more than two ports Bart Van Assche
@ 2018-06-26 23:10 ` Steve Wise
2018-06-29 16:20 ` Jason Gunthorpe
1 sibling, 0 replies; 6+ messages in thread
From: Steve Wise @ 2018-06-26 23:10 UTC (permalink / raw)
To: 'Bart Van Assche', 'Jason Gunthorpe'
Cc: 'Doug Ledford', linux-rdma, 'Christoph Hellwig',
stable
> 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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] IB/srpt: Support HCAs with more than two ports
2018-06-26 22:24 [PATCH] IB/srpt: Support HCAs with more than two ports Bart Van Assche
2018-06-26 23:10 ` Steve Wise
@ 2018-06-29 16:20 ` Jason Gunthorpe
2018-06-29 16:32 ` Bart Van Assche
1 sibling, 1 reply; 6+ messages in thread
From: Jason Gunthorpe @ 2018-06-29 16:20 UTC (permalink / raw)
To: Bart Van Assche
Cc: Doug Ledford, linux-rdma, Steve Wise, Christoph Hellwig, stable
On Tue, Jun 26, 2018 at 03:24:48PM -0700, Bart Van Assche wrote:
> 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(-)
Can we write it this way instead? More typesafe.
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 1b0b285a0ae021..36d9fab7c99800 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2970,7 +2970,8 @@ static void srpt_add_one(struct ib_device *device)
pr_debug("device = %p\n", device);
- sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
+ sdev = kzalloc(struct_size(sdev, port, device->phys_port_cnt),
+ GFP_KERNEL);
if (!sdev)
goto err;
@@ -3024,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 2361483476a025..444dfd7281b5fe 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -396,9 +396,9 @@ struct srpt_port {
* @sdev_mutex: Serializes use_srq changes.
* @use_srq: Whether or not to use SRQ.
* @ioctx_ring: Per-HCA SRQ.
- * @port: Information about the ports owned by this HCA.
* @event_handler: Per-HCA asynchronous IB event handler.
* @list: Node in srpt_dev_list.
+ * @port: Information about the ports owned by this HCA.
*/
struct srpt_device {
struct ib_device *device;
@@ -410,9 +410,9 @@ struct srpt_device {
struct mutex sdev_mutex;
bool use_srq;
struct srpt_recv_ioctx **ioctx_ring;
- struct srpt_port port[2];
struct ib_event_handler event_handler;
struct list_head list;
+ struct srpt_port port[];
};
#endif /* IB_SRPT_H */
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] IB/srpt: Support HCAs with more than two ports
2018-06-29 16:20 ` Jason Gunthorpe
@ 2018-06-29 16:32 ` Bart Van Assche
2018-06-29 17:20 ` Jason Gunthorpe
0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2018-06-29 16:32 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Doug Ledford, linux-rdma@vger.kernel.org, Steve Wise,
Christoph Hellwig, stable@vger.kernel.org
On 06/29/18 09:21, Jason Gunthorpe wrote:
> On Tue, Jun 26, 2018 at 03:24:48PM -0700, Bart Van Assche wrote:
>> 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(-)
>
> Can we write it this way instead? More typesafe.
Hello Jason,
The patch you posted looks fine to me. Do you want me to add your
Signed-off-by after I have retested this patch when I repost it?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] IB/srpt: Support HCAs with more than two ports
2018-06-29 16:32 ` Bart Van Assche
@ 2018-06-29 17:20 ` Jason Gunthorpe
2018-06-29 20:16 ` Bart Van Assche
0 siblings, 1 reply; 6+ messages in thread
From: Jason Gunthorpe @ 2018-06-29 17:20 UTC (permalink / raw)
To: Bart Van Assche
Cc: Doug Ledford, linux-rdma@vger.kernel.org, Steve Wise,
Christoph Hellwig, stable@vger.kernel.org
On Fri, Jun 29, 2018 at 09:32:42AM -0700, Bart Van Assche wrote:
> On 06/29/18 09:21, Jason Gunthorpe wrote:
> >On Tue, Jun 26, 2018 at 03:24:48PM -0700, Bart Van Assche wrote:
> >>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(-)
> >
> >Can we write it this way instead? More typesafe.
>
> Hello Jason,
>
> The patch you posted looks fine to me. Do you want me to add your
> Signed-off-by after I have retested this patch when I repost it?
If you can retest it today just send me a note and I'll use it as
posted, otherwise yes please.
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] IB/srpt: Support HCAs with more than two ports
2018-06-29 17:20 ` Jason Gunthorpe
@ 2018-06-29 20:16 ` Bart Van Assche
0 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2018-06-29 20:16 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Doug Ledford, linux-rdma@vger.kernel.org, Steve Wise,
Christoph Hellwig, stable@vger.kernel.org
On 06/29/18 10:20, Jason Gunthorpe wrote:
> If you can retest it today just send me a note and I'll use it as
> posted, otherwise yes please.
Hello Jason,
The patch you posted works fine on my test setup.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-06-29 20:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-26 22:24 [PATCH] IB/srpt: Support HCAs with more than two ports Bart Van Assche
2018-06-26 23:10 ` Steve Wise
2018-06-29 16:20 ` Jason Gunthorpe
2018-06-29 16:32 ` Bart Van Assche
2018-06-29 17:20 ` Jason Gunthorpe
2018-06-29 20:16 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).