History

drm: move i915_kick_out_vgacon to vgaarb

Also rename it to vga_remove_vgacon and add kerneldoc text.

Gerd Hoffmann committed 7 years ago

Commit c6b38fb1 parent e552f083 files · +52 −34Browse files

Unified · Split

3 files
  1. drivers/gpu/drm/i915/i915_drv.c +1 −34
  2. drivers/gpu/vga/vgaarb.c +49 −0
  3. include/linux/vgaarb.h +2 −0
drivers/gpu/drm/i915/i915_drv.c+1−34
@@ -757,39 +757,6 @@ static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv) · 756 unmodified lines
757757 return ret;
758758 }
759759
760−#if !defined(CONFIG_VGA_CONSOLE)
761−static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
762−{
763− return 0;
764−}
765−#elif !defined(CONFIG_DUMMY_CONSOLE)
766−static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
767−{
768− return -ENODEV;
769−}
770−#else
771−static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
772−{
773− int ret = 0;
774−
775− DRM_INFO("Replacing VGA console driver\n");
776−
777− console_lock();
778− if (con_is_bound(&vga_con))
779− ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1);
780− if (ret == 0) {
781− ret = do_unregister_con_driver(&vga_con);
782−
783− /* Ignore "already unregistered". */
784− if (ret == -ENODEV)
785− ret = 0;
786− }
787− console_unlock();
788−
789− return ret;
790−}
791−#endif
792−
793760 static void intel_init_dpio(struct drm_i915_private *dev_priv)
794761 {
795762 /*
@@ -1420,7 +1387,7 @@ static int i915_driver_init_hw(struct drm_i915_private *dev_priv) · 624 unmodified lines
14201387 goto err_ggtt;
14211388 }
14221389
1423− ret = i915_kick_out_vgacon(dev_priv);
1390+ ret = vga_remove_vgacon(pdev);
14241391 if (ret) {
14251392 DRM_ERROR("failed to remove conflicting VGA console\n");
14261393 goto err_ggtt;
drivers/gpu/vga/vgaarb.c+49−0
@@ -48,6 +48,8 @@ · 47 unmodified lines
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
@@ -168,6 +170,53 @@ void vga_set_default_device(struct pci_dev *pdev) · 114 unmodified lines
168170 vga_default = pci_dev_get(pdev);
169171 }
170172
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);
219+
171220 static inline void vga_irq_set_state(struct vga_device *vgadev, bool state)
172221 {
173222 if (vgadev->irq_set_state)
include/linux/vgaarb.h+2−0
@@ -125,9 +125,11 @@ extern void vga_put(struct pci_dev *pdev, unsigned int rsrc); · 124 unmodified lines
125125 #ifdef CONFIG_VGA_ARB
126126 extern struct pci_dev *vga_default_device(void);
127127 extern void vga_set_default_device(struct pci_dev *pdev);
128+extern int vga_remove_vgacon(struct pci_dev *pdev);
128129 #else
129130 static inline struct pci_dev *vga_default_device(void) { return NULL; };
130131 static inline void vga_set_default_device(struct pci_dev *pdev) { };
132+static inline int vga_remove_vgacon(struct pci_dev *pdev) { return 0; };
131133 #endif
132134
133135 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t