* [v2] mfd: dln2: use irqsave() in USB's complete callback
@ 2018-07-02 7:31 Sebastian Andrzej Siewior
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-07-02 7:31 UTC (permalink / raw)
To: Johan Hovold; +Cc: Octavian Purdila, lkml, linux-usb, tglx, Lee Jones
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Octavian Purdila <tavi@cs.pub.ro>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
v1…v2: Remove also the comment that says that there is no need to
disable interrupts.
drivers/mfd/dln2.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
index 704e189ca162..90e789943466 100644
--- a/drivers/mfd/dln2.c
+++ b/drivers/mfd/dln2.c
@@ -194,6 +194,7 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb,
struct device *dev = &dln2->interface->dev;
struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle];
struct dln2_rx_context *rxc;
+ unsigned long flags;
bool valid_slot = false;
if (rx_slot >= DLN2_MAX_RX_SLOTS)
@@ -201,18 +202,13 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb,
rxc = &rxs->slots[rx_slot];
- /*
- * No need to disable interrupts as this lock is not taken in interrupt
- * context elsewhere in this driver. This function (or its callers) are
- * also not exported to other modules.
- */
- spin_lock(&rxs->lock);
+ spin_lock_irqsave(&rxs->lock, flags);
if (rxc->in_use && !rxc->urb) {
rxc->urb = urb;
complete(&rxc->done);
valid_slot = true;
}
- spin_unlock(&rxs->lock);
+ spin_unlock_irqrestore(&rxs->lock, flags);
out:
if (!valid_slot)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [v2] mfd: dln2: use irqsave() in USB's complete callback
@ 2018-07-04 7:40 Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2018-07-04 7:40 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Johan Hovold, Octavian Purdila, lkml, linux-usb, tglx
On Mon, 02 Jul 2018, Sebastian Andrzej Siewior wrote:
> The USB completion callback does not disable interrupts while acquiring
> the lock. We want to remove the local_irq_disable() invocation from
> __usb_hcd_giveback_urb() and therefore it is required for the callback
> handler to disable the interrupts while acquiring the lock.
> The callback may be invoked either in IRQ or BH context depending on the
> USB host controller.
> Use the _irqsave() variant of the locking primitives.
>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Octavian Purdila <tavi@cs.pub.ro>
> Reviewed-by: Johan Hovold <johan@kernel.org>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> v1…v2: Remove also the comment that says that there is no need to
> disable interrupts.
>
> drivers/mfd/dln2.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-04 7:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-04 7:40 [v2] mfd: dln2: use irqsave() in USB's complete callback Lee Jones
-- strict thread matches above, loose matches on Subject: below --
2018-07-02 7:31 Sebastian Andrzej Siewior
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).