diff mbox series

[v2,1/2] soc: fsl: qbman: Always disable interrupts when taking cgr_lock

Message ID 20230331151413.1684105-1-sean.anderson@seco.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] soc: fsl: qbman: Always disable interrupts when taking cgr_lock | expand

Commit Message

Sean Anderson March 31, 2023, 3:14 p.m. UTC
smp_call_function_single disables IRQs when executing the callback. To
prevent deadlocks, we must disable IRQs when taking cgr_lock elsewhere.
This is already done by qman_update_cgr and qman_delete_cgr; fix the
other lockers.

Fixes: c535e923bb97 ("soc/fsl: Introduce DPAA 1.x QMan device driver")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

Changes in v2:
- Fix one additional call to spin_unlock

 drivers/soc/fsl/qbman/qman.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Vladimir Oltean April 3, 2023, 2:02 p.m. UTC | #1
On Fri, Mar 31, 2023 at 11:14:12AM -0400, Sean Anderson wrote:
> smp_call_function_single disables IRQs when executing the callback. To
> prevent deadlocks, we must disable IRQs when taking cgr_lock elsewhere.
> This is already done by qman_update_cgr and qman_delete_cgr; fix the
> other lockers.
> 
> Fixes: c535e923bb97 ("soc/fsl: Introduce DPAA 1.x QMan device driver")

If you've identified smp_call_function_single() as the problem, then the
true issue seems to lie in commit 96f413f47677 ("soc/fsl/qbman: fix
issue in qman_delete_cgr_safe()") and not in the initial commit, no?

Anyway,

Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Sean Anderson April 3, 2023, 3:22 p.m. UTC | #2
On 4/3/23 10:02, Vladimir Oltean wrote:
> On Fri, Mar 31, 2023 at 11:14:12AM -0400, Sean Anderson wrote:
>> smp_call_function_single disables IRQs when executing the callback. To
>> prevent deadlocks, we must disable IRQs when taking cgr_lock elsewhere.
>> This is already done by qman_update_cgr and qman_delete_cgr; fix the
>> other lockers.
>> 
>> Fixes: c535e923bb97 ("soc/fsl: Introduce DPAA 1.x QMan device driver")
> 
> If you've identified smp_call_function_single() as the problem, then the
> true issue seems to lie in commit 96f413f47677 ("soc/fsl/qbman: fix
> issue in qman_delete_cgr_safe()") and not in the initial commit, no?

Yes, that seems better. I did a blame and saw that qman_delete_cgr_safe
had been around since the initial driver, but I didn't realize it worked
in a different way back then.

--Sean

> Anyway,
> 
> Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Camelia Alexandra Groza April 4, 2023, 9:32 a.m. UTC | #3
> -----Original Message-----
> From: Sean Anderson <sean.anderson@seco.com>
> Sent: Monday, April 3, 2023 18:22
> To: Vladimir Oltean <vladimir.oltean@nxp.com>
> Cc: Leo Li <leoyang.li@nxp.com>; linuxppc-dev@lists.ozlabs.org; linux-arm-
> kernel@lists.infradead.org; Scott Wood <oss@buserror.net>; Camelia
> Alexandra Groza <camelia.groza@nxp.com>; linux-kernel@vger.kernel.org;
> Roy Pledge <roy.pledge@nxp.com>; David S . Miller
> <davem@davemloft.net>; Claudiu Manoil <claudiu.manoil@nxp.com>
> Subject: Re: [PATCH v2 1/2] soc: fsl: qbman: Always disable interrupts when
> taking cgr_lock
> 
> On 4/3/23 10:02, Vladimir Oltean wrote:
> > On Fri, Mar 31, 2023 at 11:14:12AM -0400, Sean Anderson wrote:
> >> smp_call_function_single disables IRQs when executing the callback. To
> >> prevent deadlocks, we must disable IRQs when taking cgr_lock elsewhere.
> >> This is already done by qman_update_cgr and qman_delete_cgr; fix the
> >> other lockers.
> >>
> >> Fixes: c535e923bb97 ("soc/fsl: Introduce DPAA 1.x QMan device driver")
> >
> > If you've identified smp_call_function_single() as the problem, then the
> > true issue seems to lie in commit 96f413f47677 ("soc/fsl/qbman: fix
> > issue in qman_delete_cgr_safe()") and not in the initial commit, no?
> 
> Yes, that seems better. I did a blame and saw that qman_delete_cgr_safe
> had been around since the initial driver, but I didn't realize it worked
> in a different way back then.
> 
> --Sean
> 
> > Anyway,
> >
> > Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Apart from Vladimir's comment:
Reviewed-by: Camelia Groza <camelia.groza@nxp.com>
diff mbox series

Patch

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 739e4eee6b75..1bf1f1ea67f0 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -1456,11 +1456,11 @@  static void qm_congestion_task(struct work_struct *work)
 	union qm_mc_result *mcr;
 	struct qman_cgr *cgr;
 
-	spin_lock(&p->cgr_lock);
+	spin_lock_irq(&p->cgr_lock);
 	qm_mc_start(&p->p);
 	qm_mc_commit(&p->p, QM_MCC_VERB_QUERYCONGESTION);
 	if (!qm_mc_result_timeout(&p->p, &mcr)) {
-		spin_unlock(&p->cgr_lock);
+		spin_unlock_irq(&p->cgr_lock);
 		dev_crit(p->config->dev, "QUERYCONGESTION timeout\n");
 		qman_p_irqsource_add(p, QM_PIRQ_CSCI);
 		return;
@@ -1476,7 +1476,7 @@  static void qm_congestion_task(struct work_struct *work)
 	list_for_each_entry(cgr, &p->cgr_cbs, node)
 		if (cgr->cb && qman_cgrs_get(&c, cgr->cgrid))
 			cgr->cb(p, cgr, qman_cgrs_get(&rr, cgr->cgrid));
-	spin_unlock(&p->cgr_lock);
+	spin_unlock_irq(&p->cgr_lock);
 	qman_p_irqsource_add(p, QM_PIRQ_CSCI);
 }
 
@@ -2440,7 +2440,7 @@  int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
 	preempt_enable();
 
 	cgr->chan = p->config->channel;
-	spin_lock(&p->cgr_lock);
+	spin_lock_irq(&p->cgr_lock);
 
 	if (opts) {
 		struct qm_mcc_initcgr local_opts = *opts;
@@ -2477,7 +2477,7 @@  int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
 	    qman_cgrs_get(&p->cgrs[1], cgr->cgrid))
 		cgr->cb(p, cgr, 1);
 out:
-	spin_unlock(&p->cgr_lock);
+	spin_unlock_irq(&p->cgr_lock);
 	put_affine_portal();
 	return ret;
 }