From: Ashwin Sekhar T K <asekhar@marvell.com>
To: <dev@dpdk.org>, Nithin Dabilpuram <ndabilpuram@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Sunil Kumar Kori <skori@marvell.com>,
Satha Rao <skoteshwar@marvell.com>
Cc: <jerinj@marvell.com>, <pbhagavatula@marvell.com>,
<psatheesh@marvell.com>, <asekhar@marvell.com>,
<anoobj@marvell.com>, <gakhil@marvell.com>, <hkalra@marvell.com>
Subject: [PATCH] common/cnxk: synchronize NPA aura bitmap accesses
Date: Fri, 6 Jan 2023 17:06:27 +0530 [thread overview]
Message-ID: <20230106113627.42097-1-asekhar@marvell.com> (raw)
Ensure that all cnxk mempool aura bitmap accesses are synchronized.
Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
---
drivers/common/cnxk/roc_idev.c | 1 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_npa.c | 29 ++++++++++++++++++++++++++++-
drivers/common/cnxk/roc_npa.h | 2 ++
drivers/common/cnxk/version.map | 2 ++
5 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c
index 4d2eff93ce..62a4fd8880 100644
--- a/drivers/common/cnxk/roc_idev.c
+++ b/drivers/common/cnxk/roc_idev.c
@@ -40,6 +40,7 @@ idev_set_defaults(struct idev_cfg *idev)
idev->cpt = NULL;
idev->nix_inl_dev = NULL;
plt_spinlock_init(&idev->nix_inl_dev_lock);
+ plt_spinlock_init(&idev->npa_dev_lock);
__atomic_store_n(&idev->npa_refcnt, 0, __ATOMIC_RELEASE);
}
diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h
index 315cc6f52c..b97d2936a2 100644
--- a/drivers/common/cnxk/roc_idev_priv.h
+++ b/drivers/common/cnxk/roc_idev_priv.h
@@ -33,6 +33,7 @@ struct idev_cfg {
struct nix_inl_dev *nix_inl_dev;
struct idev_nix_inl_cfg inl_cfg;
plt_spinlock_t nix_inl_dev_lock;
+ plt_spinlock_t npa_dev_lock;
};
/* Generic */
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index ee42434c38..f015fc2f1b 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -325,14 +325,19 @@ npa_aura_pool_pair_alloc(struct npa_lf *lf, const uint32_t block_size,
block_size > ROC_NPA_MAX_BLOCK_SZ)
return NPA_ERR_INVALID_BLOCK_SZ;
+ roc_npa_dev_lock();
/* Get aura_id from resource bitmap */
aura_id = find_free_aura(lf, flags);
- if (aura_id < 0)
+ if (aura_id < 0) {
+ roc_npa_dev_unlock();
return NPA_ERR_AURA_ID_ALLOC;
+ }
/* Mark pool as reserved */
plt_bitmap_clear(lf->npa_bmp, aura_id);
+ roc_npa_dev_unlock();
+
/* Configuration based on each aura has separate pool(aura-pool pair) */
pool_id = aura_id;
rc = (aura_id < 0 || pool_id >= (int)lf->nr_pools ||
@@ -401,7 +406,9 @@ npa_aura_pool_pair_alloc(struct npa_lf *lf, const uint32_t block_size,
stack_mem_free:
plt_memzone_free(mz);
aura_res_put:
+ roc_npa_dev_lock();
plt_bitmap_set(lf->npa_bmp, aura_id);
+ roc_npa_dev_unlock();
exit:
return rc;
}
@@ -501,7 +508,9 @@ npa_aura_pool_pair_free(struct npa_lf *lf, uint64_t aura_handle)
rc |= npa_stack_dma_free(lf, name, pool_id);
memset(&lf->aura_attr[aura_id], 0, sizeof(struct npa_aura_attr));
+ roc_npa_dev_lock();
plt_bitmap_set(lf->npa_bmp, aura_id);
+ roc_npa_dev_unlock();
return rc;
}
@@ -921,3 +930,21 @@ roc_npa_dev_fini(struct roc_npa *roc_npa)
npa->dev.drv_inited = false;
return dev_fini(&npa->dev, npa->pci_dev);
}
+
+void
+roc_npa_dev_lock(void)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+
+ if (idev != NULL)
+ plt_spinlock_lock(&idev->npa_dev_lock);
+}
+
+void
+roc_npa_dev_unlock(void)
+{
+ struct idev_cfg *idev = idev_get_cfg();
+
+ if (idev != NULL)
+ plt_spinlock_unlock(&idev->npa_dev_lock);
+}
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index fed1942404..c9093e6448 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -762,5 +762,7 @@ int __roc_api roc_npa_pool_op_pc_reset(uint64_t aura_handle);
int __roc_api roc_npa_aura_drop_set(uint64_t aura_handle, uint64_t limit,
bool ena);
+void __roc_api roc_npa_dev_lock(void);
+void __roc_api roc_npa_dev_unlock(void);
#endif /* _ROC_NPA_H_ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 17f0ec6b48..77bf3f2807 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -321,6 +321,8 @@ INTERNAL {
roc_npa_ctx_dump;
roc_npa_dev_fini;
roc_npa_dev_init;
+ roc_npa_dev_lock;
+ roc_npa_dev_unlock;
roc_npa_dump;
roc_npa_lf_init_cb_register;
roc_npa_pool_create;
--
2.25.1
reply other threads:[~2023-01-06 11:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230106113627.42097-1-asekhar@marvell.com \
--to=asekhar@marvell.com \
--cc=anoobj@marvell.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=hkalra@marvell.com \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=pbhagavatula@marvell.com \
--cc=psatheesh@marvell.com \
--cc=skori@marvell.com \
--cc=skoteshwar@marvell.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).