irq, tasklet and i2c
hi all,
once again i' having trouble getting things to work. maybe someone here has more experience with at least one of these issues.
i'm working on a driver for a radio/rd(b)s device. the rds (radio-data-system) chip is attached via i2c. it triggers an interrupt when data has been decoded (~ every 20ms). the data will be read from the v4l device, the tuner is controlled by ioctls on that same device. all of this does work (in a way).
i've tried several scenarios:
1) reading from the device, i wait in a wait queue. an interrupt does a wakeup.
then the read process does a i2c_master_recv directly. works.
2) i assign a buffer for a single piece of data. reading from the device,
i wait in a wait queue.
an interrupt schedules a tasklet. the tasklet read the data over i2c, stores it in the buffer and does a wakeup.
then the read process reads the data out of the buffer. works.
3) i assign a ringbuffer for the data. reading from the device, i do a wait_event_interruptible on the ringbuffer. when passed, i disable_tasklet,
read the data and enable_tasklet.
in the interrupt i schedule_tasklet. in the tasklet i do the buffer handling and try to i2c_master_recv. then i get a kernel panic (AIEE ...).
leaving out only the actual receive does work (although i get no data).
i don't see, where case 3 is significantly different from case 2.
where do i cause the kernel panic?
any ideas?
regards,
Signature · 4 lines
_ plain GmbH_______________________________________________________ markus schorer fon 089.540.149.0 daiserstrasse 15 RGB fax 089.540.149.44 81371 m?nchen http://www.plain.de
Quoted 7 lines · Markus Schorer
2) i assign a buffer for a single piece of data. reading from the device,
i wait in a wait queue.
an interrupt schedules a tasklet. the tasklet read the data over i2c, stores it in the buffer and does a wakeup.
then the read process reads the data out of the buffer. works.
In general, it's wrong to sleep in a tasklet. As I understand it, i2c_master_recv is allowed to sleep (I'm writing my driver on that assumption, somebody correct me if I'm wrong). I think your first version is superior, though if you're targeting 2.4 and 2.5 kernels then a completion is easier than a wait queue.
If you want to do a ringbuffer, consider creating a worker thread and using semaphores for producer / consumer scheduling.
- Adrian Cox
http://www.humboldt.co.uk/