From: Felipe Balbi <balbi@ti.com>
To: yoshihiro shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: "balbi@TI.COM" <balbi@ti.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Greg KH <gregkh@linuxfoundation.org>,
Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
USB list <linux-usb@vger.kernel.org>,
Linux-sh list <linux-sh@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH v2 1/4] usb: renesas_usbhs: fix spinlock suspected in a gadget complete function
Date: Thu, 12 Mar 2015 16:09:07 +0000 [thread overview]
Message-ID: <20150312160907.GE9261@saruman.tx.rr.com> (raw)
In-Reply-To: <HKNPR06MB3228B5E1A95EDFCD58CF32BD8060@HKNPR06MB322.apcprd06.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 4210 bytes --]
Hi,
On Thu, Mar 12, 2015 at 05:40:56AM +0000, yoshihiro shimoda wrote:
> Hi,
>
> > On Thu, Mar 12, 2015 at 04:33:41AM +0000, yoshihiro shimoda wrote:
> > > Hi Geert-san again,
> > >
> > > > Hi Geert-san,
> > > >
> > > > Thank you for the reply again!
> > > >
> > > > > Hi Shimoda-san,
> > > > >
> > > > > On Mon, Feb 16, 2015 at 2:52 AM, Yoshihiro Shimoda
> > > > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > > According to the gadget.h, a "complete" function will always be called
> > > > > > with interrupts disabled. However, sometimes usbhsg_queue_pop() function
> > > > > > is called with interrupts enabled. So, this function should calls
> > > > > > local_irq_save() before this calls the usb_gadget_giveback_request().
> > > > > > Otherwise, there is possible to cause a spinlock suspected in a gadget
> > > > > > complete function.
> > > > >
> > > > > I still feel uneasy about adding the call to local_irq_save(), as the need for
> > > > > this is usually an indicator of another locking problem.
> > > >
> > > > I also think that I would like to avoid using local_irq_save().
> > > > But, I have no idea to resolve this issue for now.
> > >
> > > After I modified usb-dmac driver to use a tasklet instead of a kthread,
> > > this issue disappeared.
> > >
> > > My understanding is the followings:
> > > - According to the backtrace below, during usbhsf_dma_complete() was running,
> > > a softirq happened. After ncm_tx_tasklet() was called, the issue happened.
> > > http://thread.gmane.org/gmane.linux.usb.general/122023/focus=43729
> > >
> > > - This means that usbhsf_dma_complete() ran on a kthread. So, ncm driver is able
> > > to do the ncm_tx_tasklet().
> > >
> > > - After the current usb-dmac driver, since usbhsf_dma_complete() runs on a tasklet,
> > > ncm driver is not able to do the ncm_tx_tasklet during usbhsf_dma_complete() was running.
> > >
> > >
> > > So, I would like to recall this patch and I will resubmit this patch series as v3.
> >
> > try something like below:
> >
> > diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
> > index e0384af77e56..e9d75d85be59 100644
> > --- a/drivers/usb/renesas_usbhs/mod_gadget.c
> > +++ b/drivers/usb/renesas_usbhs/mod_gadget.c
> > @@ -119,7 +119,7 @@ struct usbhsg_recip_handle {
> > /*
> > * queue push/pop
> > */
> > -static void usbhsg_queue_pop(struct usbhsg_uep *uep,
> > +static void __usbhsg_queue_pop(struct usbhsg_uep *uep,
> > struct usbhsg_request *ureq,
> > int status)
> > {
> > @@ -133,6 +133,15 @@ static void usbhsg_queue_pop(struct usbhsg_uep *uep,
> > usb_gadget_giveback_request(&uep->ep, &ureq->req);
> > }
> >
> > +static void usbhsg_queue_pop(struct usbhsg_uep *uep,
> > + struct usbhsg_request *ureq,
> > + int status)
> > +{
> > + usbhs_lock(priv, flags);
> > + __usbhsg_queue_pop(uep, ureq, status);
> > + usbhs_unlock(priv, flags);
> > +}
> > +
> > static void usbhsg_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt)
> > {
> > struct usbhs_pipe *pipe = pkt->pipe;
> >
> >
> > then, for cases where lock is already held you call __usbhsg_queue_pop()
> > and for all other cases, call usbhsg_queue_pop().
>
> Thank you for the suggestion. However, we cannot use this
> usbhsg_queue_pop() because a gadget driver might call usb_ep_queue()
> in the "complete" function and this driver calls usbhs_lock() in the
> usb_ep_queue().
right, in that case just call __usbhs_queue_pop() directly.
> Perhaps my explanation was bad, but this issue was caused by the
> following conditions:
> - I use the renesas_usbhs driver as udc.
> - I use an old usb-dmac driver that the callback runs on a kthread.
> - I use the ncm driver. In this environment, the ncm driver might
> cause a spinlock suspected.
>
> As an old solution, I fixed the renesas_usbhs driver by this patch.
> However, if I use a new usb-dmac driver that the callback runs on a
> tasklet, I don't need this patch. (This is a new solution.)
then differentiate based on some revision register or something like
that ?
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Felipe Balbi <balbi@ti.com>
To: yoshihiro shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: "balbi@TI.COM" <balbi@ti.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Greg KH <gregkh@linuxfoundation.org>,
Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
USB list <linux-usb@vger.kernel.org>,
Linux-sh list <linux-sh@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH v2 1/4] usb: renesas_usbhs: fix spinlock suspected in a gadget complete function
Date: Thu, 12 Mar 2015 11:09:07 -0500 [thread overview]
Message-ID: <20150312160907.GE9261@saruman.tx.rr.com> (raw)
In-Reply-To: <HKNPR06MB3228B5E1A95EDFCD58CF32BD8060@HKNPR06MB322.apcprd06.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 4210 bytes --]
Hi,
On Thu, Mar 12, 2015 at 05:40:56AM +0000, yoshihiro shimoda wrote:
> Hi,
>
> > On Thu, Mar 12, 2015 at 04:33:41AM +0000, yoshihiro shimoda wrote:
> > > Hi Geert-san again,
> > >
> > > > Hi Geert-san,
> > > >
> > > > Thank you for the reply again!
> > > >
> > > > > Hi Shimoda-san,
> > > > >
> > > > > On Mon, Feb 16, 2015 at 2:52 AM, Yoshihiro Shimoda
> > > > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > > According to the gadget.h, a "complete" function will always be called
> > > > > > with interrupts disabled. However, sometimes usbhsg_queue_pop() function
> > > > > > is called with interrupts enabled. So, this function should calls
> > > > > > local_irq_save() before this calls the usb_gadget_giveback_request().
> > > > > > Otherwise, there is possible to cause a spinlock suspected in a gadget
> > > > > > complete function.
> > > > >
> > > > > I still feel uneasy about adding the call to local_irq_save(), as the need for
> > > > > this is usually an indicator of another locking problem.
> > > >
> > > > I also think that I would like to avoid using local_irq_save().
> > > > But, I have no idea to resolve this issue for now.
> > >
> > > After I modified usb-dmac driver to use a tasklet instead of a kthread,
> > > this issue disappeared.
> > >
> > > My understanding is the followings:
> > > - According to the backtrace below, during usbhsf_dma_complete() was running,
> > > a softirq happened. After ncm_tx_tasklet() was called, the issue happened.
> > > http://thread.gmane.org/gmane.linux.usb.general/122023/focus=43729
> > >
> > > - This means that usbhsf_dma_complete() ran on a kthread. So, ncm driver is able
> > > to do the ncm_tx_tasklet().
> > >
> > > - After the current usb-dmac driver, since usbhsf_dma_complete() runs on a tasklet,
> > > ncm driver is not able to do the ncm_tx_tasklet during usbhsf_dma_complete() was running.
> > >
> > >
> > > So, I would like to recall this patch and I will resubmit this patch series as v3.
> >
> > try something like below:
> >
> > diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
> > index e0384af77e56..e9d75d85be59 100644
> > --- a/drivers/usb/renesas_usbhs/mod_gadget.c
> > +++ b/drivers/usb/renesas_usbhs/mod_gadget.c
> > @@ -119,7 +119,7 @@ struct usbhsg_recip_handle {
> > /*
> > * queue push/pop
> > */
> > -static void usbhsg_queue_pop(struct usbhsg_uep *uep,
> > +static void __usbhsg_queue_pop(struct usbhsg_uep *uep,
> > struct usbhsg_request *ureq,
> > int status)
> > {
> > @@ -133,6 +133,15 @@ static void usbhsg_queue_pop(struct usbhsg_uep *uep,
> > usb_gadget_giveback_request(&uep->ep, &ureq->req);
> > }
> >
> > +static void usbhsg_queue_pop(struct usbhsg_uep *uep,
> > + struct usbhsg_request *ureq,
> > + int status)
> > +{
> > + usbhs_lock(priv, flags);
> > + __usbhsg_queue_pop(uep, ureq, status);
> > + usbhs_unlock(priv, flags);
> > +}
> > +
> > static void usbhsg_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt)
> > {
> > struct usbhs_pipe *pipe = pkt->pipe;
> >
> >
> > then, for cases where lock is already held you call __usbhsg_queue_pop()
> > and for all other cases, call usbhsg_queue_pop().
>
> Thank you for the suggestion. However, we cannot use this
> usbhsg_queue_pop() because a gadget driver might call usb_ep_queue()
> in the "complete" function and this driver calls usbhs_lock() in the
> usb_ep_queue().
right, in that case just call __usbhs_queue_pop() directly.
> Perhaps my explanation was bad, but this issue was caused by the
> following conditions:
> - I use the renesas_usbhs driver as udc.
> - I use an old usb-dmac driver that the callback runs on a kthread.
> - I use the ncm driver. In this environment, the ncm driver might
> cause a spinlock suspected.
>
> As an old solution, I fixed the renesas_usbhs driver by this patch.
> However, if I use a new usb-dmac driver that the callback runs on a
> tasklet, I don't need this patch. (This is a new solution.)
then differentiate based on some revision register or something like
that ?
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-03-12 16:09 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-16 1:52 [PATCH v2 0/4] usb: renesas_usbhs: add support for USB-DMAC Yoshihiro Shimoda
2015-02-16 1:52 ` Yoshihiro Shimoda
2015-02-16 1:52 ` [PATCH v2 2/4] usb: renesas_usbhs: add the channel number in dma-names Yoshihiro Shimoda
2015-02-16 1:52 ` Yoshihiro Shimoda
[not found] ` <1424051579-5060-1-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2015-02-16 1:52 ` [PATCH v2 1/4] usb: renesas_usbhs: fix spinlock suspected in a gadget complete function Yoshihiro Shimoda
2015-02-16 1:52 ` Yoshihiro Shimoda
[not found] ` <1424051579-5060-2-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2015-02-16 10:15 ` Geert Uytterhoeven
2015-02-16 10:15 ` Geert Uytterhoeven
2015-02-17 3:34 ` yoshihiro shimoda
2015-02-17 3:34 ` yoshihiro shimoda
2015-03-12 4:33 ` yoshihiro shimoda
2015-03-12 4:33 ` yoshihiro shimoda
2015-03-12 4:44 ` Felipe Balbi
2015-03-12 4:44 ` Felipe Balbi
2015-03-12 5:40 ` yoshihiro shimoda
2015-03-12 5:40 ` yoshihiro shimoda
2015-03-12 16:09 ` Felipe Balbi [this message]
2015-03-12 16:09 ` Felipe Balbi
[not found] ` <20150312160907.GE9261-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
2015-03-13 1:14 ` yoshihiro shimoda
2015-03-13 1:14 ` yoshihiro shimoda
2015-03-13 15:44 ` Felipe Balbi
2015-03-13 15:44 ` Felipe Balbi
[not found] ` <20150313154408.GE5615-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
2015-03-16 7:34 ` yoshihiro shimoda
2015-03-16 7:34 ` yoshihiro shimoda
2015-02-16 1:52 ` [PATCH v2 3/4] usb: renesas_usbhs: fix the sequence in xfer_work() Yoshihiro Shimoda
2015-02-16 1:52 ` Yoshihiro Shimoda
2015-02-16 1:52 ` [PATCH v2 4/4] usb: renesas_usbhs: add support for USB-DMAC Yoshihiro Shimoda
2015-02-16 1:52 ` Yoshihiro Shimoda
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=20150312160907.GE9261@saruman.tx.rr.com \
--to=balbi@ti.com \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=linux-sh@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.