lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon,  8 Jul 2019 10:25:14 +0800
From:   "Chen, Hu" <hu1.chen@...el.com>
To:     hdegoede@...hat.com
Cc:     hu1.chen@...el.com, Balaji <m.balaji@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] usb: roles: Add PM callbacks

On some Broxton NUC, the usb role is lost after S3 (it becomes "none").
Add PM callbacks to address this issue: save the role during suspend and
restore usb to that role during resume.

Test:
Run Android on UC6CAY, a NUC powered by Broxton. Access this NUC via
"adb shell" from a host PC. After a suspend/resume cycle, the adb still
works well.

Signed-off-by: Chen, Hu <hu1.chen@...el.com>
Signed-off-by: Balaji <m.balaji@...el.com>

diff --git a/drivers/usb/roles/intel-xhci-usb-role-switch.c b/drivers/usb/roles/intel-xhci-usb-role-switch.c
index 277de96181f9..caa1cfab41cc 100644
--- a/drivers/usb/roles/intel-xhci-usb-role-switch.c
+++ b/drivers/usb/roles/intel-xhci-usb-role-switch.c
@@ -37,6 +37,7 @@
 struct intel_xhci_usb_data {
 	struct usb_role_switch *role_sw;
 	void __iomem *base;
+	enum usb_role role;
 };
 
 static int intel_xhci_usb_set_role(struct device *dev, enum usb_role role)
@@ -167,6 +168,30 @@ static int intel_xhci_usb_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int intel_xhci_usb_suspend(struct platform_device *pdev,
+				  pm_message_t state)
+{
+	struct intel_xhci_usb_data *data = platform_get_drvdata(pdev);
+	struct device *dev = &pdev->dev;
+
+	data->role = intel_xhci_usb_get_role(dev);
+
+	return 0;
+}
+
+static int intel_xhci_usb_resume(struct platform_device *pdev)
+{
+	struct intel_xhci_usb_data *data = platform_get_drvdata(pdev);
+	struct device *dev = &pdev->dev;
+
+	if (intel_xhci_usb_get_role(dev) != data->role) {
+		if (intel_xhci_usb_set_role(dev, data->role) != 0)
+			dev_warn(dev, "Failed to set role during resume\n");
+	}
+
+	return 0;
+}
+
 static const struct platform_device_id intel_xhci_usb_table[] = {
 	{ .name = DRV_NAME },
 	{}
@@ -180,6 +205,8 @@ static struct platform_driver intel_xhci_usb_driver = {
 	.id_table = intel_xhci_usb_table,
 	.probe = intel_xhci_usb_probe,
 	.remove = intel_xhci_usb_remove,
+	.suspend = intel_xhci_usb_suspend,
+	.resume = intel_xhci_usb_resume,
 };
 
 module_platform_driver(intel_xhci_usb_driver);
-- 
2.22.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