public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
To: Patrick Mochel <mochel-3NddpPZAyC0@public.gmane.org>,
	Lyle <lwspm-RAHWjsxJnJUdnm+yROfE0A@public.gmane.org>
Cc: acpi-devel-pyega4qmqnRoyOMFzWx49A@public.gmane.org
Subject: Re: suspend.c vs driver-model.txt
Date: Wed, 24 Jul 2002 19:38:09 +0200	[thread overview]
Message-ID: <20020724173809.10194@192.168.4.1> (raw)
In-Reply-To: <Pine.LNX.4.44.0207241100080.954-100000-yZQdDDOm3n9ZQn2sFP3R7eTW4wlIGRCZ@public.gmane.org>


>
> .../...
>
>So, there needs to be a platform driver. See include/linux/platform.h and 
>kernel/platform.c for the start of this effort. There needs to be one of 
>these for each platform type. They need to be registered on startup, and 
>there needs to be prevention against multiple drivers being registered. 
>
>The platform drivers need to then do whatever device transitions they 
>need, using the device_suspend() helpers, then put the system to sleep 
>using their platform-speciifc method.

Good ! I've had my home-made bunch of stuff on pmac that looked just
like a platform driver dealing with all sort of things (basically
abtracting motherboard IOs to help drivers that need to toggle whatever
reset pin or power their device up/down physically).
(See include/asm-ppc/pmac_feature.c and arch/ppc/kernel/pmac_feature.c)

On PPC, we also have that _huge_ flat ppc_md structure that contains
pointers to functions like platform init, cpuinfo hooks, get/set_rtc_time,
irq hooks, etc... that get filled depending on the type of machine a
given kernel is booted (we support currently prep, chrp and pmac with
a single kernel binary).
(see include/asm-ppc/machdep.h)

What about generalizing the platform driver to do just those things ?

I'm not too sure about how the API would look like though. For the
ppc_md stuff, there is a fixed, well defined, but still arch specific
set of hooks to fill.

For the pmac_feature, I use a single ppc_md. hook with variable arg
list (though I do use it in a well defined format) to call a list
of "feature" functions that is usually exetended on every new kind
of motherboard I add support for. Not every machine support all
functions, etc... it would probably be a pain to define this as a
flat list of function pointers.

Anybody has better ideas on how to deal with those platform specific
things while still making them fit in a platform driver (their logical
place, especially if the platform driver ends up in driverfs, a nice
way to expose some motherboard specific settings/tweaks to userland ?

>The ACPI code that is in there is relatively close. I did that on purpose, 
>thinking that this stuff will be generalized someday. However, whatever 
>end solution that exists _must_ not be designed the behavior of ACPI. In 
>fact, I am hesitant talking about this general model on this list for fear 
>that someone that is already brainwashed by the Great Firmware Abomination 
>will say either "We can already do this!" or "I'll do it (in ACPI first 
>and generalize it)." 

I don't know ACPI well enough to talk, but the mecanism I use on PPC
is pretty basic today. The sleep procedure is dealt with by the driver
of the Power Management chip when it gets a sleep request from userland,
but that can (should be) moved to the platform driver.

Then, it does my own version of looping all devices sending them
suspend events etc... (did we ever write down what we defined during
OLS for those events semantics ?)

Then, calls the platform driver to deal with lower level motherboard
stuffs that haven't be done by any drivers and need to be done last

Finally it deals with the CPU (flushing caches, etc...).

I omitted intentionally the fact that it has to send a special command
to the power manager chip just before the low level mother board stuff,
that will cause that chip to shut the CPU down the next time it goes
to SLEEP state, which we do in the last step.

So most of this scenario is arch/platform specific cuisine. That is, all
but the first step has to be self contained somewhere in the platform
driver, those are arch/platform/cpu specific, nothing good we can do
about them.

This end up breaking the scenario into 2 main phases

 1) Looping around all drivers doing the suspend dance (suspend request,
save_state & suspend, ...) as we discussed. This is mostly (completely ?)
platform independant (except for the exact state a given device has to
be put to, oh well, let's deal that inside the device driver for now)

 2) Doing whatever additional arch specific code is needed to snooze
the machine.

1) is generic. 2) is arch/platform code.

The nice thing here, I beleive, is that suspend to disk could then just
be an additional generic step between 1) and 2) that takes care of
dumping memory content to disk.

