runtime PM ops and PCMCIA bus
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · Dominik Brodowski
Alan,
many thanks for your extensive feedback!
My pleasure.
Quoted 8 lines · Alan Stern
Quoted 7 lines · Dominik Brodowski
Quoted 5 lines
(2) Whenever two functions local to
drivers/pcmcia/ds.c--runtime_suspend()orruntime_resume()-- are called, we need to force a synchronous call topcmcia_dev_suspend(), or topcmcia_dev_resume(). Currently, we do this by takingdevice_lock()and calling the function manually.
Quoted 4 lines
Quoted 2 lines
That seems like the right thing to do. (Except that I don't know what your
device_lock()routine is for.)Actually, that's the generic
device_lock(), which replaceddown(&dev->sem)
Heh. Guess I'm not used to seeing it yet...
Quoted 2 lines
... which is used here to not let a reset or a runtime suspend/resume race with a system sleep event.
The PM core is supposed to prevent races between runtime suspend/resume and system sleep, so you don't need to worry about that. But you do need to worry about races with reset (this may or may not be the best way to handle them).
Quoted 11 lines
Quoted 3 lines
I don't understand. Aren't
runtime_suspend()andruntime_resume(), as mentioned above, already part of your runtime PM interface? Or at least, intended to be part of your runtime PM interface?Well, they are part of the PCMCIA-local runtime PM interface -- it is based around the concept that an user may, whenever she wants, can set a PCMCIA device (or the whole card) to the "suspend" state.
Well, that's not what this "
runtime_suspend()" does -- it is the wrapper for userspace-issued suspend commands.
Quoted 6 lines
Quoted 2 lines
One of the background assumptions behind the runtime PM framework is that users don't tell the system when to suspend devices.
Ah, that's the fundamental issue. I agree that the PCMCIA subsystem does something unusual here (relating to PCMCIA cards or PCMCIA devices) -- but I would prefer not to break how the system currently works.
All right. It appears that what you have implemented is really a "power-down" or "on/off" type of interface rather than a "runtime-suspend" interface. You can of course have both types of interfaces at the same time, but keep in mind that they don't work the same way.
Quoted 10 lines
Quoted 8 lines
Quoted 3 lines
(5) Another problem I'm seeing with the put/get approach: there are three different callpaths where
runtime_suspend()/runtime_resume()might be called.[*] However, each one decreases the counter, which might get < 0.The counter should never become negative; if it does, there's a bug in your driver. Every decrement should match a corresponding increment, just like with refcounts. And the device should never be runtime-suspended unless the counter is 0.
what's the initial value, actually? Is it 0 or 1?
It is 0.
Quoted 4 lines
Quoted 2 lines
Instead, the system automatically suspends devices when it realizes they aren't being used.
That's what we could use for PCMCIA sockets.
Yes, that sounds like an easy application. If the socket contains no card, or if all devices on the card are powered-down, then the socket can be runtime-suspended.
Quoted 12 lines
Quoted 11 lines
drivers/pcmcia/Kconfig if PCCARD · line 23
Quoted 7 lines
drivers/pcmcia/Kconfig +1
-0@@ -20,6 +20,7 @@ if PCCARD config PCMCIA tristate "16-bit PCMCIA support" select CRC32 + select PM_RUNTIMEThis seems very wrong. Why do you need it? Can't the pcmcia subsystem work correctly without runtime PM support? Hasn't it been working correctly that way all along?
Quoted 2 lines
Oh yes, it did. However, continuing support for the PCMCIA-style "runtime PM" might need to depend on
PM_RUNTIME.
It shouldn't be that way. Keep the existing PCMCIA-style interface if you want, but realize that it is separate and independent from the runtime PM framework and therefore it shouldn't select PM_RUNTIME.
The alternative is to remove the user's ability to power-down PCMCIA devices, and rely on the operating system to suspend them at the right times.
Alan Stern