aboutsummarylogtreecommitdiffstats
path: root/1002-6.8.0-i915-vga-arbiter.patch
blob: f7216f06e0d9e403add39c364c867277d8044af9 (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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
From 6f123acf4fecf575970c8b3ab0994ea0563fd41e Mon Sep 17 00:00:00 2001
From: xiota <>
Date: Wed, 13 Mar 2024 02:48:53 +0000
Subject: [PATCH 2/2] i915-vga-arbiter

---
 .../drm/i915/display/intel_display_driver.c   | 17 ++++++++--
 .../drm/i915/display/intel_display_driver.h   |  1 +
 .../drm/i915/display/intel_display_params.c   |  3 ++
 .../drm/i915/display/intel_display_params.h   |  1 +
 drivers/gpu/drm/i915/display/intel_vga.c      | 32 +++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_vga.h      |  4 +++
 6 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c b/drivers/gpu/drm/i915/display/intel_display_driver.c
index 9df9097a0..2c467daf8 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
@@ -29,6 +29,7 @@
 #include "intel_display_debugfs.h"
 #include "intel_display_driver.h"
 #include "intel_display_irq.h"
+#include "intel_display_params.h"
 #include "intel_display_power.h"
 #include "intel_display_types.h"
 #include "intel_display_wa.h"
@@ -215,9 +216,11 @@ int intel_display_driver_probe_noirq(struct drm_i915_private *i915)
 
 	intel_bios_init(i915);
 
-	ret = intel_vga_register(i915);
-	if (ret)
-		goto cleanup_bios;
+	if (!i915->display.params.enable_hd_vgaarb || !HAS_PCH_SPLIT(i915)) {
+		ret = intel_vga_register(i915);
+		if (ret)
+			goto cleanup_bios;
+	}
 
 	/* FIXME: completely on the wrong abstraction layer */
 	ret = intel_power_domains_init(i915);
@@ -372,6 +375,12 @@ int intel_display_driver_probe(struct drm_i915_private *i915)
 	if (ret)
 		return ret;
 
+	/*
+	 * Must do this after fbcon init so that
+	 * vgacon_save_screen() works during the handover.
+	 */
+	intel_vga_disable_mem(i915);
+
 	/* Only enable hotplug handling once the fbdev is fully set up. */
 	intel_hpd_init(i915);
 	intel_hpd_poll_disable(i915);
@@ -423,6 +432,7 @@ void intel_display_driver_remove(struct drm_i915_private *i915)
 	if (!HAS_DISPLAY(i915))
 		return;
 
+	intel_vga_enable_mem(i915);
 	flush_workqueue(i915->display.wq.flip);
 	flush_workqueue(i915->display.wq.modeset);
 
@@ -452,6 +462,7 @@ void intel_display_driver_remove_noirq(struct drm_i915_private *i915)
 	intel_unregister_dsm_handler();
 
 	/* flush any delayed tasks or pending work */
+	intel_vga_enable_mem(i915);
 	flush_workqueue(i915->unordered_wq);
 
 	intel_hdcp_component_fini(i915);
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.h b/drivers/gpu/drm/i915/display/intel_display_driver.h
index c276a58ee..54b752a93 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.h
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.h
@@ -13,6 +13,7 @@ struct drm_i915_private;
 struct drm_modeset_acquire_ctx;
 struct pci_dev;
 
+extern void intel_vga_disable_mem(struct drm_i915_private *dev_priv);
 bool intel_display_driver_probe_defer(struct pci_dev *pdev);
 void intel_display_driver_init_hw(struct drm_i915_private *i915);
 void intel_display_driver_early_probe(struct drm_i915_private *i915);
diff --git a/drivers/gpu/drm/i915/display/intel_display_params.c b/drivers/gpu/drm/i915/display/intel_display_params.c
index 11e03cfb7..8895be132 100644
--- a/drivers/gpu/drm/i915/display/intel_display_params.c
+++ b/drivers/gpu/drm/i915/display/intel_display_params.c
@@ -87,6 +87,9 @@ intel_display_param_named_unsafe(force_reset_modeset_test, bool, 0400,
 intel_display_param_named(disable_display, bool, 0400,
 	"Disable display (default: false)");
 
+intel_display_param_named(enable_hd_vgaarb, bool, 0444,
+	"Enable support for VGA arbitration on Intel HD IGD. (default: false)");
+
 intel_display_param_named(verbose_state_checks, bool, 0400,
 	"Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions.");
 
diff --git a/drivers/gpu/drm/i915/display/intel_display_params.h b/drivers/gpu/drm/i915/display/intel_display_params.h
index 6206cc51d..bfbc49c53 100644
--- a/drivers/gpu/drm/i915/display/intel_display_params.h
+++ b/drivers/gpu/drm/i915/display/intel_display_params.h
@@ -39,6 +39,7 @@ struct drm_i915_private;
 	param(bool, load_detect_test, false, 0600) \
 	param(bool, force_reset_modeset_test, false, 0600) \
 	param(bool, disable_display, false, 0400) \
+	param(bool, enable_hd_vgaarb, false, 0600) \
 	param(bool, verbose_state_checks, true, 0400) \
 	param(bool, nuclear_pageflip, false, 0400) \
 	param(bool, enable_dp_mst, true, 0600) \
diff --git a/drivers/gpu/drm/i915/display/intel_vga.c b/drivers/gpu/drm/i915/display/intel_vga.c
index 4b98833bf..25a729c95 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.c
+++ b/drivers/gpu/drm/i915/display/intel_vga.c
@@ -11,6 +11,7 @@
 #include "i915_drv.h"
 #include "i915_reg.h"
 #include "intel_de.h"
+#include "intel_display_params.h"
 #include "intel_vga.h"
 
 static i915_reg_t intel_vga_cntrl_reg(struct drm_i915_private *i915)
@@ -45,6 +46,36 @@ void intel_vga_disable(struct drm_i915_private *dev_priv)
 	intel_de_posting_read(dev_priv, vga_reg);
 }
 
+void intel_vga_enable_mem(struct drm_i915_private *dev_priv)
+{
+	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
+
+	/* Enable VGA memory on Intel HD */
+	if (dev_priv->display.params.enable_hd_vgaarb && HAS_PCH_SPLIT(dev_priv)) {
+		vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO);
+		outb(inb(VGA_MIS_R) | (1 << 1), VGA_MIS_W);
+		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 *dev_priv)
+{
+	struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
+	/* Disable VGA memory on Intel HD */
+	if (dev_priv->display.params.enable_hd_vgaarb && HAS_PCH_SPLIT(dev_priv)) {
+		vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO);
+		outb(inb(VGA_MIS_R) & ~(1 << 1), VGA_MIS_W);
+		vga_set_legacy_decoding(pdev, VGA_RSRC_LEGACY_IO |
+						   VGA_RSRC_NORMAL_IO |
+						   VGA_RSRC_NORMAL_MEM);
+		vga_put(pdev, VGA_RSRC_LEGACY_IO);
+	}
+}
+
 void intel_vga_redisable_power_on(struct drm_i915_private *dev_priv)
 {
 	i915_reg_t vga_reg = intel_vga_cntrl_reg(dev_priv);
@@ -53,6 +84,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);
 	}
 }
 
diff --git a/drivers/gpu/drm/i915/display/intel_vga.h b/drivers/gpu/drm/i915/display/intel_vga.h
index ba5b55b91..7e2af7924 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.h
+++ b/drivers/gpu/drm/i915/display/intel_vga.h
@@ -15,4 +15,8 @@ void intel_vga_redisable_power_on(struct drm_i915_private *i915);
 int intel_vga_register(struct drm_i915_private *i915);
 void intel_vga_unregister(struct drm_i915_private *i915);
 
+/* i915 vga arb patch */
+void intel_vga_enable_mem(struct drm_i915_private *i915);
+void intel_vga_disable_mem(struct drm_i915_private *i915);
+
 #endif /* __INTEL_VGA_H__ */
-- 
2.44.0