public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@ti.com>
To: Todd Poynor <toddpoynor@google.com>
Cc: "Munegowda\, Keshava" <keshava_mgowda@ti.com>,
	linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-kernel@vger.kernel.org, balbi@ti.com, gadiyar@ti.com,
	sameo@linux.intel.com, parthab@india.ti.com, tony@atomide.com,
	b-cousson@ti.com, paul@pwsan.com, johnstul@us.ibm.com,
	vishwanath.bs@ti.com, nm@ti.com, vikram.pandita@ti.com
Subject: Re: [PATCH 5/5 v4] mfd: omap: usb: Runtime PM support
Date: Mon, 29 Aug 2011 11:36:34 -0700	[thread overview]
Message-ID: <874o10t68d.fsf@ti.com> (raw)
In-Reply-To: <20110812213037.GA24803@google.com> (Todd Poynor's message of "Fri, 12 Aug 2011 14:30:37 -0700")

Todd Poynor <toddpoynor@google.com> 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@google.com> 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@ti.com>
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@google.com>
    Tested-by: Nishanth Menon <nm@ti.com>
    Signed-off-by: Kevin Hilman <khilman@ti.com>
    Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>


  parent reply	other threads:[~2011-08-29 18:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-09 14:15 [PATCH 0/5 v4] mfd: omap: usb: Runtime PM support for EHCI and OHCI drivers Keshava Munegowda
2011-08-09 14:15 ` [PATCH 1/5 v4] arm: omap: usb: ehci and ohci hwmod structures for omap4 Keshava Munegowda
2011-08-09 14:15   ` [PATCH 2/5 v4] arm: omap: usb: ehci and ohci hwmod structures for omap3 Keshava Munegowda
2011-08-09 14:15     ` [PATCH 3/5 v4] arm: omap: usb: register hwmods of usbhs Keshava Munegowda
2011-08-09 14:15       ` [PATCH 4/5 v4] arm: omap: usb: device name change for the clk names " Keshava Munegowda
2011-08-09 14:15         ` [PATCH 5/5 v4] mfd: omap: usb: Runtime PM support Keshava Munegowda
2011-08-10 16:31           ` Todd Poynor
2011-08-12  6:50             ` Munegowda, Keshava
2011-08-12 21:30               ` Todd Poynor
2011-08-12 23:19                 ` Menon, Nishanth
2011-08-17 10:26                 ` Munegowda, Keshava
2011-08-29 18:36                 ` Kevin Hilman [this message]
2011-08-11 15:20           ` Ming Lei
2011-08-29 18:50           ` Kevin Hilman
2011-08-29 20:47             ` Kevin Hilman
2011-08-30  6:17               ` Munegowda, Keshava
2011-08-11 15:23     ` [PATCH 2/5 v4] arm: omap: usb: ehci and ohci hwmod structures for omap3 Ming Lei
2011-08-12  5:46       ` Munegowda, Keshava
2011-08-12  7:25         ` Ming Lei
2011-08-12  8:12           ` Munegowda, Keshava

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874o10t68d.fsf@ti.com \
    --to=khilman@ti.com \
    --cc=b-cousson@ti.com \
    --cc=balbi@ti.com \
    --cc=gadiyar@ti.com \
    --cc=johnstul@us.ibm.com \
    --cc=keshava_mgowda@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=parthab@india.ti.com \
    --cc=paul@pwsan.com \
    --cc=sameo@linux.intel.com \
    --cc=toddpoynor@google.com \
    --cc=tony@atomide.com \
    --cc=vikram.pandita@ti.com \
    --cc=vishwanath.bs@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox