LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: alex.williamson@redhat.com, kvm@vger.kernel.org
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] vfio-pci: Add module option to disable VGA region access
Date: Wed, 04 Mar 2015 13:02:49 -0700	[thread overview]
Message-ID: <20150304200249.26766.14344.stgit@gimli.home> (raw)
In-Reply-To: <20150304194711.26766.75450.stgit@gimli.home>

Add a module option so that we don't require a CONFIG change and
kernel rebuild to disable VGA support.  Not only can VGA support be
troublesome in itself, but by disabling it we can reduce the impact
to host devices by doing a VGA arbitration opt-out.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/vfio/pci/vfio_pci.c |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index b3bae4c..9c854b0 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -41,8 +41,24 @@ module_param_named(nointxmask, nointxmask, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(nointxmask,
 		  "Disable support for PCI 2.3 style INTx masking.  If this resolves problems for specific devices, report lspci -vvvxxx to linux-pci@vger.kernel.org so the device can be fixed automatically via the broken_intx_masking flag.");
 
+#ifdef CONFIG_VFIO_PCI_VGA
+static bool disable_vga;
+module_param_named(disable_vga, disable_vga, bool, S_IRUGO);
+MODULE_PARM_DESC(disable_vga,
+		 "Disable VGA resource access for VGA-capable devices");
+#endif
+
 static DEFINE_MUTEX(driver_lock);
 
+static inline bool vfio_vga_disabled(void)
+{
+#ifdef CONFIG_VFIO_PCI_VGA
+	return disable_vga;
+#else
+	return true;
+#endif
+}
+
 static void vfio_pci_try_bus_reset(struct vfio_pci_device *vdev);
 
 static int vfio_pci_enable(struct vfio_pci_device *vdev)
@@ -97,10 +113,8 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
 	} else
 		vdev->msix_bar = 0xFF;
 
-#ifdef CONFIG_VFIO_PCI_VGA
-	if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+	if (!vfio_vga_disabled() && (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
 		vdev->has_vga = true;
-#endif
 
 	return 0;
 }


  parent reply	other threads:[~2015-03-04 20:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 20:02 [PATCH 0/5] vfio-pci: Misc enhancements Alex Williamson
2015-03-04 20:02 ` [PATCH 1/5] vfio-pci: Allow PCI IDs to be specified as module options Alex Williamson
2015-03-04 20:49   ` Bandan Das
2015-03-04 22:18     ` Alex Williamson
2015-03-04 22:32       ` Bandan Das
2015-03-04 23:01         ` Alex Williamson
2015-03-06 22:11   ` Bjorn Helgaas
2015-03-11 20:14     ` Alex Williamson
2015-03-11 20:20       ` Bjorn Helgaas
2015-03-04 20:02 ` Alex Williamson [this message]
2015-03-04 20:02 ` [PATCH 3/5] vfio-pci: Remove warning if try-reset fails Alex Williamson
2015-03-04 20:03 ` [PATCH 4/5] vfio-pci: Move idle devices to D3hot power state Alex Williamson
2015-03-04 20:03 ` [PATCH 5/5] vfio-pci: Add VGA arbiter client Alex Williamson

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=20150304200249.26766.14344.stgit@gimli.home \
    --to=alex.williamson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --subject='Re: [PATCH 2/5] vfio-pci: Add module option to disable VGA region access' \
    /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

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).