Skip to contentSkip to conversation

uio: add generic driver for PCI 2.3 devices

RFC PATCH Superseded Michael S. Tsirkin 1 participant 1 message Jul 9, 2009

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

RFC PATCH 1/1 uio: add generic driver for PCI 2.3 devices

Resending with corrected addresses. Sorry about the churn.

-----------

I got annoyed by the fact that we don't support shared interrupts with PCI in assigned devides, so here's a draft patch to add that support in kernel through uio.

I intend to send this to lkml, but meanwhile I'd appreciate some early feedback/flames from people on the list.

Thanks!

----------->

This adds a generic uio driver that can bind to any PCI device. First user will be virtualization where a qemu userspace process needs to give guest OS access to the device.

Interrupts are handled using the Interrupt Disable bit in the PCI command register and Interrupt Status bit in the PCI status register. All devices compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should support these bits. Driver detects this support, and won't bind to devices which do not support the Interrupt Disable Bit in the command register.

It's expected that MSI/MSI-X support will be added to this driver in the future, to interface with virtualization irqfd/eventfd infrastructure. Another area to examine, and of interest to virtualization, is iommu.

---
 drivers/uio/Kconfig           |   10 ++
 drivers/uio/Makefile          |    1 +
 drivers/uio/uio_pci_generic.c |  202 +++++++++++++++++++++++++++++++++++++++++
 include/linux/pci_regs.h      |    1 +
 4 files changed, 214 insertions(+), 0 deletions(-)
 create mode 100644 drivers/uio/uio_pci_generic.c
drivers/uio/Kconfig +10 -0
index 7f86534..0f14c8e 100644
@@ -89,4 +89,14 @@ config UIO_SERCOS3
 
 	  If you compile this as a module, it will be called uio_sercos3.
 
+config UIO_PCI_GENERIC
+	tristate "Generic driver for PCI 2.3 and PCI Express cards"
+	depends on PCI
+	default n
+	help
+	  Generic driver that you can bind, dynamically, to any
+	  PCI 2.3 compliant and PCI Express card. It is useful,
+	  primarily, for virtualization scenarios.
+	  If you compile this as a module, it will be called uio_pci_generic.
+
 endif
drivers/uio/Makefile +1 -0
index 5c2586d..73b2e75 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_UIO_PDRV_GENIRQ)	+= uio_pdrv_genirq.o
 obj-$(CONFIG_UIO_SMX)	+= uio_smx.o
 obj-$(CONFIG_UIO_AEC)	+= uio_aec.o
 obj-$(CONFIG_UIO_SERCOS3)	+= uio_sercos3.o
+obj-$(CONFIG_UIO_PCI_GENERIC)	+= uio_pci_generic.o
drivers/uio/uio_pci_generic.c new file +202 -0

202 lines not on this page · raw message

include/linux/pci_regs.h +1 -0
index 616bf8b..bfb9b31 100644
@@ -42,6 +42,7 @@
 #define  PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
 
 #define PCI_STATUS		0x06	/* 16 bits */
+#define  PCI_STATUS_INTERRUPT	0x08	/* Interrupt status */
 #define  PCI_STATUS_CAP_LIST	0x10	/* Support Capability List */
 #define  PCI_STATUS_66MHZ	0x20	/* Support 66 Mhz PCI 2.1 bus */
 #define  PCI_STATUS_UDF		0x40	/* Support User Definable Features [obsolete] */
Signature · 1 line
1.6.2.5