linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: chipidea: get lock before calling usb_[disable|enable]_autosuspend()
@ 2021-08-02 21:52 Salah Triki
  2021-08-04  1:38 ` Peter Chen
  0 siblings, 1 reply; 4+ messages in thread
From: Salah Triki @ 2021-08-02 21:52 UTC (permalink / raw)
  To: Peter Chen, Greg Kroah-Hartman

Based on the documentation of usb_[disable|enable]_autosuspend(), the
caller must hold udev's device lock.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/usb/chipidea/otg_fsm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 6ed4b00dba96..2d4174250432 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -518,12 +518,14 @@ static void ci_otg_loc_sof(struct otg_fsm *fsm, int on)
 	if (!udev)
 		return;
 
+	usb_lock_device(udev);
 	if (on) {
 		usb_disable_autosuspend(udev);
 	} else {
 		pm_runtime_set_autosuspend_delay(&udev->dev, 0);
 		usb_enable_autosuspend(udev);
 	}
+	usb_unlock_device(udev);
 }
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: chipidea: get lock before calling usb_[disable|enable]_autosuspend()
  2021-08-02 21:52 [PATCH] usb: chipidea: get lock before calling usb_[disable|enable]_autosuspend() Salah Triki
@ 2021-08-04  1:38 ` Peter Chen
  2021-08-05  9:58   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Chen @ 2021-08-04  1:38 UTC (permalink / raw)
  To: Salah Triki; +Cc: Greg Kroah-Hartman, linux-usb

On 21-08-02 22:52:12, Salah Triki wrote:
> Based on the documentation of usb_[disable|enable]_autosuspend(), the
> caller must hold udev's device lock.
> 
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
>  drivers/usb/chipidea/otg_fsm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> index 6ed4b00dba96..2d4174250432 100644
> --- a/drivers/usb/chipidea/otg_fsm.c
> +++ b/drivers/usb/chipidea/otg_fsm.c
> @@ -518,12 +518,14 @@ static void ci_otg_loc_sof(struct otg_fsm *fsm, int on)
>  	if (!udev)
>  		return;
>  
> +	usb_lock_device(udev);
>  	if (on) {
>  		usb_disable_autosuspend(udev);
>  	} else {
>  		pm_runtime_set_autosuspend_delay(&udev->dev, 0);
>  		usb_enable_autosuspend(udev);
>  	}
> +	usb_unlock_device(udev);
>  }
>  

Acked-by: Peter Chen <peter.chen@kernel.org>

-- 

Thanks,
Peter Chen


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: chipidea: get lock before calling usb_[disable|enable]_autosuspend()
  2021-08-04  1:38 ` Peter Chen
@ 2021-08-05  9:58   ` Greg Kroah-Hartman
  2021-08-09  0:42     ` Peter Chen
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-05  9:58 UTC (permalink / raw)
  To: Peter Chen; +Cc: Salah Triki, linux-usb

On Wed, Aug 04, 2021 at 09:38:09AM +0800, Peter Chen wrote:
> On 21-08-02 22:52:12, Salah Triki wrote:
> > Based on the documentation of usb_[disable|enable]_autosuspend(), the
> > caller must hold udev's device lock.
> > 
> > Signed-off-by: Salah Triki <salah.triki@gmail.com>
> > ---
> >  drivers/usb/chipidea/otg_fsm.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> > index 6ed4b00dba96..2d4174250432 100644
> > --- a/drivers/usb/chipidea/otg_fsm.c
> > +++ b/drivers/usb/chipidea/otg_fsm.c
> > @@ -518,12 +518,14 @@ static void ci_otg_loc_sof(struct otg_fsm *fsm, int on)
> >  	if (!udev)
> >  		return;
> >  
> > +	usb_lock_device(udev);
> >  	if (on) {
> >  		usb_disable_autosuspend(udev);
> >  	} else {
> >  		pm_runtime_set_autosuspend_delay(&udev->dev, 0);
> >  		usb_enable_autosuspend(udev);
> >  	}
> > +	usb_unlock_device(udev);
> >  }
> >  
> 
> Acked-by: Peter Chen <peter.chen@kernel.org>

I think this is not ok, see the other threads...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: chipidea: get lock before calling usb_[disable|enable]_autosuspend()
  2021-08-05  9:58   ` Greg Kroah-Hartman
@ 2021-08-09  0:42     ` Peter Chen
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Chen @ 2021-08-09  0:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Salah Triki, linux-usb

On 21-08-05 11:58:59, Greg Kroah-Hartman wrote:
> On Wed, Aug 04, 2021 at 09:38:09AM +0800, Peter Chen wrote:
> > On 21-08-02 22:52:12, Salah Triki wrote:
> > > Based on the documentation of usb_[disable|enable]_autosuspend(), the
> > > caller must hold udev's device lock.
> > > 
> > > Signed-off-by: Salah Triki <salah.triki@gmail.com>
> > > ---
> > >  drivers/usb/chipidea/otg_fsm.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> > > index 6ed4b00dba96..2d4174250432 100644
> > > --- a/drivers/usb/chipidea/otg_fsm.c
> > > +++ b/drivers/usb/chipidea/otg_fsm.c
> > > @@ -518,12 +518,14 @@ static void ci_otg_loc_sof(struct otg_fsm *fsm, int on)
> > >  	if (!udev)
> > >  		return;
> > >  
> > > +	usb_lock_device(udev);
> > >  	if (on) {
> > >  		usb_disable_autosuspend(udev);
> > >  	} else {
> > >  		pm_runtime_set_autosuspend_delay(&udev->dev, 0);
> > >  		usb_enable_autosuspend(udev);
> > >  	}
> > > +	usb_unlock_device(udev);
> > >  }
> > >  
> > 
> > Acked-by: Peter Chen <peter.chen@kernel.org>
> 
> I think this is not ok, see the other threads...

Thanks for checking it, I read Alan's comments for the similar patches.
Yes, it doesn't need since all callers have already holds fsm->lock.

-- 

Thanks,
Peter Chen


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-09  0:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 21:52 [PATCH] usb: chipidea: get lock before calling usb_[disable|enable]_autosuspend() Salah Triki
2021-08-04  1:38 ` Peter Chen
2021-08-05  9:58   ` Greg Kroah-Hartman
2021-08-09  0:42     ` Peter Chen

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).