hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/gpu/vga/vgaarb.c
....@@ -48,6 +48,8 @@
4848 #include <linux/miscdevice.h>
4949 #include <linux/slab.h>
5050 #include <linux/screen_info.h>
51
+#include <linux/vt.h>
52
+#include <linux/console.h>
5153
5254 #include <linux/uaccess.h>
5355
....@@ -167,6 +169,53 @@
167169 pci_dev_put(vga_default);
168170 vga_default = pci_dev_get(pdev);
169171 }
172
+
173
+/**
174
+ * vga_remove_vgacon - deactivete vga console
175
+ *
176
+ * Unbind and unregister vgacon in case pdev is the default vga
177
+ * device. Can be called by gpu drivers on initialization to make
178
+ * sure vga register access done by vgacon will not disturb the
179
+ * device.
180
+ *
181
+ * @pdev: pci device.
182
+ */
183
+#if !defined(CONFIG_VGA_CONSOLE)
184
+int vga_remove_vgacon(struct pci_dev *pdev)
185
+{
186
+ return 0;
187
+}
188
+#elif !defined(CONFIG_DUMMY_CONSOLE)
189
+int vga_remove_vgacon(struct pci_dev *pdev)
190
+{
191
+ return -ENODEV;
192
+}
193
+#else
194
+int vga_remove_vgacon(struct pci_dev *pdev)
195
+{
196
+ int ret = 0;
197
+
198
+ if (pdev != vga_default)
199
+ return 0;
200
+ vgaarb_info(&pdev->dev, "deactivate vga console\n");
201
+
202
+ console_lock();
203
+ if (con_is_bound(&vga_con))
204
+ ret = do_take_over_console(&dummy_con, 0,
205
+ MAX_NR_CONSOLES - 1, 1);
206
+ if (ret == 0) {
207
+ ret = do_unregister_con_driver(&vga_con);
208
+
209
+ /* Ignore "already unregistered". */
210
+ if (ret == -ENODEV)
211
+ ret = 0;
212
+ }
213
+ console_unlock();
214
+
215
+ return ret;
216
+}
217
+#endif
218
+EXPORT_SYMBOL(vga_remove_vgacon);
170219
171220 static inline void vga_irq_set_state(struct vga_device *vgadev, bool state)
172221 {
....@@ -480,7 +529,7 @@
480529 *
481530 * 0 on success, negative error code on failure.
482531 */
483
-int vga_tryget(struct pci_dev *pdev, unsigned int rsrc)
532
+static int vga_tryget(struct pci_dev *pdev, unsigned int rsrc)
484533 {
485534 struct vga_device *vgadev;
486535 unsigned long flags;
....@@ -505,7 +554,6 @@
505554 spin_unlock_irqrestore(&vga_lock, flags);
506555 return rc;
507556 }
508
-EXPORT_SYMBOL(vga_tryget);
509557
510558 /**
511559 * vga_put - release lock on legacy VGA resources
....@@ -676,7 +724,7 @@
676724 vga_arbiter_check_bridge_sharing(vgadev);
677725
678726 /* Add to the list */
679
- list_add(&vgadev->list, &vga_list);
727
+ list_add_tail(&vgadev->list, &vga_list);
680728 vga_count++;
681729 vgaarb_info(&pdev->dev, "VGA device added: decodes=%s,owns=%s,locks=%s\n",
682730 vga_iostate_to_str(vgadev->decodes),
....@@ -1408,6 +1456,18 @@
14081456 struct vga_device *vgadev;
14091457
14101458 #if defined(CONFIG_X86) || defined(CONFIG_IA64)
1459
+ u64 base = screen_info.lfb_base;
1460
+ u64 size = screen_info.lfb_size;
1461
+ u64 limit;
1462
+ resource_size_t start, end;
1463
+ unsigned long flags;
1464
+ int i;
1465
+
1466
+ if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
1467
+ base |= (u64)screen_info.ext_lfb_base << 32;
1468
+
1469
+ limit = base + size;
1470
+
14111471 list_for_each_entry(vgadev, &vga_list, list) {
14121472 struct device *dev = &vgadev->pdev->dev;
14131473 /*
....@@ -1418,11 +1478,6 @@
14181478 * Select the device owning the boot framebuffer if there is
14191479 * one.
14201480 */
1421
- resource_size_t start, end, limit;
1422
- unsigned long flags;
1423
- int i;
1424
-
1425
- limit = screen_info.lfb_base + screen_info.lfb_size;
14261481
14271482 /* Does firmware framebuffer belong to us? */
14281483 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
....@@ -1437,7 +1492,7 @@
14371492 if (!start || !end)
14381493 continue;
14391494
1440
- if (screen_info.lfb_base < start || limit >= end)
1495
+ if (base < start || limit >= end)
14411496 continue;
14421497
14431498 if (!vga_default_device())