All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman-l0cyMroinI0@public.gmane.org>
To: Todd Poynor <toddpoynor-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: "Munegowda,
	Keshava" <keshava_mgowda-l0cyMroinI0@public.gmane.org>,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	balbi-l0cyMroinI0@public.gmane.org,
	gadiyar-l0cyMroinI0@public.gmane.org,
	sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	parthab-PpE0FKYn9XJWk0Htik3J/w@public.gmane.org,
	tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org,
	b-cousson-l0cyMroinI0@public.gmane.org,
	paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org,
	johnstul-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org,
	vishwanath.bs-l0cyMroinI0@public.gmane.org,
	nm-l0cyMroinI0@public.gmane.org,
	vikram.pandita-l0cyMroinI0@public.gmane.org
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-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> (Todd Poynor's message of "Fri, 12 Aug 2011 14:30:37 -0700")

Todd Poynor <toddpoynor-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> 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-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> 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-l0cyMroinI0@public.gmane.org>
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-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
    Tested-by: Nishanth Menon <nm-l0cyMroinI0@public.gmane.org>
    Signed-off-by: Kevin Hilman <khilman-l0cyMroinI0@public.gmane.org>
    Signed-off-by: Rafael J. Wysocki <rjw-KKrjLPT3xs0@public.gmane.org>

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
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: 38+ 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 ` 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   ` 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     ` 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       ` 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         ` Keshava Munegowda
2011-08-09 14:15         ` [PATCH 5/5 v4] mfd: omap: usb: Runtime PM support Keshava Munegowda
2011-08-09 14:15           ` Keshava Munegowda
2011-08-10 16:31           ` Todd Poynor
2011-08-12  6:50             ` Munegowda, Keshava
2011-08-12  6:50               ` Munegowda, Keshava
2011-08-12 21:30               ` Todd Poynor
2011-08-12 21:30                 ` Todd Poynor
2011-08-12 23:19                 ` Menon, Nishanth
2011-08-12 23:19                   ` Menon, Nishanth
2011-08-17 10:26                 ` Munegowda, Keshava
2011-08-17 10:26                   ` Munegowda, Keshava
     [not found]                 ` <20110812213037.GA24803-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2011-08-29 18:36                   ` Kevin Hilman [this message]
2011-08-29 18:36                     ` Kevin Hilman
2011-08-11 15:20           ` Ming Lei
2011-08-11 15:20             ` Ming Lei
     [not found]           ` <1312899309-24067-6-git-send-email-keshava_mgowda-l0cyMroinI0@public.gmane.org>
2011-08-29 18:50             ` Kevin Hilman
2011-08-29 18:50               ` Kevin Hilman
2011-08-29 20:47               ` Kevin Hilman
     [not found]                 ` <8739gkrllg.fsf-l0cyMroinI0@public.gmane.org>
2011-08-30  6:17                   ` Munegowda, Keshava
2011-08-30  6:17                     ` Munegowda, Keshava
     [not found]     ` <1312899309-24067-3-git-send-email-keshava_mgowda-l0cyMroinI0@public.gmane.org>
2011-08-11 15:23       ` [PATCH 2/5 v4] arm: omap: usb: ehci and ohci hwmod structures for omap3 Ming Lei
2011-08-11 15:23         ` Ming Lei
2011-08-12  5:46         ` Munegowda, Keshava
2011-08-12  5:46           ` Munegowda, Keshava
2011-08-12  7:25           ` Ming Lei
2011-08-12  7:25             ` Ming Lei
2011-08-12  8:12             ` Munegowda, Keshava
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-l0cymroini0@public.gmane.org \
    --cc=b-cousson-l0cyMroinI0@public.gmane.org \
    --cc=balbi-l0cyMroinI0@public.gmane.org \
    --cc=gadiyar-l0cyMroinI0@public.gmane.org \
    --cc=johnstul-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=keshava_mgowda-l0cyMroinI0@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nm-l0cyMroinI0@public.gmane.org \
    --cc=parthab-PpE0FKYn9XJWk0Htik3J/w@public.gmane.org \
    --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=toddpoynor-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org \
    --cc=vikram.pandita-l0cyMroinI0@public.gmane.org \
    --cc=vishwanath.bs-l0cyMroinI0@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.