Sender: Alexis Berlemont From: Alexis Berlemont Date: Mon, 23 Nov 2009 23:10:44 +0100 References: <4bed572e0911221135s64fc4726x1cd7235f116e11a4@domain.hid> <72cf3fb0911230424w1c8b6484i1329baa792fc0be7@domain.hid> <4bed572e0911230926x33f45553o7333082488fcfa49@domain.hid> In-Reply-To: <4bed572e0911230926x33f45553o7333082488fcfa49@domain.hid> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <200911232310.44441.berlemont.hauw@domain.hid> Subject: Re: [Xenomai-help] Help on analogy_ni_pcimio (Alexis Berlemont?) List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ettore Pedretti Cc: xenomai@xenomai.org Hi, On Monday 23 November 2009 18:26:15 Ettore Pedretti wrote: > Hi, > > It is finally working. here is the dmesg after I insert a module: > > irq_test: before rtdm_irq_request > irq_test: after rtdm_irq_request (err = -22) > irq_test: before rtdm_irq_enable > irq_test: after rtdm_irq_enable (err = -22) rtdm_irq_request() returns -EINVAL because the IO APIC is disabled. So, the irq 48 turns into the irq 5; > Attached are a complete call-stack dump and my present kernel > configuration. With the fact that there is still a NULL pointer bug without IO APIC, the bug is bound to be located in analogy. There may be some wrong write access on the interrupt structure. I will come back with a patch which dumps the structure's content at various locations in the attach code. > Cheers > Ettore > 2009/11/23 Alexis Berlemont : > > Hi, > > > > On Mon, Nov 23, 2009 at 9:28 AM, Ettore Pedretti wrote: > >> Hi, > >> > >> I have compiled the module using this makefile: > >> > >> prefix := $(shell /usr/bin/xeno-config --prefix) > >> obj-m := irqTest.o > >> > >> ifeq ($(prefix),) > >> $(error Please add /bin to your PATH variable) > >> endif > >> > >> KDIR := /lib/modules/$(shell uname -r)/build > >> PWD := $(shell pwd) > >> EXTRA_CFLAGS := -I/usr/include/xenomai -I/usr/include/ > >> > >> > >> all: default > >> > >> default: > >> $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules > >> > >> install: > >> $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules_install > >> > >> clean: > >> rm -fr *.mod.c *.o *.ko irqTest *~ .irqTest* .tmp_versions > >> > >> The module seems to compiles fine: > >> > >> make -C /lib/modules/2.6.31.1/build > >> SUBDIRS=/home/ep41/control/CHAMP/irqTest modules > >> make[1]: Entering directory `/usr/src/linux-2.6.31.1' > >> CC [M] /home/ep41/control/CHAMP/irqTest/irqTest.o > >> Building modules, stage 2. > >> MODPOST 1 modules > >> CC /home/ep41/control/CHAMP/irqTest/irqTest.mod.o > >> LD [M] /home/ep41/control/CHAMP/irqTest/irqTest.ko > >> make[1]: Leaving directory `/usr/src/linux-2.6.31.1' > >> > >> To make sure module dependencies are in place I modprobe irqbench > >> (probably not necessary). > >> > >> modprobe xeno_irqbench > >> > >> All the loaded modules: > >> > >> fangorn:~# lsmod > >> Module Size Used by > >> xeno_irqbench 5152 0 > >> xeno_native 83296 0 > >> analogy_ni_pcimio 15676 0 > >> analogy_ni_mio 41596 1 analogy_ni_pcimio > >> analogy_ni_tio 21724 1 analogy_ni_mio > >> analogy_8255 4060 1 analogy_ni_mio > >> analogy_ni_mite 9980 3 > >> analogy_ni_pcimio,analogy_ni_mio,analogy_ni_tio xeno_analogy > >> 38876 5 > >> analogy_ni_pcimio,analogy_ni_mio,analogy_ni_tio,analogy_8255,analogy_ni_ > >>mite xeno_rtdm 24244 3 > >> xeno_irqbench,analogy_ni_mio,xeno_analogy astropci 10968 > >> 0 > >> ext3 112900 1 > >> jbd 44016 1 ext3 > >> mbcache 6652 1 ext3 > >> ide_pci_generic 3712 0 > >> ide_core 79388 1 ide_pci_generic > >> e1000 118204 0 > >> ata_piix 15968 2 > >> sata_mv 27632 0 > >> libata 151468 2 ata_piix,sata_mv > >> unix 24460 10 > >> > >> > >> When I insert the module it complains about missing symbols: > >> > >> insmod irqTest.ko > >> > >> insmod: error inserting 'irqTest.ko': -1 Unknown symbol in module > >> > >> dmesg: > >> > >> irqTest: module license 'unspecified' taints kernel. > >> Disabling lock debugging due to kernel taint > >> irqTest: Unknown symbol xnintr_enable > >> irqTest: Unknown symbol xnintr_detach > >> > >> What am I doing wrong? > > > > It's me who did wrong. I just tested the compilation inside the kernel. > > > > xnintr_* symbols are only exported for GPL compliant modules. So, > > could you add the following line in the test module: > > MODULE_LICENSE("GPL"); > > > > With that, the insmod operation should work. > > > >> BTW, I disabled CONFIG_X86_IO_APIC and the SMP option: same problem. > > > > Could you send the call-stack dump ? Maybe, that will unveil a clue. > > > >> Cheers > >> Ettore > >> > >> 2009/11/22 Alexis Berlemont : > >>> Hi, > >>> > >>> On Sunday 22 November 2009 20:35:51 Ettore Pedretti wrote: > >>>> Hello, > >>>> > >>>> I downloaded Xenomai 2.5-rc4 from the xenomai-head.git. I need to use > >>>> the comedi drivers for Xenomai for a NI PCI-6711 function generator > >>>> board. > >>>> > >>>> When I try to use the test program cmd_write (or cmd-read) I obtain > >>>> the following: > >>>> > >>>> fangorn:~# cmd_write -vcmd_write: device analogy0 opened (fd=0) > >>>> cmd_write: basic descriptor retrieved > >>>> subdevices count = 0 > >>>> read subdevice index = 0 > >>>> write subdevice index = 0 > >>>> cmd_write: a4l_get_desc failed (ret=-22) > >>>> *** glibc detected *** cmd_write: free(): invalid next size (fast): > >>>> 0x0804d008 *** > >>>> ======= Backtrace: ========= > >>>> /lib/i686/cmov/libc.so.6[0xb7e52624] > >>>> /lib/i686/cmov/libc.so.6(cfree+0x96)[0xb7e54826] > >>>> cmd_write[0x804927c] > >>>> /lib/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7dfa455] > >>>> cmd_write[0x8048b01] > >>>> ======= Memory map: ======== > >>>> 08048000-0804a000 r-xp 00000000 08:01 10855303 /usr/bin/cmd_write > >>>> 0804a000-0804b000 rw-p 00002000 08:01 10855303 /usr/bin/cmd_write > >>>> 0804b000-0806e000 rw-p 00000000 00:00 0 [heap] > >>>> b7c00000-b7c21000 rw-p 00000000 00:00 0 > >>>> b7c21000-b7d00000 ---p 00000000 00:00 0 > >>>> b7dce000-b7dda000 r-xp 00000000 08:01 6127619 /lib/libgcc_s.so.1 > >>>> b7dda000-b7ddb000 rw-p 0000b000 08:01 6127619 /lib/libgcc_s.so.1 > >>>> b7de0000-b7de3000 rw-s 00000000 00:0b 426 /dev/rtheap > >>>> b7de3000-b7de4000 rw-p 00000000 00:00 0 > >>>> b7de4000-b7f39000 r-xp 00000000 08:01 6144250 > >>>> /lib/i686/cmov/libc-2.7.so b7f39000-b7f3a000 r--p 00155000 08:01 > >>>> 6144250 /lib/i686/cmov/libc-2.7.so b7f3a000-b7f3c000 rw-p 00156000 > >>>> 08:01 6144250 /lib/i686/cmov/libc-2.7.so b7f3c000-b7f3f000 rw-p > >>>> 00000000 00:00 0 > >>>> b7f3f000-b7f54000 r-xp 00000000 08:01 6144264 > >>>> /lib/i686/cmov/libpthread-2.7.so > >>>> b7f54000-b7f56000 rw-p 00014000 08:01 6144264 > >>>> /lib/i686/cmov/libpthread-2.7.so > >>>> b7f56000-b7f58000 rw-p 00000000 00:00 0 > >>>> b7f58000-b7f5a000 r-xp 00000000 08:01 10808118 > >>>> /usr/lib/librtdm.so.1.0.0 b7f5a000-b7f5b000 rw-p 00001000 08:01 > >>>> 10808118 /usr/lib/librtdm.so.1.0.0 b7f5b000-b7f5c000 rw-p 00000000 > >>>> 00:00 0 > >>>> b7f5c000-b7f63000 r-xp 00000000 08:01 10808119 > >>>> /usr/lib/libnative.so.3.0.0 b7f63000-b7f64000 rw-p 00006000 08:01 > >>>> 10808119 /usr/lib/libnative.so.3.0.0 b7f64000-b7f67000 r-xp 00000000 > >>>> 08:01 10808112 /usr/lib/libanalogy.so.1.0.0 b7f67000-b7f68000 rw-p > >>>> 00002000 08:01 10808112 /usr/lib/libanalogy.so.1.0.0 > >>>> b7f69000-b7f6a000 rw-p 00000000 00:00 0 > >>>> b7f6a000-b7f6d000 rw-s 00000000 00:0b 426 /dev/rtheap > >>>> b7f6d000-b7f6f000 rw-p 00000000 00:00 0 > >>>> b7f6f000-b7f89000 r-xp 00000000 08:01 6127618 /lib/ld-2.7.so > >>>> b7f89000-b7f8b000 rw-p 0001a000 08:01 6127618 /lib/ld-2.7.so > >>>> bfab1000-bfac6000 rw-p 00000000 00:00 0 [stack] > >>>> ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] > >>>> Aborted > >>>> > >>>> This is probably because the device /dev/analogy0 does not exist. > >>>> > >>>> This is the output of uname -a > >>>> > >>>> Linux fangorn 2.6.31.1 #1 SMP PREEMPT Fri Nov 20 20:42:26 PST 2009 > >>>> i686 GNU/Linux > >>>> > >>>> And these are the relevant entries in dmesg > >>>> > >>>> dmesg: > >>>> > >>>> I-pipe 2.4-06: pipeline enabled. > >>>> I-pipe: Domain Xenomai registered. > >>>> > >>>> Xenomai: hal/i386 started. > >>>> Xenomai: scheduling class idle registered. > >>>> Xenomai: scheduling class rt registered. > >>>> Xenomai: real-time nucleus v2.5-rc4 (Flying In A Blue Dream) loaded. > >>>> Xenomai: SMI-enabled chipset found > >>>> Xenomai: SMI workaround enabled > >>>> Xenomai: starting RTDM services. > >>>> Xenomai: starting native API services. > >>>> Analogy: MITE: Available NI device IDs: 0x1880 > >>>> > >>>> result of lspci for the relevant board: > >>>> > >>>> 04:01.0 Class ff00: National Instruments PCI-6711 > >>>> > >>>> And lsmod: > >>>> > >>>> Module Size Used by > >>>> xeno_native 105088 0 > >>>> analogy_ni_pcimio 15644 0 > >>>> analogy_ni_mio 44860 1 analogy_ni_pcimio > >>>> analogy_ni_tio 24956 1 analogy_ni_mio > >>>> analogy_8255 3900 1 analogy_ni_mio > >>>> analogy_ni_mite 10140 3 > >>>> analogy_ni_pcimio,analogy_ni_mio,analogy_ni_tio xeno_analogy > >>>> 40220 5 > >>>> analogy_ni_pcimio,analogy_ni_mio,analogy_ni_tio,analogy_8255,analogy_n > >>>>i_mit e xeno_rtdm 28436 2 analogy_ni_mio,xeno_analogy > >>>> astropci 10944 0 > >>>> ext3 109636 1 > >>>> jbd 43920 1 ext3 > >>>> mbcache 6272 1 ext3 > >>>> ide_pci_generic 3712 0 > >>>> ide_core 74204 1 ide_pci_generic > >>>> ata_piix 15748 2 > >>>> sata_mv 26448 0 > >>>> e1000 114208 0 > >>>> libata 142156 2 ata_piix,sata_mv > >>>> unix 22992 10 > >>>> > >>>> > >>>> According to this post: > >>>> http://www.mail-archive.com/xenomai@xenomai.org > >>>> > >>>> >The analogy driver "a4l_pcimio" will be registered with your last > >>>> >insmod (analogy_ni_pcimio). You can check that by typing "cat > >>>> >/proc/analogy/drivers", you will see only one entry: a4l_pcimio. > >>>> > >>>> fangorn:~# cat /proc/analogy/drivers > >>>> -- Analogy drivers -- > >>>> > >>>> | idx | driver name > >>>> | 00 | analogy_ni_pcimio > >>>> | 01 | analogy_8255 > >>>> > >>>> There are two entries and the drivers are not attached: > >>>> > >>>> fangorn:~# cat /proc/analogy/devices > >>>> -- Analogy devices -- > >>>> > >>>> | idx | status | driver > >>>> | 00 | Unused | No driver > >>>> | 01 | Unused | No driver > >>>> | 02 | Unused | No driver > >>>> | 03 | Unused | No driver > >>>> | 04 | Unused | No driver > >>>> | 05 | Unused | No driver > >>>> | 06 | Unused | No driver > >>>> | 07 | Unused | No driver > >>>> | 08 | Unused | No driver > >>>> | 09 | Unused | No driver > >>>> > >>>> I'm aware of the name change of the drivers: > >>>> http://www.mail-archive.com/xenomai-git@xenomai.org > >>>> > >>>> >- a4l_pcimio becomes analogy_ni_pcimio > >>>> >- 8255 becomes analogy_8255. > >>>> >Consequently, the command line to attach these drivers has > >>>> >changed. Starting from now, we have to type: > >>>> >- analogy_config analogyX analogy_ni_pcimio (instead of a4l_pcimio) > >>>> > >>>> This is what happens when I try to attach the driver to de device: > >>>> > >>>> fangorn:~# analogy_config analogy0 analogy_ni_pcimio > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:Oops: 0000 [#1] PREEMPT SMP > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:last sysfs file: > >>>> /sys/devices/pci0000:00/0000:00:1e.0/0000:06:02.0/class > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:Process analogy_config (pid: 3409, ti=f64cc000 task=f79013b0 > >>>> task.ti=f64cc000) > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:I-pipe domain Linux > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:Stack: > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:Call Trace: > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:Code: 8b 45 9c e8 f2 f1 fa ff 89 c2 83 f8 01 0f 85 d4 fe ff ff > >>>> 8b 55 9c 8b 82 74 01 00 00 8b 00 f6 40 3c 06 0f 84 22 01 00 00 8b 42 > >>>> 18 <8b> 40 04 89 45 b0 8b 40 14 8b 40 04 85 c0 0f 84 0b 01 00 00 31 > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:EIP: [] ni_E_init+0x267/0xff1 [analogy_ni_mio] > >>>> SS:ESP 0068:f64cddc8 > >>>> > >>>> Message from syslogd@domain.hid at Nov 21 23:22:37 ... > >>>> kernel:CR2: 0000000000000004 > >>>> > >>>> > >>>> relevant dmeg: > >>>> > >>>> a4l: analogy_ni_pcimio: pcimio_attach: found pci-6711 board > >>>> mite 0000:04:01.0: PCI->APIC IRQ transform: INT A -> IRQ 48 > >>>> mite 0000:04:01.0: setting latency timer to 64 > >>>> a4l: MITE: 0xd0801000 mapped to f8e26000 > >>>> a4l: DAQ: 0xd0800000 mapped to f8e2a000 > >>>> a4l: MITE: version = 1, type = 1, mite mode = 1, interface mode = 3 > >>>> a4l: MITE: num channels = 3, write post fifo depth = 1, wins = 0, > >>>> iowins = 2 a4l: analogy_ni_pcimio: pcimio_attach: found irq 48 > >>>> BUG: unable to handle kernel NULL pointer dereference at 00000004 > >>>> IP: [] ni_E_init+0x267/0xff1 [analogy_ni_mio] > >>>> *pde = 00000000 > >>>> Oops: 0000 [#1] PREEMPT SMP > >>>> last sysfs file: > >>>> /sys/devices/pci0000:00/0000:00:1e.0/0000:06:02.0/class Modules linked > >>>> in: xeno_native analogy_ni_pcimio analogy_ni_mio analogy_ni_tio > >>>> analogy_8255 analogy_ni_mite xeno_analogy xeno_rtdm astropci ext3 jbd > >>>> mbcache ide_pci_generic ide_core ata_piix sata_mv e1000 libata unix > >>>> [last unloaded: scsi_wait_scan] > >>>> > >>>> Pid: 3409, comm: analogy_config Not tainted (2.6.31.1 #1) X6DA8 > >>>> EIP: 0060:[] EFLAGS: 00010202 CPU: 1 > >>>> EIP is at ni_E_init+0x267/0xff1 [analogy_ni_mio] > >>>> EAX: 00000000 EBX: f8a22280 ECX: f8c31e6c EDX: f8c31e60 > >>>> ESI: 00000000 EDI: f8c31e60 EBP: f64cde38 ESP: f64cddc8 > >>>> DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068 > >>>> Process analogy_config (pid: 3409, ti=f64cc000 task=f79013b0 > >>>> task.ti=f64cc000) I-pipe domain Linux > >>>> Stack: > >>>> f64cddd0 c10142b6 f64cddd8 f8c31e60 f64cdde0 c105abf7 f64cddfc > >>>> f8a0ea5d <0> f8c2be00 00000000 00000001 f8c31e94 fffffff0 f64cde14 > >>>> f8c2c118 00000001 <0> f8c2ed0d f8c31e88 f8c31e60 f64cde38 f8c2cccf > >>>> 00000001 f8c31e60 00000030 Call Trace: > >>>> [] ? unmask_IO_APIC_irq+0xd/0xf > >>>> [] ? xnintr_enable+0xb/0xd > >>>> [] ? rtdm_irq_request+0x48/0x5e [xeno_rtdm] > >>>> [] ? a4l_handle_irq+0x0/0x1a [xeno_analogy] > >>>> [] ? __a4l_request_irq+0x33/0x39 [xeno_analogy] > >>>> [] ? a4l_request_irq+0x98/0xaf [xeno_analogy] > >>>> [] ? pcimio_attach+0x54d/0x664 [analogy_ni_pcimio] > >>>> [] ? a4l_assign_driver+0x61/0x134 [xeno_analogy] > >>>> [] ? a4l_device_attach+0x54/0x6d [xeno_analogy] > >>>> [] ? xnshadow_ppd_get+0x4f/0x58 > >>>> [] ? a4l_ioctl_devcfg+0x57/0x104 [xeno_analogy] > >>>> [] ? a4l_rt_ioctl+0x33/0x3a [xeno_analogy] > >>>> [] ? __rt_dev_ioctl+0xd1/0xd8 [xeno_rtdm] > >>>> [] ? sys_rtdm_open+0x5c/0x64 [xeno_rtdm] > >>>> [] ? sys_rtdm_ioctl+0x29/0x2b [xeno_rtdm] > >>>> [] ? losyscall_event+0xa9/0x190 > >>>> [] ? __ipipe_dispatch_event+0xdf/0x201 > >>>> [] ? losyscall_event+0x0/0x190 > >>>> [] ? __ipipe_syscall_root+0x3b/0xc4 > >>>> [] ? system_call+0x2d/0x4f > >>>> Code: 8b 45 9c e8 f2 f1 fa ff 89 c2 83 f8 01 0f 85 d4 fe ff ff 8b 55 > >>>> 9c 8b 82 74 01 00 00 8b 00 f6 40 3c 06 0f 84 22 01 00 00 8b 42 18 <8b> > >>>> 40 04 89 45 b0 8b 40 14 8b 40 04 85 c0 0f 84 0b 01 00 00 31 > >>>> EIP: [] ni_E_init+0x267/0xff1 [analogy_ni_mio] SS:ESP > >>>> 0068:f64cddc8 CR2: 0000000000000004 > >>>> ---[ end trace c887d49bb5e86cf4 ]--- > >>> > >>> Thanks for such a great report. > >>> > >>> I keep two things in mind: > >>> - cmd_write's error handling path is not buggy (that was already in my > >>> todo list). I will fix that as soon as possible. > >>> > >>> - according to the call-stack dump you made, the irq handler > >>> registering seems to be the source of the trouble. What strikes me is > >>> that the oops occurred very low (unmask_IO_APIC_irq: we are no more in > >>> the analogy layer). > >>> > >>> In order to be sure that the problem is located in analogy, it would be > >>> great to test that calling rtdm_request_irq(... , 48, ...) does not > >>> trigger the bug. > >>> > >>> Here is a little test module you could try to insmod. If you do not > >>> want to bother finding out how to compile it, you can replace the code > >>> of an existing rtdm driver (for example: > >>> xenomai/ksrc/drivers/testing/irqbench.c) with the source below. > >>> > >>> Another interesting test would be to disable CONFIG_X86_IO_APIC in your > >>> kernel configuration (in "Processor type and features", disable the SMP > >>> option and disable "IO APIC" under "Local APIC"). > >>> > >>> #include > >>> #include > >>> #include > >>> > >>> #include > >>> > >>> > >>> int test_handler(rtdm_irq_t *irq_handle) > >>> { > >>> > >>> rtdm_printk("irq_test: INTERRUPT!\n"); > >>> > >>> return RTDM_IRQ_HANDLED; > >>> } > >>> > >>> static rtdm_irq_t handle; > >>> > >>> static int __init __test_init(void) > >>> { > >>> > >>> int err; > >>> > >>> rtdm_printk("irq_test: before rtdm_irq_request\n"); > >>> > >>> err = rtdm_irq_request(&handle, 48, test_handler, 0, "test_irq", > >>> NULL); > >>> > >>> rtdm_printk("irq_test: after rtdm_irq_request (err = %d)\n", > >>> err); > >>> > >>> rtdm_printk("irq_test: before rtdm_irq_enable\n"); > >>> > >>> err = rtdm_irq_enable(&handle); > >>> > >>> rtdm_printk("irq_test: after rtdm_irq_enable (err = %d)\n", > >>> err); > >>> > >>> > >>> return err; > >>> } > >>> > >>> static void __exit __test_exit(void) > >>> { > >>> > >>> rtdm_irq_free(&handle); > >>> > >>> } > >>> > >>> module_init(__test_init); > >>> module_exit(__test_exit); > >>> > >>>> Can anyone help? > >>>> > >>>> Best regards > >>>> Ettore Pedretti > > > > Alexis. > Alexis.