public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	<linux-kernel@vger.kernel.org>, Patrick Mochel <mochel@osdl.org>,
	Jonathan Lundell <jlundell@pobox.com>
Subject: Re: [RFC] New Driver Model for 2.5
Date: Wed, 24 Oct 2001 12:34:51 +0200	[thread overview]
Message-ID: <20011024103451.8099@smtp.adsl.oleane.com> (raw)
In-Reply-To: <E15wKn8-00013C-00@the-village.bc.nu>
In-Reply-To: <E15wKn8-00013C-00@the-village.bc.nu>

>
>The two trees are certainly closely related - USB devices before USB hub,
>USB hub before PCI etc. The scanner example works fine there, providing that
>we are careful about memory issues - remember the USB layer allocates memory
>to do any transaction, so the scanner has to complete its state save before 
>we do any interrupt disabling/memory alloc freezing.

That's why we have that first step that is run before any device is blocked
and with interrupts still flowing. Devices that need memory for either state
save or for requests used during power down are supposed to allocate them
at this point.

>Thats still just ordering and maybe two passes

Well, 3 passes actually ;) I'd suggest you re-read Patrick's mochel latest
document, which describes the 3 step process. One first pass give a chance
to device to "prepare" for sleep, that is allocate anything they will need
without actually blocking or suspending anything. On the second pass, devices
are asked to suspend IOs, complete pending ones, and save state. This is
done with interrupts still enabled. The 3rd pass is called with interrupt
disabled and is where the actual shutdown of the device is supposed to happen.

In practice, a lot of drivers will only need to implement 1 or 2 of these
3 passes. But the flexibility has to be there for a device that need both\
to allocate memory and to suspend with interrupts disabled.

An additional idea we had was to make pass 2 somewhat asyncrhonous by
allowing some kind of "call my later" result code (basically, a device
would block it's queue, and return "call me later" while it still has
pending IOs). This is an optional "feature".

>> the HW or not when getting a new request). In cases where a mid-layer
>> enters the scene, like SCSI, that wants to do timeouts, then well...
>> we can let it timeout (just stop processing requests), or we can
>> have the midlayer go to sleep as well :) That later solution
>> may cause some interesting ordering issues however...
>
>For scsi you have to complete the pending commands, you don't know what the
>transaction granularity is in some cases and half completing the sequence
>won't help you. In addition the upper layers have to queue additional scsi
>commands to do stuff like cd drawer locking and to ask the drive firmware
>to enter powerdown modes

Yes. SCSI is a problem as the current SCSI layer is tricky enough to
make this difficult. I beleive that if the SCSI devices are childs of
the SCSI controller, then they can take care of suspending the device
(that is sending whatever command to lock the drawer or stop the disk
spinning) before the controller is actually going to sleep. In that
case, there's not much left to the controller, it isn't supposed to
have any command in queue nor receive any new one once all it's child
drivers have suspended.

>> For USB, for example, we can consider that when a device driver
>> (not a controller driver) suspend has been done, any URB it submits
>> can just be dropped (returned immediately with an error). We don't
>> need blocking here neither. Of course, that means we have the
>> framework to call devices' suspend/resume callbacks when the
>> controller is about to go to sleep.
>
>That will scramble large numbers of devices. Randomly erroring pending block
>writes is -not- civilised.

The drivers will have to be adapted for PM, whatever scheme we use. The
USB case is very similar to SCSI. The controller is a parent of all
devices. Devices will get the suspend before the controller, they will
have a chance to suspend requests and wait for pending ones to complete
(for example, the USB storage will have a chance to block new incoming
requests in the queue and wait for pending ones to complete) before
the USB controller is put to suspend.
That way, once we are reaching real USB controller suspend, we can safely
discard urbs as we are not supposed to get any until devices have been
resumed.

I currently don't do that on pmac (I just let URBs be handled by OHCI
and let OHCI fill the TD queues in memory, I only prevent the controller
from actually handling those queues). It's not good as some drivers will
get error messages due to their underlying device beeing suspended,
and won't understand why the URBs are going away.

