Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp426054rwr; Wed, 3 May 2023 00:11:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Gpe5fTXAnW1PKasxQw+0sEFOgHaJOlon+kqM27k8Qwv6gUrHJHxhq8r9q/GL/avrHb89/ X-Received: by 2002:a17:902:7c8d:b0:1a9:765c:77ac with SMTP id y13-20020a1709027c8d00b001a9765c77acmr1177416pll.7.1683097862129; Wed, 03 May 2023 00:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683097862; cv=none; d=google.com; s=arc-20160816; b=iiD4aUBw6ituKcpqrFgJLNTHkheuHy4U7bAriTheAJd1NQsUHFKA0kTsSUNjA9Ar8v 7pERHVyfPC78zXHZAo4xhsIT9wRJjZupnEBtaZqhveTmKndbjRcOeVR5AUZnSk8PkAEM 3awCD62X1y2gtdDKTvuGgKus0+Tipl6lXZ4+bN+yvXII5xokbnBfkd5MvhrOmuxl0+CP ux2+ZrKBXdauCBClBZfrRNp/zMvUpdLBWLD17TdaTfOFAygf+FaT8g0Ne6zxYuXAT4eV A+Wt7gisE13xtohtIQR3E8SjkmTyS21jYELInbXcJMvKYWrbNbH3PMD9j/AYAfkk0Rga mFOQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jw7FfDLMGTKpgSF5ca1sdut6Rpkx65gv2wVX/lQRlLQ=; b=jwngCKLyfQq89NG478arzm19GUuaLC+FKgplW29qMiiaSeAJ3pqaLXeAJ/y80J2aJc b0t2hrNgAMSaoABLXm03b4jVBH4xU7ndmUI+dT+7z4XArMtzepkOvIbN1cYHUH0WR4ax r4KdP5+arBglEcCkgC0duq4IfSkZyRZ/ZWUNaxeHy40bqwb2AzCV7/+bIC/pPd7ec2p6 sXvOsvEkAiHVMXiT7F2q+LCICw1X+j/EYXaFy06ezLYkMP1u10C+eVotvGZOM7M6I6TW 7gcNC0ubL/ThfjOetnmnIii32GFehI6WppTir+sT8eVHoYm21LNW+RMRTwLQE+KB5aMw vPlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=c7uFZC9e; 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=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a170902bc4700b001aaea258805si8235390plz.134.2023.05.03.00.10.46; Wed, 03 May 2023 00:11:02 -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=@marvell.com header.s=pfpt0220 header.b=c7uFZC9e; 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=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbjECHK0 (ORCPT + 99 others); Wed, 3 May 2023 03:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjECHKV (ORCPT ); Wed, 3 May 2023 03:10:21 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CF1340FD; Wed, 3 May 2023 00:10:15 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34369xss003337; Wed, 3 May 2023 00:10:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=jw7FfDLMGTKpgSF5ca1sdut6Rpkx65gv2wVX/lQRlLQ=; b=c7uFZC9ejNA8rmTM8RFX3PhIwYPS0Sru1ymFJmHttqwGrpJ2PjU04hCFWn/Kk+La4CbN w7MgtWvuq8l+NCtJaFKS3ZXs03Oe6FwxvU1sfP7MdDzo/FvBgjrgT9JYp8cKyZhikTo3 Xj+7lte1GHQH/vSbKdCDaEbyVpcX5LEm/qgPHHaJjFlPDkTF4k44oFvEKxrcQs5H4aBT tgC26KlYxzjK/o2bz26W2hvggp7USS5Cw4hP02SVv27Xjumltd3qxjU8JmlzV2PwWo3O 8X0orTwR6pd6AcSfVH3h+iW49ReyrmC8WSdGJhNDhq0qII0BV2Aly/uls+swu4mxHyXi mA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3q92rp3m6s-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 03 May 2023 00:09:59 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 3 May 2023 00:09:56 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 3 May 2023 00:09:55 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id C67A73F707B; Wed, 3 May 2023 00:09:51 -0700 (PDT) From: Sai Krishna To: , , , , , , , , , , , , , CC: Sai Krishna Subject: [net PATCH v5 01/11] octeontx2-af: Secure APR table update with the lock Date: Wed, 3 May 2023 12:39:34 +0530 Message-ID: <20230503070944.960190-2-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230503070944.960190-1-saikrishnag@marvell.com> References: <20230503070944.960190-1-saikrishnag@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: D_1w4CZRsf0yk7a9uvP9KixEeLBlDBtm X-Proofpoint-GUID: D_1w4CZRsf0yk7a9uvP9KixEeLBlDBtm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-03_04,2023-04-27_01,2023-02-09_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: Geetha sowjanya APR table contains the lmtst base address of PF/VFs. These entries are updated by the PF/VF during the device probe. The lmtst address is fetched from HW using "TXN_REQ" and "ADDR_RSP_STS" registers. The lock tries to protect these registers from getting overwritten when multiple PFs invokes rvu_get_lmtaddr() simultaneously. For example, if PF1 submit the request and got permitted before it reads the response and PF2 got scheduled submit the request then the response of PF1 is overwritten by the PF2 response. Fixes: 893ae97214c3 ("octeontx2-af: cn10k: Support configurable LMTST regions") Signed-off-by: Geetha sowjanya Signed-off-by: Sunil Kovvuri Goutham Signed-off-by: Sai Krishna Reviewed-by: Simon Horman --- .../net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c index 4ad9ff025c96..0e74c5a2231e 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c @@ -60,13 +60,14 @@ static int rvu_get_lmtaddr(struct rvu *rvu, u16 pcifunc, u64 iova, u64 *lmt_addr) { u64 pa, val, pf; - int err; + int err = 0; if (!iova) { dev_err(rvu->dev, "%s Requested Null address for transulation\n", __func__); return -EINVAL; } + mutex_lock(&rvu->rsrc_lock); rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_REQ, iova); pf = rvu_get_pf(pcifunc) & 0x1F; val = BIT_ULL(63) | BIT_ULL(14) | BIT_ULL(13) | pf << 8 | @@ -76,12 +77,13 @@ static int rvu_get_lmtaddr(struct rvu *rvu, u16 pcifunc, err = rvu_poll_reg(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_RSP_STS, BIT_ULL(0), false); if (err) { dev_err(rvu->dev, "%s LMTLINE iova transulation failed\n", __func__); - return err; + goto exit; } val = rvu_read64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_RSP_STS); if (val & ~0x1ULL) { dev_err(rvu->dev, "%s LMTLINE iova transulation failed err:%llx\n", __func__, val); - return -EIO; + err = -EIO; + goto exit; } /* PA[51:12] = RVU_AF_SMMU_TLN_FLIT0[57:18] * PA[11:0] = IOVA[11:0] @@ -89,8 +91,9 @@ static int rvu_get_lmtaddr(struct rvu *rvu, u16 pcifunc, pa = rvu_read64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_TLN_FLIT0) >> 18; pa &= GENMASK_ULL(39, 0); *lmt_addr = (pa << 12) | (iova & 0xFFF); - - return 0; +exit: + mutex_unlock(&rvu->rsrc_lock); + return err; } static int rvu_update_lmtaddr(struct rvu *rvu, u16 pcifunc, u64 lmt_addr) -- 2.25.1