From patchwork Wed Apr 26 07:43:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Krishna Gajula X-Patchwork-Id: 87700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp74570vqo; Wed, 26 Apr 2023 01:00:15 -0700 (PDT) X-Google-Smtp-Source: AKy350b0J3/3TTS2dz/qz+8Nqcw2e2Th6Vqoh84rtmmgYBSfUUNgcN9XwI/Zk2cSl9RlFTX40ls7 X-Received: by 2002:a05:6a00:2d05:b0:63d:2f13:200 with SMTP id fa5-20020a056a002d0500b0063d2f130200mr26186946pfb.16.1682496015173; Wed, 26 Apr 2023 01:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496015; cv=none; d=google.com; s=arc-20160816; b=ZzsWJCxCUJLbFIylcoogsFsuUg3OXEC+ghaaLoAf3eOr9iEHagdzKmC6RczCiVfS5L V6zVu3Sgj/lYKLbpReBrUDkTfeCU2LZqDUbj7AEHcom3sp1V7eBPugppTKMBJdAvLgQf h4LT9DuSNop/3X7cfdXzVXEwvtLVOo4p4N2jtHMV/po/EDQjcBrODD51H4GqbrMzukfd BrOFGt6uGoZhl2cH29q5/qYey8eRNbnZrygoYsTCSEzLtUiMOH+aWyYOjRly59Qa9rEX qQJv04Xiir2IQNz7R7zwmrWrxu5YhEM34XjQF97PpAxNR7XEt13MGFO+O+YpCZdZ1D+o yo9w== 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=TKyZS7l9j4DcNjRTF48UhbQwxCa4nWx18HfMe5EtntOLfgZcp7uC+HlKLcgA3hI2bT 6TjerMQH6qFixD9DftTi5jVceio7uWAV6SVt+x2JGlcVN082Qemj5yNOuUKm8Z2yt/X3 6eDC6HRjiqboEySV4onDeMydv/rekt+6QYXd6XRxmDzEfnvDLYsbd2ylHiQVWdVbCh1a X5Dxaz06xUfA1d07BXcLeKBJmfKcg68PNy/4iZmV8fGa6aejDlZ/CwqA5Rp6kH7J6aHg dqPKZitrhWd7m5+m3m3fxJiNNnwuo0qWZ/cw0cSzu34k1ipA03+8QZNJvFRouzfzBbae R23A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=La41dtws; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h22-20020aa796d6000000b0063b6e71d1fbsi15637079pfq.319.2023.04.26.01.00.00; Wed, 26 Apr 2023 01:00:15 -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=La41dtws; 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 S240007AbjDZHoN (ORCPT + 99 others); Wed, 26 Apr 2023 03:44:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239976AbjDZHoG (ORCPT ); Wed, 26 Apr 2023 03:44:06 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41326A7; Wed, 26 Apr 2023 00:44:05 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33Q6oZhi013107; Wed, 26 Apr 2023 00:43:59 -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=La41dtws6EQapyAm/oxnb253lbLkX2IHMzgm8Qcsc7tE+Idj+SRjqQSnFUwUvsBBs5XU fp8PwzDeVwu5I3qJ2xYNrhrfAzUfKHvtACSqVK2W0kG+uJEIS8k3eTY+5f0qhZD3SrYU LHhuZIPMlXIi95cxwtZzd44ao/yiHO3/Vd/1Xlnp7IuahRg2c0MN1TDm2XznAfh6RPhx 1da/Nx9xzK4qrRTC/WEUtdW3rSHJh1adiO1srXK0EUgDqyFZnRubDE0rBoOo+27XMc4G Lkptt9BnJx3wbfUAPokU4YFUC+7VdPvRdpoGTG9GddYyCeJcfx+MLfPbCy56pSQeOhtJ RA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3q6c2fdd30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 26 Apr 2023 00:43:58 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 26 Apr 2023 00:43:57 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 26 Apr 2023 00:43:57 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id E9C985B692D; Wed, 26 Apr 2023 00:43:52 -0700 (PDT) From: Sai Krishna To: , , , , , , , , , , , , , CC: Sai Krishna Subject: [net PATCH v4 01/10] octeontx2-af: Secure APR table update with the lock Date: Wed, 26 Apr 2023 13:13:36 +0530 Message-ID: <20230426074345.750135-2-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230426074345.750135-1-saikrishnag@marvell.com> References: <20230426074345.750135-1-saikrishnag@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: deks-t5Nr-z0ktb_WJkNRraPbXxaDLAe X-Proofpoint-ORIG-GUID: deks-t5Nr-z0ktb_WJkNRraPbXxaDLAe 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-04-26_02,2023-04-26_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764224941686685174?= X-GMAIL-MSGID: =?utf-8?q?1764224941686685174?= 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)