On Friday 21 September 2007, Rusty Russell wrote: > Hmm, I guess we could have a PCI driver which claims all VIRTIO vendor > devices. yes, that was the idea. > Then it can call virtio_find_driver() (?) at the top of its > probe function to find if there's a matching virtio driver. > This PCI driver would have to be initialized after all the virtio > drivers are registered, but that's easy. No, just use the driver model, instead of working against it: struct pci_virtio_device { struct pci_dev *pdev; char __iomem *mmio_space; struct virtio_device vdev; }; static int __devinit pci_virtio_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct pci_virtio_device *dev = kzalloc(sizeof (*dev), GFP_KERNEL); dev->pdev = pdev; dev->mmio_space = pcim_iomap(pdev, 0, PCI_VIRTIO_BUFSIZE); dev->vdev->ops = &pci_virtqueue_ops; dev->vdev->config = &pci_virtio_config_ops; dev->vdev->type = ent->device; dev->vdev->class = ent->class; dev->vdev.dev.parent = &pdev->dev; return virtio_device_register(&dev->vdev; } > The virtio layer would simply maintain a linked list of drivers and > implement the virtio_find_driver() matching function. nonono, just a virtio_bus that all virtio drivers register to: static int virtio_net_probe(struct device *dev) { struct virtio_device *vdev = to_virtio_dev(dev); struct virtqueue_ops *vq_ops = vdev->ops; /* same as current code */ ... return 0; } static struct virtio_device_id virtio_net_ids[] = { { .type = VIRTIO_ID_NET, .class = PCI_CLASS_NETWORK_OTHER }, { }, }; static struct virtio_driver virtio_net = { .id_table = &virtio_net_ids, .driver = { .name = "virtionet", .probe = virtio_net_probe, .remove = virtionet_remove, .bus = &virtio_bus, /* <- look here */ }, }; static int __init virtio_net_init(void) { return driver_register(&virtio_net.driver); } module_init(virtio_net_init); > And since we've suppressed normal PCI driver request_module (since it > always finds "the driver") then we can implement that in > virtio_find_driver(), and not use a PCI MODULE_DEVICE_TABLE. Then we > don't need (full) PCI ids at all. right, as shown in my example above. Arnd <>< _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/virtualization