patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Nipun Gupta <nipun.gupta@nxp.com>
To: <thomas@monjalon.net>
Cc: <dev@dpdk.org>, <hemant.agrawal@nxp.com>,
	<shreyansh.jain@nxp.com>, Nipun Gupta <nipun.gupta@nxp.com>,
	<stable@dpdk.org>
Subject: [dpdk-stable] [PATCH 2/7] bus/dpaa: allocate qman portals in thread safe manner
Date: Tue, 23 Jan 2018 18:01:06 +0530	[thread overview]
Message-ID: <1516710671-13897-3-git-send-email-nipun.gupta@nxp.com> (raw)
In-Reply-To: <1516710671-13897-1-git-send-email-nipun.gupta@nxp.com>

Fixes: 9d32ef0f5d61 ("bus/dpaa: support creating dynamic HW portal")
Cc: stable@dpdk.org

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/bus/dpaa/base/qbman/qman.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c
index e7fdf03..4d8bdae 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -625,7 +625,7 @@ struct qman_portal *qman_create_portal(
 
 #define MAX_GLOBAL_PORTALS 8
 static struct qman_portal global_portals[MAX_GLOBAL_PORTALS];
-static int global_portals_used[MAX_GLOBAL_PORTALS];
+rte_atomic16_t global_portals_used[MAX_GLOBAL_PORTALS];
 
 static struct qman_portal *
 qman_alloc_global_portal(void)
@@ -633,10 +633,8 @@ struct qman_portal *qman_create_portal(
 	unsigned int i;
 
 	for (i = 0; i < MAX_GLOBAL_PORTALS; i++) {
-		if (global_portals_used[i] == 0) {
-			global_portals_used[i] = 1;
+		if (rte_atomic16_test_and_set(&global_portals_used[i]))
 			return &global_portals[i];
-		}
 	}
 	pr_err("No portal available (%x)\n", MAX_GLOBAL_PORTALS);
 
@@ -650,7 +648,7 @@ struct qman_portal *qman_create_portal(
 
 	for (i = 0; i < MAX_GLOBAL_PORTALS; i++) {
 		if (&global_portals[i] == portal) {
-			global_portals_used[i] = 0;
+			rte_atomic16_clear(&global_portals_used[i]);
 			return 0;
 		}
 	}
-- 
1.9.1

  parent reply	other threads:[~2018-01-23  7:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1516710671-13897-1-git-send-email-nipun.gupta@nxp.com>
     [not found] ` <1516710427-22843-1-git-send-email-nipun.gupta@nxp.com>
2018-01-23 12:27   ` [dpdk-stable] [PATCH 1/7 v2] bus/dpaa: check flag in qman multi enqueue Nipun Gupta
2018-01-24  5:24     ` Hemant Agrawal
2018-01-31 12:45       ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
2018-01-23 12:27   ` [dpdk-stable] [PATCH 2/7 v2] bus/dpaa: allocate qman portals in thread safe manner Nipun Gupta
2018-01-23 12:27   ` [dpdk-stable] [PATCH 3/7 v2] mempool/dpaa: fix the phy to virt optimization Nipun Gupta
2018-01-23 12:27   ` [dpdk-stable] [PATCH 4/7 v2] bus/dpaa: fix port order shuffling Nipun Gupta
2018-01-23 12:31 ` [dpdk-stable] [PATCH 1/7] bus/dpaa: check flag in qman multi enqueue Nipun Gupta
2018-01-23 12:31 ` Nipun Gupta [this message]
2018-01-23 12:31 ` [dpdk-stable] [PATCH 3/7] mempool/dpaa: fix the phy to virt optimization Nipun Gupta
2018-01-23 12:31 ` [dpdk-stable] [PATCH 4/7] bus/dpaa: fix port order shuffling Nipun Gupta

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=1516710671-13897-3-git-send-email-nipun.gupta@nxp.com \
    --to=nipun.gupta@nxp.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=shreyansh.jain@nxp.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).