(CC'ing gpio-f7188x author)
Discussion summary:
I'm writing a minimal platform driver, declaring 8 GPIO leds and 2 GPIO
input keys. When setting two leds to blink ("timer" trigger) in very
short succession (ie, enable both next to each other in shell script),
kernel emits:
[ 1210.586990] Trying to free nonexistent resource
<000000000000002e-000000000000002f>
[ 1211.227414] Trying to free nonexistent resource
<000000000000002e-000000000000002f>
[ 1211.867890] Trying to free nonexistent resource
<000000000000002e-000000000000002f>
[ 1212.508299] Trying to free nonexistent resource
<000000000000002e-000000000000002f>
[ 1213.148734] Trying to free nonexistent resource
<000000000000002e-000000000000002f>
[ 1213.789172] Trying to free nonexistent resource
<000000000000002e-000000000000002f>
[ 1214.429607] Trying to free nonexistent resource
<000000000000002e-000000000000002f>
This is with 500ms on & 500ms off, which matches the aproximate 2
lines/s from this log.
This error goes away when running on a single core.
2e-2f is the f7188x GPIO address range.
On Tue, 18 Aug 2015 12:02:16 +0300, Mika Westerberg
<[email protected]> wrote:
> For each GPIO operation the f7188x driver calls
> superio_enter()/superio_exit().
>
> However, I don't think that is enough to prevent multiple threads
> accessing a GPIO at the same time.
>
> One option is to add mutex to the private structure and then do
> something like this in each callback:
>
> static int f7188x_gpio_get(...)
> {
> mutex_lock(&sio->lock);
>
> /* request the resource and touch the hardware */
>
> mutex_unlock(&sio->lock);
>
> ...
> }
>
> It is a bit weird that it needs to acquire/release the ioport region each
> time.
There several modules which are using the same two IO addresses for the
many function the SuperIO has, I assumed acquiring the IO range would
prevent them to do any access once the first is loaded.
But as you point out, it seem to not be the case. I also noticed the
fintek-cir driver (for IR sensor, also managed by GPIO) calls
request_region in .probe and release_region() in .remove, which also
goes in this direction.
Regards,
--
Vincent Pelletier
--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html