aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/1498-drm-amd-dal-initial-framework-for-s3-debugging.patch
blob: 979516c3ad64d7538dbb521de7b85baef5f683da (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From bbc6f9552e6a997fe753dd95592d323e1b917d2e Mon Sep 17 00:00:00 2001
From: Mykola Lysenko <Mykola.Lysenko@amd.com>
Date: Wed, 9 Mar 2016 05:45:11 -0500
Subject: [PATCH 1498/1565] drm/amd/dal: initial framework for s3 debugging

Adds sysfs driver property to trigger suspend/resume
sequences, thus allow to debug through them w/o actual
s3.

E.g.

# echo 0 > /sys/<path_to_driver>/s3_debug

will trigger suspend sequence and

# echo 1 > /sys/<path_to_driver>/s3_debug

will trigger resume sequence.

Currently it only supports DAL s3 sequences, but could be
expanded to support whole driver sequence.

Change-Id: I1131e07781721462ec771780fe8eb81afe100945
Signed-off-by: Mykola Lysenko <Mykola.Lysenko@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
---
 drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c | 37 +++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c
index 5bef63c..bf4ad69 100644
--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm.c
@@ -1232,6 +1232,38 @@ static const struct amdgpu_display_funcs dm_dce_v11_0_display_funcs = {
 	.resume_mc_access = dce_v11_0_resume_mc_access, /* called unconditionally */
 };
 
+#if defined(CONFIG_DEBUG_KERNEL_DAL)
+
+static ssize_t s3_debug_store(
+	struct device *device,
+	struct device_attribute *attr,
+	const char *buf,
+	size_t count)
+{
+	int ret;
+	int s3_state;
+	struct pci_dev *pdev = to_pci_dev(device);
+	struct drm_device *drm_dev = pci_get_drvdata(pdev);
+	struct amdgpu_device *adev = drm_dev->dev_private;
+
+	ret = kstrtoint(buf, 0, &s3_state);
+
+	if (ret == 0) {
+		if (s3_state) {
+			dm_resume(adev);
+			amdgpu_dm_display_resume(adev);
+			drm_kms_helper_hotplug_event(adev->ddev);
+		} else
+			dm_suspend(adev);
+	}
+
+	return ret == 0 ? count : 0;
+}
+
+DEVICE_ATTR_WO(s3_debug);
+
+#endif
+
 static int dm_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -1279,6 +1311,11 @@ static int dm_early_init(void *handle)
 	/* Note: Do NOT change adev->audio_endpt_rreg and
 	 * adev->audio_endpt_wreg because they are initialised in
 	 * amdgpu_device_init() */
+#if defined(CONFIG_DEBUG_KERNEL_DAL)
+	device_create_file(
+		adev->ddev->dev,
+		&dev_attr_s3_debug);
+#endif
 
 	return 0;
 }
-- 
1.9.1