Re: [BISECTED] (?) since 3.16: USB video cam of an HP Pavilion dv7 laptop not working

From: JÃrg-Volker Peetz
Date: Tue Sep 09 2014 - 07:36:19 EST


JÃrg-Volker Peetz wrote on 09/08/2014 17:17:
> Since 3.16 the builtin USB video cam of an HP Pavilion dv7 laptop shows only a
> black screen with the application guvcview although the video LED is turned on.
> There is no hint in dmesg. Also the output of guvcview shows no conspicuousness.
>
> With kernel version 3.15.9 the camera works.
>
> I tried to bisect between good v3.15 and bad v3.16, which identified
>
> commit 9262c19d14c433a6a1ba25c3ff897cb89e412309
> Author: Dan Williams <dan.j.williams@xxxxxxxxx>
> Date: Tue May 20 18:08:12 2014 -0700
>
> usb: disable port power control if not supported in wHubCharacteristics
>
> A hub indicates whether it supports per-port power control via the
> wHubCharacteristics field in its descriptor. If it is not supported
> a hub will still emulate ClearPortPower(PORT_POWER) requests by
> stopping the link state machine. However, since this does not save
> power do not bother suspending.
>
> This also consolidates support checks into a
> hub_is_port_power_switchable() helper.
>
> Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
>
> In the bad bisection steps the video device even was not found. Therefore, I'm
> not sure if I identified the right culprit.
>

As you suggested Dan, I reverted this commit on top of 3.16.0 (the commit could
not be reverted cleanly, I had to do it manually, patch appended). But still I
see a black picture from the camera. So this commit is not the culprit.

How to proceed with the bisection?
--
Regards,
JÃrg-Volker.

--- hub.c.orig 2014-08-04 00:25:02.000000000 +0200
+++ hub.c 2014-09-09 11:56:24.721312469 +0200
@@ -820,6 +820,8 @@ EXPORT_SYMBOL_GPL(usb_hub_clear_tt_buffe
static void hub_power_on(struct usb_hub *hub, bool do_delay)
{
int port1;
+ u16 wHubCharacteristics =
+ le16_to_cpu(hub->descriptor->wHubCharacteristics);

/* Enable power on each port. Some hubs have reserved values
* of LPSM (> 2) in their descriptors, even though they are
@@ -827,7 +829,7 @@ static void hub_power_on(struct usb_hub
* but only emulate it. In all cases, the ports won't work
* unless we send these messages to the hub.
*/
- if (hub_is_port_power_switchable(hub))
+ if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2)
dev_dbg(hub->intfdev, "enabling power on all ports\n");
else
dev_dbg(hub->intfdev, "trying to enable port power on "
@@ -4548,6 +4550,8 @@ static void hub_port_connect(struct usb_
unsigned unit_load;
struct usb_device *hdev = hub->hdev;
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
+ unsigned wHubCharacteristics =
+ le16_to_cpu(hub->descriptor->wHubCharacteristics);
struct usb_port *port_dev = hub->ports[port1 - 1];
struct usb_device *udev = port_dev->child;

@@ -4586,7 +4590,7 @@ static void hub_port_connect(struct usb_
test_bit(port1, hub->removed_bits)) {

/* maybe switch power back on (e.g. root hub was reset) */
- if (hub_is_port_power_switchable(hub)
+ if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
&& !port_is_power_on(hub, portstatus))
set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);

--- hub.h.orig 2014-08-04 00:25:02.000000000 +0200
+++ hub.h 2014-09-09 12:52:40.027903791 +0200
@@ -119,16 +119,6 @@ extern int hub_port_debounce(struct usb_
extern int usb_clear_port_feature(struct usb_device *hdev,
int port1, int feature);

-static inline bool hub_is_port_power_switchable(struct usb_hub *hub)
-{
- __le16 hcs;
-
- if (!hub)
- return false;
- hcs = hub->descriptor->wHubCharacteristics;
- return (le16_to_cpu(hcs) & HUB_CHAR_LPSM) < HUB_CHAR_NO_LPSM;
-}
-
static inline int hub_is_superspeed(struct usb_device *hdev)
{
return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS;
--- port.c.orig 2014-08-04 00:25:02.000000000 +0200
+++ port.c 2014-09-09 12:58:46.521229430 +0200
@@ -445,16 +445,11 @@ int usb_hub_create_port_device(struct us
*/
pm_runtime_set_active(&port_dev->dev);
pm_runtime_get_noresume(&port_dev->dev);
- pm_runtime_enable(&port_dev->dev);
+ if (!dev_pm_qos_expose_flags(&port_dev->dev,
+ PM_QOS_FLAG_NO_POWER_OFF))
+ pm_runtime_enable(&port_dev->dev);
device_enable_async_suspend(&port_dev->dev);

- /*
- * Keep hidden the ability to enable port-poweroff if the hub
- * does not support power switching.
- */
- if (!hub_is_port_power_switchable(hub))
- return 0;
-
/* Attempt to let userspace take over the policy. */
retval = dev_pm_qos_expose_flags(&port_dev->dev,
PM_QOS_FLAG_NO_POWER_OFF);