All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: "Li, Shaohua" <shaohua.li@intel.com>
Cc: "linux-pm@lists.linux-foundation.org"
	<linux-pm@lists.linux-foundation.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"stern@rowland.harvard.edu" <stern@rowland.harvard.edu>
Subject: Re: [RFC 1/5] devcore introduce wakeup_event callback
Date: Mon, 8 Sep 2008 22:26:11 -0700	[thread overview]
Message-ID: <200809082226.11399.david-b@pacbell.net> (raw)
In-Reply-To: <76780B19A496DC4B80439008DAD7076C01AC7F328B@PDSMSX501.ccr.corp.intel.com>

On Monday 08 September 2008, Li, Shaohua wrote:
> 
> >> + * @wakeup_event: Checks if a wakeup event occurs.
> >> + *    If yes, wakeup event should be disabled.
> >
> >And ... what else??  What does the return value indicate?
> >Should anything be done with it other than printing it out
> >if it's nonzero and we're debugging?
>
> Return 0 if the device invokes a wakeup event. In this case, driver 
> should clear/disable wakeup event. 
> Return < 0 if device didn't invoke wakeup.

So it's effectively "bool"?  I'd declare it as "bool" then...
and rename it to sound like a predicate; "is_wakedev()" maybe.


> If device follows standard wakeup mechanism which bus level can
> handle, driver isn't required to provide this callback.

There seems to be a semi-hidden distinction between bus-level
code and device-level code.  Somewhat apparent in later code;
but not at all clear in this initial set-the-stage patch.


> >> @@ -151,6 +153,7 @@ struct pm_ops {
> >>         int (*thaw)(struct device *dev);
> >>         int (*poweroff)(struct device *dev);
> >>         int (*restore)(struct device *dev);
> >> +       int (*wakeup_event)(struct device *dev);
> >
> >My reaction to adding this method is:  why do it here rather
> >than at the bus level?

Your answer probably should have been:  "The recent method
reshuffling makes that method work both at the level of the
'struct bus_type' and at the level of 'struct device'.  So
this _does_ add it at the bus level."

:)


> >In my particular experience there are two basic types of wakeup
> >event:
> >
> > 	...
> >
> >     * ACPI GPEs.  Bus-specific ... and similar to GPIO IRQs.
> >       Also sharable; bytecode is used to map the GPE and
> >       some register state to the ACPI device(s) which
> >       issued that GPE.
>
> This isn't bus specific.

It's bus-specific in the sense of "ACPI bus" (/sys/bus/acpi).
If the DSDT defines a GPE and maps it to an ACPI device, it will
follow those rules.

Devices not on the "ACPI bus" -- like add-on PCI cards, USB
peripherals, and other devices which have some such ACPI device
higher in the driver model tre -- don't use GPEs to wake up.
(An ancestral device may well do so:  a PCI bridge, a USB
host controller, etc.)


> ACPI devices can map to any physical devices, like PCI, IDE
> drive, PNP device. In this case, a bus specific mechanism can't
> handle all.

Sure it can.  And it'd be more natural to do it that way too.
I'd be tempted to call them from ACPI like

	struct device *dev;
	acpi_handle adev;

	/* adev received a wake event notification */

	...
	dev = acpi_get_physical_device(adev);
	if (dev) {
		/* this chunk of code should probably live in
		 * drivers/base/power/... somewhere and be
		 * part of this patch 1/5 so it's more clear
		 * what the infrastructure is doing.
		 */
		if (... && dev->bus->pm.base->is_wakedev(dev)) {
			... call dev->driver->pm.resume(dev)
			... else if resume is null, issue diagnostic
		} else {
			... report suitable generic confusion ...
		}
	} else {
		... report ACPI-specific confusion ...
	}
	...

When that's a PCI device -- bridge or otherwise -- that
would call something resembling your patch #3 (but fixed
to handle the case of PCI bridges, so add-in cards will
work properly).

And for a non-ACPI system, whatever IRQ handler receives the
PME# signal would just call that chunk of code for the PCI
root bridge(s) it handles.  All done.  :)


> For example the UHCI case. A GPE is fired, we need to clear/disable
> the wakeup event. PCI bus can't handle it, as UHCI has special
> registers for this, so we need call into device specific handling.  

So the bus-level PCI operation would end up with a device
that's either (a) known to have fired PME#, or (b) known
to be a device with legacy PM -- like UHCI -- which it's
presuming has been wakeup-enabled.

Then in the (a) case it can clear PME# the normal way, and
would rarely need to do anything else.

While in the (b) case the UHCI driver would need to have
provided some device-specific -- not bus-generic -- op
called like dev->driver->pm.is_wakeup(), to diddle those
registers (only for Intel silicon, not UHCI from VIA or
Genesys or anyone else).


