2004-10-04 21:43:14

by David Brownell

[permalink] [raw]
Subject: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

This lets drivers standardize how they present their ability to issue
wakeups, and how they manage whether that ability should be used.


Attachments:
(No filename) (136.00 B)
wake-core.patch (4.39 kB)
Download all attachments

2004-10-05 19:46:10

by Pavel Machek

[permalink] [raw]
Subject: Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

Hi!

> This lets drivers standardize how they present their ability to issue
> wakeups, and how they manage whether that ability should be used.

Why do you assign "enabled" to variable instead of using it directly?
And perhaps you should print "not supported" instead of empty string...

Pavel

--
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms

2004-10-05 20:11:27

by David Brownell

[permalink] [raw]
Subject: Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

On Tuesday 05 October 2004 12:37 pm, Pavel Machek wrote:
> Hi!
>
> > This lets drivers standardize how they present their ability to issue
> > wakeups, and how they manage whether that ability should be used.
>
> Why do you assign "enabled" to variable instead of using it directly?

So there's exactly one copy of that string in use, agreeing with itself.
Also, so strncmp() can be used. It won't matter if the sysadmin goes

echo -n enabled > wakeup
echo enabled > wakeup

I'd personally rather use "on" and "off", but there seems to be
a convention in /proc/acpi/wakeup in favor of polysyllabicism.


> And perhaps you should print "not supported" instead of empty string...

Except that's two words, not one, which will make shell script
bugs happen more readily. I thought about "(none)" which
has the same issue, and "-". But I figured that if it were very
important, a good solution would appear ... ;)

- Dave

2004-10-05 20:43:03

by Pavel Machek

[permalink] [raw]
Subject: Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

Hi!

> > > This lets drivers standardize how they present their ability to issue
> > > wakeups, and how they manage whether that ability should be used.
> >
> > Why do you assign "enabled" to variable instead of using it directly?
>
> So there's exactly one copy of that string in use, agreeing with itself.
> Also, so strncmp() can be used. It won't matter if the sysadmin goes
>
> echo -n enabled > wakeup
> echo enabled > wakeup

Well, you could make that 0,1. That would be more sysfs-style...

> I'd personally rather use "on" and "off", but there seems to be
> a convention in /proc/acpi/wakeup in favor of polysyllabicism.
>
>
> > And perhaps you should print "not supported" instead of empty string...
>
> Except that's two words, not one, which will make shell script
> bugs happen more readily. I thought about "(none)" which
> has the same issue, and "-". But I figured that if it were very
> important, a good solution would appear ... ;)

On the second thought, perhaps file simply should not be there if
wakeup is not supported.
Pavel
--
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

2004-10-05 21:53:21

by David Brownell

[permalink] [raw]
Subject: Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

On Tuesday 05 October 2004 1:15 pm, Pavel Machek wrote:

> > Also, so strncmp() can be used. It won't matter if the sysadmin goes
> >
> > echo -n enabled > wakeup
> > echo enabled > wakeup
>
> Well, you could make that 0,1. That would be more sysfs-style...

Only for things like detach_state and power_state, which shouldn't
be numbers in the first place ... :)

