From patchwork Fri Feb 10 23:56:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9567619 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 7E7F5602B6 for ; Fri, 10 Feb 2017 23:56:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67B1B285D2 for ; Fri, 10 Feb 2017 23:56:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B2F4285F3; Fri, 10 Feb 2017 23:56:31 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 00146285D2 for ; Fri, 10 Feb 2017 23:56:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751452AbdBJX41 (ORCPT ); Fri, 10 Feb 2017 18:56:27 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:53437 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751326AbdBJX4V (ORCPT ); Fri, 10 Feb 2017 18:56:21 -0500 X-IronPort-AV: E=Sophos;i="5.33,348,1477929600"; d="scan'208";a="83251610" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 11 Feb 2017 07:56:18 +0800 Received: from MILHUBIP03.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 9B.5A.57638.2235E985; Fri, 10 Feb 2017 15:56:18 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Fri, 10 Feb 2017 15:56:14 -0800 X-AuditID: 0ac94369-26dee9800001e126-51-589e5322f974 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 6F.A4.11415.F135E985; Fri, 10 Feb 2017 15:56:15 -0800 (PST) From: Bart Van Assche To: Doug Ledford CC: , Bart Van Assche , Israel Rukshin , Max Gurtovoy , Laurence Oberman Subject: [PATCH 6/8] IB/srp: Use the IB_DEVICE_SG_GAPS_REG HCA feature if supported Date: Fri, 10 Feb 2017 15:56:09 -0800 Message-ID: <20170210235611.3243-7-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170210235611.3243-1-bart.vanassche@sandisk.com> References: <20170210235611.3243-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRmVeSWpSXmKPExsXCddJ5ka5S8LwIg8tfjSxenv/AanFj8VoW i2eHelkszn94xWRx+tEBdgdWj2fTDzN5vN93lc3j8ya5AOYoLpuU1JzMstQifbsEroxNR7qY Ck6LVxxvWMjcwHhbqIuRk0NCwERiZc8zRhBbSGApk8TstbpdjFxA9g5GiY9H1jPBFL3acJUd IrGZUeLtgYssIAk2ASOJb+9ngtkiAmoSm14tAitiFjjMKPH++2ywscICwRLTXxwEs1kEVCVu vf4OZvMK2EksPLkKaoO8xK62i6wgNqeAvcT3ZdNYIU6yk3jz9RMryFAJgS5Wid+HmtkgmgUl Ts58AraZWUBC4uCLF8wQDeoSJ5fMZ5rAKDQLSdksJGULGJlWMYrlZuYU56anFhia6hUn5qVk FmfrJefnbmKEBHfmDsa7T7wPMQpwMCrx8CYcnxshxJpYVlyZe4hRgoNZSYQ3yXVehBBvSmJl VWpRfnxRaU5q8SFGaQ4WJXHeczJTI4QE0hNLUrNTUwtSi2CyTBycUg2MDGePKlgtr1V5Gub6 RfPBv2N5ocLsZicL2BXPi79627IqdePxL688O7OaZ7gbT9Aoqiw4G9v9N93yxc58leV1QZsq yo75m7AxmfTWuMwv3ivRI6Fx0jXZ3c0rs97C/mOke/uLF0uU86ftVp7CUFC1431bpVHEhcUn 5VntF7yteR3TIXV9irMSS3FGoqEWc1FxIgB0+fj4agIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGJMWRmVeSWpSXmKPExsXCtZEjRVc+eF6Ewes+RouDP9sYLV6e/8Bq cWPxWhaLZ4d6WSzOf3jFZHH60QF2BzaPZ9MPM3m833eVzWPamvNMHp83yQWwRHHZpKTmZJal FunbJXBlbDrSxVRwWrzieMNC5gbG20JdjJwcEgImEq82XGXvYuTiEBLYyCjRe/cvE0iCTcBI 4tv7mSwgtoiAmsSmV4vYQWxmgaOMEnM+coPYwgLBEtNfHGQEsVkEVCVuvf4OZvMK2EksetXH DLFAXmJX20VWEJtTwF7i+7JpYLYQUM2br59YJzByL2BkWMUolpuZU5ybnllgaKhXnJiXklmc rZecn7uJERwSnJE7GJ9OND/EyMTBKdXAGDptrXjS/CNO/zfK3fwcvf3Kdani/Z3f7Vb0vfq1 YE2AQ8pVHp6Wp8Jn1R/IzygRmiv4QW7dktyWWb8fLrmb1zy577jiFr5Zc3qE96k/Ssj+0Pr5 1PJlrzP/71S7dSpon93N+MWfPNVrHFfJJQkbG7XtcSjbz9n9NfX0frN/jVtLXtaY3MzvXKzE UpyRaKjFXFScCABRBsyNuQEAAA== MIME-Version: 1.0 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 If a HCA supports the SG_GAPS_REG feature then a single memory region of type IB_MR_TYPE_SG_GAPS is sufficient. This patch reduces the number of memory regions that is allocated per SRP session. Signed-off-by: Bart Van Assche Cc: Israel Rukshin Cc: Max Gurtovoy Cc: Laurence Oberman --- drivers/infiniband/ulp/srp/ib_srp.c | 43 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 87efb702b1c6..2f85255d2aca 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3356,25 +3356,34 @@ static ssize_t srp_create_target(struct device *dev, } if (srp_dev->use_fast_reg || srp_dev->use_fmr) { - /* - * FR and FMR can only map one HCA page per entry. If the - * start address is not aligned on a HCA page boundary two - * entries will be used for the head and the tail although - * these two entries combined contain at most one HCA page of - * data. Hence the "+ 1" in the calculation below. - * - * The indirect data buffer descriptor is contiguous so the - * memory for that buffer will only be registered if - * register_always is true. Hence add one to mr_per_cmd if - * register_always has been set. - */ + bool gaps_reg = (ibdev->attrs.device_cap_flags & + IB_DEVICE_SG_GAPS_REG); + max_sectors_per_mr = srp_dev->max_pages_per_mr << (ilog2(srp_dev->mr_page_size) - 9); - mr_per_cmd = register_always + - (target->scsi_host->max_sectors + 1 + - max_sectors_per_mr - 1) / max_sectors_per_mr; - pr_debug("max_sectors = %u; max_pages_per_mr = %u; mr_page_size = %u; max_sectors_per_mr = %u; mr_per_cmd = %u\n", - target->scsi_host->max_sectors, + if (!gaps_reg) { + /* + * FR and FMR can only map one HCA page per entry. If + * the start address is not aligned on a HCA page + * boundary two entries will be used for the head and + * the tail although these two entries combined + * contain at most one HCA page of data. Hence the "+ + * 1" in the calculation below. + * + * The indirect data buffer descriptor is contiguous + * so the memory for that buffer will only be + * registered if register_always is true. Hence add + * one to mr_per_cmd if register_always has been set. + */ + mr_per_cmd = register_always + + (target->scsi_host->max_sectors + 1 + + max_sectors_per_mr - 1) / max_sectors_per_mr; + mr_per_cmd = max(2U, mr_per_cmd); + } else { + mr_per_cmd = 1; + } + pr_debug("IB_DEVICE_SG_GAPS_REG = %d; max_sectors = %u; max_pages_per_mr = %u; mr_page_size = %u; max_sectors_per_mr = %u; mr_per_cmd = %u\n", + gaps_reg, target->scsi_host->max_sectors, srp_dev->max_pages_per_mr, srp_dev->mr_page_size, max_sectors_per_mr, mr_per_cmd); }