Re: staging: comedi: USB devs not working / some comedi core reorganization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

here is another patch which fixes a kernel warning where a subdevice is released which no longer exists. The subdevice was removed before the main comedi device. The functions for the main dev removal and the subdevice were in different files/modules, were called from different subsystems and I've moved them together to make sure the order is right.

There is still a problem that the subdevices are sometimes not generated at boot time (cold boot) but hotplug does. I don't get any error messages though so firmware load is probably not the problem. I've put loads of the printk in it but then the error disappears (!). Seems to be a very tight race condition.

/Bernd


There is another issue which has to the with the subdevices. This
happens when I unplug the DUX board (all boards cause this):

[ 4972.978379] ------------[ cut here ]------------
[ 4972.978386] WARNING: CPU: 0 PID: 33 at fs/sysfs/group.c:214
sysfs_remove_group+0xc6/0xd0()
[ 4972.978389] sysfs group ffffffff81caa2e0 not found for kobject
'comedi0_subd1'
[ 4972.978392] Modules linked in: usbdux(O) usbduxsigma(O) comedi_fc(O)
comedi(O) radeon bnep rfcomm bluetooth snd_hda_codec_idt snd_hda_intel
snd_hda_codec parport_pc ppdev rc_hauppauge snd_bt87x ir_kbd_i2c
snd_hwdep tuner snd_pcm msp3400 snd_page_alloc snd_seq_midi bttv
snd_seq_midi_event snd_rawmidi pcmcia hid_generic snd_seq pcmcia_core
ttm usbhid hid drm_kms_helper snd_seq_device drm btcx_risc snd_timer
tveeprom videobuf_dma_sg rc_core snd v4l2_common psmouse videobuf_core
gpio_ich videodev dcdbas microcode serio_raw lpc_ich i2c_algo_bit
soundcore mac_hid lp parport e100 ahci mii libahci [last unloaded: comedi]
[ 4972.978454] CPU: 0 PID: 33 Comm: khubd Tainted: G        WC O
3.13.0-rc3+ #1
[ 4972.978457] Hardware name: Dell Inc.                 Dimension 9100
               /0X8582, BIOS A01 05/25/2005
[ 4972.978460]  0000000000000009 ffff88005c801a38 ffffffff81721083
ffff88005c801a80
[ 4972.978466]  ffff88005c801a70 ffffffff810645fd 0000000000000000
ffffffff81caa2e0
[ 4972.978472]  ffff8800560ed810 ffff88005a615000 0000000000000000
ffff88005c801ad0
[ 4972.978478] Call Trace:
[ 4972.978484]  [<ffffffff81721083>] dump_stack+0x45/0x56
[ 4972.978489]  [<ffffffff810645fd>] warn_slowpath_common+0x7d/0xa0
[ 4972.978494]  [<ffffffff8106466c>] warn_slowpath_fmt+0x4c/0x50
[ 4972.978499]  [<ffffffff8122fb7e>] ? sysfs_get_dirent_ns+0x4e/0x70
[ 4972.978504]  [<ffffffff81230e56>] sysfs_remove_group+0xc6/0xd0
[ 4972.978509]  [<ffffffff814a5793>] dpm_sysfs_remove+0x43/0x50
[ 4972.978513]  [<ffffffff8149b1c5>] device_del+0x45/0x1c0
[ 4972.978518]  [<ffffffff8149b35e>] device_unregister+0x1e/0x60
[ 4972.978522]  [<ffffffff8149b41c>] device_destroy+0x3c/0x50
[ 4972.978530]  [<ffffffffa0221525>]
comedi_free_subdevice_minor+0x75/0xa0 [comedi]
[ 4972.978539]  [<ffffffffa0221f68>] comedi_device_detach+0x48/0x160
[comedi]
[ 4972.978546]  [<ffffffffa021e2b3>] comedi_device_cleanup+0x33/0x90
[comedi]
[ 4972.978552]  [<ffffffffa021e346>] comedi_free_board_dev+0x36/0x50
[comedi]
[ 4972.978558]  [<ffffffffa02213b0>]
comedi_release_hardware_device+0x80/0x90 [comedi]
[ 4972.978565] [<ffffffffa0221a63>] comedi_auto_unconfig+0x13/0x20 [comedi]
[ 4972.978572]  [<ffffffffa0223172>] comedi_usb_auto_unconfig+0x12/0x20
[comedi]
[ 4972.978578]  [<ffffffff815520f4>] usb_unbind_interface+0x64/0x1c0
[ 4972.978583]  [<ffffffff8149eedf>] __device_release_driver+0x7f/0xf0
[ 4972.978587]  [<ffffffff8149ef73>] device_release_driver+0x23/0x30
[ 4972.978592]  [<ffffffff8149e7f8>] bus_remove_device+0x108/0x180
[ 4972.978596]  [<ffffffff8149b2a9>] device_del+0x129/0x1c0
[ 4972.978601]  [<ffffffff8154faa0>] usb_disable_device+0xb0/0x290
[ 4972.978605]  [<ffffffff815442bd>] usb_disconnect+0xad/0x200
[ 4972.978609]  [<ffffffff8154763d>] hub_thread+0x70d/0x1750
[ 4972.978614]  [<ffffffff8109a4c8>] ? sched_clock_cpu+0xa8/0x100
[ 4972.978619]  [<ffffffff810a88c0>] ? prepare_to_wait_event+0x100/0x100
[ 4972.978623]  [<ffffffff81546f30>] ? usb_reset_device+0x1d0/0x1d0
[ 4972.978627]  [<ffffffff81088152>] kthread+0xd2/0xf0
[ 4972.978632]  [<ffffffff81088080>] ? kthread_create_on_node+0x190/0x190
[ 4972.978637]  [<ffffffff81731d3c>] ret_from_fork+0x7c/0xb0
[ 4972.978641]  [<ffffffff81088080>] ? kthread_create_on_node+0x190/0x190
[ 4972.978644] ---[ end trace 69c2b5c4559cdf1b ]---

I guess that subdevice no longer exists at this point?

/Bernd

I'm hoping that will be fixed by other changes I made to the comedi core recently that aren't in the RC kernel yet.


--
http://www.berndporr.me.uk
http://www.linux-usb-daq.co.uk
http://www.imdb.com/name/nm3293421/
+44 (0)7840 340069
>From 5971245d01f25890826fc05f7bab0d2b8d6bfd63 Mon Sep 17 00:00:00 2001
From: Bernd Porr <mail@xxxxxxxxxxxxxxx>
Date: Fri, 20 Dec 2013 23:32:08 +0000
Subject: [PATCH 1/1] Moving un-registering of the subdevices and the main
 comedi device into one function and the module which is responsible for file
 operations. The kernel oops observed before was because the main device was
 un-registered first and then the subdevices which were then no longer valid.

Signed-off-by: Bernd Porr <mail@xxxxxxxxxxxxxxx>
---
 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 d7f63c4..33b4e58 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -152,7 +152,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 9d71b4d..29b3480 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 comedi_device_detach_cleanup(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;
-- 
1.8.5.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux