From: Sai Krishna <saikrishnag@marvell.com>
To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <simon.horman@corigine.com>,
<leon@kernel.org>, <sgoutham@marvell.com>, <gakula@marvell.com>,
<lcherian@marvell.com>, <jerinj@marvell.com>,
<hkelam@marvell.com>, <sbhatta@marvell.com>
Cc: Sai Krishna <saikrishnag@marvell.com>
Subject: [net PATCH v3 01/10] octeontx2-af: Secure APR table update with the lock
Date: Wed, 19 Apr 2023 11:50:09 +0530 [thread overview]
Message-ID: <20230419062018.286136-2-saikrishnag@marvell.com> (raw)
In-Reply-To: <20230419062018.286136-1-saikrishnag@marvell.com>
From: Geetha sowjanya <gakula@marvell.com>
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 <gakula@marvell.com>
Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com>
Signed-off-by: Sai Krishna <saikrishnag@marvell.com>
---
.../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
next prev parent reply other threads:[~2023-04-19 6:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 6:20 [net PATCH v3 00/10] octeontx2: Miscellaneous fixes Sai Krishna
2023-04-19 6:20 ` Sai Krishna [this message]
2023-04-19 6:20 ` [net PATCH v3 02/10] octeontx2-af: Fix start and end bit for scan config Sai Krishna
2023-04-19 10:35 ` Simon Horman
2023-04-20 7:32 ` Sai Krishna Gajula
2023-04-19 6:20 ` [net PATCH v3 03/10] octeontx2-af: Fix depth of cam and mem table Sai Krishna
2023-04-19 9:54 ` Simon Horman
2023-04-20 7:40 ` Sai Krishna Gajula
2023-04-19 6:20 ` [net PATCH v3 04/10] octeontx2-pf: Increase the size of dmac filter flows Sai Krishna
2023-04-19 10:38 ` Simon Horman
2023-04-19 6:20 ` [net PATCH v3 05/10] octeontx2-af: Add validation for lmac type Sai Krishna
2023-04-19 6:20 ` [net PATCH v3 06/10] octeontx2-af: Update correct mask to filter IPv4 fragments Sai Krishna
2023-04-19 6:20 ` [net PATCH v3 07/10] octeontx2-af: Update/Fix NPC field hash extract feature Sai Krishna
2023-04-19 11:05 ` Simon Horman
2023-04-19 6:20 ` [net PATCH v3 08/10] octeontx2-af: Fix issues with NPC field hash extract Sai Krishna
2023-04-19 11:06 ` Simon Horman
2023-04-19 6:20 ` [net PATCH v3 09/10] octeontx2-af: Skip PFs if not enabled Sai Krishna
2023-04-19 10:51 ` Simon Horman
2023-04-20 7:29 ` Sai Krishna Gajula
2023-04-19 6:20 ` [net PATCH v3 10/10] octeontx2-pf: Disable packet I/O for graceful exit Sai Krishna
2023-04-19 11:03 ` Simon Horman
2023-04-20 7:21 ` Sai Krishna Gajula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230419062018.286136-2-saikrishnag@marvell.com \
--to=saikrishnag@marvell.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=hkelam@marvell.com \
--cc=jerinj@marvell.com \
--cc=kuba@kernel.org \
--cc=lcherian@marvell.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.com \
--cc=simon.horman@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).