Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp147110lqk; Sat, 9 Mar 2024 04:29:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVC94ouClB26/phM72Qj8bmO57JN1uUWVjkYSV5/pZoD3t1Vguh1uDR3OsoJ00xF05+GVyF9C1L9H4tYRO0Y3+7HbyqLBCGDm3NefaKjQ== X-Google-Smtp-Source: AGHT+IFC2hClzkydkXN/7fRq3lIGGUPXolYdB2zsz87mHyYC1XqEFYBJkxu0AFPn4srOkFUP25Kc X-Received: by 2002:a05:6512:2316:b0:512:f59d:7612 with SMTP id o22-20020a056512231600b00512f59d7612mr1326614lfu.57.1709987384108; Sat, 09 Mar 2024 04:29:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709987384; cv=pass; d=google.com; s=arc-20160816; b=KXa/mkZfIuzKuxPuppYHcRdskqjqltZ9l7l7fJi0uQ4uaNJLJ/1tMp2Urdi/I2zF2v BdglbnlabgZr7erm9GH+U2d0ZYUuLUMoN/HNcqNoA6QKK4uOL/SfCaQAEgZMkvJnntpA ZrghN38sSOG6Qeu2R294qp9en7TZ/ItyeUOz4K9jfywD1/Sz/ntH/GVPMQmKbyaBJQm1 2cXnbQRc39lBoiSYBRXO9E8ktUCUmacxAhnU/h5SwCcd/gz0EMJj+HMG82nWsGWQPSxz ldap9le6ffxRJKW6uIsiDqtzzriUirRPL9nuIRFX4IjbZoW8rXS9NsySohAVsrjk4DwI jiDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:subject:cc:to:from :message-id:dkim-signature; bh=XEGyaJ+kCmmZhZFVWlD1MMdKR2X8OhuRS+vIOPo518c=; fh=I648NRffxoTt01kSSzOqSf2KL7cs8AG4fxddI+tSkdc=; b=miEvOQB1P21e4Asg2iGAnTT0fzOlJSCSN2cl+L3pHwGSiPEQrWUO84yeKT/3HT/EAO n9kteoJBRezO53gMneLCr4p0tgHhEl0NItIBd/pJ55Q/kOHBO4jQV/sNs84g63kDwykJ Ko0C4SAskHO7pFhxdyt8S5RiMYej2ih/E7+ds8YuE+d6qG9HM2SsB5+c+7zLYb/DxNIB znKui6FkslklWQBd4tWSQ0fvHWHWlHJHdZzxxKtyMdjc+YY4XYS/Tp4RpAxXDb9ED9Nf 2WIOxKeDgVdgmgj79KcpkzjkhpDlb33hCgyIRs+HUWzqDr6jnvGn7v+NkUBSPGLRMAIf Dkyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=Hg6Y2d6t; arc=pass (i=1 spf=pass spfdomain=qq.com dkim=pass dkdomain=qq.com dmarc=pass fromdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-97886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u22-20020aa7d896000000b00567f50ff747si744413edq.598.2024.03.09.04.29.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 04:29:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=Hg6Y2d6t; arc=pass (i=1 spf=pass spfdomain=qq.com dkim=pass dkdomain=qq.com dmarc=pass fromdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-97886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97886-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CE8071F216E1 for ; Sat, 9 Mar 2024 12:29:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06EF03A267; Sat, 9 Mar 2024 12:27:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="Hg6Y2d6t" Received: from out203-205-251-59.mail.qq.com (out203-205-251-59.mail.qq.com [203.205.251.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 596F9383B5; Sat, 9 Mar 2024 12:27:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.205.251.59 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709987274; cv=none; b=Ngv1T/lRWTNy3CoGC6f1Y0iTzN1L2AGTD9K/g1jUAn2rzxbQg7R502zWlu6M3LfPBABtY00tSnwpLaw50XoTsuxHK1aq9SO+ved2LRJTjmN6qrHJzDRvxTbzZUWwwej/hxPON5IxhIaEPwFg1Qd8w8f2PLuHT1fLrT0kw6YyEjI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709987274; c=relaxed/simple; bh=yyHJI+i8YTw2Aotpj/dejaVqSVyw4wQdRc2NjI1BysY=; h=Message-ID:From:To:Cc:Subject:Date:MIME-Version; b=NGYL2WXALSxQ8H7oSqSq4QHXIumhcSOAmd56+Ug9Ku5zL+Dz7aVinzMg9kv2FPiErQ9KZoIvolqkMrigFPvQTNij6lo3WZUmu1mPcQkKOGXOYLwQddhmIBWGW2lPlR+GWbrY2+8CN7nntURX0PsfmmK9+AX2NvpktLQ0ukGE20I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b=Hg6Y2d6t; arc=none smtp.client-ip=203.205.251.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1709987258; bh=XEGyaJ+kCmmZhZFVWlD1MMdKR2X8OhuRS+vIOPo518c=; h=From:To:Cc:Subject:Date; b=Hg6Y2d6tTpKXk51dBycFCehLr9RpYTOLkpALRSlUcu69losoh/YqtPTyoiAamGDZV kMXJhVIlZFZDG8zgiQR1tiuD0dDiJv+rjv6ofM7X3GlCRE5nnqhcWN++bNksfE5aEi sx5nGerzAadhHBF3qB8r6BCAnENNqqaLsqgPqprE= Received: from localhost.localdomain ([58.213.8.163]) by newxmesmtplogicsvrszb9-1.qq.com (NewEsmtp) with SMTP id 6E4874DF; Sat, 09 Mar 2024 20:27:36 +0800 X-QQ-mid: xmsmtpt1709987256tzodkmkla Message-ID: X-QQ-XMAILINFO: MmPNY57tR1XnXVRJMLsi2St93kTXMHZDv9XOtN6QXUCt17MhWfoztaSxFUWTti NGvIQO/0OK+86B+DaF94LQqsTOQTyeDowjon/yqBcs7fVBZ8Tiaf5RPqRzLtJ7CQK/wIanfFqKiD oZc47qHOQEEtTbpi6nyR5uMziAJJPjYrwhR9YbaEoXwUcvHieGse+IFlvinsw12hTFtL5Sq6ZxUc aRNH1lIEO6KKQoZ7xnIY+i1gwqD62/SFUFRzLWgt+rmSnQ0qUWSKtj1UQPDW4goRts/hABqws1Us ZdZ+oWk9RSl9cs7n40nGMELoz/+H0awRebUJT05j5hQE/WzZSW+JlqRHgh3S6aLNKtUTWC5OML9u CpI8TjizY3U0btH6WACG4I5GGHtvqRt96+AOzRdhQksXNdpAp/dNHPGzsqTLmSwljMEe2hljE6Ro 9dWr+4KUXIVBXg5ZSgGus//CxhXykO25w7fWMNBQSBrflOb5fCmo2SIRi4wSEDoBXQvDa9Uz7/7J P7ZvM5mzOggv08Xr7QX4P2uVHLgW4W9b/PK+hijvVvUFbIYbK5f/6Da2aHgguk2oEEMo5v/+9Rcg NJn+Q4qPQbmDNxffzt1eWfBk7N71qY2yWvczxaw+wGq+X9bLr+KplQZaKuD/tTXk+45OZGjBTh0d pPzZwXUz9bi1AkXClQcohAQSWg+sJX+sLvso7epWO0IjiVILPmaAUCRt/038hs6X5MNHQP/9T1M7 GCYHt8pqNkitiL7ave3mLZWUUS7afJrurhtz6Hwv7+gZUEMC7pFjKOjAq4+MqSoBvq4axQNDQhQi NzI7fnXlFAcBUapiuMao3Dt71hau7LlPNpqbvhTVe2a1C74rw0iurPuJIBAbhn7AD0u0q4F+aJG8 H5HJE4C3Pkzxe93HGvrMHT352G5m31xd+DTMv3M5FjQVka6guH1/8CyOQ6124U6yjdLmiLT2wnVI rz54xqcXRjRL3v9WvtRYA+/Fcmp5x0X2SvjVvVfgh2qcpQsoQ6xqOW/LPbLv4xQFaQGqWlqf3Fa7 4YToBChTCecAk2TSnO9hSId6HVLS30t/nhVqGfpxnW6QuVQNjPpsoVJ84DTZwnlAYZLKFBHQ== X-QQ-XMRINFO: NyFYKkN4Ny6FSmKK/uo/jdU= From: linke li To: Cc: lilinke99@qq.com, Bernard Metzler , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] RDMA/siw: Reuse value read using READ_ONCE instead of re-reading it Date: Sat, 9 Mar 2024 20:27:16 +0800 X-OQ-MSGID: <20240309122717.54920-1-lilinke99@qq.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In siw_orqe_start_rx, the orqe's flag in the if condition is read using READ_ONCE, checked, and then re-read, voiding all guarantees of the checks. Reuse the value that was read by READ_ONCE to ensure the consistency of the flags throughout the function. Signed-off-by: linke li --- drivers/infiniband/sw/siw/siw_qp_rx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c index ed4fc39718b4..f5f69de56882 100644 --- a/drivers/infiniband/sw/siw/siw_qp_rx.c +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c @@ -740,6 +740,7 @@ static int siw_orqe_start_rx(struct siw_qp *qp) { struct siw_sqe *orqe; struct siw_wqe *wqe = NULL; + u16 orqe_flags; if (unlikely(!qp->attrs.orq_size)) return -EPROTO; @@ -748,7 +749,8 @@ static int siw_orqe_start_rx(struct siw_qp *qp) smp_mb(); orqe = orq_get_current(qp); - if (READ_ONCE(orqe->flags) & SIW_WQE_VALID) { + orqe_flags = READ_ONCE(orqe->flags); + if (orqe_flags & SIW_WQE_VALID) { /* RRESP is a TAGGED RDMAP operation */ wqe = rx_wqe(&qp->rx_tagged); wqe->sqe.id = orqe->id; @@ -756,7 +758,7 @@ static int siw_orqe_start_rx(struct siw_qp *qp) wqe->sqe.sge[0].laddr = orqe->sge[0].laddr; wqe->sqe.sge[0].lkey = orqe->sge[0].lkey; wqe->sqe.sge[0].length = orqe->sge[0].length; - wqe->sqe.flags = orqe->flags; + wqe->sqe.flags = orqe_flags; wqe->sqe.num_sge = 1; wqe->bytes = orqe->sge[0].length; wqe->processed = 0; -- 2.39.3 (Apple Git-146)