The /sys/module/*/OPTION strings use Y/N for booleans, and
maybe sysfs should actually have generic code to read/write
such boolean values.


> On the second thought, perhaps file simply should not be there if
> wakeup is not supported.

That doesn't work too well for things like USB, where one config
may support wakeup but another doesn't ... and unconfigured
devices never support it. The "can_support" value changes
over time.

- Dave

2004-10-16 06:04:24

by Brown, Len

[permalink] [raw]
Subject: Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

> - ACPI (this should probably replace the new /proc/acpi/wakeup)

Agreed. That file is a temporary solution.
The right solution is for the devices to appear in the right
place in the device tree and to hang the wakeup capabilities
off of them there.

thanks,
-Len


2004-10-19 03:40:37

by David Brownell

[permalink] [raw]
Subject: Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

On Friday 15 October 2004 11:03 pm, Len Brown wrote:
> > - ACPI (this should probably replace the new /proc/acpi/wakeup)
>
> Agreed. That file is a temporary solution.
> The right solution is for the devices to appear in the right
> place in the device tree and to hang the wakeup capabilities
> off of them there.

So what would that patch need before ACPI could convert to use it?

I didn't notice any obvious associations between the strings in
the acpi/wakeup file and anything in sysfs. Which of USB1..USB4
was which of the three controllers shown by "lspci" (and which
one was "extra"!), as one head-scratcher.

For PCI, I'd kind of expect pci_enable_wake() to trigger the
additional ACPI-specific work to make sure the device can
actually wake that system. Seems like dev->platform_data
might need to combine with some platform-specific API hook.

- Dave

2004-10-19 04:56:21

by Hiroshi 2 Itoh

[permalink] [raw]
Subject: Re: [ACPI] Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)





David Brownell wrote:

>So what would that patch need before ACPI could convert to use it?

>I didn't notice any obvious associations between the strings in
>the acpi/wakeup file and anything in sysfs. Which of USB1..USB4
>was which of the three controllers shown by "lspci" (and which
>one was "extra"!), as one head-scratcher.

>For PCI, I'd kind of expect pci_enable_wake() to trigger the
>additional ACPI-specific work to make sure the device can
>actually wake that system. Seems like dev->platform_data
>might need to combine with some platform-specific API hook.

>- Dave

Does anoyone give me a link to the original RFC?
I cannot find the original mail as a newbie associated with this list.

Hiro.

2004-10-19 05:18:07

by David Brownell

[permalink] [raw]
Subject: Re: [ACPI] Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

On Monday 18 October 2004 9:55 pm, Hiroshi 2 Itoh wrote:
> >So what would that patch need before ACPI could convert to use it?
>
> Does anoyone give me a link to the original RFC?
> I cannot find the original mail as a newbie associated with this list.

Messages 0-4 are:

http://marc.theaimsgroup.com/?l=linux-kernel&m=109692668310738&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=109692668228442&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=109692610403412&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=109692915107429&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=109692881326178&w=2

Click on the second one ... :)

- Dave

2004-10-19 09:11:29

by Shaohua Li

[permalink] [raw]
Subject: RE: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

A final solution is device core adds an ACPI layer. That is we can link
ACPI device and physical device. This way, the PCI device can know which
ACPI is linked with it, so the PCI API can use specific ACPI method.
You are right, we currently haven't a method to reach the goal. To match
a physical device and ACPI device, we need to know the ACPI device's
_ADR and bus.
I have a toy to link the PCI device and ACPI device, and some PCI
function can use _SxD method and _PSx method to get some information for
suspend/resume.

Thanks,
Shaohua
>-----Original Message-----
>From: [email protected] [mailto:linux-kernel-
>[email protected]] On Behalf Of David Brownell
>Sent: Tuesday, October 19, 2004 11:41 AM
>To: Brown, Len
>Cc: Pavel Machek; [email protected]; ACPI Developers
>Subject: Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)
>
>On Friday 15 October 2004 11:03 pm, Len Brown wrote:
>> > - ACPI (this should probably replace the new /proc/acpi/wakeup)
>>
>> Agreed. That file is a temporary solution.
>> The right solution is for the devices to appear in the right
>> place in the device tree and to hang the wakeup capabilities
>> off of them there.
>
>So what would that patch need before ACPI could convert to use it?
>
>I didn't notice any obvious associations between the strings in
>the acpi/wakeup file and anything in sysfs. Which of USB1..USB4
>was which of the three controllers shown by "lspci" (and which
>one was "extra"!), as one head-scratcher.
>
>For PCI, I'd kind of expect pci_enable_wake() to trigger the
>additional ACPI-specific work to make sure the device can
>actually wake that system. Seems like dev->platform_data
>might need to combine with some platform-specific API hook.
>
>- Dave
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel"
in
>the body of a message to [email protected]
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/

2004-10-20 04:33:05

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [ACPI] RE: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

On Tuesday 19 October 2004 04:11 am, Li, Shaohua wrote:
> A final solution is device core adds an ACPI layer. That is we can link
> ACPI device and physical device. This way, the PCI device can know which
> ACPI is linked with it, so the PCI API can use specific ACPI method.
> You are right, we currently haven't a method to reach the goal. To match
> a physical device and ACPI device, we need to know the ACPI device's
> _ADR and bus.
> I have a toy to link the PCI device and ACPI device, and some PCI
> function can use _SxD method and _PSx method to get some information for
> suspend/resume.
>

The only caveat is that PCI core should not depend on ACPI because it is not
available on all platforms, not all world is x86.

--
Dmitry

2004-10-20 06:26:30

by Brown, Len

[permalink] [raw]
Subject: Re: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

On Mon, 2004-10-18 at 23:41, David Brownell wrote:
> On Friday 15 October 2004 11:03 pm, Len Brown wrote:
> > > - ACPI (this should probably replace the new /proc/acpi/wakeup)
> >
> > Agreed. That file is a temporary solution.
> > The right solution is for the devices to appear in the right
> > place in the device tree and to hang the wakeup capabilities
> > off of them there.
>
> So what would that patch need before ACPI could convert to use it?
>
> I didn't notice any obvious associations between the strings in
> the acpi/wakeup file and anything in sysfs. Which of USB1..USB4
> was which of the three controllers shown by "lspci" (and which
> one was "extra"!), as one head-scratcher.

The strings "USB1" etc. are completely arbitrary, which is one
reason that /proc/acpi/wakeup is only marginally useful.

> For PCI, I'd kind of expect pci_enable_wake() to trigger the
> additional ACPI-specific work to make sure the device can
> actually wake that system. Seems like dev->platform_data
> might need to combine with some platform-specific API hook.

In the ACPI DSDT...
Devices are explicitly identified as PCI busses by their PNP-id.
These PCI busses are enumerated by their _BBN or _CRS.
The devices under the PCI busses all contain an _ADR which encodes the
PCI device/function number.

Ie. ACPI tells us the PCI bus/dev/func for each PCI device in the DSDT,
and with this information it needs to be able to find devices in the
Linux device tree and associate some ACPI capabilities with it.

-Len


2004-10-20 17:13:30

by David Brownell

[permalink] [raw]
Subject: Re: [ACPI] RE: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

On Tuesday 19 October 2004 20:51, Dmitry Torokhov wrote:
> On Tuesday 19 October 2004 04:11 am, Li, Shaohua wrote:
> > A final solution is device core adds an ACPI layer. That is we can link
> > ACPI device and physical device. This way, the PCI device can know which
> > ACPI is linked with it, so the PCI API can use specific ACPI method.

The driver model core has platform_notify hooks for device add/remove,
and ACPI should kick in that way ... they might well need tweaks though.


> > You are right, we currently haven't a method to reach the goal. To match
> > a physical device and ACPI device, we need to know the ACPI device's
> > _ADR and bus.
> > I have a toy to link the PCI device and ACPI device, and some PCI
> > function can use _SxD method and _PSx method to get some information for
> > suspend/resume.
> >
>
> The only caveat is that PCI core should not depend on ACPI because it is not
> available on all platforms, not all world is x86.

RIght! Maybe something like:

int pci_enable_wake(pci_dev, on_or_off) {
...
if (dev->platform_data)
platform_enable_wake(dev, on_or_off)
...
}

That'd call an acpi_enable_wake(). I guess OpenBoot would
do its thing, and embedded boards could do all kinds of stuff.

- Dave

2004-10-21 01:44:47

by Shaohua Li

[permalink] [raw]
Subject: Re: [ACPI] RE: PATCH/RFC: driver model/pmcore wakeup hooks (1/4)

On Thu, 2004-10-21 at 01:02, David Brownell wrote:
> On Tuesday 19 October 2004 20:51, Dmitry Torokhov wrote:
> > On Tuesday 19 October 2004 04:11 am, Li, Shaohua wrote:
> > > A final solution is device core adds an ACPI layer. That is we can
> link
> > > ACPI device and physical device. This way, the PCI device can know
> which
> > > ACPI is linked with it, so the PCI API can use specific ACPI
> method.
>
> The driver model core has platform_notify hooks for device add/remove,
> and ACPI should kick in that way ... they might well need tweaks
> though.
The platform_notify information isn't enough to find an ACPI device for
a physical device. To find an ACPI device, the bus information and
device information is needed. Only the specific bus knows the meaning of
an device's id, so I think the bus type should provide a callback to
interpret device id.

Thanks,
Shaohua