public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: David Brownell <david-b@pacbell.net>
Cc: Pavel Machek <pavel@suse.cz>,
	Linux Kernel list <linux-kernel@vger.kernel.org>,
	Patrick Mochel <mochel@digitalimplant.org>
Subject: Re: Solving suspend-level confusion
Date: Sat, 31 Jul 2004 15:49:23 +1000	[thread overview]
Message-ID: <1091252962.7387.14.camel@gaston> (raw)
In-Reply-To: <200407302102.12554.david-b@pacbell.net>

On Sat, 2004-07-31 at 14:02, David Brownell wrote:
> On Friday 30 July 2004 09:44, Pavel Machek wrote:
> 
> > * system-wide suspend level is always passed down (it is more
> > detailed, and for example IDE driver cares)
> 
> This bothers me -- why should a "system" suspend level matter
> to a device-level suspend call?  Seems like if IDE cares, it's
> probably being given the wrong device-level suspend state,
> or it needs more information than the target device state.

Well, as I explained you during OLS ... Drivers will act differently
for suspend-to-ram, suspend-to-disk, and eventually other states we
may introduce, like a system "idle" state.

Disks in general are an example (IDE beeing the one that is currently
implemented, but we'll probably have to do the same for SATA and SCSI
at one point), you want to spin them off (with proper cache flush
etc...) when suspending to RAM, while you don't when suspending to
disk, as you really don't want them to be spun up again right away to
write the suspend image.

USB is another example. Typically, suspend-to-RAM wants to do a bus
suspend, eventually enabling remote wakeup on some devices, and expects
to recover the bus on wakeup, while suspend-to-disk is roughtly
equivalent to a full shutdown & reconnect on wakeup.

I have other platform drivers that will behave differently. Most of the
time the difference is that suspend-to-disk will not bother actually
shutting down the HW, just freeze the state of the device, while suspend
to RAM will actually want to enter whatever D state is appropriate.

> The problem I'm clear on is with PCI suspend, which some
> earlier driver model PM changes goofed up.  It's trying to
> pass a system state to driver suspend() methods that are
> expecting a value appropriate for pci_set_power_state().
> You're proposing to fix that by changing the call semantics,
> while I'd rather just see the call site fixed.

No, I don't agree. It's a driver policy to decide what PCI state
to use based on the system suspend level.

> I trust nobody is now disagreeing that's the root cause of
> several suspend problems ... and I suspect that API changes,
> to pass enums, should be part of the "real" fix.  (As Len has
> commented, C enums aren't type-safe ... but at least they
> provide documentation which "u32 state" can't!)
> 
> 
> > * if you want to derive Dx state, just use provided inline function to
> > convert.
> 
> If the model is that there's some PM "layer" (for lack of better term)
> that's in charge of "system suspend" (e.g. to ACPI S3), then I have
> no qualms saying that layer is responsible for mapping the those
> states into PCI D-states before calling PCI suspend routines.  But
> we don't really seem to have such a layer.  MontaVista has some
> "DPM" code, distinct from drivers/base/power calls with that TLA,
> that are one example of such a layer ... allowing multiple power
> configurations.  Not the only way to do it -- but also not quite the
> limited "laptop into S3 now" kind of model either.
> 
> Point being that it should certainly be possible to selectively
> suspend devices without trying to put the whole system into a
> different state (just certain devices) ... and also without lying to
> any device about the system state.  (In fact, devices should as
> a rule not care about system power state, only their own state.)
> It should be easy for one driver to suspend or resume another
> one, without any changes to "system" state.
> 
> 
> Some specific comments on the patch:
> 
> > +enum pci_state {
> > +	D0 = 20,		/* For debugging, symbolic constants should be everywhere */
> > +	D1,
> > +	D2,
> > +	D3hot,
> > +	D3cold
> > +};
> 
> Those would be better as PCI_D0, PCI_D2 etc ... so they're not confused
> with ACPI_D0, ACPI_D2 etc.
> 
> > +
> > +static inline enum pci_state to_pci_state(enum suspend_state state)
> > +{
> > +	switch(state) {
> > +	case RUNTIME_D1:
> > +		return D1;
> > +	case RUNTIME_D2:
> > +		return D2;
> > +	case RUNTIME_D3hot:
> > +		return D3hot;
> > +	case SNAPSHOT:
> > +	case POWERDOWN:
> > +	case RESTART:
> > +	case RUNTIME_D3cold:
> > +		return D3cold;
> > +	default:
> > +		BUG();
> > +	}
> > +}
> >  
> >  #endif /* __KERNEL__ */
> 
> This stuff, if it's used, belongs in <linux/pci.h> not <linux/pm.h> ... it's
> not generic to all busses.  And pci_set_power_state() should probably
> be modified to take the enum ... though I don't much like that notion,
> it'd require changing every driver that actually tries to use the PCI
> PM calls (since they currently "know" D3hot==3 and D3cold==4).
> 
> - Dave
-- 
Benjamin Herrenschmidt <benh@kernel.crashing.org>


  parent reply	other threads:[~2004-07-31  5:51 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-30 16:44 Solving suspend-level confusion Pavel Machek
2004-07-30 22:39 ` Benjamin Herrenschmidt
2004-07-30 23:06   ` Pavel Machek
2004-07-31  4:02 ` David Brownell
2004-07-31  4:36   ` Pavel Machek
2004-07-31  5:49   ` Benjamin Herrenschmidt [this message]
2004-07-31 14:23     ` David Brownell
2004-07-31 17:01       ` Oliver Neukum
2004-07-31 17:51         ` David Brownell
2004-08-01  0:41         ` David Brownell
2004-08-01  1:34           ` Benjamin Herrenschmidt
2004-08-02 16:38             ` David Brownell
2004-08-03  0:38               ` Benjamin Herrenschmidt
2004-08-04  2:28                 ` David Brownell
2004-08-04  2:26                   ` Nigel Cunningham
2004-08-04  2:53                     ` Benjamin Herrenschmidt
2004-08-04  2:52                       ` Nigel Cunningham
2004-08-04  4:14                         ` Benjamin Herrenschmidt
2004-08-04  4:25                           ` Nigel Cunningham
2004-08-04  4:52                             ` Benjamin Herrenschmidt
2004-08-04  4:54                               ` Nigel Cunningham
2004-08-04  5:03                                 ` Benjamin Herrenschmidt
2004-08-04  5:05                                   ` Nigel Cunningham
2004-08-05 10:05                                   ` Nigel Cunningham
2004-08-05 22:31                                   ` Nigel Cunningham
2004-08-06  0:39                                     ` Benjamin Herrenschmidt
2004-08-06 21:30                                     ` Pavel Machek
2004-08-06 21:29                           ` Pavel Machek
2004-08-06 22:27                             ` Benjamin Herrenschmidt
2004-08-06 22:37                               ` Pavel Machek
2004-08-06 21:26                         ` Pavel Machek
2004-08-05  1:29                     ` David Brownell
2004-08-05 10:19                       ` Nigel Cunningham
2004-08-06  0:32                         ` David Brownell
     [not found]                           ` <1091772799.2532.50.camel@laptop.cunninghams>
2004-08-07 22:24                             ` David Brownell
2004-08-04  2:56                   ` Benjamin Herrenschmidt
2004-08-04  3:30                     ` David Brownell
2004-08-04  4:19                       ` Benjamin Herrenschmidt
2004-08-04  4:47                       ` What PM should be and do (Was Re: Solving suspend-level confusion) Nigel Cunningham
2004-08-04  4:53                         ` Benjamin Herrenschmidt
2004-08-04  4:59                           ` Nigel Cunningham
2004-08-08 16:54                             ` Pavel Machek
2004-08-08 21:55                               ` Nigel Cunningham
2004-08-09  8:42                                 ` Pavel Machek
2004-08-05 18:19                         ` Greg KH
2004-08-05 22:14                           ` Nigel Cunningham
2004-08-07  0:08                             `  Éric Brunet
2004-08-08 19:48                               ` Pavel Machek
2004-08-11 21:23                             ` Greg KH
2004-08-08  0:54                         ` David Brownell
2004-08-06 21:21               ` Solving suspend-level confusion Pavel Machek
2004-07-31 21:09       ` Benjamin Herrenschmidt
2004-08-02 16:40         ` David Brownell
2004-08-03  0:50           ` Benjamin Herrenschmidt
2004-08-07 23:30             ` David Brownell
2004-08-06 21:10           ` Pavel Machek
2004-08-07 23:23             ` David Brownell
2004-08-08 17:16               ` Pavel Machek
2004-08-06 20:04       ` Pavel Machek
2004-08-07 22:14         ` David Brownell
2004-08-07 23:53           ` Benjamin Herrenschmidt

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=1091252962.7387.14.camel@gaston \
    --to=benh@kernel.crashing.org \
    --cc=david-b@pacbell.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@digitalimplant.org \
    --cc=pavel@suse.cz \
    /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