MTD API locking and concurrency
Hi,
I came across a concurrent usage of my MTD driver by UBIFS by doing an IOC_UBI_UPVOL. As my chip doesn't support multiple requests at a time, I need to protect the access to chip registers.
I wonder if mtd api function can be called in interrupt context. My wish would be to use mutexes, but I have to be sure there is no interrupt path I have not seen. The only thing I'm certain is that my MTD drivers doesn't handle interrupts, so the interrupt won't come from him.
Is there a guarantee that mtd api functions are called with !in_interrupt() ?
Cheers.
Signature · 1 line
Robert
Quoted 7 lines · Robert Jarzmik
Hi,
I came across a concurrent usage of my MTD driver by UBIFS by doing an
IOC_UBI_UPVOL. As my chip doesn't support multiple requests at a time, I need to protect the access to chip registers.I wonder if mtd api function can be called in interrupt context.
No, this is not explicitely documented and you are welcome to send a patch which adds a comment to mtd.h, but all the MTD API functions are supposed to be called from sleeping context. IOW, the caller should keep in mind that these functions may sleep.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 5 lines · Robert Jarzmik
Hi,
I came across a concurrent usage of my MTD driver by UBIFS by doing an
IOC_UBI_UPVOL. As my chip doesn't support multiple requests at a time, I need to protect the access to chip registers.
FYI, the nand infrastructure code handles this for its devices; see nand_base.c::nand_get_device()
Mike