Hello!
I'm developing a linux driver for a USB fingerprint sensor.
Right now the driver is working correctly, capturing fingerprint images from the sensor and sending them to a user-space application.
The problem I'm having is that after a random number of finger captures the driver itself crashes or makes other processes crash. I get an oops on other processes that could be anything from the file system to the X server.
I'm using Fedora Code 3 and Ubuntu with 2.6.10.
In general the driver works like this:
The sensor only has two bulk endpoints, one reading and one for writing.
I need to have a constant read from the sensor, so I implemented a bulk urb that its submitted in the open function and unlinked in the close function. The urb is resubmitted in its callback function.
The driver creates a fingerprint image after a number of data chunks had been read from the sensor. So I implemented the callback function like this (simplificated):
void read_urb_callback(struct urb *actual_urb, struct pt_regs *regs)
{
...
// check if the urb's transfer buffer has something
if ((actual_urb->transfer_buffer != NULL) && (actual_urb->actual_length > 0))
{
// create the tasklet data
tasklet_data = kmalloc(sizeof(ts_tasklet_data), GFP_ATOMIC);
if (tasklet_data != NULL)
{
// fill it
tasklet_data->tasklet_buffer = kmalloc(actual_urb->actual_length, GFP_ATOMIC);
tasklet_data->tasklet_buffer_size = actual_urb->actual_length;
if (tasklet_data->tasklet_buffer != NULL)
{
// copy the data into it
memcpy(tasklet_data->tasklet_buffer, actual_urb->transfer_buffer, actual_urb->actual_length);
// create the tasklet
tasklet_init(&process_tasklet, process_data, (unsigned long)tasklet_data);
tasklet_hi_schedule(&process_tasklet);
}
}
}
...
return_value = usb_submit_urb(actual_urb, GFP_ATOMIC);
...
}
I do this because I need to process the data from the sensor as soon as possible. I tried several ideas and the best seemed to be the tasklet implementation of the process_data() function.
The process_data() function manipulates the data in the tasklet_data->tasklet_buffer buffer, stores it in another variable and when its ready copies it to another buffer that later will be send to the user-space.
I ran out of ideas of what to check in order to solve my problem. I made sure all the memory is deallocated correctly and all the buffers are protected with spin locks. And because most of the crashes occur on other processes I don't know how to debug this.
Does somebody know what could be causing the crashes or have experienced something similar?
- Ing. Joaquin Durand Gomez http://homepage.mac.com/joakod
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
