aboutsummarylogtreecommitdiffstats
path: root/1002-6.13.0-i915-vga-arbiter.patch
blob: a6a783be8dab1efc26ffea1a48147614218e4e6e (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
From 32d421bf11726bac8f1bbf105095db02023117d5 Mon Sep 17 00:00:00 2001
From: xiota <>
Date: Mon, 27 Jan 2025 05:45:27 +0000
Subject: [PATCH] i915-vga-arbiter

---
 .../drm/i915/display/intel_display_driver.c   | 20 +++++++++--
 .../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      | 33 +++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_vga.h      |  4 +++
 .../gpu/drm/xe/compat-i915-headers/i915_drv.h |  7 ++++
 7 files changed, 66 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 56b78cf6b..b787f82dc 100644
--- a/drivers/gpu/drm/i915/display/intel_display_driver.c
+++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
@@ -30,6 +30,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"
@@ -221,9 +222,11 @@ int intel_display_driver_probe_noirq(struct drm_i915_private *i915)
 
 	intel_bios_init(display);
 
-	ret = intel_vga_register(display);
-	if (ret)
-		goto cleanup_bios;
+	if (!display->params.enable_hd_vgaarb || !HAS_PCH_SPLIT(i915)) {
+		ret = intel_vga_register(display);
+		if (ret)
+			goto cleanup_bios;
+	}
 
 	/* FIXME: completely on the wrong abstraction layer */
 	ret = intel_power_domains_init(i915);
@@ -520,6 +523,12 @@ int intel_display_driver_probe(struct drm_i915_private *i915)
 
 	intel_overlay_setup(i915);
 
+	/*
+	 * Must do this after fbcon init so that
+	 * vgacon_save_screen() works during the handover.
+	 */
+	intel_vga_disable_mem(display);
+
 	/* Only enable hotplug handling once the fbdev is fully set up. */
 	intel_hpd_init(i915);
 
@@ -566,9 +575,13 @@ void intel_display_driver_register(struct drm_i915_private *i915)
 /* part #1: call before irq uninstall */
 void intel_display_driver_remove(struct drm_i915_private *i915)
 {
+	struct intel_display *display = &i915->display;
+
 	if (!HAS_DISPLAY(i915))
 		return;
 
+	intel_vga_enable_mem(display);
+
 	flush_workqueue(i915->display.wq.flip);
 	flush_workqueue(i915->display.wq.modeset);
 
@@ -599,6 +612,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(display);
 	flush_workqueue(i915->unordered_wq);
 
 	intel_hdcp_component_fini(display);
diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.h b/drivers/gpu/drm/i915/display/intel_display_driver.h
index 42cc4af6d..3b233969b 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 intel_display *display);
 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 024de8abc..efc57e90c 100644
--- a/drivers/gpu/drm/i915/display/intel_display_params.c
+++ b/drivers/gpu/drm/i915/display/intel_display_params.c
@@ -94,6 +94,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, 0400,
+	"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 dcb6face9..1900b9ff9 100644
--- a/drivers/gpu/drm/i915/display/intel_display_params.h
+++ b/drivers/gpu/drm/i915/display/intel_display_params.h
@@ -40,6 +40,7 @@ struct drm_printer;
 	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 fd18dd07a..a587c5bc2 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.c
+++ b/drivers/gpu/drm/i915/display/intel_vga.c
@@ -12,6 +12,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 intel_display *display)
@@ -46,6 +47,37 @@ void intel_vga_disable(struct intel_display *display)
 	intel_de_posting_read(display, vga_reg);
 }
 
+void intel_vga_enable_mem(struct intel_display *display)
+{
+	struct pci_dev *pdev = to_pci_dev(display->drm->dev);
+	struct drm_i915_private *i915 = pdev_to_i915(pdev);
+	/* Enable VGA memory on Intel HD */
+	if (display->params.enable_hd_vgaarb && HAS_PCH_SPLIT(i915)) {
+		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 intel_display *display)
+{
+	struct pci_dev *pdev = to_pci_dev(display->drm->dev);
+	struct drm_i915_private *i915 = pdev_to_i915(pdev);
+	/* Disable VGA memory on Intel HD */
+	if (display->params.enable_hd_vgaarb && HAS_PCH_SPLIT(i915)) {
+		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 intel_display *display)
 {
 	i915_reg_t vga_reg = intel_vga_cntrl_reg(display);
@@ -54,6 +86,7 @@ void intel_vga_redisable_power_on(struct intel_display *display)
 		drm_dbg_kms(display->drm,
 			    "Something enabled VGA plane, disabling it\n");
 		intel_vga_disable(display);
+		intel_vga_disable_mem(display);
 	}
 }
 
diff --git a/drivers/gpu/drm/i915/display/intel_vga.h b/drivers/gpu/drm/i915/display/intel_vga.h
index 824dfc32a..ebe2c89d9 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 intel_display *display);
 int intel_vga_register(struct intel_display *display);
 void intel_vga_unregister(struct intel_display *display);
 
+/* i915 vga arb patch */
+void intel_vga_enable_mem(struct intel_display *display);
+void intel_vga_disable_mem(struct intel_display *display);
+
 #endif /* __INTEL_VGA_H__ */
diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
index 84b0991b3..a908e706e 100644
--- a/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
+++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
@@ -22,6 +22,13 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
 	return container_of(dev, struct drm_i915_private, drm);
 }
 
+static inline struct drm_i915_private *pdev_to_i915(struct pci_dev *pdev)
+{
+	struct drm_device *drm = pci_get_drvdata(pdev);
+
+	return drm ? to_i915(drm) : NULL;
+}
+
 #define IS_PLATFORM(xe, x) ((xe)->info.platform == x)
 #define INTEL_INFO(dev_priv)	(&((dev_priv)->info))
 #define IS_I830(dev_priv)	(dev_priv && 0)
-- 
2.48.1