Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1059509ybe; Wed, 11 Sep 2019 08:45:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2oJe2EwOvqCb9naxEhRCOMD4M214dp4p4w3n2qyhPXEgcL8v/NuyAIuoWx0V9+8HOVJ1t X-Received: by 2002:a50:eb07:: with SMTP id y7mr1049957edp.240.1568216755834; Wed, 11 Sep 2019 08:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568216755; cv=none; d=google.com; s=arc-20160816; b=CnJPtrrMy6m9pzJPLfcHeFx8gFg6TE6aofqg8vOwFKpaRqePYt1prnoUsckFHL5c0p ZyoCZimdSAC9wn5QJwAKveVlBcOkb5v7HhQpcqzPkvczJ2a918I+tqtnneTVMiYVrVUK mpB0B6GX4SiIowfTn3+Mh5Ox1ebxI1G4Qli9OHur0YfYQXUEzNlTg81hVTAfPbL6rvdY /16TzX+8JUcmkztsPGK/LSmRQSEkZaSQKBk2889sZp27U7obuxt6YUDUkTuJTwdUcFPj oad5yKws9tLbj1tGlFnyTy1R20Co1hQy5odbns3dF8Vg2arW6UuHqVg2ABPWq5cSIhfg gtdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=6S3cW21efHHXgPvl9wdqmlB0LlK39d0N2VP8/0kADf4=; b=ICF+OZZO/RFV/uFVsf+GhC/jzdmvqE/GpKZoyzk+9T3bnDjYiMBSc4lC9rHouuobzI kznchb/Sh+SZdGxSLNnrxdOXgPJGucvSZeA3PktK4PdDX+hLLrx2IOexVj1EBDNjJTqs hdANaGXYSVHIv7Zr/+zD7paj6o5ISEEzHDqkUN+U+HqDO508OWzQe8lUDzQ+up0k43LT 0qqnLmvDSdgGDVTA1J/mqpGmZRP+iCkOXZJmRsXMFyvfXSA0WJK5UfD7LsnUFCbKcyGh V1hC+z9PZ3hWtTU536BazL8Ufl6ojsLsOk3afY3QF97x8Nu+i2VmC9YBpD9y1426bcaj JHKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i14si11483163ejb.271.2019.09.11.08.45.31; Wed, 11 Sep 2019 08:45:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728641AbfIKPkh (ORCPT + 99 others); Wed, 11 Sep 2019 11:40:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43574 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727581AbfIKPkh (ORCPT ); Wed, 11 Sep 2019 11:40:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BCB53084029; Wed, 11 Sep 2019 15:40:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C6FA5C21E; Wed, 11 Sep 2019 15:40:35 +0000 (UTC) Received: from zmail25.collab.prod.int.phx2.redhat.com (zmail25.collab.prod.int.phx2.redhat.com [10.5.83.31]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A9C2118089C8; Wed, 11 Sep 2019 15:40:34 +0000 (UTC) Date: Wed, 11 Sep 2019 11:40:34 -0400 (EDT) From: Frediano Ziglio To: Gerd Hoffmann Cc: dri-devel@lists.freedesktop.org, Dave Airlie , David Airlie , Daniel Vetter , "open list:DRM DRIVER FOR QXL VIRTUAL GPU" , "open list:DRM DRIVER FOR QXL VIRTUAL GPU" , open list Message-ID: <964578816.11586547.1568216434638.JavaMail.zimbra@redhat.com> In-Reply-To: <20190805105401.29874-1-kraxel@redhat.com> References: <20190805105401.29874-1-kraxel@redhat.com> Subject: Re: [PATCH v2] drm/qxl: get vga ioports MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.33.32.18, 10.4.195.2] Thread-Topic: drm/qxl: get vga ioports Thread-Index: d9HGlWxFC1mjLzRge3s5uc+6p+5ECg== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 11 Sep 2019 15:40:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > 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 > Signed-off-by: Gerd Hoffmann Acked-by: Frediano Ziglio > --- > drivers/gpu/drm/qxl/qxl_drv.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c > index b57a37543613..fcb48ac60598 100644 > --- a/drivers/gpu/drm/qxl/qxl_drv.c > +++ b/drivers/gpu/drm/qxl/qxl_drv.c > @@ -63,6 +63,11 @@ module_param_named(num_heads, qxl_num_crtc, int, 0400); > static struct drm_driver qxl_driver; > static struct pci_driver qxl_pci_driver; > > +static bool is_vga(struct pci_dev *pdev) > +{ > + return pdev->class == PCI_CLASS_DISPLAY_VGA << 8; > +} > + > static int > qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > { > @@ -87,9 +92,17 @@ qxl_pci_probe(struct pci_dev *pdev, const struct > pci_device_id *ent) > if (ret) > goto disable_pci; > > + if (is_vga(pdev)) { > + ret = vga_get_interruptible(pdev, VGA_RSRC_LEGACY_IO); > + if (ret) { > + DRM_ERROR("can't get legacy vga ioports\n"); > + goto disable_pci; > + } > + } > + > ret = qxl_device_init(qdev, &qxl_driver, pdev); > if (ret) > - goto disable_pci; > + goto put_vga; > > ret = qxl_modeset_init(qdev); > if (ret) > @@ -109,6 +122,9 @@ qxl_pci_probe(struct pci_dev *pdev, const struct > pci_device_id *ent) > qxl_modeset_fini(qdev); > unload: > qxl_device_fini(qdev); > +put_vga: > + if (is_vga(pdev)) > + vga_put(pdev, VGA_RSRC_LEGACY_IO); > disable_pci: > pci_disable_device(pdev); > free_dev: > @@ -126,6 +142,8 @@ qxl_pci_remove(struct pci_dev *pdev) > > qxl_modeset_fini(qdev); > qxl_device_fini(qdev); > + if (is_vga(pdev)) > + vga_put(pdev, VGA_RSRC_LEGACY_IO); > > dev->dev_private = NULL; > kfree(qdev); Frediano