All of lore.kernel.org
 help / color / mirror / Atom feed
* Workqueue and kernel panic on device disconnect
@ 2011-10-25 21:29 Frank Schäfer
  2011-10-26 17:07 ` Frank Schäfer
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Schäfer @ 2011-10-25 21:29 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I'm trying to use a workqueue in a usb driver for polling the states of 
the device buttons.
That works fine, but when I disconnect the device, the kernel sometimes 
explodes.
The machine turns off immediately, without saving a backtrace (I will 
try to make a photo tomorrow)

The code:



static struct delayed_work poll_work;

static const struct usb_device_id device_table[] = {
     {USB_DEVICE(0x1234, 0x5678)},
     {}
};

static void poll(struct work_struct *work)
{
     schedule_delayed_work(&poll_work,
                   msecs_to_jiffies(100));
}

MODULE_DEVICE_TABLE(usb, device_table);

static int test_probe(struct usb_interface *intf,
               const struct usb_device_id *id)
{
     INIT_DELAYED_WORK(&poll_work, poll);
     schedule_delayed_work(&poll_work,
                   msecs_to_jiffies(100));
     return 0;
}

static void test_disconnect(struct usb_interface *intf)
{
     cancel_delayed_work_sync(&poll_work);
}

static struct usb_driver test_driver = {
     .name       = MODULE_NAME,
     .id_table   = device_table,
     .probe      = test_probe,
     .disconnect = test_disconnect,
};

static int __init test_mod_init(void)
{
     return usb_register(&test_driver);
}

static void __exit test_mod_exit(void)
{
     usb_deregister(&test_driver);
}

module_init(test_mod_init);
module_exit(test_mod_exit);


What am I doing wrong ?
Is there anything else I have to do in addition to calling 
cancel_delayed_work_sync() in the disconnect fcn ?

Thanks,
Frank Schaefer

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Workqueue and kernel panic on device disconnect
  2011-10-25 21:29 Workqueue and kernel panic on device disconnect Frank Schäfer
@ 2011-10-26 17:07 ` Frank Schäfer
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Schäfer @ 2011-10-26 17:07 UTC (permalink / raw)
  To: kernelnewbies

Am 25.10.2011 23:29, schrieb Frank Sch?fer:
> Hi,
>
> I'm trying to use a workqueue in a usb driver for polling the states 
> of the device buttons.
> That works fine, but when I disconnect the device, the kernel 
> sometimes explodes.
> The machine turns off immediately, without saving a backtrace (I will 
> try to make a photo tomorrow)
>
> The code:
>
>
>
> static struct delayed_work poll_work;
>
> static const struct usb_device_id device_table[] = {
>     {USB_DEVICE(0x1234, 0x5678)},
>     {}
> };
>
> static void poll(struct work_struct *work)
> {
>     schedule_delayed_work(&poll_work,
>                   msecs_to_jiffies(100));
> }
>
> MODULE_DEVICE_TABLE(usb, device_table);
>
> static int test_probe(struct usb_interface *intf,
>               const struct usb_device_id *id)
> {
>     INIT_DELAYED_WORK(&poll_work, poll);
>     schedule_delayed_work(&poll_work,
>                   msecs_to_jiffies(100));
>     return 0;
> }
>
> static void test_disconnect(struct usb_interface *intf)
> {
>     cancel_delayed_work_sync(&poll_work);
> }
>
> static struct usb_driver test_driver = {
>     .name       = MODULE_NAME,
>     .id_table   = device_table,
>     .probe      = test_probe,
>     .disconnect = test_disconnect,
> };
>
> static int __init test_mod_init(void)
> {
>     return usb_register(&test_driver);
> }
>
> static void __exit test_mod_exit(void)
> {
>     usb_deregister(&test_driver);
> }
>
> module_init(test_mod_init);
> module_exit(test_mod_exit);
>
>
> What am I doing wrong ?
> Is there anything else I have to do in addition to calling 
> cancel_delayed_work_sync() in the disconnect fcn ?
>
> Thanks,
> Frank Schaefer
>

I've managed to make a photo of the backtrace:

http://imageshack.us/photo/my-images/823/img075gv.jpg

Could this be a kernel bug ?

Regards,
Frank

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-26 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-25 21:29 Workqueue and kernel panic on device disconnect Frank Schäfer
2011-10-26 17:07 ` Frank Schäfer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.