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

Ian Abbott abbotti at mev.co.uk
Tue Dec 10 21:36:27 UTC 2013


On 2013-12-10 21:07, Bernd Porr wrote:
> Hi all,
>
> here is the patch to fix the original bug. That was easier than I
> expected. That's against the latest RC kernel.
>
> However there are a couple other issues now.
>
> There seems to be an issue with comedi generic timed and the commands
> correcting the TRIG bit. It ANDs the right bit values first in the
> "comedi_get_cmd_generic_timed" but then "comedi_command_test" gets just
> 0 and then cmd fails:
>
> [ 9525.967397] usbcore: registered new interface driver usbduxsigma
> [ 9539.981072] cfc_check_trigger_src: orig_src=ffffffff, *src=82
> [ 9539.981079] TRIG_NOW | TRIG_INT err=-22, cmd->start_src=82
> [ 9539.981082] cfc_check_trigger_src: orig_src=ffffffff, *src=10
> [ 9539.981085] TRIG_TIMER err=-22, cmd->scan_begin_src=10
> [ 9539.981088] cfc_check_trigger_src: orig_src=ffffffff, *src=2
> [ 9539.981091] TRIG_NOW err=-22, cmd->convert_src=2
> [ 9539.981094] cfc_check_trigger_src: orig_src=ffffffff, *src=20
> [ 9539.981096] TRIG_COUNT err=-22, cmd->scan_end_src=20
> [ 9539.981099] cfc_check_trigger_src: orig_src=ffffffff, *src=21
> [ 9539.981102] TRIG_COUNT | TRIG_NONE err=-22, cmd->stop_src=21
> [ 9539.981104] Wrong TRIG source
> [ 9539.981167] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981171] TRIG_NOW | TRIG_INT err=-22, cmd->start_src=0
> [ 9539.981173] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981176] TRIG_TIMER err=-22, cmd->scan_begin_src=0
> [ 9539.981178] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981181] TRIG_NOW err=-22, cmd->convert_src=0
> [ 9539.981183] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981185] TRIG_COUNT err=-22, cmd->scan_end_src=0
> [ 9539.981187] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981190] TRIG_COUNT | TRIG_NONE err=-22, cmd->stop_src=0
> [ 9539.981192] Wrong TRIG source
> [ 9539.981196] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981199] TRIG_NOW | TRIG_INT err=-22, cmd->start_src=0
> [ 9539.981201] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981203] TRIG_TIMER err=-22, cmd->scan_begin_src=0
> [ 9539.981205] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981208] TRIG_NOW err=-22, cmd->convert_src=0
> [ 9539.981210] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981212] TRIG_COUNT err=-22, cmd->scan_end_src=0
> [ 9539.981214] cfc_check_trigger_src: orig_src=0, *src=0
> [ 9539.981216] TRIG_COUNT | TRIG_NONE err=-22, cmd->stop_src=0
> [ 9539.981218] Wrong TRIG source
>
> Userspace program (cmd.c):
>
>           ret = comedi_command_test(dev, cmd);
>           if(ret < 0){
>                   comedi_perror("comedi_command_test");
>                   if(errno == EIO){
>                           fprintf(stderr,"Ummm... this subdevice doesn't
> support commands\n");
>                   }
>                   exit(1);
>           }
>           ret = comedi_command_test(dev, cmd);
>           if(ret < 0){
>                   comedi_perror("comedi_command_test");
>                   exit(1);
>           }
>           fprintf(stderr,"second test returned %d (%s)\n", ret,
>                           cmdtest_messages[ret]);
> ^^^^^^ stops here
>
>
> hacked cfc_check_trigger_src:
> -----------------------------
>
> static inline int cfc_check_trigger_src(unsigned int *src, unsigned int
> flags)
> {
>           unsigned int orig_src = *src;
>
>           *src = orig_src & flags;
>           printk("cfc_check_trigger_src: orig_src=%x, *src=%x
> \n",orig_src,*src );
>           if (*src == TRIG_INVALID || *src != orig_src)
>                   return -EINVAL;
>           return 0;
> }
>
>
> Any ideas?

I don't know off-hand, but I'll take a look when I get the chance.


> 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.

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti at mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-


More information about the devel mailing list