From patchwork Fri Apr 7 12:23:38 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: 80776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp259570vqo; Fri, 7 Apr 2023 05:47:35 -0700 (PDT) X-Google-Smtp-Source: AKy350aptqdWV1sHUBHMOn94L67BXJSRxm/UXLaCRc59ihB0hhYXEOWO0Aj5fswQbgfmooLKOymV X-Received: by 2002:aa7:ca41:0:b0:502:67b6:9734 with SMTP id j1-20020aa7ca41000000b0050267b69734mr2225842edt.6.1680871654953; Fri, 07 Apr 2023 05:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680871654; cv=none; d=google.com; s=arc-20160816; b=EKYuxLo7gctIQKsgim9pk/TF4DB5zIqZoUnY6WkSMiWI4K2h/8/tjI76wwSaMsXHb0 w2OKhx7O/CKBLQ/HbGpMSW8OgrjFkORZPwNCFv2FPmIuOKIzvdYnF5HBmIYD/DGVg907 ZWl2zqHobm5O9soMbWeq3DIbvyZk+qtQjRiiUOrNMKho1Ru+L5J0cX3oYCMpeHdiwU8a cd85UpGZD4ovJ/3lW2o4AJgVAGeGuXa4tFjzIBMDLjG6suPJW7VFA3R6N/BFmxa9jtwy oEI7x6CGMfZ6DegR+Mj+pr/9+odGK+e/RGVAE+AqCHkgitk63fIsu7pOTxiBDHvHDMzW 7cUQ== 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=aJ4BaAT3AGcAdjDo2xWVNbwi49MYlxqi2NK5V4zd0ms=; b=mo9FBGq9cj+5sZeehAZ9Auj/3cmN1HKZp8aSbWCkYudTLK+IaFeay13BKZ5qqkNFB3 RnCguTIXizaju/jVuEPr7UBCDvwgxC/3o9GdVb4hX+Jy9OVLTOjosadathUtq6UAavfc 5aRgs+ywKJ/AXOnMuBGEbaz04cy1CsQWhalZvTQxq46oUVyH3DyEUqYJu5APsvvxgNCc AdwKvMjaaxhDUkI66XNo/5WOIecR8a20oGFvw2dwDaI2ld5KcwQtyM5I2HGdtg1Q/atB IAEYK9vkcBFUR8f/frP/D/H3azYcsnOkU7M0Hlayw3sYuDjPIVzL501Wm7KVLzn/H+HJ pKOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=gcnFh8BR; 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 u7-20020a056402064700b005002aad5850si3349745edx.589.2023.04.07.05.47.08; Fri, 07 Apr 2023 05:47:34 -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=gcnFh8BR; 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 S240736AbjDGMYQ (ORCPT + 99 others); Fri, 7 Apr 2023 08:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbjDGMYL (ORCPT ); Fri, 7 Apr 2023 08:24:11 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F0C6976F; Fri, 7 Apr 2023 05:24:10 -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 337AwmMZ000622; Fri, 7 Apr 2023 05:23: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=aJ4BaAT3AGcAdjDo2xWVNbwi49MYlxqi2NK5V4zd0ms=; b=gcnFh8BRzh9UtQjT4OfHQnbtrc0gjmvjZDCQZNAuJ0/9Qddpmrl6Ohrwz8BlMqQ4r1So rsvb2V9JdsEOChu9cKCqwM+g3o94i1RrSfFECyLyoUl7hF8CYLUlZJMhfXduCpqc7JS6 wItHyiv1z5hF1tXU5SBI8lIowqGL99HXUdM1yKQKOW+EVU7yxEmNjHE9cB0FMaUI3PhU Pf11+A4o8Y5biM/1SkvsM2Tt482mDoACOcziKdrSI0Q5cNYPTf8zofuz3J3tNTYaA9i2 l/CI/u33cu1FJbYh3b9/Iz5gKHKhhyCSC/lZ0NS09Ku7fPez2YBnU2Q2UhD+FgHuWgJO Gg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pthvw88pr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 07 Apr 2023 05:23: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; Fri, 7 Apr 2023 05:23:57 -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; Fri, 7 Apr 2023 05:23:57 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id 486483F7062; Fri, 7 Apr 2023 05:23:53 -0700 (PDT) From: Sai Krishna To: , , , , , , , , , , , , CC: Sai Krishna Subject: [net PATCH v2 1/7] octeontx2-af: Secure APR table update with the lock Date: Fri, 7 Apr 2023 17:53:38 +0530 Message-ID: <20230407122344.4059-2-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230407122344.4059-1-saikrishnag@marvell.com> References: <20230407122344.4059-1-saikrishnag@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: kTQv6lgVAO_GSKLpznL0LK5J2INraHAe X-Proofpoint-GUID: kTQv6lgVAO_GSKLpznL0LK5J2INraHAe 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-07_08,2023-04-06_03,2023-02-09_01 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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?1762521676805021098?= X-GMAIL-MSGID: =?utf-8?q?1762521676805021098?= 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. Due to race condition while updating the entries are getting corrupted. Hence secure the APR table update with the lock. 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 --- drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 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..8530250f6fba 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c @@ -142,16 +142,17 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, * region, if so, convert that IOVA to physical address and * populate LMT table with that address */ + mutex_lock(&rvu->rsrc_lock); if (req->use_local_lmt_region) { err = rvu_get_lmtaddr(rvu, req->hdr.pcifunc, req->lmt_iova, &lmt_addr); if (err < 0) - return err; + goto error; /* Update the lmt addr for this PFFUNC in the LMT table */ err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, lmt_addr); if (err) - return err; + goto error; } /* Reconfiguring lmtst map table in lmt region shared mode i.e. make @@ -181,7 +182,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, */ err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, val); if (err) - return err; + goto error; } /* This mailbox can also be used to update word1 of APR_LMT_MAP_ENTRY_S @@ -230,6 +231,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, } error: + mutex_unlock(&rvu->rsrc_lock); return err; }