Re: [PATCH 5/5 v4] mfd: omap: usb: Runtime PM support

From: Kevin Hilman
Date: Mon Aug 29 2011 - 14:36:45 EST


Todd Poynor <toddpoynor@xxxxxxxxxx> writes:

> On Fri, Aug 12, 2011 at 12:20:21PM +0530, Munegowda, Keshava wrote:
>> On Wed, Aug 10, 2011 at 10:01 PM, Todd Poynor <toddpoynor@xxxxxxxxxx> wrote:
>> >> @@ -913,12 +598,15 @@ static int usbhs_enable(struct device *dev)
>> >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (pdata->ehci_data->reset_gpio_port[1], 1);
>> >> Â Â Â }
>> >>
>> >> -end_count:
>> >> - Â Â omap->count++;
>> >> + Â Â pm_runtime_put_sync(dev);
>> >> Â Â Â spin_unlock_irqrestore(&omap->lock, flags);
>> >
>> > Is pm_runtime_irq_safe() needed (else I think runtime PM callbacks may
>> > re-enable IRQs... or there's the new *_suspend runtime PM calls that
>> > may avoid this)?
>>
>> pm_runtime_irq_safe() is not required; usbhs does not have a parent
>> and it is the parent driver of
>> ehci and ohci drivers.
>
> But the above expects IRQs to be disabled during the
> pm_runtime_put_sync, and synchronous calls can turn IRQs back on in
> rpm_idle:
>
> if (callback) {
> spin_unlock_irq(&dev->power.lock);
>
> callback(dev);
>
> I see other folks who know this better than me are discussing USB run
> time PM and might_sleep contexts, so I'll note this concern and let
> others chime in if they think there's a real problem here.

FYI... The commit below fixes this mainline (merged as of v3.1-rc4).

Kevin


commit 02b26774afebb2d62695ba3230319d70d8c6cc2d
Author: Kevin Hilman <khilman@xxxxxx>
Date: Fri Aug 5 21:45:20 2011 +0200

PM / Runtime: Allow _put_sync() from interrupts-disabled context

Currently the use of pm_runtime_put_sync() is not safe from
interrupts-disabled context because rpm_idle() will release the
spinlock and enable interrupts for the idle callbacks. This enables
interrupts during a time where interrupts were expected to be
disabled, and can have strange side effects on drivers that expected
interrupts to be disabled.

This is not a bug since the documentation clearly states that only
_put_sync_suspend() is safe in IRQ-safe mode.

However, pm_runtime_put_sync() could be made safe when in IRQ-safe
mode by releasing the spinlock but not re-enabling interrupts, which
is what this patch aims to do.

Problem was found when using some buggy drivers that set
pm_runtime_irq_safe() and used _put_sync() in interrupts-disabled
context.

Reported-by: Colin Cross <ccross@xxxxxxxxxx>
Tested-by: Nishanth Menon <nm@xxxxxx>
Signed-off-by: Kevin Hilman <khilman@xxxxxx>
Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/