Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/qxl: get vga ioports

qxl has two modes: "native" (used by the drm driver) and "vga" (vga
compatibility mode, typically used for boot display and firmware
framebuffers).

Accessing any vga ioport will switch the qxl device into vga mode.
The qxl driver never does that, but other drivers accessing vga ports
can trigger that too and therefore disturb qxl operation. So aquire
the legacy vga ioports from vgaarb to avoid that.

Reproducer: Boot kvm guest with both qxl and i915 vgpu, with qxl being
first in pci scan order.

v2: Skip this for secondary qxl cards which don't have vga mode in the
first place (Frediano).

Cc: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190805105401.29874-1-kraxel@redhat.com

+19 -1
+19 -1
drivers/gpu/drm/qxl/qxl_drv.c
··· 59 59 static struct drm_driver qxl_driver; 60 60 static struct pci_driver qxl_pci_driver; 61 61 62 + static bool is_vga(struct pci_dev *pdev) 63 + { 64 + return pdev->class == PCI_CLASS_DISPLAY_VGA << 8; 65 + } 66 + 62 67 static int 63 68 qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 64 69 { ··· 88 83 if (ret) 89 84 goto disable_pci; 90 85 86 + if (is_vga(pdev)) { 87 + ret = vga_get_interruptible(pdev, VGA_RSRC_LEGACY_IO); 88 + if (ret) { 89 + DRM_ERROR("can't get legacy vga ioports\n"); 90 + goto disable_pci; 91 + } 92 + } 93 + 91 94 ret = qxl_device_init(qdev, &qxl_driver, pdev); 92 95 if (ret) 93 - goto disable_pci; 96 + goto put_vga; 94 97 95 98 ret = qxl_modeset_init(qdev); 96 99 if (ret) ··· 118 105 qxl_modeset_fini(qdev); 119 106 unload: 120 107 qxl_device_fini(qdev); 108 + put_vga: 109 + if (is_vga(pdev)) 110 + vga_put(pdev, VGA_RSRC_LEGACY_IO); 121 111 disable_pci: 122 112 pci_disable_device(pdev); 123 113 free_dev: ··· 138 122 139 123 qxl_modeset_fini(qdev); 140 124 qxl_device_fini(qdev); 125 + if (is_vga(pdev)) 126 + vga_put(pdev, VGA_RSRC_LEGACY_IO); 141 127 142 128 dev->dev_private = NULL; 143 129 kfree(qdev);