From patchwork Wed Apr 1 13:15:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 6140251 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3A0B39F2EC for ; Wed, 1 Apr 2015 13:16:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C76720109 for ; Wed, 1 Apr 2015 13:16:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 70903201F5 for ; Wed, 1 Apr 2015 13:16:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F9BF6E875; Wed, 1 Apr 2015 06:16:10 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTP id A4CAA6E875 for ; Wed, 1 Apr 2015 06:16:09 -0700 (PDT) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t31DG6ol004796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 1 Apr 2015 09:16:06 -0400 Received: from nilsson.home.kraxel.org (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t31DG5bg031457; Wed, 1 Apr 2015 09:16:06 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id AC62E80F99; Wed, 1 Apr 2015 15:16:04 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org, virtio-dev@lists.oasis-open.org Subject: [PATCH v2 4/4] Add virtio-vga bits. Date: Wed, 1 Apr 2015 15:15:30 +0200 Message-Id: <1427894130-14228-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1427894130-14228-1-git-send-email-kraxel@redhat.com> References: <1427894130-14228-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Cc: mst@redhat.com, Rusty Russell , open list , "open list:VIRTIO CORE, NET..." , airlied@redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP --- 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) {