[0/4] USB: fix runtime PM after driver unbind

Message ID 20190930161205.18803-1-johan@kernel.org (mailing list archive)
Headers
Series USB: fix runtime PM after driver unbind |

Message

Johan Hovold Sept. 30, 2019, 4:12 p.m. UTC
  A recent change in USB core broke runtime-PM after driver unbind in
several drivers (when counting all USB serial drivers). Specifically,
drivers which took care not modify the runtime-PM usage counter after
their disconnect callback had returned, would now fail to be suspended
when a driver is later bound.

I guess Greg could take all of these directly through his tree, unless
the media maintainers disagree.

Johan


Johan Hovold (4):
  USB: usb-skeleton: fix runtime PM after driver unbind
  USB: usblp: fix runtime PM after driver unbind
  USB: serial: fix runtime PM after driver unbind
  media: stkwebcam: fix runtime PM after driver unbind

 drivers/media/usb/stkwebcam/stk-webcam.c | 3 +--
 drivers/usb/class/usblp.c                | 8 +++++---
 drivers/usb/serial/usb-serial.c          | 5 +----
 drivers/usb/usb-skeleton.c               | 8 +++-----
 4 files changed, 10 insertions(+), 14 deletions(-)
  

Comments

Mauro Carvalho Chehab Sept. 30, 2019, 4:36 p.m. UTC | #1
Em Mon, 30 Sep 2019 18:12:01 +0200
Johan Hovold <johan@kernel.org> escreveu:

> A recent change in USB core broke runtime-PM after driver unbind in
> several drivers (when counting all USB serial drivers). Specifically,
> drivers which took care not modify the runtime-PM usage counter after
> their disconnect callback had returned, would now fail to be suspended
> when a driver is later bound.
> 
> I guess Greg could take all of these directly through his tree, unless
> the media maintainers disagree.

Patches look ok and I'm fine if they go via Greg's tree. So:

Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

Yet, on a quick look on media:

	$ git grep -l usb_.*pm drivers/media/usb/
	drivers/media/usb/cpia2/cpia2_usb.c
	drivers/media/usb/dvb-usb-v2/az6007.c
	drivers/media/usb/dvb-usb-v2/dvb_usb.h
	drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
	drivers/media/usb/gspca/gspca.c
	drivers/media/usb/gspca/gspca.h
	drivers/media/usb/siano/smsusb.c
	drivers/media/usb/stkwebcam/stk-webcam.c
	drivers/media/usb/usbvision/usbvision-i2c.c
	drivers/media/usb/uvc/uvc_driver.c
	drivers/media/usb/uvc/uvc_v4l2.c
	drivers/media/usb/zr364xx/zr364xx.c

There are other drivers beside stkwebcam with has some PM routines.

Ok, only two (stkwebcam and uvcvideo) uses usb_autopm_get_interface() and
usb_autopm_put_interface(), but I'm wondering if the others are doing the
right thing, as their implementation are probably older.

> 
> Johan
> 
> 
> Johan Hovold (4):
>   USB: usb-skeleton: fix runtime PM after driver unbind
>   USB: usblp: fix runtime PM after driver unbind
>   USB: serial: fix runtime PM after driver unbind
>   media: stkwebcam: fix runtime PM after driver unbind
> 
>  drivers/media/usb/stkwebcam/stk-webcam.c | 3 +--
>  drivers/usb/class/usblp.c                | 8 +++++---
>  drivers/usb/serial/usb-serial.c          | 5 +----
>  drivers/usb/usb-skeleton.c               | 8 +++-----
>  4 files changed, 10 insertions(+), 14 deletions(-)
> 



Thanks,
Mauro
  
Johan Hovold Oct. 1, 2019, 8:23 a.m. UTC | #2
On Mon, Sep 30, 2019 at 01:36:03PM -0300, Mauro Carvalho Chehab wrote:
> Em Mon, 30 Sep 2019 18:12:01 +0200
> Johan Hovold <johan@kernel.org> escreveu:
> 
> > A recent change in USB core broke runtime-PM after driver unbind in
> > several drivers (when counting all USB serial drivers). Specifically,
> > drivers which took care not modify the runtime-PM usage counter after
> > their disconnect callback had returned, would now fail to be suspended
> > when a driver is later bound.
> > 
> > I guess Greg could take all of these directly through his tree, unless
> > the media maintainers disagree.
> 
> Patches look ok and I'm fine if they go via Greg's tree. So:
> 
> Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

Thanks for taking a look.

> Yet, on a quick look on media:
> 
> 	$ git grep -l usb_.*pm drivers/media/usb/
> 	drivers/media/usb/cpia2/cpia2_usb.c
> 	drivers/media/usb/dvb-usb-v2/az6007.c
> 	drivers/media/usb/dvb-usb-v2/dvb_usb.h
> 	drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
> 	drivers/media/usb/gspca/gspca.c
> 	drivers/media/usb/gspca/gspca.h
> 	drivers/media/usb/siano/smsusb.c
> 	drivers/media/usb/stkwebcam/stk-webcam.c
> 	drivers/media/usb/usbvision/usbvision-i2c.c
> 	drivers/media/usb/uvc/uvc_driver.c
> 	drivers/media/usb/uvc/uvc_v4l2.c
> 	drivers/media/usb/zr364xx/zr364xx.c
> 
> There are other drivers beside stkwebcam with has some PM routines.

Yeah, but that may be for system-wide suspend.

> Ok, only two (stkwebcam and uvcvideo) uses usb_autopm_get_interface() and
> usb_autopm_put_interface(), but I'm wondering if the others are doing the
> right thing, as their implementation are probably older.

Right, only these two support runtime PM through USB core (autosuspend).

In fact, I see now that stkwebcam fails to set the supports_autosuspend
flag in its usb_driver struct, so runtime PM has never actually been
enabled for this driver either. But I guess it doesn't hurt to fix
missing puts if someones wants to try enabling it, if not only for
documentation purposes and avoiding copy-paste proliferation.

Lots of legacy...

Johan