diff mbox

[v2,4/7,media] uvcvideo: Enable runtime PM of descendant devices

Message ID 1428065887-16017-5-git-send-email-tomeu.vizoso@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomeu Vizoso April 3, 2015, 12:57 p.m. UTC
So UVC devices can remain runtime-suspended when the system goes into a
sleep state, they and all of their descendant devices need to have
runtime PM enable.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
 drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Laurent Pinchart April 4, 2015, 12:33 p.m. UTC | #1
Hi Tomeu,

Thank you for the patch.

Could you please CC me on the whole series for v3 ?

On Friday 03 April 2015 14:57:53 Tomeu Vizoso wrote:
> So UVC devices can remain runtime-suspended when the system goes into a
> sleep state, they and all of their descendant devices need to have
> runtime PM enable.
> 
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c
> b/drivers/media/usb/uvc/uvc_driver.c index cf27006..687e5fb 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -1855,6 +1855,15 @@ static int uvc_register_chains(struct uvc_device
> *dev) return 0;
>  }
> 
> +static int uvc_pm_runtime_enable(struct device *dev, void *data)
> +{
> +	pm_runtime_enable(dev);
> +
> +	device_for_each_child(dev, NULL, uvc_pm_runtime_enable);

How many recursion levels do we typically have with uvcvideo ?

> +
> +	return 0;
> +}

The function isn't UVC-specific, how about renaming it to 
pm_runtime_enable_recursive() (or something similar) and moving it to the 
runtime PM core ?

> +
>  /* ------------------------------------------------------------------------
> * USB probe, disconnect, suspend and resume
>   */
> @@ -1959,6 +1968,8 @@ static int uvc_probe(struct usb_interface *intf,
>  			"supported.\n", ret);
>  	}
> 
> +	device_for_each_child(&dev->intf->dev, NULL, uvc_pm_runtime_enable);

You could just call uvc_pm_runtime_enable(&dev->intf->dev, NULL) here.

> +
>  	uvc_trace(UVC_TRACE_PROBE, "UVC device initialized.\n");
>  	usb_enable_autosuspend(udev);
>  	return 0;
Tomeu Vizoso April 9, 2015, 10:52 a.m. UTC | #2
On 4 April 2015 at 14:33, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Hi Tomeu,
>
> Thank you for the patch.
>
> Could you please CC me on the whole series for v3 ?

Sure.

> On Friday 03 April 2015 14:57:53 Tomeu Vizoso wrote:
>> So UVC devices can remain runtime-suspended when the system goes into a
>> sleep state, they and all of their descendant devices need to have
>> runtime PM enable.
>>
>> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
>> ---
>>  drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/media/usb/uvc/uvc_driver.c
>> b/drivers/media/usb/uvc/uvc_driver.c index cf27006..687e5fb 100644
>> --- a/drivers/media/usb/uvc/uvc_driver.c
>> +++ b/drivers/media/usb/uvc/uvc_driver.c
>> @@ -1855,6 +1855,15 @@ static int uvc_register_chains(struct uvc_device
>> *dev) return 0;
>>  }
>>
>> +static int uvc_pm_runtime_enable(struct device *dev, void *data)
>> +{
>> +     pm_runtime_enable(dev);
>> +
>> +     device_for_each_child(dev, NULL, uvc_pm_runtime_enable);
>
> How many recursion levels do we typically have with uvcvideo ?

it has video%d -> input%d -> event%d, when USB_VIDEO_CLASS_INPUT_EVDEV
is enabled.

>> +
>> +     return 0;
>> +}
>
> The function isn't UVC-specific, how about renaming it to
> pm_runtime_enable_recursive() (or something similar) and moving it to the
> runtime PM core ?

Yeah, that would be handy when doing the same to other drivers.

>> +
>>  /* ------------------------------------------------------------------------
>> * USB probe, disconnect, suspend and resume
>>   */
>> @@ -1959,6 +1968,8 @@ static int uvc_probe(struct usb_interface *intf,
>>                       "supported.\n", ret);
>>       }
>>
>> +     device_for_each_child(&dev->intf->dev, NULL, uvc_pm_runtime_enable);
>
> You could just call uvc_pm_runtime_enable(&dev->intf->dev, NULL) here.

I will go with the above for now.

Thanks,

Tomeu

>> +
>>       uvc_trace(UVC_TRACE_PROBE, "UVC device initialized.\n");
>>       usb_enable_autosuspend(udev);
>>       return 0;
>
> --
> Regards,
>
> Laurent Pinchart
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index cf27006..687e5fb 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1855,6 +1855,15 @@  static int uvc_register_chains(struct uvc_device *dev)
 	return 0;
 }
 
+static int uvc_pm_runtime_enable(struct device *dev, void *data)
+{
+	pm_runtime_enable(dev);
+
+	device_for_each_child(dev, NULL, uvc_pm_runtime_enable);
+
+	return 0;
+}
+
 /* ------------------------------------------------------------------------
  * USB probe, disconnect, suspend and resume
  */
@@ -1959,6 +1968,8 @@  static int uvc_probe(struct usb_interface *intf,
 			"supported.\n", ret);
 	}
 
+	device_for_each_child(&dev->intf->dev, NULL, uvc_pm_runtime_enable);
+
 	uvc_trace(UVC_TRACE_PROBE, "UVC device initialized.\n");
 	usb_enable_autosuspend(udev);
 	return 0;