b5cf2a1
From a5ffa27c07e06900fcfc50b08de6d11e45830168 Mon Sep 17 00:00:00 2001
b5cf2a1
From: Hans de Goede <hdegoede@redhat.com>
b5cf2a1
Date: Wed, 3 Jan 2018 12:49:44 +0100
b5cf2a1
Subject: [PATCH v2] Bluetooth: btusb: Disable autosuspend on QCA Rome devices
b5cf2a1
b5cf2a1
Commit fd865802c66b ("Bluetooth: btusb: fix QCA Rome suspend/resume") fixes
b5cf2a1
a suspend/resume problem on QCA devices by doing a full reset on resume,
b5cf2a1
reloading the firmware.
b5cf2a1
b5cf2a1
A similar problem happens when using runtime-pm / autosuspend, when this is
b5cf2a1
enabled by the user the QCA Rome device stops working. Reloading the
b5cf2a1
firmware after a runtime suspend is not really an option since the latency
b5cf2a1
caused by this is unacceptable.
b5cf2a1
b5cf2a1
To fix the runtime-pm issues, this commit disables runtime-pm on QCA Rome
b5cf2a1
HCIs, by getting (and not releasing) an usb autopm reference on the btusb
b5cf2a1
interface.
b5cf2a1
b5cf2a1
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1514836
b5cf2a1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
b5cf2a1
---
b5cf2a1
 drivers/bluetooth/btusb.c | 7 +++++++
b5cf2a1
 1 file changed, 7 insertions(+)
b5cf2a1
b5cf2a1
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
b5cf2a1
index 808c249845db..6ed3a0e5b8f6 100644
b5cf2a1
--- a/drivers/bluetooth/btusb.c
b5cf2a1
+++ b/drivers/bluetooth/btusb.c
b5cf2a1
@@ -3122,8 +3122,15 @@ static int btusb_probe(struct usb_interface *intf,
b5cf2a1
 		/* QCA Rome devices lose their updated firmware over suspend,
b5cf2a1
 		 * but the USB hub doesn't notice any status change.
b5cf2a1
 		 * Explicitly request a device reset on resume.
b5cf2a1
+		 * And disable runtime pm by getting a pm reference, the USB
b5cf2a1
+		 * core will drop our reference on disconnect.
b5cf2a1
 		 */
b5cf2a1
 		set_bit(BTUSB_RESET_RESUME, &data->flags);
b5cf2a1
+		err = usb_autopm_get_interface(data->intf);
b5cf2a1
+		if (err < 0) {
b5cf2a1
+			BT_ERR("failed to get pm reference %d", err);
b5cf2a1
+			goto out_free_dev;
b5cf2a1
+		}
b5cf2a1
 	}
b5cf2a1
 
b5cf2a1
 #ifdef CONFIG_BT_HCIBTUSB_RTL
b5cf2a1
-- 
b5cf2a1
2.14.3
b5cf2a1