I think I'm getting a bit more clear on what you're trying
to do with this.  Restructure it a bit and I will be able
to see that from reading the code (as will others).  :)

- Dave


  reply	other threads:[~2008-09-09  5:26 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-08  9:19 [RFC 0/5] device wakeup event support shaohua.li
2008-09-08  9:19 ` [RFC 1/5] devcore introduce wakeup_event callback shaohua.li
2008-09-09  2:56   ` David Brownell
2008-09-09  2:56   ` David Brownell
2008-09-09  3:49     ` Li, Shaohua
2008-09-09  3:49     ` Li, Shaohua
2008-09-09  5:26       ` David Brownell [this message]
2008-09-09  8:36         ` Li, Shaohua
2008-09-09  8:36         ` Li, Shaohua
2008-09-09 11:45           ` Rafael J. Wysocki
2008-09-09 11:45           ` Rafael J. Wysocki
2008-09-09 14:22             ` Alan Stern
2008-09-09 14:22             ` Alan Stern
2008-09-09 14:18         ` Alan Stern
2008-09-09 14:18         ` Alan Stern
2008-09-09 15:52           ` David Brownell
2008-09-09 18:39             ` Alan Stern
2008-09-09 18:39             ` Alan Stern
2008-09-09 15:52           ` David Brownell
2008-09-09  5:26       ` David Brownell
2008-09-08  9:19 ` shaohua.li
2008-09-08  9:19 ` [RFC 2/5] devcore adds generic wakeup event handler shaohua.li
2008-09-08  9:19 ` shaohua.li
2008-09-08  9:19 ` [RFC 3/5] pci wakeup handler shaohua.li
2008-09-08  9:19 ` shaohua.li
2008-09-08 13:09   ` Rafael J. Wysocki
2008-09-09  1:44     ` Li, Shaohua
2008-09-09  2:56       ` David Brownell
2008-09-09  3:38         ` Li, Shaohua
2008-09-09  3:38         ` Li, Shaohua
2008-09-09  2:56       ` David Brownell
2008-09-09  1:44     ` Li, Shaohua
2008-09-08 13:09   ` Rafael J. Wysocki
2008-09-09  2:56   ` David Brownell
2008-09-09  3:33     ` Li, Shaohua
2008-09-09  3:33     ` Li, Shaohua
2008-09-09  4:04       ` David Brownell
2008-09-09  4:04       ` David Brownell
2008-09-09 11:09     ` Rafael J. Wysocki
2008-09-09 11:09     ` Rafael J. Wysocki
2008-09-09 16:18       ` David Brownell
2008-09-09 16:18       ` David Brownell
2008-09-09  2:56   ` David Brownell
2008-09-08  9:19 ` [RFC 4/5] PCIe native PME detection shaohua.li
2008-09-08  9:19 ` shaohua.li
2008-09-08 21:36   ` Rafael J. Wysocki
2008-09-09  1:21     ` Li, Shaohua
2008-09-09  1:21     ` Li, Shaohua
2008-09-08 21:36   ` Rafael J. Wysocki
2008-09-08  9:19 ` [RFC 5/5] ACPI GPE based wakeup event detection shaohua.li
2008-09-08  9:19 ` shaohua.li
2008-09-08 20:57   ` Rafael J. Wysocki
2008-09-08 20:57   ` Rafael J. Wysocki
2008-09-09  1:13     ` Zhao Yakui
2008-09-09  1:13     ` Zhao Yakui
2008-09-09  1:08       ` Li, Shaohua
2008-09-09  1:08       ` Li, Shaohua
2008-09-09 11:17         ` Rafael J. Wysocki
2008-09-09 11:17         ` Rafael J. Wysocki
2008-09-09 14:08       ` Alan Stern
2008-09-09 14:08       ` Alan Stern
2008-09-09  2:41 ` [RFC 0/5] device wakeup event support David Brownell
2008-09-09  3:54   ` Li, Shaohua
2008-09-09  3:54   ` Li, Shaohua
2008-09-09  2:41 ` David Brownell
  -- strict thread matches above, loose matches on Subject: below --
2008-09-11  6:30 [RFC 0/5] device wakeup event support v2 Shaohua Li
2008-09-11  6:30 ` [RFC 1/5] devcore introduce wakeup_event callback Shaohua Li
2008-09-11  6:30 ` Shaohua Li
2008-10-19 19:04   ` Rafael J. Wysocki
2008-10-19 19:42     ` Rafael J. Wysocki
2008-10-19 19:42     ` Rafael J. Wysocki
2008-10-22  5:23     ` Shaohua Li
2008-10-22  5:23     ` Shaohua Li

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=200809082226.11399.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=shaohua.li@intel.com \
    --cc=stern@rowland.harvard.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.