public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Michael Nazzareno Trimarchi <michael@amarulasolutions.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Meng Li <Meng.Li@windriver.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"quic_uaggarwa@quicinc.com" <quic_uaggarwa@quicinc.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"xu.yang_2@nxp.com" <xu.yang_2@nxp.com>
Subject: Re: [v2 PATCH] usb: dwc3: core: remove lock of otg mode during gadget suspend/resume to avoid deadlock
Date: Tue, 18 Jun 2024 23:05:44 +0000	[thread overview]
Message-ID: <20240618230540.dcxsud42532sep4h@synopsys.com> (raw)
In-Reply-To: <CAOf5uw=pmKOgA1ct766Q-F6c4P21bNV-i_acEisxO9gxg0gQDA@mail.gmail.com>

On Wed, Jun 19, 2024, Michael Nazzareno Trimarchi wrote:
> Hi
> 
> On Wed, Jun 19, 2024 at 12:42 AM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
> >
> > Hi,
> >
> > On Wed, Jun 19, 2024, Michael Nazzareno Trimarchi wrote:
> > > Hi
> > >
> > > On Tue, Jun 18, 2024 at 11:55 PM Thinh Nguyen <Thinh.Nguyen@synopsys.com> wrote:
> > > >
> > > > On Tue, Jun 18, 2024, Meng Li wrote:
> > > > > When config CONFIG_USB_DWC3_DUAL_ROLE is selected, and trigger system
> > > > > to enter suspend status with below command:
> > > > > echo mem > /sys/power/state
> > > > > There will be a deadlock issue occurring. Detailed invoking path as
> > > > > below:
> > > > > dwc3_suspend_common()
> > > > >     spin_lock_irqsave(&dwc->lock, flags);              <-- 1st
> > > > >     dwc3_gadget_suspend(dwc);
> > > > >         dwc3_gadget_soft_disconnect(dwc);
> > > > >             spin_lock_irqsave(&dwc->lock, flags);      <-- 2nd
> > >
> > >
> > > In resume path the spinlock was taken too and I see that there is a call
> > > dwc3_gadget_soft_connect that call the dwc3_core_soft_reset that can poll
> > > using msleep for time.  I don't know if this is a valid fix but seems
> > > does not fix
> > > only commit c7ebd8149ee5
> > >
> >
> > Meng did take the resume path into account. Can you clarify what you
> > meant with "does not fix only commit c7ebd8149ee5"?
> 
> I have seen that is suppose to fix something introduced by that commit
> but I think
> that resume path was already broken before
> 
> spinlock_irqsave()
> dwc3_gadget_resume -> dwc3_gadget_soft_connect -> dwc3_core_soft_reset
> (can sleep)
> 

The code path for OTG should not hit that sleep. The sleep is only
applicable to DWC_usb31 and DWC_usb32. Technically, it wasn't broken
before. But we should remove this spinlock on resume as it is done here.

BR,
Thinh

  reply	other threads:[~2024-06-18 23:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18  3:19 [v2 PATCH] usb: dwc3: core: remove lock of otg mode during gadget suspend/resume to avoid deadlock Meng Li
2024-06-18 21:54 ` Thinh Nguyen
2024-06-18 22:19   ` Michael Nazzareno Trimarchi
2024-06-18 22:42     ` Thinh Nguyen
2024-06-18 22:55       ` Michael Nazzareno Trimarchi
2024-06-18 23:05         ` Thinh Nguyen [this message]
2024-06-19  1:48   ` Li, Meng
2024-06-19  2:02     ` Li, Meng
2024-06-21 23:14       ` Thinh Nguyen
2024-06-22  4:14         ` Li, Meng

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=20240618230540.dcxsud42532sep4h@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=Meng.Li@windriver.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michael@amarulasolutions.com \
    --cc=quic_uaggarwa@quicinc.com \
    --cc=xu.yang_2@nxp.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