Today, irq handler only get interrupt signal as argument.
It may be difficult from the signal to get back to a meaningful data structure, like sensor data, [we want to collect exact timestamp when hard interrupt occurs, so we are currently limited to one sensor of a given type per board].
kernel irq handler has an additional argument (private).
I am proposing to add an array for argument:
void* gpio_irq_privates[]
In gpio_interrupt, we would use this array when calling interrupt handler.
However, it cost in ram: I roughly counted the number of interrupts per board with:
find build -name \*RW.smap -exec grep -l gpio_irq_handlers {} \+ | \
xargs -n 1 awk 'BEGIN { s = 0 }
/gpio_irq_handlers/ { if ( s == 0 ) { b="0x" $1; s=$2 } next }
/ [Rr] / { if ( s == $2 ) {
d=strtonum("0x" $1) - strtonum(b) ; print FILENAME ":" d; exit
} }' | \
sort -r -n -t ':' -k 2 | less
There are some number I don't get, but one of the worst case, lux, has 21 interrupts, so we are talking to up to ~100 bytes used in ram.
If we want to be thriftier with ram, we could have a second smaller array, a bitfield and use popcount() to find the right index in gpio_irq_privates[], something like
(1 << i) & gpio_irq_private_map ?
gpio_irq_privates(
popcount(gpio_irq_private_map & ((1 << i+1) - 1))] - 1):
NULL)
Given gpio_irq_private_map is a constant, an inline version of popcount can reduce the number of test iteration.
|
Deleted:
all_int.txt
3.5 KB
|
Comment 1 by amstan@chromium.org
, Mar 15 2018