In the case of USB devices that don't support suspend state, it's slightly
more tricky as on some HW, I may have to actually turn them off. That mean
the driver must deal with re-doing configuration & set-interface on
wakeup. That is again a driver matter, and a bit like the PCI case we
mentioned previously, we need some way to know if driver for a given
device can handle the requested power state or not. If not, we should
probably abort the suspend sequence, and find a clean interface to tell
userland about which device caused the failure so the user can deal with
it (rmmod the driver for example).


Ben.



  reply	other threads:[~2001-10-24 10:35 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-19 23:33 [RFC] New Driver Model for 2.5 Benjamin Herrenschmidt
2001-10-20  0:09 ` Linus Torvalds
2001-10-20  9:28   ` Benjamin Herrenschmidt
2001-10-21 17:09     ` Pavel Machek
2001-10-23  0:19       ` Patrick Mochel
2001-10-23  0:31         ` Alan Cox
2001-10-23  0:29           ` Patrick Mochel
2001-10-23  7:53             ` Alan Cox
2001-10-23 15:10               ` Jonathan Lundell
2001-10-23 15:49                 ` Alan Cox
2001-10-23 20:22                 ` Benjamin Herrenschmidt
2001-10-23 20:54                   ` Alan Cox
2001-10-24  0:26                     ` Benjamin Herrenschmidt
2001-10-24  9:57                       ` Alan Cox
2001-10-24 10:34                         ` Benjamin Herrenschmidt [this message]
2001-10-24 10:54                           ` Alan Cox
2001-10-24 13:04                             ` Benjamin Herrenschmidt
2001-10-24 13:25                               ` Alan Cox
2001-10-24 16:19                                 ` Linus Torvalds
2001-10-24 16:36                                   ` Michael H. Warfield
2001-10-24 16:45                                     ` Linus Torvalds
2001-10-24 22:48                                   ` Alan Cox
2001-10-24 16:15                               ` Linus Torvalds
2001-10-24 16:46                                 ` Xavier Bestel
2001-10-24 16:54                                   ` Patrick Mochel
2001-10-24 16:55                                   ` Linus Torvalds
2001-10-24 22:45                                     ` Alan Cox
2001-10-24 17:33                                 ` Benjamin Herrenschmidt
2001-10-24 22:41                                   ` Alan Cox
2001-10-24 22:41                                     ` Linus Torvalds
2001-10-25  7:58                                     ` Benjamin Herrenschmidt
2001-10-25 12:22                                       ` Alan Cox
2001-10-25 14:57                                         ` Benjamin Herrenschmidt
2001-10-25  8:03                                     ` Benjamin Herrenschmidt
2001-10-25  8:09                                       ` Benjamin Herrenschmidt
2001-10-25 12:20                                       ` Alan Cox
2001-10-25 21:47                                   ` Pavel Machek
2001-10-24 22:50                                 ` Alan Cox
2001-10-25  4:14                                   ` Linus Torvalds
2001-10-25 12:42                                     ` Alan Cox
2001-10-25 21:52                                       ` Xavier Bestel
2001-10-25 23:53                                         ` Benjamin Herrenschmidt
2001-10-25 23:53                                           ` Alan Cox
2001-10-26 11:35                                       ` Helge Hafting
2001-10-26 12:38                                         ` Alan Cox
2001-10-25  8:27                                 ` Rob Turk
2001-10-25 10:01                                   ` Benjamin Herrenschmidt
2001-10-25 10:02                                   ` Helge Hafting
2001-10-25 14:20                                   ` Victor Yodaiken
2001-10-25 14:44                                     ` Jeff Garzik
2001-10-25 14:45                                     ` Jeff Garzik
2001-10-25 15:22                                     ` Rob Turk
2001-10-25 15:44                                       ` Jonathan Lundell
2001-10-25 16:26                                     ` David Lang
2001-10-25 21:59                                   ` Pavel Machek
2001-10-25 21:32                                     ` Rob Turk
2001-10-24 17:01                               ` Mike Anderson
2001-10-25  9:02                               ` Eric W. Biederman
2001-10-25  9:29                                 ` Linus Torvalds
2001-10-25  9:47                                   ` Benjamin Herrenschmidt
2001-10-25 10:11                                   ` Eric W. Biederman
2001-10-25 10:59                                     ` Linus Torvalds
2001-10-24 15:18                         ` Jonathan Lundell
2001-10-24 15:41                         ` Linus Torvalds
2001-10-24 15:59                           ` Alan Cox
2001-10-24 15:56                             ` Linus Torvalds
2001-10-23  9:44             ` Pavel Machek
2001-10-23 11:03               ` Benjamin Herrenschmidt
2001-10-23 11:49                 ` Benjamin Herrenschmidt
2001-10-23 10:54           ` Benjamin Herrenschmidt
  -- strict thread matches above, loose matches on Subject: below --
2001-10-24 17:56 Grover, Andrew
2001-10-24 18:45 ` Benjamin Herrenschmidt
2001-10-19 21:43 Grover, Andrew
2001-10-19 17:01 Kevin Easton
2001-10-19 18:40 ` Patrick Mochel
2001-10-17 23:52 Patrick Mochel
2001-10-18  6:23 ` Jeff Garzik
2001-10-18 12:13   ` Benjamin Herrenschmidt
2001-10-18 16:19     ` Patrick Mochel
2001-10-18 17:38       ` Tim Jansen
2001-10-18 22:06       ` Benjamin Herrenschmidt
2001-10-19 17:09         ` Kai Henningsen
2001-10-18 22:10       ` Kai Henningsen
2001-10-19 18:26         ` Patrick Mochel
2001-10-19 19:02           ` Tim Jansen
2001-10-19 19:21             ` Mike Fedyk
2001-10-19 20:07               ` Tim Jansen
2001-10-19 20:24                 ` Mike Fedyk
2001-10-19 22:25                   ` Tim Jansen
2001-10-20 13:47                   ` Kai Henningsen
2001-10-20  1:41               ` john slee
2001-10-20 13:52               ` Kai Henningsen
2001-10-22 11:02                 ` Padraig Brady
2001-10-27 11:01                   ` Kai Henningsen
2001-10-19  7:57     ` Henning P. Schmiedehausen
2001-10-19  8:09       ` Jeff Garzik
2001-10-19  8:31         ` Keith Owens
2001-10-19  8:43           ` Jeff Garzik
2001-10-19 18:50       ` Tim Jansen
2001-10-19 15:21     ` Taral
2001-10-19 23:30     ` Benjamin Herrenschmidt
2001-10-19 23:54       ` Benjamin Herrenschmidt
2001-10-18 15:17   ` Patrick Mochel
2001-10-18 16:08 ` Taral
2001-10-18 16:52   ` Jonathan Lundell
2001-10-18 17:38     ` Patrick Mochel
2001-10-18 17:41       ` Patrick Mochel
2001-10-18 18:28       ` Jonathan Lundell
2001-10-18 19:49         ` Patrick Mochel
2001-10-18 20:40           ` Jeff Garzik
2001-10-18 21:32           ` John Alvord
2001-10-18 22:23             ` Benjamin Herrenschmidt
2001-10-18 22:26             ` Jeff Garzik
2001-10-18 22:18           ` Benjamin Herrenschmidt
2001-10-18 23:30             ` Patrick Mochel
2001-10-18 23:44               ` Benjamin Herrenschmidt
2001-10-18 23:52                 ` Jeff Garzik
     [not found]         ` <3BCF3941.D4B79FE1@mandrakesoft.com>
2001-10-19 17:12           ` Jonathan Lundell
2001-10-18 17:05 ` Jonathan Corbet
2001-10-18 17:33   ` Patrick Mochel

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=20011024103451.8099@smtp.adsl.oleane.com \
    --to=benh@kernel.crashing.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jlundell@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    --cc=torvalds@transmeta.com \
    /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