From patchwork Tue Jun 16 09:34:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 6616141 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 BED779F972 for ; Tue, 16 Jun 2015 09:34:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD6D62077A for ; Tue, 16 Jun 2015 09:34:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0489220761 for ; Tue, 16 Jun 2015 09:34:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B109D6E559; Tue, 16 Jun 2015 02:34:41 -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 8D3DA6E160 for ; Tue, 16 Jun 2015 02:34:40 -0700 (PDT) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 4FF93345B3F; Tue, 16 Jun 2015 09:34:40 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5G9YdQH013129; Tue, 16 Jun 2015 05:34:39 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id B4AFC81C55; Tue, 16 Jun 2015 11:34:38 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] Add virtio-vga bits. Date: Tue, 16 Jun 2015 11:34:29 +0200 Message-Id: <1434447271-16461-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1434447271-16461-1-git-send-email-kraxel@redhat.com> References: <1434447271-16461-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Cc: open list , "open list:VIRTIO GPU DRIVER" 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.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 | 44 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c index f4ec816..88a3916 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, 0); + ap->ranges[0].size = pci_resource_len(pci_dev, 0); + + 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; @@ -52,27 +72,11 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) struct pci_dev *pdev = to_pci_dev(vdev->dev.parent); bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; - if (vga) { - /* - * Need to make sure we don't have two drivers - * for the same hardware here. Some day we - * will simply kick out the firmware - * (vesa/efi) framebuffer. - * - * Virtual hardware specs for virtio-vga are - * not finalized yet, therefore we can't add - * code for that yet. - * - * So ignore the device for the time being, - * and suggest to the user use the device - * variant without vga compatibility mode. - */ - DRM_ERROR("virtio-vga not (yet) supported\n"); - DRM_ERROR("please use virtio-gpu-pci instead\n"); - ret = -ENODEV; - goto err_free; - } + 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);