From patchwork Mon Feb 25 16:45:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10828903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 379A61575 for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 256B329014 for ; Mon, 25 Feb 2019 16:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17F7B2B811; Mon, 25 Feb 2019 16:46:01 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 B5AD829014 for ; Mon, 25 Feb 2019 16:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728406AbfBYQp7 (ORCPT ); Mon, 25 Feb 2019 11:45:59 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58467 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728563AbfBYQp7 (ORCPT ); Mon, 25 Feb 2019 11:45:59 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 25 Feb 2019 18:45:55 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x1PGjtau003067; Mon, 25 Feb 2019 18:45:55 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id x1PGjtYW017016; Mon, 25 Feb 2019 18:45:55 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id x1PGjtk8017015; Mon, 25 Feb 2019 18:45:55 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, monis@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 2/3] verbs: Fix implicit ODP MR support for 32 bit systems Date: Mon, 25 Feb 2019 18:45:27 +0200 Message-Id: <1551113128-16917-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1551113128-16917-1-git-send-email-yishaih@mellanox.com> References: <1551113128-16917-1-git-send-email-yishaih@mellanox.com> 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 From: Moni Shoua One of the conditions to recognize an implicit ODP MR in kernel is having length of UINT64_MAX. Since the type of the parameter 'length' in ibv_reg_mr() is size_t which is 32 bit long, it is impossible for an application that runs on a 32 bit system to pass this value to the library. To solve this, let ibv_cmd_reg_mr() replace SIZE_MAX with UINT64_MAX when building the command to the kernel. On 64 bit systems this has no effect. On 32 bit systems set a value that the kernel understands as a request for implicit ODP MR. Signed-off-by: Moni Shoua Signed-off-by: Yishai Hadas --- libibverbs/cmd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index ec551e2..7bcaeea 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -336,6 +336,16 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length, cmd->start = (uintptr_t) addr; cmd->length = length; + /* On demand access and entire address space means implicit. + * In that case set the value in the command to what kernel expects. + */ + if (access & IBV_ACCESS_ON_DEMAND) { + if (length == SIZE_MAX && addr) + return EINVAL; + if (length == SIZE_MAX) + cmd->length = UINT64_MAX; + } + cmd->hca_va = hca_va; cmd->pd_handle = pd->handle; cmd->access_flags = access;