Skip to content

Commit e620ebf

Browse files
KAGA-KOKOjgunthorpe
authored andcommitted
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 <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Cc: Steve Wise <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: <[email protected]> Reviewed-by: Steve Wise <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 6834844 commit e620ebf

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

drivers/infiniband/ulp/srpt/ib_srpt.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,8 @@ static void srpt_add_one(struct ib_device *device)
29702970

29712971
pr_debug("device = %p\n", device);
29722972

2973-
sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
2973+
sdev = kzalloc(struct_size(sdev, port, device->phys_port_cnt),
2974+
GFP_KERNEL);
29742975
if (!sdev)
29752976
goto err;
29762977

@@ -3024,8 +3025,6 @@ static void srpt_add_one(struct ib_device *device)
30243025
srpt_event_handler);
30253026
ib_register_event_handler(&sdev->event_handler);
30263027

3027-
WARN_ON(sdev->device->phys_port_cnt > ARRAY_SIZE(sdev->port));
3028-
30293028
for (i = 1; i <= sdev->device->phys_port_cnt; i++) {
30303029
sport = &sdev->port[i - 1];
30313030
INIT_LIST_HEAD(&sport->nexus_list);

drivers/infiniband/ulp/srpt/ib_srpt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ struct srpt_port {
396396
* @sdev_mutex: Serializes use_srq changes.
397397
* @use_srq: Whether or not to use SRQ.
398398
* @ioctx_ring: Per-HCA SRQ.
399-
* @port: Information about the ports owned by this HCA.
400399
* @event_handler: Per-HCA asynchronous IB event handler.
401400
* @list: Node in srpt_dev_list.
401+
* @port: Information about the ports owned by this HCA.
402402
*/
403403
struct srpt_device {
404404
struct ib_device *device;
@@ -410,9 +410,9 @@ struct srpt_device {
410410
struct mutex sdev_mutex;
411411
bool use_srq;
412412
struct srpt_recv_ioctx **ioctx_ring;
413-
struct srpt_port port[2];
414413
struct ib_event_handler event_handler;
415414
struct list_head list;
415+
struct srpt_port port[];
416416
};
417417

418418
#endif /* IB_SRPT_H */

0 commit comments

Comments
 (0)