Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3094061rwb; Mon, 15 Aug 2022 17:59:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR6RDaODtcLXSbuc43abcnxQ/cbJxIByiLMKwUk1iEg0zs+66eRqUOFH76JFbBz+ORS1hUhP X-Received: by 2002:aa7:cd51:0:b0:440:595d:aeed with SMTP id v17-20020aa7cd51000000b00440595daeedmr16656035edw.143.1660611557520; Mon, 15 Aug 2022 17:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611557; cv=none; d=google.com; s=arc-20160816; b=ql8d4d0m+tsS8w3swbIZjseTF64sfpUYVBThgpoDiOsLuk+nskOn9HSNGWMuRXYyP2 ySsyrxC6QiGGHdUBIANak7mZcFoRk/kfBLPZsiLnApT+IFIlkuMflGq/WG/bvJOt6nOv CVgtQoDu9VEFbFwZYlN2LstYXgM+WpMQ9mgV5GmHVjDMzPETHWH53kswrbRaBAMcYLPE srAqLGPkmg1nFJkjF/YoSAT/3IRRBa07ST4NRNMRbv5EFyDs9O5x/SS30VlJ2S8vik9S qDpR0MJzAwIp5oOOmtx8vNrj4Xq4lP39eMODXpwKu3Qh0RKxOnvWFH5VSKrg2x865ScW Gzew== 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=gds+4YVf1BMmhx0bnybN/eU+WA1Mvu0j4g1CMI/ZRuY=; b=PzpBnf05oLslIFXofq5WlIMzlr7zMjjymSQNhaWr4oUxhOv5ko5gS3OOHi4UO1t9QK kTawmvvjXFxRTufCi8hsL4u3kG6JiNzQa9rgtCVaYgFG/tloYmvHJydlgTyWKzESQ/gV HBH9Hbad/yD0h4GFJZi44AgQ4FJ4nZHVfgAksodvPNmyT+26mWleYVfVU+YdBuxMHBaI DU2m21FJKyRcmUyDgbpqs2uCJ5NJH9dH6jb7iRNghx/Z9PI6RubgmbzoFnWjBR5Dkd2J XWLHgHh/tHEw+HLyDtcNMYNT7rJ+df7c5MphBbdOt0fmNoyDPvdQErV4VnIZFlGRvF7l tp1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tQ2VBzoU; 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 bk19-20020a170906b0d300b00730951e6030si7995686ejb.188.2022.08.15.17.58.51; Mon, 15 Aug 2022 17:59:17 -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=tQ2VBzoU; 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 S1343624AbiHPAbt (ORCPT + 99 others); Mon, 15 Aug 2022 20:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348329AbiHPAaC (ORCPT ); Mon, 15 Aug 2022 20:30:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 144CA18348F; Mon, 15 Aug 2022 13:35:30 -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 526F3B81197; Mon, 15 Aug 2022 20:34:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 888CBC433C1; Mon, 15 Aug 2022 20:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595692; bh=IDIwAkQQ1rgpwdaDGimBIwi8KjFH42GBtfyya8ZSpmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tQ2VBzoUrUSaO73WQtV9hc+91HexVSaJYdP3cuFnvacsGSh69H4EPS0PLwF/PGh3E FbtjLGqRITlSQGx/OPGzOXttDgN+m/KGEwPIzowgvJ0ZR5z+POpG5ffwLfO2dQ5LTH 86n2t4U/kjuSCx1qKvPegX730mtVAe/m3VLjz2Yk= 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.19 0845/1157] RDMA/rxe: For invalidate compare according to set keys in mr Date: Mon, 15 Aug 2022 20:03:21 +0200 Message-Id: <20220815180513.307964974@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 0e022ae1b8a5..37484a559d20 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 fc3942e04a1f..3add52129006 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