linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Roy Pledge <Roy.Pledge@freescale.com>
To: <linuxppc-dev@lists.ozlabs.org>, <scottwood@freescale.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [v2 11/11] soc/qman: add qman_delete_cgr_safe()
Date: Wed, 12 Aug 2015 16:14:57 -0400	[thread overview]
Message-ID: <1439410497-19039-12-git-send-email-Roy.Pledge@freescale.com> (raw)
In-Reply-To: <1439410497-19039-1-git-send-email-Roy.Pledge@freescale.com>

From: Madalin Bucur <madalin.bucur@freescale.com>

Add qman_delete_cgr_safe() that can be called from any CPU.
This in turn schedules qman_delete_cgr() on the proper CPU.

Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
Signed-off-by: Roy Pledge <Roy.Pledge@freescale.com>
---
 drivers/soc/fsl/qbman/qman_api.c |   46 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/soc/fsl/qbman/qman_api.c b/drivers/soc/fsl/qbman/qman_api.c
index d4f9be0..1dd60f2 100644
--- a/drivers/soc/fsl/qbman/qman_api.c
+++ b/drivers/soc/fsl/qbman/qman_api.c
@@ -2463,6 +2463,8 @@ EXPORT_SYMBOL(qman_modify_cgr);
 					QM_CHANNEL_SWPORTAL0))
 #define PORTAL_IDX(n) (n->config->public_cfg.channel - QM_CHANNEL_SWPORTAL0)
 
+static u8 qman_cgr_cpus[__CGR_NUM];
+
 int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
 			struct qm_mcc_initcgr *opts)
 {
@@ -2479,7 +2481,10 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
 	if (cgr->cgrid >= __CGR_NUM)
 		return -EINVAL;
 
+	preempt_disable();
 	p = get_affine_portal();
+	qman_cgr_cpus[cgr->cgrid] = smp_processor_id();
+	preempt_enable();
 
 	memset(&local_opts, 0, sizeof(struct qm_mcc_initcgr));
 	cgr->chan = p->config->public_cfg.channel;
@@ -2621,6 +2626,47 @@ put_portal:
 }
 EXPORT_SYMBOL(qman_delete_cgr);
 
+struct cgr_comp {
+	struct qman_cgr *cgr;
+	struct completion completion;
+};
+
+static int qman_delete_cgr_thread(void *p)
+{
+	struct cgr_comp *cgr_comp = (struct cgr_comp *)p;
+	int res;
+
+	res = qman_delete_cgr((struct qman_cgr *)cgr_comp->cgr);
+	complete(&cgr_comp->completion);
+
+	return res;
+}
+
+void qman_delete_cgr_safe(struct qman_cgr *cgr)
+{
+	struct task_struct *thread;
+	struct cgr_comp cgr_comp;
+
+	preempt_disable();
+	if (qman_cgr_cpus[cgr->cgrid] != smp_processor_id()) {
+		init_completion(&cgr_comp.completion);
+		cgr_comp.cgr = cgr;
+		thread = kthread_create(qman_delete_cgr_thread, &cgr_comp,
+					"cgr_del");
+
+		if (likely(!IS_ERR(thread))) {
+			kthread_bind(thread, qman_cgr_cpus[cgr->cgrid]);
+			wake_up_process(thread);
+			wait_for_completion(&cgr_comp.completion);
+			preempt_enable();
+			return;
+		}
+	}
+	qman_delete_cgr(cgr);
+	preempt_enable();
+}
+EXPORT_SYMBOL(qman_delete_cgr_safe);
+
 int qman_set_wpm(int wpm_enable)
 {
 	return qm_set_wpm(wpm_enable);
-- 
1.7.9.5

  parent reply	other threads:[~2015-08-12 20:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12 20:14 [v2 00/11] Freescale DPAA QBMan Drivers Roy Pledge
2015-08-12 20:14 ` [v2 01/11] powerpc: re-add devm_ioremap_prot() Roy Pledge
2015-08-12 20:14 ` [v2 02/11] soc/fsl: Introduce DPAA BMan device management driver Roy Pledge
2015-08-25  0:11   ` Scott Wood
2015-08-12 20:14 ` [v2 03/11] soc/fsl: Introduce the DPAA BMan portal driver Roy Pledge
2015-08-25  1:25   ` Scott Wood
2015-10-27 14:38   ` Sebastian Huber
2015-08-12 20:14 ` [v2 04/11] soc/fsl: Introduce drivers for the DPAA QMan Roy Pledge
2015-09-12  1:10   ` Scott Wood
2015-09-15 15:32     ` Roy Pledge
2015-08-12 20:14 ` [v2 05/11] soc/bman: Add self-tester for BMan driver Roy Pledge
2015-08-12 20:14 ` [v2 06/11] soc/qman: Add self-tester for QMan driver Roy Pledge
2015-08-12 20:14 ` [v2 07/11] soc/bman: Add debugfs support for the BMan driver Roy Pledge
2015-08-12 20:14 ` [v2 08/11] soc/qman: Add debugfs support for the QMan driver Roy Pledge
2015-08-12 20:14 ` [v2 09/11] soc/bman: Add HOTPLUG_CPU support to the BMan driver Roy Pledge
2015-08-12 20:14 ` [v2 10/11] soc/qman: Add HOTPLUG_CPU support to the QMan driver Roy Pledge
2015-08-12 20:14 ` Roy Pledge [this message]
2015-08-24 22:33 ` [v2 00/11] Freescale DPAA QBMan Drivers Scott Wood

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=1439410497-19039-12-git-send-email-Roy.Pledge@freescale.com \
    --to=roy.pledge@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=scottwood@freescale.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).