From patchwork Sun Aug 1 09:20:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 12412861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C32E5C4338F for ; Sun, 1 Aug 2021 09:23:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F65461058 for ; Sun, 1 Aug 2021 09:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbhHAJXM (ORCPT ); Sun, 1 Aug 2021 05:23:12 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:55609 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231446AbhHAJXL (ORCPT ); Sun, 1 Aug 2021 05:23:11 -0400 IronPort-HdrOrdr: A9a23:OwFzqay8Krp2i7N1pzyEKrPwxr1zdoMgy1knxilNoRw8SK2lfqeV7ZMmPH7P+VAssR4b6LO90cW7Lk80lqQFhbX5X43SPjUO0VHAROoJgOffKlbbexEWmNQy6U4ZSdkaNDTvNykBse/KpBm/D807wMSKtIShheLlxX9rSg1wApsQlztRO0KKFFFsXglaCd4cHJqY3MBOoD2tYjA5dcK+b0N1JNTrlpnako78ex4aC1oC4AmKtzmh77n3CFy5834lIkpy/Ys= X-IronPort-AV: E=Sophos;i="5.84,286,1620662400"; d="scan'208";a="112191140" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 01 Aug 2021 17:22:53 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 8A2E64D0BA67; Sun, 1 Aug 2021 17:22:49 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Sun, 1 Aug 2021 17:22:50 +0800 Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Sun, 1 Aug 2021 17:22:50 +0800 Received: from FNSTPC.g08.fujitsu.local (10.167.226.45) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Sun, 1 Aug 2021 17:22:49 +0800 From: Li Zhijian To: , , , , CC: Li Zhijian Subject: [PATCH] RDMA/mlx5: return the EFAULT per ibv_advise_mr(3) Date: Sun, 1 Aug 2021 17:20:50 +0800 Message-ID: <20210801092050.6322-1-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 8A2E64D0BA67.AFA37 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@fujitsu.com Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org ibv_advise_mr(3) says: EFAULT In one of the following: o When the range requested is out of the MR bounds, or when parts of it are not part of the process address space. o One of the lkeys provided in the scatter gather list is invalid or with wrong write access Actually get_prefetchable_mr() will return NULL if it see above conditions Signed-off-by: Li Zhijian Reviewed-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/odp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c index d0d98e584ebc..8d2a626c87cf 100644 --- a/drivers/infiniband/hw/mlx5/odp.c +++ b/drivers/infiniband/hw/mlx5/odp.c @@ -1791,7 +1791,7 @@ static int mlx5_ib_prefetch_sg_list(struct ib_pd *pd, mr = get_prefetchable_mr(pd, advice, sg_list[i].lkey); if (!mr) - return -ENOENT; + return -EFAULT; ret = pagefault_mr(mr, sg_list[i].addr, sg_list[i].length, &bytes_mapped, pf_flags); if (ret < 0) {