[PATCH] usb-storage: block runtime suspend when the host is added

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A warning message that was recently added to the PM core has alerted
us to a potential problem in usb-storage.  Although the USB interface
is in the runtime active state when the probe routine starts, until
the runtime-PM usage count is incremented nothing forces it to remain
active.  The increment doesn't happen until after scsi_add_host() is
called, and that call causes the interface to go into runtime suspend.

Although this hasn't caused anything to go wrong for anyone, as far as
I know, it still is a bug.

To prevent this from happening, move the existing call to
usb_autopm_get_interface_no_resume() up from its current position to
before scsi_add_host() is called.

Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
Reported-by: Carsten Mattner <carstenmattner@xxxxxxxxx>
Tested-by: Carsten Mattner <carstenmattner@xxxxxxxxx>
CC: <stable@xxxxxxxxxxxxxxx>

---


[as1813]


 drivers/usb/storage/usb.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Index: usb-4.x/drivers/usb/storage/usb.c
===================================================================
--- usb-4.x.orig/drivers/usb/storage/usb.c
+++ usb-4.x/drivers/usb/storage/usb.c
@@ -1070,17 +1070,18 @@ int usb_stor_probe2(struct us_data *us)
 	result = usb_stor_acquire_resources(us);
 	if (result)
 		goto BadDevice;
+
+	usb_autopm_get_interface_no_resume(us->pusb_intf);
 	snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
 					dev_name(&us->pusb_intf->dev));
 	result = scsi_add_host(us_to_host(us), dev);
 	if (result) {
 		dev_warn(dev,
 				"Unable to add the scsi host\n");
-		goto BadDevice;
+		goto AddHostFailed;
 	}
 
 	/* Submit the delayed_work for SCSI-device scanning */
-	usb_autopm_get_interface_no_resume(us->pusb_intf);
 	set_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
 
 	if (delay_use > 0)
@@ -1090,7 +1091,9 @@ int usb_stor_probe2(struct us_data *us)
 	return 0;
 
 	/* We come here if there are any problems */
-BadDevice:
+ AddHostFailed:
+	usb_autopm_put_interface_no_suspend(us->pusb_intf);
+ BadDevice:
 	usb_stor_dbg(us, "storage_probe() failed\n");
 	release_everything(us);
 	return result;

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux