Dear all, I am trying to test a dummy UIO driver to get timer interrupt events in Userspace. I register the UIO driver as a platform driver: static struct platform_device *uio_dummy_device; static struct device_driver uio_dummy_driver = { .name = "uio_dummy", .bus = &platform_bus_type, .probe = uio_dummy_probe, .remove = uio_dummy_remove, .shutdown = uio_dummy_shutdown, }; /* * Main initialization/remove routines */ static int __init uio_dummy_init(void) { printk("uio_dummy_init( )\n" ); uio_dummy_device = platform_device_register_simple("uio_dummy", -1, NULL, 0); if (IS_ERR(uio_dummy_device)) return PTR_ERR(uio_dummy_device); return driver_register(&uio_dummy_driver); } So after the driver_register() My probe should be called but it isn't. Why is this happening. Thanks Nayan
On Fri, Apr 15, 2016 at 1:29 AM, Gadre Nayan <gadrenayan@gmail.com> wrote:
Dear all,
I am trying to test a dummy UIO driver to get timer interrupt events in Userspace.
I register the UIO driver as a platform driver:
static struct platform_device *uio_dummy_device;
static struct device_driver uio_dummy_driver = { .name = "uio_dummy", .bus = &platform_bus_type, .probe = uio_dummy_probe, .remove = uio_dummy_remove, .shutdown = uio_dummy_shutdown, };
/* * Main initialization/remove routines */ static int __init uio_dummy_init(void) { printk("uio_dummy_init( )\n" ); uio_dummy_device = platform_device_register_simple("uio_dummy", -1, NULL, 0); if (IS_ERR(uio_dummy_device)) return PTR_ERR(uio_dummy_device);
return driver_register(&uio_dummy_driver); }
So after the driver_register() My probe should be called but it isn't.
yes but did you register the device in your device tree or your boot file?
Why is this happening.
Thanks Nayan
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi, I am using this on x86 machine..so no device tree...where do I have to register elsewhere here.? On 15 Apr 2016 2:15 p.m., "anish singh" <anish198519851985@gmail.com> wrote:
On Fri, Apr 15, 2016 at 1:29 AM, Gadre Nayan <gadrenayan@gmail.com> wrote:
Dear all,
I am trying to test a dummy UIO driver to get timer interrupt events in Userspace.
I register the UIO driver as a platform driver:
static struct platform_device *uio_dummy_device;
static struct device_driver uio_dummy_driver = { .name = "uio_dummy", .bus = &platform_bus_type, .probe = uio_dummy_probe, .remove = uio_dummy_remove, .shutdown = uio_dummy_shutdown, };
/* * Main initialization/remove routines */ static int __init uio_dummy_init(void) { printk("uio_dummy_init( )\n" ); uio_dummy_device = platform_device_register_simple("uio_dummy", -1, NULL, 0); if (IS_ERR(uio_dummy_device)) return PTR_ERR(uio_dummy_device);
return driver_register(&uio_dummy_driver); }
So after the driver_register() My probe should be called but it isn't.
yes but did you register the device in your device tree or your boot file?
Why is this happening.
Thanks Nayan
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Fri, Apr 15, 2016 at 01:59:12PM +0530, Gadre Nayan wrote:
Dear all,
I am trying to test a dummy UIO driver to get timer interrupt events in Userspace.
I register the UIO driver as a platform driver:
static struct platform_device *uio_dummy_device;
static struct device_driver uio_dummy_driver = { .name = "uio_dummy", .bus = &platform_bus_type, .probe = uio_dummy_probe, .remove = uio_dummy_remove, .shutdown = uio_dummy_shutdown, };
/* * Main initialization/remove routines */ static int __init uio_dummy_init(void) { printk("uio_dummy_init( )\n" ); uio_dummy_device = platform_device_register_simple("uio_dummy", -1, NULL, 0);
Why are you using a platform driver and device on x86? That's not going to work at all, as your device doesn't have an irq. Please use this on a "real" device that has an interrupt assigned to it. hope this helps, greg k-h
Oh offcourse, I forgot. So then should a char driver interface suffice. On 15 Apr 2016 7:29 p.m., "Greg KH" <greg@kroah.com> wrote:
On Fri, Apr 15, 2016 at 01:59:12PM +0530, Gadre Nayan wrote:
Dear all,
I am trying to test a dummy UIO driver to get timer interrupt events in Userspace.
I register the UIO driver as a platform driver:
static struct platform_device *uio_dummy_device;
static struct device_driver uio_dummy_driver = { .name = "uio_dummy", .bus = &platform_bus_type, .probe = uio_dummy_probe, .remove = uio_dummy_remove, .shutdown = uio_dummy_shutdown, };
/* * Main initialization/remove routines */ static int __init uio_dummy_init(void) { printk("uio_dummy_init( )\n" ); uio_dummy_device = platform_device_register_simple("uio_dummy", -1, NULL, 0);
Why are you using a platform driver and device on x86? That's not going to work at all, as your device doesn't have an irq. Please use this on a "real" device that has an interrupt assigned to it.
hope this helps,
greg k-h
Sorry I am completely out of sort here, should I register it on a PCI bus without any ID table? On 15 Apr 2016 7:43 p.m., "Gadre Nayan" <gadrenayan@gmail.com> wrote:
Oh offcourse, I forgot.
So then should a char driver interface suffice. On 15 Apr 2016 7:29 p.m., "Greg KH" <greg@kroah.com> wrote:
On Fri, Apr 15, 2016 at 01:59:12PM +0530, Gadre Nayan wrote:
Dear all,
I am trying to test a dummy UIO driver to get timer interrupt events in Userspace.
I register the UIO driver as a platform driver:
static struct platform_device *uio_dummy_device;
static struct device_driver uio_dummy_driver = { .name = "uio_dummy", .bus = &platform_bus_type, .probe = uio_dummy_probe, .remove = uio_dummy_remove, .shutdown = uio_dummy_shutdown, };
/* * Main initialization/remove routines */ static int __init uio_dummy_init(void) { printk("uio_dummy_init( )\n" ); uio_dummy_device = platform_device_register_simple("uio_dummy", -1, NULL, 0);
Why are you using a platform driver and device on x86? That's not going to work at all, as your device doesn't have an irq. Please use this on a "real" device that has an interrupt assigned to it.
hope this helps,
greg k-h
On Fri, Apr 15, 2016 at 07:45:16PM +0530, Gadre Nayan wrote:
Sorry I am completely out of sort here,
should I register it on a PCI bus without any ID table?
What exactly will that do? You have to have a ID of a PCI device in order to properly bind to it, correct? Do you have a device you want to write a UIO driver for? If not, you aren't going to get very far :) greg k-h
I am trying to replicate the igb_uio for realtek card on my system. I saw the igb_uio source and it uses no ID table. Struct pci_driver igb_pci_driver = { .id_table = NULL; }; So I wanted to understand the mechanism by which the igb_uio binds to a igb network card driver. On 15 Apr 2016 7:51 p.m., "Greg KH" <greg@kroah.com> wrote:
On Fri, Apr 15, 2016 at 07:45:16PM +0530, Gadre Nayan wrote:
Sorry I am completely out of sort here,
should I register it on a PCI bus without any ID table?
What exactly will that do? You have to have a ID of a PCI device in order to properly bind to it, correct?
Do you have a device you want to write a UIO driver for? If not, you aren't going to get very far :)
greg k-h
On Sat, Apr 16, 2016 at 07:03:37AM +0530, Gadre Nayan wrote:
I am trying to replicate the igb_uio for realtek card on my system. I saw the igb_uio source and it uses no ID table.
Struct pci_driver igb_pci_driver = { .id_table = NULL; };
So I wanted to understand the mechanism by which the igb_uio binds to a igb network card driver.
That does so in a very odd, and strange way and none that I would ever recommend anyone else doing. It's through userspace only, using the bind/unbind sysfs files because their tool knows exactly when it is safe to do it. But this is not a UIO issue, it's just a PCI driver issue, very far away from a platform device. Also, don't try to bind UIO to a device that you don't know exactly how it works, you will end up with "raw" memory access to the card, which can cause bad things to happen if you aren't careful. good luck! greg k-h
* Main initialization/remove routines */ static int __init uio_dummy_init(void) { printk("uio_dummy_init( )\n" ); uio_dummy_device = platform_device_register_simple("uio_dummy", -1, NULL, 0);
You also need to register the UIO driver by calling uio_register_device() after populating your "struct uio_info" appropriately.
Why are you using a platform driver and device on x86? That's not going to work at all, as your device doesn't have an irq. Please use this on a "real" device that has an interrupt assigned to it.
If it's only for learning purpose, I guess one can skip registering a IRQ handler and use UIO_IRQ_CUSTOM, right? I did something similar for testing a UIO hotplug bug once. I used to fake an IRQ event from a timer by using uio_event_notify(). https://github.com/mandeepsandhu/uio-hotplug-test/blob/master/uio_fake_hotpl... Although, I'm not sure if the OP wants to do something similar HTH, -mandeep
hope this helps,
greg k-h
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi mandeep, THanks for sharing the test code. Its a good starting point without having a physical device or emulating a physical device with Kmalloc and a fake interrupt. Thanks. Nayan On Fri, Apr 15, 2016 at 11:06 PM, Mandeep Sandhu <mandeepsandhu.chd@gmail.com> wrote:
* Main initialization/remove routines */ static int __init uio_dummy_init(void) { printk("uio_dummy_init( )\n" ); uio_dummy_device = platform_device_register_simple("uio_dummy", -1, NULL, 0);
You also need to register the UIO driver by calling uio_register_device() after populating your "struct uio_info" appropriately.
Why are you using a platform driver and device on x86? That's not going to work at all, as your device doesn't have an irq. Please use this on a "real" device that has an interrupt assigned to it.
If it's only for learning purpose, I guess one can skip registering a IRQ handler and use UIO_IRQ_CUSTOM, right?
I did something similar for testing a UIO hotplug bug once. I used to fake an IRQ event from a timer by using uio_event_notify(). https://github.com/mandeepsandhu/uio-hotplug-test/blob/master/uio_fake_hotpl...
Although, I'm not sure if the OP wants to do something similar
HTH, -mandeep
hope this helps,
greg k-h
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
participants (4)
-
anish singh -
Gadre Nayan -
Greg KH -
Mandeep Sandhu