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?


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

On 10/12/13 16:31, Hartley Sweeten wrote:
On Tuesday, December 10, 2013 4:48 AM, Bernd Porr wrote:
I've just checked out after a while the newest RC kernel and the
usb-auto config/attach is broken. Seems so that the driver specific usb
attach is no longer called and no firmware is loaded. Hartly, can you
point me to the code bits which should call the driver spcific attach or
give a short summary how that should work? I had a look at the git logs
but there are quite lot of subsequent changes. Can you give me some
guidance because it has changed a lot since I had a look at it the last
time. I don't have much time this week but can crack on next week re
that and test that thoroughly. Just now none of my DUX boards work at
all. They all have the same problem that there are zero subdevices and
the firmware is not loaded so I assume that the driver specific attach
is not called.

Hello Bernd,

I'm not sure why the usbdux drivers are not auto attaching correctly.
Sorry about the problems.

What version of the kernel are you testing with?

Are the USB_DEVICE() id's correct in the driver?

The comedi USB drivers should auto attach when the device is detected.
The USB driver (*probe) will call comedi_usb_auto_config() which then
calls the comedi driver (*auto_attach).

All of the usbdux drivers do the initial USB setup, buffer allocation etc., then
call comedi_load_firmware() to request and load the firmware for the device.
After that the subdevices are allocated and initialized.

Try putting a couple printk debug messages in the usb (*probe) and comedi
(*auto_attach) functions in the drivers. You might also put a printk in the
callback functions that actually upload the firmware to the device.

Please let me know what you find. Hopefully this is a minor bug and we can
resolve it quickly.

Thanks,
Hartley


--
www:    http://www.berndporr.me.uk/
        http://www.linux-usb-daq.co.uk/
        http://www.imdb.com/name/nm3293421/
Mobile: +44 (0)7840 340069
Work:   +44 (0)141 330 5237
        University of Glasgow
        School of Engineering
        Rankine Building, Oakfield Avenue,
        Glasgow, G12 8LT
>From e2e07ce084f20d0d678d3cc85cc9b941a40c1d6c Mon Sep 17 00:00:00 2001
From: Bernd Porr <m...@berndporr.me.uk>
Date: Tue, 10 Dec 2013 19:42:13 +0000
Subject: [PATCH 1/1] comedi_load_firmware returns the number of transmitted
 bytes to the USB controller. The result is negative on failure. Thus, the ret
 argument needs to be checked if negative.

Signed-off-by: Bernd Porr <m...@berndporr.me.uk>
---
 drivers/staging/comedi/drivers/usbduxfast.c  | 2 +-
 drivers/staging/comedi/drivers/usbduxsigma.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
index 9707dd1..4b7f360 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -1092,7 +1092,7 @@ static int usbduxfast_auto_attach(struct comedi_device *dev,
 
 	ret = comedi_load_firmware(dev, &usb->dev, FIRMWARE,
 				   usbduxfast_upload_firmware, 0);
-	if (ret)
+	if (ret < 0)
 		return ret;
 
 	return usbduxfast_attach_common(dev);
diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index a5363de..4ee6271 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1596,7 +1596,7 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev,
 
 	ret = comedi_load_firmware(dev, &usb->dev, FIRMWARE,
 				   usbduxsigma_firmware_upload, 0);
-	if (ret)
+	if (ret < 0)
 		return ret;
 
 	ret = comedi_alloc_subdevices(dev, (devpriv->high_speed) ? 4 : 3);
-- 
1.8.5.1

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

Reply via email to