Hi Shimoda-san,
On Mon, Feb 9, 2015 at 9:16 AM, Yoshihiro Shimoda
<[email protected]> wrote:
> The usbhsf_pkt_handler(pipe, USBHSF_PKT_DMA_DONE) in usbhsf_dma_complete()
> will call the complete function of a usb gadget driver finally.
> According to the gadget.h, "The function will always be called with
> interrupts disabled".
>
> So, this patch adds a local_irq_save/local_irq_restore in the
> usbhsf_dma_complete() because a dmaengine driver may call this
> callback function when interrupts enabled (e.g. in tasklet).
>
> Signed-off-by: Yoshihiro Shimoda <[email protected]>
> ---
> drivers/usb/renesas_usbhs/fifo.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/renesas_usbhs/fifo.c
> b/drivers/usb/renesas_usbhs/fifo.c
> index d891bff..b1440d0 100644
> --- a/drivers/usb/renesas_usbhs/fifo.c
> +++ b/drivers/usb/renesas_usbhs/fifo.c
> @@ -1165,11 +1165,14 @@ static void usbhsf_dma_complete(void *arg)
> struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
> struct device *dev = usbhs_priv_to_dev(priv);
> int ret;
> + unsigned long flags;
>
> + local_irq_save(flags);
Adding "local_irq_save()" without a spinlock is usually not correct.
I'm a bit confused here. usbhsf_pkt_handler() itself calls
usbhs_lock(priv, flags);
which is actually
spin_lock_irqsave(usbhs_priv_to_lock(priv), flags)
so it does disable interrupts internally?
Or is this about protecting the call to
pkt->done(priv, pkt);
at the end of usbhsf_pkt_handler(), which is done after releasing the
spinlock?
Still, that would need some better protection, as local_irq_save() disables
interrupts only on the CPU it's running on, not on other CPUs in a
multiprocessor system.
> ret = usbhsf_pkt_handler(pipe, USBHSF_PKT_DMA_DONE);
> if (ret < 0)
> dev_err(dev, "dma_complete run_error %d : %d\n",
> usbhs_pipe_number(pipe), ret);
> + local_irq_restore(flags);
> }
>
> void usbhs_fifo_clear_dcp(struct usbhs_pipe *pipe)
> --
> 1.7.9.5
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html