From patchwork Tue Jun 26 22:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10490247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5FAA4601A0 for ; Tue, 26 Jun 2018 22:24:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55108285B6 for ; Tue, 26 Jun 2018 22:24:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47A7A2870C; Tue, 26 Jun 2018 22:24:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C822D285B6 for ; Tue, 26 Jun 2018 22:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754736AbeFZWYu (ORCPT ); Tue, 26 Jun 2018 18:24:50 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:45022 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752793AbeFZWYt (ORCPT ); Tue, 26 Jun 2018 18:24:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1530051889; x=1561587889; h=from:to:cc:subject:date:message-id; bh=EljaDQInAbJHAtrqLmesZ6toRbcGI6VsLnqVd2MTLmA=; b=RmUqgHhLMj3M5ql99RqN13mPI2VEA6A3w1FDVGMd9gPoknP5fjy+b9FU kfCvloMvY/D8Pn4wi1P5lyJG+5Nx/dW9IPK7YpH5M7O2SVaZjYCIm0+50 HlfBDeOl5ci4MQNOK6k2M7d1tvxZWXPl5MJfnLHj0kbHj6DC/5/zSSenk EKrXUYCSqKiUVhmlQ0ns+UWMAG7jmxHLamWlAkTvvE7abHq7wDlGwlVBs wHJyzN07KhOisBS6wCOPEiV1OqCJUpEFMFCg7S8Giba4nyejPDZfT2VnC QKoRaIhgflQVcVyVNnmiWmT43YdRazNLTda/zgFoHYTe4lvg7hXIjoXPX A==; X-IronPort-AV: E=Sophos;i="5.51,276,1526313600"; d="scan'208";a="82579946" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 27 Jun 2018 06:24:49 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 26 Jun 2018 15:14:07 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Jun 2018 15:24:48 -0700 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , linux-rdma@vger.kernel.org, Bart Van Assche , Steve Wise , Christoph Hellwig , stable@vger.kernel.org Subject: [PATCH] IB/srpt: Support HCAs with more than two ports Date: Tue, 26 Jun 2018 15:24:48 -0700 Message-Id: <20180626222448.11411-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.17.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Bart Van Assche Cc: Steve Wise Cc: Christoph Hellwig Cc: Reviewed-by: Steve Wise --- 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; };