From: Peter Chen <peter.chen@nxp.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Peter Chen <peter.chen@kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 1/1] usb: chipidea: udc: fix sleeping function called from invalid context
Date: Wed, 11 Mar 2020 06:57:13 +0000 [thread overview]
Message-ID: <20200311065716.GC14625@b29397-desktop> (raw)
In-Reply-To: <Pine.LNX.4.44L0.2003100952060.1651-100000@iolanthe.rowland.org>
On 20-03-10 09:57:00, Alan Stern wrote:
> On Tue, 10 Mar 2020, Peter Chen wrote:
>
> > From: Peter Chen <peter.chen@nxp.com>
> >
> > The code calls pm_runtime_get_sync with irq disabled, it causes below
> > warning:
> >
> > BUG: sleeping function called from invalid context at
> > wer/runtime.c:1075
> > in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid:
> > er/u8:1
>
> ...
>
> > Tested-by: Dmitry Osipenko <digetx@gmail.com>
> > Cc: <stable@vger.kernel.org> #v5.5
> > Fixes: 72dc8df7920f ("usb: chipidea: udc: protect usb interrupt enable")
> > Reported-by: Dmitry Osipenko <digetx@gmail.com>
> > Signed-off-by: Peter Chen <peter.chen@nxp.com>
> > ---
> > drivers/usb/chipidea/udc.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> > index ffaf46f5d062..1fa587ec52fc 100644
> > --- a/drivers/usb/chipidea/udc.c
> > +++ b/drivers/usb/chipidea/udc.c
> > @@ -1539,9 +1539,11 @@ static void ci_hdrc_gadget_connect(struct usb_gadget *_gadget, int is_active)
> > if (ci->driver) {
> > hw_device_state(ci, ci->ep0out->qh.dma);
> > usb_gadget_set_state(_gadget, USB_STATE_POWERED);
> > + spin_unlock_irqrestore(&ci->lock, flags);
> > usb_udc_vbus_handler(_gadget, true);
> > + } else {
> > + spin_unlock_irqrestore(&ci->lock, flags);
> > }
> > - spin_unlock_irqrestore(&ci->lock, flags);
>
> There's something strange about this patch.
>
> Do you really know that interrupts will be enabled following the
> spin_unlock_irqrestore()? In other words, do you know that interrupts
> were enabled upon entry to this routine?
>
> If they were, then why use spin_lock_irqsave/spin_unlock_irqrestore?
> Why not use spin_lock_irq and spin_unlock_irq?
>
This function is called at process context, so the interrupt is
enabled, I will use spin_lock_irq, thanks, Alan.
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2020-03-11 6:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 6:59 [PATCH 0/1] usb: chipidea: fixes for usb-linus Peter Chen
2020-03-10 6:59 ` [PATCH 1/1] usb: chipidea: udc: fix sleeping function called from invalid context Peter Chen
2020-03-10 13:57 ` Alan Stern
2020-03-11 6:57 ` Peter Chen [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-03-16 3:10 [PATCH 0/1] usb: chipidea: fix for usb-linus Peter Chen
2020-03-16 3:10 ` [PATCH 1/1] usb: chipidea: udc: fix sleeping function called from invalid context Peter Chen
2020-03-05 1:55 Peter Chen
2020-03-05 20:53 ` Dmitry Osipenko
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=20200311065716.GC14625@b29397-desktop \
--to=peter.chen@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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).