summarylogtreecommitdiffstats
path: root/0013-reattach-after-resume.patch
blob: 33e9af0e925d5ec6659563b8b0ab546c26591a7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
index a3316efdf8ac..f96364c9eea0 100644
--- a/drivers/soundwire/amd_manager.c
+++ b/drivers/soundwire/amd_manager.c
@@ -1384,7 +1384,7 @@ static int __maybe_unused amd_resume_runtime(struct device *dev)
 {
 	struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev);
 	struct sdw_bus *bus = &amd_manager->bus;
-	int ret;
+	int ret, retry = 5;
 	u32 val;
 
 	if (bus->prop.hw_disabled) {
@@ -1431,6 +1431,22 @@ static int __maybe_unused amd_resume_runtime(struct device *dev)
 		if (ret)
 			return ret;
 		amd_sdw_set_frameshape(amd_manager);
+
+		usleep_range(500, 750);
+		while (retry--) {
+			amd_sdw_read_and_process_ping_status(amd_manager);
+			if (amd_manager->status[0] == SDW_SLAVE_ATTACHED) {
+				dev_dbg(amd_manager->dev, "Devices detected after resume\n");
+				break;
+			}
+			dev_dbg(amd_manager->dev, "Devices not detected waiting\n");
+			usleep_range(500, 750);
+		}
+
+		if (amd_manager->status[0] == SDW_SLAVE_ATTACHED)
+			schedule_work(&amd_manager->amd_sdw_work);
+		else
+			dev_err(amd_manager->dev, "No devices attached after resume timeout\n");
 	}
 	if (amd_manager->acp_rev >= ACP70_PCI_REV_ID) {
 		ret = amd_sdw_set_device_state(amd_manager, AMD_SDW_DEVICE_STATE_D0);