Skip to contentSkip to conversation

MTD API locking and concurrency

DISCUSSION Robert Jarzmik 3 participants 3 messages Mar 13, 2012 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw
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
#2 lore raw
In reply to Robert Jarzmik
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