linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: dri-devel@lists.freedesktop.org, virtio-dev@lists.oasis-open.org
Cc: airlied@gmail.com, airlied@redhat.com, mst@redhat.com,
	Gerd Hoffmann <kraxel@redhat.com>,
	David Airlie <airlied@linux.ie>,
	Rusty Russell <rusty@rustcorp.com.au>,
	linux-kernel@vger.kernel.org (open list),
	virtualization@lists.linux-foundation.org (open list:VIRTIO CORE,
	NET...)
Subject: [PATCH v2 4/4] Add virtio-vga bits.
Date: Wed,  1 Apr 2015 15:15:30 +0200	[thread overview]
Message-ID: <1427894130-14228-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1427894130-14228-1-git-send-email-kraxel@redhat.com>

---
 drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 32 ++++++++++++++++++++++++++++++--
 drivers/virtio/virtio_pci_common.c       |  7 ++++++-
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
index 56bd4ed..33d12d5 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c
@@ -37,6 +37,26 @@ int drm_virtio_set_busid(struct drm_device *dev, struct drm_master *master)
 	return 0;
 }
 
+static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev)
+{
+	struct apertures_struct *ap;
+	bool primary;
+
+	ap = alloc_apertures(1);
+	if (!ap)
+		return;
+
+	ap->ranges[0].base = pci_resource_start(pci_dev, 2);
+	ap->ranges[0].size = pci_resource_len(pci_dev, 2);
+
+	primary = pci_dev->resource[PCI_ROM_RESOURCE].flags
+		& IORESOURCE_ROM_SHADOW;
+
+	remove_conflicting_framebuffers(ap, "virtiodrmfb", primary);
+
+	kfree(ap);
+}
+
 int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
 {
 	struct drm_device *dev;
@@ -48,8 +68,16 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
 	dev->virtdev = vdev;
 	vdev->priv = dev;
 
-	if (strcmp(vdev->dev.parent->bus->name, "pci") == 0)
-		dev->pdev = to_pci_dev(vdev->dev.parent);
+	if (strcmp(vdev->dev.parent->bus->name, "pci") == 0) {
+		struct pci_dev *pdev = to_pci_dev(vdev->dev.parent);
+		bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
+
+		DRM_INFO("pci: %s detected\n",
+			 vga ? "virtio-vga" : "virtio-gpu-pci");
+		dev->pdev = pdev;
+		if (vga)
+			virtio_pci_kick_out_firmware_fb(pdev);
+	}
 
 	ret = drm_dev_register(dev, 0);
 	if (ret)
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index e894eb2..36d82e8 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -510,7 +510,12 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
 		goto err_enable_device;
 
 	rc = pci_request_regions(pci_dev, "virtio-pci");
-	if (rc)
+	/*
+	 * virtio-vga: vesafb/efifb might hold vga framebuffer
+	 * resource, but don't fail on that, we'll kick out vesafb
+	 * later on.
+	 */
+	if (rc && ((pci_dev->class >> 8) != PCI_CLASS_DISPLAY_VGA))
 		goto err_request_regions;
 
 	if (force_legacy) {
-- 
1.8.3.1


  parent reply	other threads:[~2015-04-01 13:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1427894130-14228-1-git-send-email-kraxel@redhat.com>
2015-04-01 13:15 ` [PATCH v2 1/4] break kconfig dependency loop Gerd Hoffmann
2015-04-01 13:47   ` Jani Nikula
2015-04-06  9:50     ` Paul Bolle
2015-04-06 14:27       ` Mauro Carvalho Chehab
     [not found]   ` <CAEG8a3+Wp-jgtwKmcBhG2gVAOP2tQ5MHuJwYe-m2HwYQRB06HQ@mail.gmail.com>
2015-04-01 15:08     ` Michael S. Tsirkin
2015-04-01 15:38     ` Gerd Hoffmann
2015-05-14 18:23   ` Mauro Carvalho Chehab
2015-04-01 13:15 ` [PATCH v2 2/4] drm_vblank_get: don't WARN_ON in case vblanks are not initialized Gerd Hoffmann
2015-04-02 13:37   ` Alex Deucher
2015-04-01 13:15 ` [PATCH v2 3/4] Add virtio gpu driver Gerd Hoffmann
2015-04-01 13:31   ` Michael S. Tsirkin
     [not found]   ` <CAJ+F1CK3ibbn8e1-rUY4OUJuaCt_=JmuT00Fqx4YDD9M5zJv=A@mail.gmail.com>
2015-04-07  9:41     ` Gerd Hoffmann
2015-04-01 13:15 ` Gerd Hoffmann [this message]
2015-04-01 13:26   ` [PATCH v2 4/4] Add virtio-vga bits Michael S. Tsirkin
2015-04-01 13:42     ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427894130-14228-5-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=airlied@gmail.com \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).