As far as suspend to disk is concerned, we have all sort of nasty issues
we discussed that I don't feel like resuming right now, so I would rather
have the lowest level driver able to play the backing store export a
couple of "hooks" used to dump the pages to the medium, those would work
synchronously, without VM activity, etc... The driver that is target for
that would have pre-allocated what it needs, pre-mapped DMA mappings it
needs etc...
Though, thinking as I write, injecting requests via the BIO layer may
be a nicer solution, provided we make sure the driver won't get any
request _but_ the ones we feed it. I don't trust a mecanism that would
selectively stop given kernel threads, then just hope nobody will push
requests any more. That's way too fragile to my taste. I'd rather freeze
the request queue for real like any other device, then eventually provide
a special pass-through.

><harshness>
>The ACPI subsystem has a tendency to duplicate existing interfaces, or 
>come up with completely new ones, intending to be applicable to the rest 
>of the kernel. The are highly ACPI-centric, yet they expect them to be 
>standard. They aren't publicized or discussed on any list but this one. 
>But, they're left to be fixed up and cleaned up by the other people in the 
>community. 
>
>I refuse to lay blame on anyone for my inability to work faster or harder. 
>But, a lot of people complain that I've been working on this for a year, 
>and they still can't suspend their laptop. My rebuttal is that if I had 
>actually gotten cooperation and compromise at the source level, in many 
>areas, we probably wouldn't still be dealing with this. 
></harshness>

