Skip to contentSkip to conversation

virtio: remove explicit pci ids from virtio_pci.c

PATCH In review Rusty Russell 6 participants 7 messages Jan 21, 2008 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio: remove explicit pci ids from virtio_pci.c

Qumranet let us use their PCI vendor ID, with device ids >= 0x1000. We can specify that we accept all of them in the device ID table, and then return -ENODEV in the probe routine.

modprobe will load all the modules which match a given alias so we might be loaded when we're not needed, but that's the worst that can happen.

---
 drivers/virtio/virtio_pci.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/virtio/virtio_pci.c +6 -3
diff -r 4edff5e24614 drivers/virtio/virtio_pci.c
@@ -62,10 +62,9 @@ struct virtio_pci_vq_info
 	struct list_head node;
 };
 
-/* We have to enumerate here all virtio PCI devices. */
+/* Qumranet donated their vendor ID and devices >= 0x1000 */
 static struct pci_device_id virtio_pci_id_table[] = {
-	{ 0x1af4, 0x1000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* virtio net */
-	{ 0x1af4, 0x1001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* virtio blk */
+	{ 0x1af4, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
 	{ 0 },
 };
 
@@ -303,6 +302,10 @@ static int __devinit virtio_pci_probe(st
 	struct virtio_pci_device *vp_dev;
 	int err;
 
+	/* We only own device ids >= 0x1000 */
+	if (pci_dev->device < 0x1000)
+		return -ENODEV;
+
 	/* allocate our structure and fill it out */
 	vp_dev = kzalloc(sizeof(struct virtio_pci_device), GFP_KERNEL);
 	if (vp_dev == NULL)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#2 lore raw
In reply to a message not in the archive
Quoted 4 lines · Rusty Russell

Qumranet let us use their PCI vendor ID, with device ids >= 0x1000. We can specify that we accept all of them in the device ID table, and then return -ENODEV in the probe routine.

I thought the device id range was smaller. Avi?

Regards,

Anthony Liguori

Quoted 27 lines

modprobe will load all the modules which match a given alias so we might be loaded when we're not needed, but that's the worst that can happen.

---
 drivers/virtio/virtio_pci.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff -r 4edff5e24614 drivers/virtio/virtio_pci.c

drivers/virtio/virtio_pci.c +2 -3
@@ -62,10 +62,9 @@ struct virtio_pci_vq_info
 	struct list_head node;
 };
 
-/* We have to enumerate here all virtio PCI devices. */
+/* Qumranet donated their vendor ID and devices >= 0x1000 */
 static struct pci_device_id virtio_pci_id_table[] = {
-	{ 0x1af4, 0x1000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* virtio net */
-	{ 0x1af4, 0x1001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* virtio blk */
+	{ 0x1af4, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
 	{ 0 },
 };
 

drivers/virtio/virtio_pci.c static int __devinit virtio_pci_probe(st · line 311

Quoted 10 lines
drivers/virtio/virtio_pci.c +4 -0
@@ -303,6 +302,10 @@ static int __devinit virtio_pci_probe(st
 	struct virtio_pci_device *vp_dev;
 	int err;
 
+	/* We only own device ids >= 0x1000 */
+	if (pci_dev->device < 0x1000)
+		return -ENODEV;
+
 	/* allocate our structure and fill it out */
 	vp_dev = kzalloc(sizeof(struct virtio_pci_device), GFP_KERNEL);
 	if (vp_dev == NULL)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#9 lore raw
In reply to Rusty Russell
Quoted 4 lines · Rusty Russell

Qumranet let us use their PCI vendor ID, with device ids >= 0x1000. We can specify that we accept all of them in the device ID table, and then return -ENODEV in the probe routine.

I thought the device id range was smaller. Avi?

Regards,

Anthony Liguori

Quoted 37 lines

modprobe will load all the modules which match a given alias so we might be loaded when we're not needed, but that's the worst that can happen.

---
 drivers/virtio/virtio_pci.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff -r 4edff5e24614 drivers/virtio/virtio_pci.c

drivers/virtio/virtio_pci.c +6 -3
@@ -62,10 +62,9 @@ struct virtio_pci_vq_info
 	struct list_head node;
 };
 
-/* We have to enumerate here all virtio PCI devices. */
+/* Qumranet donated their vendor ID and devices >= 0x1000 */
 static struct pci_device_id virtio_pci_id_table[] = {
-	{ 0x1af4, 0x1000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* virtio net */
-	{ 0x1af4, 0x1001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* virtio blk */
+	{ 0x1af4, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
 	{ 0 },
 };
 
@@ -303,6 +302,10 @@ static int __devinit virtio_pci_probe(st
 	struct virtio_pci_device *vp_dev;
 	int err;
 
+	/* We only own device ids >= 0x1000 */
+	if (pci_dev->device < 0x1000)
+		return -ENODEV;
+
 	/* allocate our structure and fill it out */
 	vp_dev = kzalloc(sizeof(struct virtio_pci_device), GFP_KERNEL);
 	if (vp_dev == NULL)
#4 lore raw
In reply to a message not in the archive
Quoted 8 lines · Anthony Liguori
Quoted 4 lines · Rusty Russell

Qumranet let us use their PCI vendor ID, with device ids >= 0x1000. We can specify that we accept all of them in the device ID table, and then return -ENODEV in the probe routine.

I thought the device id range was smaller. Avi?

Yes, 0x1000-0x10ff IIRC.

Also, if we break compatibility in the future, won't this claim devices we don't actually support?

Signature · 7 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
#8 lore raw
In reply to Anthony Liguori
Quoted 8 lines · Anthony Liguori
Quoted 4 lines · Rusty Russell

Qumranet let us use their PCI vendor ID, with device ids >= 0x1000. We can specify that we accept all of them in the device ID table, and then return -ENODEV in the probe routine.

I thought the device id range was smaller. Avi?

Yes, 0x1000-0x10ff IIRC.

Also, if we break compatibility in the future, won't this claim devices we don't actually support?

Signature · 1 line
error compiling committee.c: too many arguments to function
#6 lore raw
In reply to a message not in the archive
Quoted 6 lines · On Monday 21 January 2008 20:12:46 Avi Kivity wrote:
Quoted 5 lines · Anthony Liguori
Quoted 3 lines · Rusty Russell

Qumranet let us use their PCI vendor ID, with device ids >= 0x1000. We can specify that we accept all of them in the device ID table, and then return -ENODEV in the probe routine.

Quoted 6 lines
Quoted 1 line

I thought the device id range was smaller. Avi?

Yes, 0x1000-0x10ff IIRC.

Also, if we break compatibility in the future, won't this claim devices we don't actually support?

Yep, I reduced it to 0x1000 - 0x103F for the moment. We can always expand long before we get our 64th device type.

Cheers,
Rusty.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#7 lore raw
In reply to Avi Kivity
Quoted 6 lines · On Monday 21 January 2008 20:12:46 Avi Kivity wrote:
Quoted 5 lines · Anthony Liguori
Quoted 3 lines · Rusty Russell

Qumranet let us use their PCI vendor ID, with device ids >= 0x1000. We can specify that we accept all of them in the device ID table, and then return -ENODEV in the probe routine.

Quoted 6 lines
Quoted 1 line

I thought the device id range was smaller. Avi?

Yes, 0x1000-0x10ff IIRC.

Also, if we break compatibility in the future, won't this claim devices we don't actually support?

Yep, I reduced it to 0x1000 - 0x103F for the moment. We can always expand long before we get our 64th device type.

Cheers,
Rusty.