-
Notifications
You must be signed in to change notification settings - Fork 0
/
0002-i915-VGA-arbiter-patch.patch
166 lines (151 loc) · 6.14 KB
/
0002-i915-VGA-arbiter-patch.patch
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
From 725dd2b2144a213ce950beefb67aae04bccf771e Mon Sep 17 00:00:00 2001
From: Philip Zander <[email protected]>
Date: Wed, 1 Jul 2015 16:04:33 +0200
Subject: [PATCH 2/2] i915 VGA arbiter patch
By Alex Williamson
---
drivers/gpu/drm/i915/display/intel_display.c | 2 +
drivers/gpu/drm/i915/display/intel_vga.c | 43 ++++++++++++++++++--
drivers/gpu/drm/i915/display/intel_vga.h | 2 +
drivers/gpu/drm/i915/i915_driver.c | 6 +++
drivers/gpu/drm/i915/i915_params.c | 5 ++-
drivers/gpu/drm/i915/i915_params.h | 3 +-
6 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index fc5d94862ef3..835256356b63 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -8993,6 +8993,8 @@ void intel_modeset_driver_remove(struct drm_i915_private *i915)
{
if (!HAS_DISPLAY(i915))
return;
+ intel_vga_enable_mem(i915);
+
flush_workqueue(i915->flip_wq);
flush_workqueue(i915->modeset_wq);
diff --git a/drivers/gpu/drm/i915/display/intel_vga.c b/drivers/gpu/drm/i915/display/intel_vga.c
index b5d058404c14..e3ebc26d4dfa 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.c
+++ b/drivers/gpu/drm/i915/display/intel_vga.c
@@ -53,6 +53,7 @@ void intel_vga_redisable_power_on(struct drm_i915_private *dev_priv)
drm_dbg_kms(&dev_priv->drm,
"Something enabled VGA plane, disabling it\n");
intel_vga_disable(dev_priv);
+ intel_vga_disable_mem(dev_priv);
}
}
@@ -124,6 +125,10 @@ intel_vga_set_state(struct drm_i915_private *i915, bool enable_decode)
return 0;
}
+#define VGA_MSR_WRITE 0x3c2
+#define VGA_MSR_READ 0x3cc
+#define VGA_MSR_MEM_EN (1 << 1)
+
static unsigned int
intel_vga_set_decode(struct pci_dev *pdev, bool enable_decode)
{
@@ -138,6 +143,36 @@ intel_vga_set_decode(struct pci_dev *pdev, bool enable_decode)
return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
}
+void intel_vga_enable_mem(struct drm_i915_private *i915)
+{
+ struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
+ /* Enable VGA memory on Intel HD */
+ if (i915_modparams.enable_hd_vgaarb && HAS_PCH_SPLIT(i915)) {
+ vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO);
+ outb(inb(VGA_MSR_READ) | VGA_MSR_MEM_EN, VGA_MSR_WRITE);
+ vga_set_legacy_decoding(pdev, VGA_RSRC_LEGACY_IO |
+ VGA_RSRC_LEGACY_MEM |
+ VGA_RSRC_NORMAL_IO |
+ VGA_RSRC_NORMAL_MEM);
+ vga_put(pdev, VGA_RSRC_LEGACY_IO);
+ }
+}
+
+void intel_vga_disable_mem(struct drm_i915_private *i915)
+{
+ struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
+ /* Disable VGA memory on Intel HD */
+ if (i915_modparams.enable_hd_vgaarb && HAS_PCH_SPLIT(i915)) {
+ vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO);
+ outb(inb(VGA_MSR_READ) & ~VGA_MSR_MEM_EN, VGA_MSR_WRITE);
+ vga_set_legacy_decoding(pdev, VGA_RSRC_LEGACY_IO |
+ VGA_RSRC_NORMAL_IO |
+ VGA_RSRC_NORMAL_MEM);
+ vga_put(pdev, VGA_RSRC_LEGACY_IO);
+ }
+}
+
+
int intel_vga_register(struct drm_i915_private *i915)
{
@@ -152,9 +187,11 @@ int intel_vga_register(struct drm_i915_private *i915)
* then we do not take part in VGA arbitration and the
* vga_client_register() fails with -ENODEV.
*/
- ret = vga_client_register(pdev, intel_vga_set_decode);
- if (ret && ret != -ENODEV)
- return ret;
+ if (!i915_modparams.enable_hd_vgaarb || !HAS_PCH_SPLIT(i915)) {
+ ret = vga_client_register(pdev, intel_vga_set_decode);
+ if (ret && ret != -ENODEV)
+ return ret;
+ }
return 0;
}
diff --git a/drivers/gpu/drm/i915/display/intel_vga.h b/drivers/gpu/drm/i915/display/intel_vga.h
index ba5b55b917f0..d74c72ee985e 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.h
+++ b/drivers/gpu/drm/i915/display/intel_vga.h
@@ -12,6 +12,8 @@ void intel_vga_reset_io_mem(struct drm_i915_private *i915);
void intel_vga_disable(struct drm_i915_private *i915);
void intel_vga_redisable(struct drm_i915_private *i915);
void intel_vga_redisable_power_on(struct drm_i915_private *i915);
+void intel_vga_enable_mem(struct drm_i915_private *i915);
+void intel_vga_disable_mem(struct drm_i915_private *i915);
int intel_vga_register(struct drm_i915_private *i915);
void intel_vga_unregister(struct drm_i915_private *i915);
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index deb8a8b76965..d48db66fd4f3 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -902,6 +902,12 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
goto out_cleanup_gem;
+ /*
+ * Must do this after fbcon init so that
+ * vgacon_save_screen() works during the handover.
+ */
+ intel_vga_disable_mem(i915);
+
i915_driver_register(i915);
enable_rpm_wakeref_asserts(&i915->runtime_pm);
diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
index 6fc475a5db61..68e14b9b15c6 100644
--- a/drivers/gpu/drm/i915/i915_params.c
+++ b/drivers/gpu/drm/i915/i915_params.c
@@ -145,7 +145,10 @@ i915_param_named(disable_display, bool, 0400,
i915_param_named(memtest, bool, 0400,
"Perform a read/write test of all device memory on module load (default: off)");
-i915_param_named(mmio_debug, int, 0400,
+i915_param_named(enable_hd_vgaarb, bool, 0444,
+ "Enable support for VGA arbitration on Intel HD IGD. (default: false)");
+
+i915_param_named(mmio_debug, int, 0600,
"Enable the MMIO debug code for the first N failures (default: off). "
"This may negatively affect performance.");
diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h
index 2733cb6cfe09..501ca0d53e39 100644
--- a/drivers/gpu/drm/i915/i915_params.h
+++ b/drivers/gpu/drm/i915/i915_params.h
@@ -84,7 +84,8 @@ struct drm_printer;
param(bool, verbose_state_checks, true, 0) \
param(bool, nuclear_pageflip, false, 0400) \
param(bool, enable_dp_mst, true, 0600) \
- param(bool, enable_gvt, false, IS_ENABLED(CONFIG_DRM_I915_GVT) ? 0400 : 0)
+ param(bool, enable_gvt, false, IS_ENABLED(CONFIG_DRM_I915_GVT) ? 0400 : 0) \
+ param(bool, enable_hd_vgaarb, false, 0400)
#define MEMBER(T, member, ...) T member;
struct i915_params {
--
2.38.1