I'm probably to blame for not writing code here as I mostly only
contributed with speetch and ideas (and my old pmac code) so far.
I'm sorry, i'm not even been able to find time to convert the pmac
drivers to driverfs yet :( My time dedicated to linux is spare, and
so variable, and it tends to be quite small nowadays.

>So, someone needs to do it. I don't have time. And, I don't trust anyone 
>related to ACPI to do it right (except maybe Andy in a different context, 
>but he's overworked as it is). 

I've subscribed to this list, it may be a good oportunity to use it
for discussing & defining things at the API level now.

Regards,
Ben.




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

  parent reply	other threads:[~2002-07-24 17:38 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mochel@osdl.org>
     [not found] ` <Pine.LNX.4.44.0207240843090.954-100000-yZQdDDOm3n9ZQn2sFP3R7eTW4wlIGRCZ@public.gmane.org>
2002-07-24 16:37   ` suspend.c vs driver-model.txt Lyle
     [not found]     ` <20020724163701.D99F714808-RAHWjsxJnJUdnm+yROfE0A@public.gmane.org>
2002-07-24 18:25       ` Patrick Mochel
     [not found]         ` <Pine.LNX.4.44.0207241100080.954-100000-yZQdDDOm3n9ZQn2sFP3R7eTW4wlIGRCZ@public.gmane.org>
2002-07-24 17:38           ` Benjamin Herrenschmidt [this message]
     [not found]             ` <20020724173809.10194-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-29  9:00               ` Pavel Machek
     [not found]                 ` <20020729090041.GB115-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2002-07-29 15:08                   ` Benjamin Herrenschmidt
     [not found]                     ` <20020729150807.3604-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-29 17:56                       ` Pavel Machek
     [not found]                         ` <20020729175650.GA1233-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2002-07-29 17:33                           ` Benjamin Herrenschmidt
     [not found]                             ` <20020729173302.30557-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-29 18:31                               ` Pavel Machek
     [not found]                                 ` <20020729183143.GA13729-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2002-07-29 18:05                                   ` Benjamin Herrenschmidt
     [not found]                                     ` <20020729180547.20998-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-29 19:11                                       ` Pavel Machek
     [not found]                                         ` <20020729191146.GE13729-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2002-07-30  7:57                                           ` Benjamin Herrenschmidt
2002-07-29 22:36               ` Patrick Mochel
2002-07-24 17:56   ` Lyle
2002-07-30  0:25 Grover, Andrew
     [not found] <20020729180037.GB1233@elf.ucw.cz>
     [not found] ` <20020729180037.GB1233-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2002-07-29 17:55   ` Benjamin Herrenschmidt
     [not found]     ` <20020729175556.13645-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-29 19:02       ` Pavel Machek
     [not found]         ` <20020729190219.GD13729-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2002-07-30  7:53           ` Benjamin Herrenschmidt
     [not found]             ` <20020730075329.26474-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 18:29               ` Pavel Machek
     [not found]                 ` <20020730182921.GD7567-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:18                   ` Benjamin Herrenschmidt
     [not found]                     ` <20020730181810.30687-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 19:38                       ` Pavel Machek
     [not found]                         ` <20020730193857.GC12091-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:39                           ` Benjamin Herrenschmidt
     [not found]                             ` <20020730183941.6386-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 19:51                               ` Pavel Machek
     [not found]                                 ` <20020730195149.GI12091-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:50                                   ` Benjamin Herrenschmidt
2002-07-30 18:47                   ` Patrick Mochel
     [not found]                     ` <Pine.LNX.4.44.0207301136050.22697-100000-yZQdDDOm3n9ZQn2sFP3R7eTW4wlIGRCZ@public.gmane.org>
2002-07-30 18:54                       ` Pavel Machek
2002-07-30  8:04           ` Benjamin Herrenschmidt
     [not found]             ` <20020730080418.11907-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 18:22               ` Pavel Machek
     [not found]                 ` <20020730182255.GC7567-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:32                   ` Patrick Mochel
     [not found]                     ` <Pine.LNX.4.44.0207301125370.22697-100000-yZQdDDOm3n9ZQn2sFP3R7eTW4wlIGRCZ@public.gmane.org>
2002-07-30 18:44                       ` Pavel Machek
     [not found]                         ` <20020730184442.GE7567-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:22                           ` Benjamin Herrenschmidt
     [not found]                             ` <20020730182219.13608-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 19:42                               ` Pavel Machek
     [not found]                                 ` <20020730194214.GD12091-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:43                                   ` Benjamin Herrenschmidt
     [not found]                                     ` <20020730184305.23369-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 19:56                                       ` Pavel Machek
     [not found]                                         ` <20020730195655.GK12091-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:57                                           ` Benjamin Herrenschmidt
     [not found]                                             ` <20020730185730.615-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 20:06                                               ` Pavel Machek
     [not found]                                                 ` <20020730200634.GA16297-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 21:21                                                   ` Patrick Mochel
     [not found]                                                     ` <Pine.LNX.4.44.0207301406440.22697-100000-yZQdDDOm3n9ZQn2sFP3R7eTW4wlIGRCZ@public.gmane.org>
2002-07-31 21:44                                                       ` Pavel Machek
2002-07-30 22:33                                                   ` Benjamin Herrenschmidt
2002-07-30 18:51                           ` Patrick Mochel
     [not found]                             ` <Pine.LNX.4.44.0207301148350.22697-100000-yZQdDDOm3n9ZQn2sFP3R7eTW4wlIGRCZ@public.gmane.org>
2002-07-30 18:25                               ` Benjamin Herrenschmidt
     [not found]                                 ` <20020730182552.1477-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 19:47                                   ` Pavel Machek
2002-07-30 19:00                               ` Pavel Machek
     [not found]                                 ` <20020730190041.GH7567-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:27                                   ` Benjamin Herrenschmidt
2002-07-30 19:03                                   ` Patrick Mochel
     [not found]                                     ` <Pine.LNX.4.44.0207301202250.22697-100000-yZQdDDOm3n9ZQn2sFP3R7eTW4wlIGRCZ@public.gmane.org>
2002-07-30 19:11                                       ` Pavel Machek
     [not found]                                         ` <20020730191127.GB11531-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 19:12                                           ` Patrick Mochel
2002-07-30 20:46                                   ` Alan Cox
     [not found]                                     ` <1028061979.7974.40.camel-MMxVpc8zpTQVh3rx8e9g/fyykp6/JSeS3vcXtXqGYxw@public.gmane.org>
2002-07-30 18:34                                       ` Benjamin Herrenschmidt
     [not found]                                         ` <20020730183448.20582-Q0ErXNX1RuY/GWcAdfcqrQ@public.gmane.org>
2002-07-30 19:53                                           ` Pavel Machek
     [not found]                                             ` <20020730195348.GJ12091-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2002-07-30 18:51                                               ` Benjamin Herrenschmidt
2002-07-30 20:11                       ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2002-07-24 19:43 Grover, Andrew
     [not found] ` <59885C5E3098D511AD690002A5072D3C07990D78-OU+JdkIUtvcLll3ZsUKC9FDQ4js95KgL@public.gmane.org>
2002-07-29 22:50   ` Patrick Mochel
     [not found] <lwspm@o-o.yi.org>
     [not found] ` <20020724133821.5598714808-RAHWjsxJnJUdnm+yROfE0A@public.gmane.org>
2002-07-24 13:47   ` Lyle
     [not found]     ` <20020724134715.6060914808-RAHWjsxJnJUdnm+yROfE0A@public.gmane.org>
2002-07-24 15:51       ` Patrick Mochel
2002-07-24 17:07   ` Pavel Machek
2002-07-24 13:38 Lyle

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=20020724173809.10194@192.168.4.1 \
    --to=benh-xvmvhmargas8u2djnn8i7kb+6bgklq7r@public.gmane.org \
    --cc=acpi-devel-pyega4qmqnRoyOMFzWx49A@public.gmane.org \
    --cc=lwspm-RAHWjsxJnJUdnm+yROfE0A@public.gmane.org \
    --cc=mochel-3NddpPZAyC0@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox