On Wednesday 12 February 2014, Courtney Cavin wrote: > On Tue, Feb 11, 2014 at 09:35:01AM +0100, Arnd Bergmann wrote: > > On Monday 10 February 2014 16:23:48 Courtney Cavin wrote: > Then again, I think that the context management stuff is the exception as well, > and I think that can/should also be handled in a higher level. Regardless, I > went ahead and drafted the async flags idea out anyway, so here's some > pseudo-code. I also tried to shoe-horn in 'peek', and you can see how that > turns out. Let me know if this is something like what you had in mind. The async implementation looks good to me, assuming we actually need both sync and async operations, which I can't tell for sure. For the peek operation, it wouldn't work for the ethernet case, which has to call it from atomic context in net_rx_action. > /** > * so this is where this lock makes things difficult, as this function > * might_sleep(), but only really because of the lock. Either we can > * remove the lock and force the adapter to do its own locking > * spinlock-style, or we can accept the sleep here, which seems a bit > * stupid in a peek function. Neither option is good. Additionally, > * there's no guarantee that the adapter doesn't operate over a bus > * which itself might_sleep(), exacerbating the problem. > */ > mutex_lock(&mbox->adapter->lock); > rc = mbox->adapter->ops->peek_message(mbox->adapter, mbox->chan, msg); > mutex_lock(&mbox->adapter->lock); If we decide that peek() must not sleep, any driver that operates on a slow bus could just always report "no data" here. Moving the locking into the mbox driver here sounds appropriate. Arnd -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html