Re: [PATCH 1/3] staging: comedi: fix auto-unconfig kernel error
Ian Abbott wrote: On 2013-12-28 21:31, Bernd Porr wrote: Merging the un-registering of both the subdevices and the main comedi device into one function and the module which actually associated with it. The kernel oops observed before was because the main device was un-registered first and then the subdevices which were then no longer valid. This has been also tested with 'comedi_config -r' for both autoconfigured and legacy devices. Signed-off-by: Bernd Porr m...@berndporr.me.uk --- drivers/staging/comedi/comedi_fops.c | 19 +++ drivers/staging/comedi/drivers.c | 18 -- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index f3d59e2..2680b72 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -141,7 +141,26 @@ static struct comedi_device *comedi_clear_board_minor(unsigned minor) static void comedi_free_board_dev(struct comedi_device *dev) { +int i; +struct comedi_subdevice *s; + if (dev) { +if (dev-subdevices) { +for (i = 0; i dev-n_subdevices; i++) { +s = dev-subdevices[i]; +if (s-runflags SRF_FREE_SPRIV) +kfree(s-private); +comedi_free_subdevice_minor(s); +if (s-async) { +comedi_buf_alloc(dev, s, 0); +kfree(s-async); +} +} +kfree(dev-subdevices); +dev-subdevices = NULL; +dev-n_subdevices = 0; +} + if (dev-class_dev) { device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, dev-minor)); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 4964d2a..d6dc58a 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -97,24 +97,6 @@ EXPORT_SYMBOL_GPL(comedi_alloc_subdevices); static void cleanup_device(struct comedi_device *dev) { -int i; -struct comedi_subdevice *s; - -if (dev-subdevices) { -for (i = 0; i dev-n_subdevices; i++) { -s = dev-subdevices[i]; -if (s-runflags SRF_FREE_SPRIV) -kfree(s-private); -comedi_free_subdevice_minor(s); -if (s-async) { -comedi_buf_alloc(dev, s, 0); -kfree(s-async); -} -} -kfree(dev-subdevices); -dev-subdevices = NULL; -dev-n_subdevices = 0; -} kfree(dev-private); dev-private = NULL; dev-driver = NULL; This doesn't apply to linux-next any more. (For example, cleanup_device() function was renamed amongst other stuff.) I've also fixed a load of stuff related to this bug since this patch was applicable, so possibly the bug has been squashed already. Bernd, can you reproduce the problem on the latest tagged linux-next branch? I can. Still the same problem as before. Linux bp1-Dimension-9100 3.13.0-rc7-next-20140106 #1 SMP Tue Jan 7 06:36:37 GMT 2014 x86_64 x86_64 x86_64 GNU/Linux [ 74.183729] [ cut here ] [ 74.183741] WARNING: CPU: 0 PID: 28 at fs/sysfs/group.c:216 sysfs_remove_group+0x93/0xa0() [ 74.183744] sysfs group 81caa9e0 not found for kobject 'comedi0_subd0' [ 74.183747] Modules linked in: radeon bnep rfcomm bluetooth snd_hda_codec_idt snd_hda_codec_generic snd_hda_intel 6lowpan_iphc(P) snd_hda_codec rc_hauppauge ir_kbd_i2c ttm tuner drm_kms_helper msp3400 snd_hwdep snd_bt87x drm snd_pcm bttv hid_generic gpio_ich dcdbas microcode usbduxsigma(C) snd_page_alloc comedi_fc(C) comedi(C) usbhid btcx_risc snd_seq_midi tveeprom videobuf_dma_sg snd_seq_midi_event snd_rawmidi rc_core psmouse snd_seq v4l2_common pcmcia pcmcia_core hid snd_seq_device videobuf_core snd_timer serio_raw videodev snd lpc_ich i2c_algo_bit soundcore ahci e100 libahci mii [ 74.183798] CPU: 0 PID: 28 Comm: khubd Tainted: PWC 3.13.0-rc7-next-20140106 #1 [ 74.183801] Hardware name: Dell Inc. Dimension 9100 /0X8582, BIOS A01 05/25/2005 [ 74.183804] 0009 88005cfb1a30 8172cf2d 88005cfb1a78 [ 74.183809] 88005cfb1a68 81066cbd 81caa9e0 [ 74.183813] 880058562010 880058413400 88005cfb1ac8 [ 74.183817] Call Trace: [ 74.183827] [8172cf2d] dump_stack+0x45/0x56 [ 74.183832] [81066cbd] warn_slowpath_common+0x7d/0xa0 [ 74.183836] [81066d2c] warn_slowpath_fmt+0x4c/0x50 [ 74.183841] [81236b98] ? kernfs_find_and_get_ns+0x48/0x60 [ 74.183845] [812358e3] sysfs_remove_group+0x93/0xa0 [ 74.183850] [814afc53] dpm_sysfs_remove+0x43/0x50 [ 74.183854] [814a5635] device_del+0x45/0x1c0 [ 74.183857] [814a57ce]
Re: [PATCH 1/3] staging: comedi: fix auto-unconfig kernel error
Ian Abbott wrote: On 2014-01-07 10:01, Bernd Porr wrote: Ian Abbott wrote: On 2013-12-28 21:31, Bernd Porr wrote: This doesn't apply to linux-next any more. (For example, cleanup_device() function was renamed amongst other stuff.) I've also fixed a load of stuff related to this bug since this patch was applicable, so possibly the bug has been squashed already. Bernd, can you reproduce the problem on the latest tagged linux-next branch? I can. Still the same problem as before. Linux bp1-Dimension-9100 3.13.0-rc7-next-20140106 #1 SMP Tue Jan 7 06:36:37 GMT 2014 x86_64 x86_64 x86_64 GNU/Linux [ 74.183729] [ cut here ] [ 74.183741] WARNING: CPU: 0 PID: 28 at fs/sysfs/group.c:216 sysfs_remove_group+0x93/0xa0() [ 74.183744] sysfs group 81caa9e0 not found for kobject 'comedi0_subd0' I'll try and reproduce it. I don't have the usbdux devices, but I should be able to reproduce it with PCI devices that support comedi asynchronous commands by removing them via the /sys/bus/pci/devices/:xx:xx.x/remove interface. (I thought I had tested it actually, but must have missed something!). Was the device in use by a comedi application when disconnected, or was it just idle? Hi, it was idling and gave the kernel error above. I've just run comedirecord and pulled the plug. That works fine (gives error -1 in userspace) and after plugging it back in it works. /Bernd BTW: I've also tried to compile Greg's staging tree but that goes into busybox (no root fs) without a working keyboard / mouse. -- http://www.berndporr.me.uk http://www.linux-usb-daq.co.uk http://www.imdb.com/name/nm3293421/ +44 (0)7840 340069 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/3] staging: comedi: fix auto-unconfig kernel error
On 2014-01-07 10:50, Bernd Porr wrote: Ian Abbott wrote: On 2014-01-07 10:01, Bernd Porr wrote: Ian Abbott wrote: On 2013-12-28 21:31, Bernd Porr wrote: This doesn't apply to linux-next any more. (For example, cleanup_device() function was renamed amongst other stuff.) I've also fixed a load of stuff related to this bug since this patch was applicable, so possibly the bug has been squashed already. Bernd, can you reproduce the problem on the latest tagged linux-next branch? I can. Still the same problem as before. Linux bp1-Dimension-9100 3.13.0-rc7-next-20140106 #1 SMP Tue Jan 7 06:36:37 GMT 2014 x86_64 x86_64 x86_64 GNU/Linux [ 74.183729] [ cut here ] [ 74.183741] WARNING: CPU: 0 PID: 28 at fs/sysfs/group.c:216 sysfs_remove_group+0x93/0xa0() [ 74.183744] sysfs group 81caa9e0 not found for kobject 'comedi0_subd0' I'll try and reproduce it. I don't have the usbdux devices, but I should be able to reproduce it with PCI devices that support comedi asynchronous commands by removing them via the /sys/bus/pci/devices/:xx:xx.x/remove interface. (I thought I had tested it actually, but must have missed something!). Was the device in use by a comedi application when disconnected, or was it just idle? Hi, it was idling and gave the kernel error above. I've just run comedirecord and pulled the plug. That works fine (gives error -1 in userspace) and after plugging it back in it works. That might be what I missed. I was mostly testing by disconnecting them (via the sysfs remove mechanism mentioned earlier) while they were open (and possibly running an asynchronous acquisition at the time). /Bernd BTW: I've also tried to compile Greg's staging tree but that goes into busybox (no root fs) without a working keyboard / mouse. Well the comedi stuff seems to be in sync between Greg's staging-next branch and the linux-next tree at the moment, so using linux-next shouldn't affect this testing. -- -=( Ian Abbott @ MEV Ltd.E-mail: abbo...@mev.co.uk)=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/3] staging: comedi: fix auto-unconfig kernel error
On 2013-12-28 21:31, Bernd Porr wrote: Merging the un-registering of both the subdevices and the main comedi device into one function and the module which actually associated with it. The kernel oops observed before was because the main device was un-registered first and then the subdevices which were then no longer valid. This has been also tested with 'comedi_config -r' for both autoconfigured and legacy devices. Signed-off-by: Bernd Porr m...@berndporr.me.uk --- drivers/staging/comedi/comedi_fops.c | 19 +++ drivers/staging/comedi/drivers.c | 18 -- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index f3d59e2..2680b72 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -141,7 +141,26 @@ static struct comedi_device *comedi_clear_board_minor(unsigned minor) static void comedi_free_board_dev(struct comedi_device *dev) { + int i; + struct comedi_subdevice *s; + if (dev) { + if (dev-subdevices) { + for (i = 0; i dev-n_subdevices; i++) { + s = dev-subdevices[i]; + if (s-runflags SRF_FREE_SPRIV) + kfree(s-private); + comedi_free_subdevice_minor(s); + if (s-async) { + comedi_buf_alloc(dev, s, 0); + kfree(s-async); + } + } + kfree(dev-subdevices); + dev-subdevices = NULL; + dev-n_subdevices = 0; + } + if (dev-class_dev) { device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, dev-minor)); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 4964d2a..d6dc58a 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -97,24 +97,6 @@ EXPORT_SYMBOL_GPL(comedi_alloc_subdevices); static void cleanup_device(struct comedi_device *dev) { - int i; - struct comedi_subdevice *s; - - if (dev-subdevices) { - for (i = 0; i dev-n_subdevices; i++) { - s = dev-subdevices[i]; - if (s-runflags SRF_FREE_SPRIV) - kfree(s-private); - comedi_free_subdevice_minor(s); - if (s-async) { - comedi_buf_alloc(dev, s, 0); - kfree(s-async); - } - } - kfree(dev-subdevices); - dev-subdevices = NULL; - dev-n_subdevices = 0; - } kfree(dev-private); dev-private = NULL; dev-driver = NULL; This doesn't apply to linux-next any more. (For example, cleanup_device() function was renamed amongst other stuff.) I've also fixed a load of stuff related to this bug since this patch was applicable, so possibly the bug has been squashed already. Bernd, can you reproduce the problem on the latest tagged linux-next branch? Also, the removal of all that code from cleanup_device() (since renamed to comedi_device_detach_cleanup()) would stop the COMEDI_DEVCONFIG ioctl with NULL argument (e.g. via the 'comedi_config -r' command to detach a device) cleaning up after the detachment, especially for the preallocated legacy comedi devices that hang around after the detachment, ready to be reattached via another instance of the ioctl call. -- -=( Ian Abbott @ MEV Ltd.E-mail: abbo...@mev.co.uk)=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel