From: Andrew S. <g.a...@gm...> - 2008-08-19 02:01:12
|
Hi lirc users! I was able to fix the kernel hang that I was seeing with lirc_streamzap and Ubuntu and in doing so I have come across a number of issues. As I mentionned in a prior post, I was seeing kernel hangs after after running for several hours with a lot of lirc traffic. The most important issue seems to be universal, not streamzap specific so please read if you do any lirc development. The issue is that the lirc_buffer API functions do not readily let the user do atomic "check and read" or "check and writes". For example, in streamzap, I see a lot of code that looks like this: while (!lirc_buffer_empty(&sz->delay_buf)) { empty = 0; lirc_buffer_read_1(&sz->delay_buf, (unsigned char *) &data); if (!lirc_buffer_full(&sz->lirc_buf)) { lirc_buffer_write_1(&sz->lirc_buf, (unsigned char *) &data); That is, it first checks some state of the buffer, and THEN it operates on the buffer. A spinlock is taken inside the empty call and inside the read call. However, I believe that it is possible that the state of the buffer may have changed between the check and the read or write (an interrupt could have come in). Since the bounds of the array is not tested inside the read and write functions, this could cause array bounds overruns. A better approach is to have the lirc_buffer_read_1 function atomically check-and-read, returning true/false if there was data in the buffer (and analagous for the write). Another issue is that do_gettimeofday is hanging. I'm not sure why it is hanging, but if you google "do_gettimeofday hang" you will see some older hits. Regardless, I do not think that do_gettimeofday is that good of a choice for interval timing because the wall-clock time can change abruptly during daylight savings transitions, when the user sets the time, etc. It is better to use the kernel's "jiffies" counter for interval timing since that is a monotonically increasing count. I have made these and more changes on top of 0.8.3. I am wondering how the lirc devs would like me to submit these patches. In particular, should I merge to cvs mainline first? Also, is it better to submit all the changes in a single patch file, or to submit each one separately? Who do I submit to? Regards, Andrew Stone |