Re: [linux-pm] [patch update 2 fix] PM: Introduce core framework for run-time PM of I/O devices



On Sat, Jun 20, 2009 at 11:30 PM, Alan Stern<stern@xxxxxxxxxxxxxxxxxxx> wrote:
Some more thoughts...

Magnus, you might have some insights here.  It occurred to me that some
devices can switch power levels very quickly, and the drivers might
therefore want the runtime suspend and resume methods to be called as
soon as possible, even in interrupt context.

I'd like to call pm_request_suspend() from interrupt context. I don't
depend on it, but being able to perform runtime suspend directly from
the ISR would be convenient from a device driver POV. I'm not sure if
that should result in bus/device ->runtime_suspend() calls from
interrupt context though.

In my case the bus specific code for ->runtime_suspend() may just
decrease the usage count of the powerdomain but refrain from calling
the device ->runtime_suspend() callbacks until all devices in the
powerdomain have been suspended. The bus/device runtime suspend
callbacks do not need to be executed from interrupt context. Just
noting that the device is idle is enough at interrupt time. This could
be handled by generic code IMO.

Runtime resume needs to block until the hardware is woken up though.
Just marking the device as resumed and letting the driver access the
hardware before it is woken up does not seem like a good idea. =) For
my SuperH devices I do not need to resume from interrupt context, at
least at this point.

From my perspective it's ok to specificy that the ->runtime_suspend()
and ->runtime_resume() callbacks are executed from process context
only and may sleep. Seems like a simple and good interface that can be
accepted by many bus types. My bus and driver code do not need to
sleep though, so a direct-from-interrupt-context design is fine as
well.

In terms of the current framework, this probably means holding the
runtime PM lock (i.e., not releasing it) across the calls to
->runtime_suspend and ->runtime_resume.  It also means that
pm_request_suspend and pm_request_resume should carry out their jobs
immediately instead of queuing a work item.  (Unless the current status
is RPM_SUSPENDING or RPM_RESUMING, which should never happen.)

No problem holding a per struct device lock. I suspect that executing
the callbacks from interrupt context is the most efficient design, but
it may come with interrupt latency side effects.

Should there be a flag in dev_pm_info to select this behavior?

I'd say that executing the callbacks from process context is enough
for now. This will probably be a good match together with interrupt
threads as well.

Maybe the ARM guys have more advanced requriements?

Cheers,

/ magnus
--
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/



Relevant Pages

  • Re: [linux-pm] [patch update 2 fix] PM: Introduce core framework for run-time PM of I/O devi
    ... but being able to perform runtime suspend directly from ... decrease the usage count of the powerdomain but refrain from calling ... callbacks do not need to be executed from interrupt context. ...
    (Linux-Kernel)
  • Re: [PATCH/RFC] SPI: add DMAUNSAFE analog to David Brownells core
    ... how the ads7846 touchscreen driver does small async transfers. ... One cannot allocate memory in interrupt context, so the way to go is allocating it on stack, thus the buffer is not DMA-safe. ... causes a USB packet to be dynamically created and sent to the USB core. ...
    (Linux-Kernel)
  • Re: [RFC PATCH 0/3] sysfs: allow suicide
    ... The reference is dropped when the suiciding thread calls delete on the ... device has been removed or will be removed in interrupt context. ... Therefore every hotplug driver I have looked at has it's own workqueue ...
    (Linux-Kernel)
  • Re: RTC , ds1307 I2C driver and NTP does not work.
    ... from an interrupt context, which is what appears to be happening here. ... So the ds1307 driver would need to be changed not to directly call ... There is no way around the delay in the case of I2C RTC chips anyway ... bus driver may sleep as part of the bus transaction, ...
    (Linux-Kernel)
  • Re: [net-next PATCH 1/2] igbvf: add new driver to support 82576 virtual functions
    ... I tried to incorporate most of them into the igbvf driver and also ended up porting some over to our other drivers, specifically igb since the igbvf driver copies much of the code. ... int err; ... This is always used out of interrupt context and is just to prevent multiple setting changes at the same time. ... return err; ...
    (Linux-Kernel)