mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Badhri Jagan Sridharan <badhri@google.com>
Cc: gregkh@linuxfoundation.org, colin.i.king@gmail.com,
	xuetao09@huawei.com, quic_eserrao@quicinc.com,
	water.zhangjiantao@huawei.com, peter.chen@freescale.com,
	balbi@ti.com, francesco@dolcini.it, alistair@alistair23.me,
	stephan@gerhold.net, bagasdotme@gmail.com, luca@z3ntu.xyz,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,
	Francesco Dolcini <francesco.dolcini@toradex.com>
Subject: Re: [PATCH v1] usb: gadget: udc: core: Offload usb_udc_vbus_handler processing
Date: Wed, 17 May 2023 16:01:28 -0400	[thread overview]
Message-ID: <c7cb96ea-628d-4591-908c-d6ea572ef5a0@rowland.harvard.edu> (raw)
In-Reply-To: <CAPTae5JB2LLEF7ZNaJxMnF==8WCWoEYvmF_FK3F=BDq0Hko0xQ@mail.gmail.com>

On Wed, May 17, 2023 at 10:19:25AM -0700, Badhri Jagan Sridharan wrote:
> On Wed, May 17, 2023 at 7:44 AM Alan Stern <stern@rowland.harvard.edu> wrote:
> >
> > On Wed, May 17, 2023 at 11:59:55AM +0000, Badhri Jagan Sridharan wrote:
> > > chipidea udc calls usb_udc_vbus_handler from udc_start gadget
> > > ops causing a deadlock. Avoid this by offloading usb_udc_vbus_handler
> > > processing.
> >
> > Surely that is the wrong approach.
> >
> > The real problem here is that usb_udc_vbus_handler() gets called from
> > within a udc_start routine.  But this is totally unnecessary, because
> > the UDC core will call usb_udc_connect_control_locked() itself, later on
> > during gadget_bind_driver().
> 
> Hi Alan,
> 
> usb_udc_vbus_handler sets the udc->vbus flag as well apart from
> calling usb_udc_connect_control_locked().  So, removing usb_udc_vbus_handler
> from chip specific start callback might prevent the controller from
> starting.
> 
> void usb_udc_vbus_handler(struct usb_gadget *gadget, bool status)
> {
> struct usb_udc *udc = gadget->udc;
> 
> mutex_lock(&udc->connect_lock);
> if (udc) {
> udc->vbus = status;
> usb_udc_connect_control_locked(udc);

Then add "udc->vbus = true;" at the appropriate spot in 
gadget_bind_driver().

Alan Stern

PS: I just noticed that in max3420_udc.c, the max_3420_vbus_handler() 
function calls usb_udc_vbus_handler() from within an interrupt handler.  
This won't work, since interrupt handlers aren't allowed to sleep and 
therefore can't lock mutexes.

  reply	other threads:[~2023-05-17 20:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 11:59 Badhri Jagan Sridharan
2023-05-17 12:04 ` Badhri Jagan Sridharan
2023-05-17 14:44 ` Alan Stern
2023-05-17 17:19   ` Badhri Jagan Sridharan
2023-05-17 20:01     ` Alan Stern [this message]
2023-05-19  4:29       ` Badhri Jagan Sridharan

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=c7cb96ea-628d-4591-908c-d6ea572ef5a0@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=alistair@alistair23.me \
    --cc=badhri@google.com \
    --cc=bagasdotme@gmail.com \
    --cc=balbi@ti.com \
    --cc=colin.i.king@gmail.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=francesco@dolcini.it \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=luca@z3ntu.xyz \
    --cc=peter.chen@freescale.com \
    --cc=quic_eserrao@quicinc.com \
    --cc=stable@vger.kernel.org \
    --cc=stephan@gerhold.net \
    --cc=water.zhangjiantao@huawei.com \
    --cc=xuetao09@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®