Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3020579rwb; Mon, 15 Aug 2022 16:17:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/Rz2f4KxzQQOHURnSXIH6YJ7AqaMYsdUXIMbTRVEkWmypTkqfuANjyjIIillK8BUAbNwv X-Received: by 2002:a17:902:cec1:b0:16d:c4f2:66c5 with SMTP id d1-20020a170902cec100b0016dc4f266c5mr19184255plg.20.1660605464107; Mon, 15 Aug 2022 16:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605464; cv=none; d=google.com; s=arc-20160816; b=nmsUwSCe26rojvQgxMrjHXX4x9XsK1Kp9MmmY3YEMx6aBs/scvuL6fkSXrG2zDzQBV FwIjbO5zVLQl3/RuYo8rDikOulhA5OySCdyWv5BKNLNdUm8/ppoA/n5chj4oX5iHLAwP oFRNphB6QS43Qn/7vq7gvwUx2IVuJW9A98RNfwziIgr/SRd5ysMEcItwu+nT9mvCzobs GBt58/w2G43Jh+LV3/RLa2+jHVqoYn//zvpgv+rMz02hTjumO/qytZdEMQoS9QzcZoho brrORLmcNd5Oub9W2J/qga8F5Nf7vMZeniabmQumN+LhoMWH5OAamcoRPwbQFtXxLSWT aAwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=16SF4uNf2m9ypCDSFpNPoSupx/fZckVuXXKoA4sv2gE=; b=jKJZv2qOwg8zy0lhtPnVJHdIAnRGeFiu5FlQTR4bwcqUtte1j4KFlH5KLb3v6Ci9Yg NyUVeYoTCIHa1hRKSP81UnRx2D74R0uJsH+2wuWoeIAeEYJ5rtPxpdJD/ozr5lv3KaOr wsvVWYntXaT5kvNJmYWQ+1RcLtjV293iFAAFIxU2WjPoILXYjuAZKE7EyjmmWeR13d0A FnoWr9ZCxsJaJYflyZ8sQVSoUufsNNW1dTHbFNlfAV0e7Q/c94HwdL5yr5vY/O3AfFlp XhtwVjD18fZ/v+z9vzZZBlSwHExzlCSaO5SXV6GzSi4BZGNsqPY7QL1miY0xKBBvAcPs jJjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QwrQcloQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 203-20020a6300d4000000b0041aee1c45f6si10724590pga.504.2022.08.15.16.17.33; Mon, 15 Aug 2022 16:17:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QwrQcloQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346855AbiHOWWJ (ORCPT + 99 others); Mon, 15 Aug 2022 18:22:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350351AbiHOWRq (ORCPT ); Mon, 15 Aug 2022 18:17:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85A34108978; Mon, 15 Aug 2022 12:40:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E1E2AB80EA9; Mon, 15 Aug 2022 19:40:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3516DC433C1; Mon, 15 Aug 2022 19:40:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592448; bh=l4lXvZEXXOSETi6/YJDc4cxoVT+OkLmsyME2xliMa0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QwrQcloQWQtISI9tpJjMxSny0+k6ATNzQyZHzIHeM84WfGf3uOc8HbAhWZ9k6sHYt Y10vNV7aq8oPkXWybSx3gjy6RsMxYI4dap+Xts7aGUOX3wU4yTXst01l50RDqUp8R/ xoqfulMeoFa2B8AIPKIBZHq076d51yz5VGz0ERBM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Md Haris Iqbal , Bob Pearson , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.18 0788/1095] RDMA/rxe: For invalidate compare according to set keys in mr Date: Mon, 15 Aug 2022 20:03:07 +0200 Message-Id: <20220815180501.846579817@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Md Haris Iqbal [ Upstream commit 174e7b137042f19b5ce88beb4fc0ff4ec6b0c72a ] The 'rkey' input can be an lkey or rkey, and in rxe the lkey or rkey have the same value, including the variant bits. So, if mr->rkey is set, compare the invalidate key with it, otherwise compare with the mr->lkey. Since we already did a lookup on the non-varient bits to get this far, the check's only purpose is to confirm that the wqe has the correct variant bits. Fixes: 001345339f4c ("RDMA/rxe: Separate HW and SW l/rkeys") Link: https://lore.kernel.org/r/20220707073006.328737-1-haris.phnx@gmail.com Signed-off-by: Md Haris Iqbal Reviewed-by: Bob Pearson Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_loc.h | 2 +- drivers/infiniband/sw/rxe/rxe_mr.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index 2ffbe3390668..2b0edf360474 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -77,7 +77,7 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, enum rxe_mr_lookup_type type); int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); -int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey); +int rxe_invalidate_mr(struct rxe_qp *qp, u32 key); int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe); int rxe_mr_set_page(struct ib_mr *ibmr, u64 addr); int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata); diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index 60a31b718774..76d6498e83f9 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -576,22 +576,22 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, return mr; } -int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey) +int rxe_invalidate_mr(struct rxe_qp *qp, u32 key) { struct rxe_dev *rxe = to_rdev(qp->ibqp.device); struct rxe_mr *mr; int ret; - mr = rxe_pool_get_index(&rxe->mr_pool, rkey >> 8); + mr = rxe_pool_get_index(&rxe->mr_pool, key >> 8); if (!mr) { - pr_err("%s: No MR for rkey %#x\n", __func__, rkey); + pr_err("%s: No MR for key %#x\n", __func__, key); ret = -EINVAL; goto err; } - if (rkey != mr->rkey) { - pr_err("%s: rkey (%#x) doesn't match mr->rkey (%#x)\n", - __func__, rkey, mr->rkey); + if (mr->rkey ? (key != mr->rkey) : (key != mr->lkey)) { + pr_err("%s: wr key (%#x) doesn't match mr key (%#x)\n", + __func__, key, (mr->rkey ? mr->rkey : mr->lkey)); ret = -EINVAL; goto err_drop_ref; } -- 2.35.1