Skip to contentSkip to conversation

pci_choose_state() works, does ACPI magic

PATCH In review David Brownell 4 participants 17 messages May 9, 2007 – May 21, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci_choose_state() works, does ACPI magic

Provide new ACPI method tracking the target system state, for use during suspend() and other PM calls. It returns ACPI_STATE_S0 except during true suspend paths.

Use that to finally implement the platform_pci_choose_state() hook on ACPI platforms. It calls "_S3D" and similar methods, and uses the result appropriately.

Fix pci_choose_state() to finally behave sanely too.

Minor whitespace fixes.

Lightly tested -- STR only, with only USB affected by the new code.

---
 drivers/acpi/sleep/main.c |   29 +++++++++++-
 drivers/pci/pci-acpi.c    |  107 +++++++++++++++++++++++++++++++++-------------
 drivers/pci/pci.c         |   51 ++++++++++++---------
 include/acpi/acpixf.h     |    2 
 4 files changed, 135 insertions(+), 54 deletions(-)
include/acpi/acpixf.h +2 -0
@@ -329,6 +329,8 @@ acpi_get_sleep_type_data(u8 sleep_state,
 
 acpi_status acpi_enter_sleep_state_prep(u8 sleep_state);
 
+int acpi_get_target_sleep_state(void);
+
 acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state);
 
 acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void);
drivers/acpi/sleep/main.c +27 -2
@@ -35,6 +35,20 @@ static u32 acpi_suspend_states[] = {
 
 static int init_8259A_after_S1;
 
+static u8 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ *	acpi_get_target_sleep_state - return target ACPI S-state
+ *
+ *	When used during suspend processing, this returns the target state
+ *	such as ACPI_STATE_S3.  Otherwise it returns ACPI_STATE_S0.
+ */
+int acpi_get_target_sleep_state(void)
+{
+	return acpi_target_sleep_state;
+}
+/* EXPORT_SYMBOL(acpi_get_target_sleep_state); ... if you need it */
+
 /**
  *	acpi_pm_prepare - Do preliminary suspend work.
  *	@pm_state:		suspend state we're entering.
@@ -50,12 +64,16 @@ extern void acpi_power_off(void);
 static int acpi_pm_prepare(suspend_state_t pm_state)
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
+	int status;
 
 	if (!sleep_states[acpi_state]) {
 		printk("acpi_pm_prepare does not support %d \n", pm_state);
 		return -EPERM;
 	}
-	return acpi_sleep_prepare(acpi_state);
+	status = acpi_sleep_prepare(acpi_state);
+	if (status == 0)
+		acpi_target_sleep_state = acpi_state;
+	return status;
 }
 
 /**
@@ -78,8 +96,10 @@ static int acpi_pm_enter(suspend_state_t
 	/* Do arch specific saving of state. */
 	if (pm_state > PM_SUSPEND_STANDBY) {
 		int error = acpi_save_state_mem();
-		if (error)
+		if (error) {
+			acpi_target_sleep_state = ACPI_STATE_S0;
 			return error;
+		}
 	}
 
 	local_irq_save(flags);
@@ -103,6 +123,10 @@ static int acpi_pm_enter(suspend_state_t
 		break;
 
 	default:
+		/* "should never happen" */
+		acpi_target_sleep_state = ACPI_STATE_S0;
+		local_irq_restore(flags);
+		WARN_ON(1);
 		return -EINVAL;
 	}
 
@@ -113,6 +137,7 @@ static int acpi_pm_enter(suspend_state_t
 	if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3))
 		acpi_clear_event(ACPI_EVENT_POWER_BUTTON);
 
+	acpi_target_sleep_state = ACPI_STATE_S0;
 	local_irq_restore(flags);
 	printk(KERN_DEBUG "Back to C!\n");
 
drivers/pci/pci-acpi.c +77 -30

129 lines not on this page · raw message

drivers/pci/pci.c +29 -22

72 lines not on this page · raw message

#1 lore raw
Quoted 63 lines · David Brownell

Provide new ACPI method tracking the target system state, for use during suspend() and other PM calls. It returns ACPI_STATE_S0 except during true suspend paths.

Use that to finally implement the platform_pci_choose_state() hook on ACPI platforms. It calls "_S3D" and similar methods, and uses the result appropriately.

Fix pci_choose_state() to finally behave sanely too.

Minor whitespace fixes.

Lightly tested -- STR only, with only USB affected by the new code.

---
 drivers/acpi/sleep/main.c |   29 +++++++++++-
 drivers/pci/pci-acpi.c    |  107 +++++++++++++++++++++++++++++++++-------------
 drivers/pci/pci.c         |   51 ++++++++++++---------
 include/acpi/acpixf.h     |    2 
 4 files changed, 135 insertions(+), 54 deletions(-)
include/acpi/acpixf.h +2 -0
@@ -329,6 +329,8 @@ acpi_get_sleep_type_data(u8 sleep_state,
 
 acpi_status acpi_enter_sleep_state_prep(u8 sleep_state);
 
+int acpi_get_target_sleep_state(void);
+
 acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state);
 
 acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void);
drivers/acpi/sleep/main.c +15 -0
@@ -35,6 +35,20 @@ static u32 acpi_suspend_states[] = {
 
 static int init_8259A_after_S1;
 
+static u8 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ *	acpi_get_target_sleep_state - return target ACPI S-state
+ *
+ *	When used during suspend processing, this returns the target state
+ *	such as ACPI_STATE_S3.  Otherwise it returns ACPI_STATE_S0.
+ */
+int acpi_get_target_sleep_state(void)
+{
+	return acpi_target_sleep_state;
+}
+/* EXPORT_SYMBOL(acpi_get_target_sleep_state); ... if you need it */
+
 /**
  *	acpi_pm_prepare - Do preliminary suspend work.
  *	@pm_state:		suspend state we're entering.
@@ -50,12 +64,16 @@ extern void acpi_power_off(void);
 static int acpi_pm_prepare(suspend_state_t pm_state)
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
+	int status;
 

drivers/acpi/sleep/main.c extern void acpi_power_off(void); · line 77

Quoted 10 lines
drivers/acpi/sleep/main.c +4 -1
 	if (!sleep_states[acpi_state]) {
 		printk("acpi_pm_prepare does not support %d \n", pm_state);
 		return -EPERM;
 	}
-	return acpi_sleep_prepare(acpi_state);
+	status = acpi_sleep_prepare(acpi_state);
+	if (status == 0)
+		acpi_target_sleep_state = acpi_state;
+	return status;
 }

I guess we'll need an analogous change for the hibernation too?

Rafael

#2 lore raw
Quoted 20 lines · Rafael J. Wysocki
Quoted 19 lines · David Brownell

Provide new ACPI method tracking the target system state, for use during suspend() and other PM calls. It returns ACPI_STATE_S0 except during true suspend paths.

Use that to finally implement the platform_pci_choose_state() hook on ACPI platforms. It calls "_S3D" and similar methods, and uses the result appropriately.

Fix pci_choose_state() to finally behave sanely too.

...

---
 drivers/acpi/sleep/main.c |   29 +++++++++++-
 drivers/pci/pci-acpi.c    |  107 +++++++++++++++++++++++++++++++++-------------
 drivers/pci/pci.c         |   51 ++++++++++++---------
 include/acpi/acpixf.h     |    2 
 4 files changed, 135 insertions(+), 54 deletions(-)
Quoted 3 lines
Quoted 1 line

...

I guess we'll need an analogous change for the hibernation too?

I guess so too. This probably isn't in shape to merge, because of those changes to split hibernation out; and not enough testing. So far as I know, those are the only real issues with this patch.

- Dave

#3 lore raw
In reply to Rafael J. Wysocki
Quoted 20 lines · Rafael J. Wysocki
Quoted 19 lines · David Brownell

Provide new ACPI method tracking the target system state, for use during suspend() and other PM calls. It returns ACPI_STATE_S0 except during true suspend paths.

Use that to finally implement the platform_pci_choose_state() hook on ACPI platforms. It calls "_S3D" and similar methods, and uses the result appropriately.

Fix pci_choose_state() to finally behave sanely too.

...

---
 drivers/acpi/sleep/main.c |   29 +++++++++++-
 drivers/pci/pci-acpi.c    |  107 +++++++++++++++++++++++++++++++++-------------
 drivers/pci/pci.c         |   51 ++++++++++++---------
 include/acpi/acpixf.h     |    2 
 4 files changed, 135 insertions(+), 54 deletions(-)
Quoted 3 lines
Quoted 1 line

...

I guess we'll need an analogous change for the hibernation too?

I guess so too. This probably isn't in shape to merge, because of those changes to split hibernation out; and not enough testing. So far as I know, those are the only real issues with this patch.

- Dave

#4 lore raw
In reply to David Brownell
Quoted 63 lines · David Brownell

Provide new ACPI method tracking the target system state, for use during suspend() and other PM calls. It returns ACPI_STATE_S0 except during true suspend paths.

Use that to finally implement the platform_pci_choose_state() hook on ACPI platforms. It calls "_S3D" and similar methods, and uses the result appropriately.

Fix pci_choose_state() to finally behave sanely too.

Minor whitespace fixes.

Lightly tested -- STR only, with only USB affected by the new code.

---
 drivers/acpi/sleep/main.c |   29 +++++++++++-
 drivers/pci/pci-acpi.c    |  107 +++++++++++++++++++++++++++++++++-------------
 drivers/pci/pci.c         |   51 ++++++++++++---------
 include/acpi/acpixf.h     |    2 
 4 files changed, 135 insertions(+), 54 deletions(-)
include/acpi/acpixf.h +2 -0
@@ -329,6 +329,8 @@ acpi_get_sleep_type_data(u8 sleep_state,
 
 acpi_status acpi_enter_sleep_state_prep(u8 sleep_state);
 
+int acpi_get_target_sleep_state(void);
+
 acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state);
 
 acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void);
drivers/acpi/sleep/main.c +15 -0
@@ -35,6 +35,20 @@ static u32 acpi_suspend_states[] = {
 
 static int init_8259A_after_S1;
 
+static u8 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ *	acpi_get_target_sleep_state - return target ACPI S-state
+ *
+ *	When used during suspend processing, this returns the target state
+ *	such as ACPI_STATE_S3.  Otherwise it returns ACPI_STATE_S0.
+ */
+int acpi_get_target_sleep_state(void)
+{
+	return acpi_target_sleep_state;
+}
+/* EXPORT_SYMBOL(acpi_get_target_sleep_state); ... if you need it */
+
 /**
  *	acpi_pm_prepare - Do preliminary suspend work.
  *	@pm_state:		suspend state we're entering.
@@ -50,12 +64,16 @@ extern void acpi_power_off(void);
 static int acpi_pm_prepare(suspend_state_t pm_state)
 {
 	u32 acpi_state = acpi_suspend_states[pm_state];
+	int status;
 

drivers/acpi/sleep/main.c extern void acpi_power_off(void); · line 77

Quoted 10 lines
drivers/acpi/sleep/main.c +4 -1
 	if (!sleep_states[acpi_state]) {
 		printk("acpi_pm_prepare does not support %d \n", pm_state);
 		return -EPERM;
 	}
-	return acpi_sleep_prepare(acpi_state);
+	status = acpi_sleep_prepare(acpi_state);
+	if (status == 0)
+		acpi_target_sleep_state = acpi_state;
+	return status;
 }

I guess we'll need an analogous change for the hibernation too?

Rafael

#5 lore raw
In reply to David Brownell

Hi!

Quoted 36 lines

Provide new ACPI method tracking the target system state, for use during suspend() and other PM calls. It returns ACPI_STATE_S0 except during true suspend paths.

Use that to finally implement the platform_pci_choose_state() hook on ACPI platforms. It calls "_S3D" and similar methods, and uses the result appropriately.

Fix pci_choose_state() to finally behave sanely too.

Minor whitespace fixes.

Lightly tested -- STR only, with only USB affected by the new code.

---
 drivers/acpi/sleep/main.c |   29 +++++++++++-
 drivers/pci/pci-acpi.c    |  107 +++++++++++++++++++++++++++++++++-------------
 drivers/pci/pci.c         |   51 ++++++++++++---------
 include/acpi/acpixf.h     |    2 
 4 files changed, 135 insertions(+), 54 deletions(-)
drivers/acpi/sleep/main.c +7 -0
@@ -35,6 +35,20 @@ static u32 acpi_suspend_states[] = {
 
 static int init_8259A_after_S1;
 
+static u8 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ *	acpi_get_target_sleep_state - return target ACPI S-state
+ *
+ *	When used during suspend processing, this returns the target state
+ *	such as ACPI_STATE_S3.  Otherwise it returns ACPI_STATE_S0.

drivers/acpi/sleep/main.c static u32 acpi_suspend_states[] = { · line 54

Quoted 10 lines
drivers/acpi/sleep/main.c +7 -0
+ */
+int acpi_get_target_sleep_state(void)
+{
+	return acpi_target_sleep_state;
+}
+/* EXPORT_SYMBOL(acpi_get_target_sleep_state); ... if you need it */
+
 /**
  *	acpi_pm_prepare - Do preliminary suspend work.
  *	@pm_state:		suspend state we're entering.

This is quite an ugly hack, right? Is it really neccessary to use global variable for this?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw
Quoted 18 lines · Pavel Machek
Quoted 18 lines
drivers/acpi/sleep/main.c +12 -0
@@ -35,6 +35,20 @@ static u32 acpi_suspend_states[] = {
 
 static int init_8259A_after_S1;
 
+static u8 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ *	acpi_get_target_sleep_state - return target ACPI S-state
+ *
+ *	When used during suspend processing, this returns the target state
+ *	such as ACPI_STATE_S3.  Otherwise it returns ACPI_STATE_S0.
+ */
+int acpi_get_target_sleep_state(void)
+{
+	return acpi_target_sleep_state;
+}
Quoted 8 lines

drivers/acpi/sleep/main.c static u32 acpi_suspend_states[] = { · line 54

Quoted 5 lines
drivers/acpi/sleep/main.c +2 -0
+/* EXPORT_SYMBOL(acpi_get_target_sleep_state); ... if you need it */
+
 /**
  *	acpi_pm_prepare - Do preliminary suspend work.
  *	@pm_state:		suspend state we're entering.

This is quite an ugly hack, right? Is it really neccessary to use global variable for this?

It's not a global variable; observe the "static", and the way it has an accessor. It does expose global state however.

- Dave

#7 lore raw
In reply to Pavel Machek
Quoted 18 lines · Pavel Machek
Quoted 18 lines
drivers/acpi/sleep/main.c +12 -0
@@ -35,6 +35,20 @@ static u32 acpi_suspend_states[] = {
 
 static int init_8259A_after_S1;
 
+static u8 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ *	acpi_get_target_sleep_state - return target ACPI S-state
+ *
+ *	When used during suspend processing, this returns the target state
+ *	such as ACPI_STATE_S3.  Otherwise it returns ACPI_STATE_S0.
+ */
+int acpi_get_target_sleep_state(void)
+{
+	return acpi_target_sleep_state;
+}
Quoted 8 lines

drivers/acpi/sleep/main.c static u32 acpi_suspend_states[] = { · line 54

Quoted 5 lines
drivers/acpi/sleep/main.c +2 -0
+/* EXPORT_SYMBOL(acpi_get_target_sleep_state); ... if you need it */
+
 /**
  *	acpi_pm_prepare - Do preliminary suspend work.
  *	@pm_state:		suspend state we're entering.

This is quite an ugly hack, right? Is it really neccessary to use global variable for this?

It's not a global variable; observe the "static", and the way it has an accessor. It does expose global state however.

- Dave

#8 lore raw
In reply to David Brownell

Hi!

Quoted 36 lines

Provide new ACPI method tracking the target system state, for use during suspend() and other PM calls. It returns ACPI_STATE_S0 except during true suspend paths.

Use that to finally implement the platform_pci_choose_state() hook on ACPI platforms. It calls "_S3D" and similar methods, and uses the result appropriately.

Fix pci_choose_state() to finally behave sanely too.

Minor whitespace fixes.

Lightly tested -- STR only, with only USB affected by the new code.

---
 drivers/acpi/sleep/main.c |   29 +++++++++++-
 drivers/pci/pci-acpi.c    |  107 +++++++++++++++++++++++++++++++++-------------
 drivers/pci/pci.c         |   51 ++++++++++++---------
 include/acpi/acpixf.h     |    2 
 4 files changed, 135 insertions(+), 54 deletions(-)
drivers/acpi/sleep/main.c +7 -0
@@ -35,6 +35,20 @@ static u32 acpi_suspend_states[] = {
 
 static int init_8259A_after_S1;
 
+static u8 acpi_target_sleep_state = ACPI_STATE_S0;
+
+/**
+ *	acpi_get_target_sleep_state - return target ACPI S-state
+ *
+ *	When used during suspend processing, this returns the target state
+ *	such as ACPI_STATE_S3.  Otherwise it returns ACPI_STATE_S0.

drivers/acpi/sleep/main.c static u32 acpi_suspend_states[] = { · line 54

Quoted 10 lines
drivers/acpi/sleep/main.c +7 -0
+ */
+int acpi_get_target_sleep_state(void)
+{
+	return acpi_target_sleep_state;
+}
+/* EXPORT_SYMBOL(acpi_get_target_sleep_state); ... if you need it */
+
 /**
  *	acpi_pm_prepare - Do preliminary suspend work.
  *	@pm_state:		suspend state we're entering.

This is quite an ugly hack, right? Is it really neccessary to use global variable for this?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw
In reply to David Brownell
Quoted 4 lines · David Brownell

static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) {
...

drivers/pci/pci-acpi.c +1 -0
+	switch (state) {

drivers/pci/pci-acpi.c acpi_status pci_osc_control_set(acpi_han · line 321

Quoted 10 lines
drivers/pci/pci-acpi.c +9 -0
+	case PCI_D0:
+	case PCI_D1:
+	case PCI_D2:
+	case PCI_D3hot:
+	case PCI_D3cold:
+		return acpi_bus_set_power(handle, state_conv[state]);
+	}
+
+	return -EINVAL;
 }

Did you account for the fact that PCI works on a per-function basis, but ACPI power management works on a per-slot basis?

We had a bug[1] a while back where e1000 would suspend a device and call pci_power_state(), which used ACPI to turn off the slot. The only problem was that this was a dual-port card and the other port was still active when the lights went out.

Maybe you deal with this already; it just wasn't obvious to me from a quick glance through your patch.

Bjorn

[1] https://bugzilla.novell.com/show_bug.cgi?id=162320

#10 lore raw
Quoted 14 lines · Bjorn Helgaas

drivers/pci/pci-acpi.c acpi_status pci_osc_control_set(acpi_han · line 320

Quoted 13 lines · David Brownell

static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) {
...

drivers/pci/pci-acpi.c +10 -0
+	switch (state) {
+	case PCI_D0:
+	case PCI_D1:
+	case PCI_D2:
+	case PCI_D3hot:
+	case PCI_D3cold:
+		return acpi_bus_set_power(handle, state_conv[state]);
+	}
+
+	return -EINVAL;

... i.e. a cleaned-up version of the existing code ...

Quoted 4 lines
Quoted 1 line

}

Did you account for the fact that PCI works on a per-function basis, but ACPI power management works on a per-slot basis?

This is a per-function method though. The ACPI code should be able to keep that straight ... simple refcounting on the power resources would suffice, assuming it goes the route of managing power resources rather than just invoking the methods associated with each device.

Quoted 4 lines

We had a bug[1] a while back where e1000 would suspend a device and call pci_power_state(), which used ACPI to turn off the slot. The only problem was that this was a dual-port card and the other port was still active when the lights went out.

Sounds like an ACPI bug to me: not properly tracking the users of a given PCI power resource. I can't see that bug without getting a Novell login -- you might want post the report rather than its URL.

Quoted 2 lines

Maybe you deal with this already; it just wasn't obvious to me from a quick glance through your patch.

Didn't touch it ... pre-existing bugs shouldn't have been affected.

The only behavioral change in that particular method should have been safer handling of an out-of-range parameter.

- Dave

Quoted 5 lines

Bjorn

[1] https://bugzilla.novell.com/show_bug.cgi?id=162320

#11 lore raw
In reply to Bjorn Helgaas
Quoted 14 lines · Bjorn Helgaas

drivers/pci/pci-acpi.c acpi_status pci_osc_control_set(acpi_han · line 320

Quoted 13 lines · David Brownell

static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) {
...

drivers/pci/pci-acpi.c +10 -0
+	switch (state) {
+	case PCI_D0:
+	case PCI_D1:
+	case PCI_D2:
+	case PCI_D3hot:
+	case PCI_D3cold:
+		return acpi_bus_set_power(handle, state_conv[state]);
+	}
+
+	return -EINVAL;

... i.e. a cleaned-up version of the existing code ...

Quoted 4 lines
Quoted 1 line

}

Did you account for the fact that PCI works on a per-function basis, but ACPI power management works on a per-slot basis?

This is a per-function method though. The ACPI code should be able to keep that straight ... simple refcounting on the power resources would suffice, assuming it goes the route of managing power resources rather than just invoking the methods associated with each device.

Quoted 4 lines

We had a bug[1] a while back where e1000 would suspend a device and call pci_power_state(), which used ACPI to turn off the slot. The only problem was that this was a dual-port card and the other port was still active when the lights went out.

Sounds like an ACPI bug to me: not properly tracking the users of a given PCI power resource. I can't see that bug without getting a Novell login -- you might want post the report rather than its URL.

Quoted 2 lines

Maybe you deal with this already; it just wasn't obvious to me from a quick glance through your patch.

Didn't touch it ... pre-existing bugs shouldn't have been affected.

The only behavioral change in that particular method should have been safer handling of an out-of-range parameter.

- Dave

Quoted 5 lines

Bjorn

[1] https://bugzilla.novell.com/show_bug.cgi?id=162320

#12 lore raw
Quoted 8 lines · David Brownell
Quoted 4 lines · Bjorn Helgaas

We had a bug[1] a while back where e1000 would suspend a device and call pci_power_state(), which used ACPI to turn off the slot. The only problem was that this was a dual-port card and the other port was still active when the lights went out.

Sounds like an ACPI bug to me: not properly tracking the users of a given PCI power resource.

acpi_bus_set_power() takes a "handle", which refers to the slot. I don't know where the refcounting should occur, and I don't know whether your patch affects this path. Just something to be aware of in this area.

Quoted 3 lines

I can't see that bug without
getting a Novell login -- you might want post the report rather than its URL.

Yeah, that's irritating. It likely was protected just by default, but I don't feel empowered to change that.

The synopsis is that e1000_suspend() called pci_set_power_state(), which called platform_pci_set_power_state(), which evaluated the SxFy _PS3 method, which turned off the power to slot "x".

Unfortunately, slot "x" contained a dual-port NIC, so suspending one port turned off the power to *both* ports. The e1000 driver didn't expect that, so it tried to do something with the other port and blew up.

It was non-intuitive to me that a SxFy\_PS3 method would turn off the slot, affecting all functions, not just "Fy", but I guess that's the standard behavior:

http://www.microsoft.com/whdc/system/pnppwr/hotadd/hotplugpci.mspx

Quoted 1 line
Quoted 1 line

[1] https://bugzilla.novell.com/show_bug.cgi?id=162320

#13 lore raw
In reply to David Brownell
Quoted 8 lines · David Brownell
Quoted 4 lines · Bjorn Helgaas

We had a bug[1] a while back where e1000 would suspend a device and call pci_power_state(), which used ACPI to turn off the slot. The only problem was that this was a dual-port card and the other port was still active when the lights went out.

Sounds like an ACPI bug to me: not properly tracking the users of a given PCI power resource.

acpi_bus_set_power() takes a "handle", which refers to the slot. I don't know where the refcounting should occur, and I don't know whether your patch affects this path. Just something to be aware of in this area.

Quoted 3 lines

I can't see that bug without
getting a Novell login -- you might want post the report rather than its URL.

Yeah, that's irritating. It likely was protected just by default, but I don't feel empowered to change that.

The synopsis is that e1000_suspend() called pci_set_power_state(), which called platform_pci_set_power_state(), which evaluated the SxFy _PS3 method, which turned off the power to slot "x".

Unfortunately, slot "x" contained a dual-port NIC, so suspending one port turned off the power to *both* ports. The e1000 driver didn't expect that, so it tried to do something with the other port and blew up.

It was non-intuitive to me that a SxFy\_PS3 method would turn off the slot, affecting all functions, not just "Fy", but I guess that's the standard behavior:

http://www.microsoft.com/whdc/system/pnppwr/hotadd/hotplugpci.mspx

Quoted 1 line
Quoted 1 line

[1] https://bugzilla.novell.com/show_bug.cgi?id=162320

#14 lore raw
Quoted 11 lines · Bjorn Helgaas
Quoted 8 lines · David Brownell
Quoted 4 lines · Bjorn Helgaas

We had a bug[1] a while back where e1000 would suspend a device and call pci_power_state(), which used ACPI to turn off the slot. The only problem was that this was a dual-port card and the other port was still active when the lights went out.

Sounds like an ACPI bug to me: not properly tracking the users of a given PCI power resource.

acpi_bus_set_power() takes a "handle", which refers to the slot.

Odd; elsewhere the "handle" refers to a single logical device, and that's normally been a single function. And the examples in the Microsoft doc you mentioned show that structure too.

Of course, I'm not used to seeing ACPI look at devices in slots either ... usually it just tells me about things on the mainboard. It seems hotplug PCI needs work yet.

... Regardless, this pre-existing problem wasn't affected by the $SUBJECT patch.

- Dave

Quoted 4 lines

http://www.microsoft.com/whdc/system/pnppwr/hotadd/hotplugpci.mspx

Quoted 1 line
Quoted 1 line

[1] https://bugzilla.novell.com/show_bug.cgi?id=162320

#15 lore raw
In reply to Bjorn Helgaas
Quoted 11 lines · Bjorn Helgaas
Quoted 8 lines · David Brownell
Quoted 4 lines · Bjorn Helgaas

We had a bug[1] a while back where e1000 would suspend a device and call pci_power_state(), which used ACPI to turn off the slot. The only problem was that this was a dual-port card and the other port was still active when the lights went out.

Sounds like an ACPI bug to me: not properly tracking the users of a given PCI power resource.

acpi_bus_set_power() takes a "handle", which refers to the slot.

Odd; elsewhere the "handle" refers to a single logical device, and that's normally been a single function. And the examples in the Microsoft doc you mentioned show that structure too.

Of course, I'm not used to seeing ACPI look at devices in slots either ... usually it just tells me about things on the mainboard. It seems hotplug PCI needs work yet.

... Regardless, this pre-existing problem wasn't affected by the $SUBJECT patch.

- Dave

Quoted 4 lines

http://www.microsoft.com/whdc/system/pnppwr/hotadd/hotplugpci.mspx

Quoted 1 line
Quoted 1 line

[1] https://bugzilla.novell.com/show_bug.cgi?id=162320

#16 lore raw
In reply to David Brownell
Quoted 4 lines · David Brownell

static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) {
...

drivers/pci/pci-acpi.c +1 -0
+	switch (state) {

drivers/pci/pci-acpi.c acpi_status pci_osc_control_set(acpi_han · line 321

Quoted 10 lines
drivers/pci/pci-acpi.c +9 -0
+	case PCI_D0:
+	case PCI_D1:
+	case PCI_D2:
+	case PCI_D3hot:
+	case PCI_D3cold:
+		return acpi_bus_set_power(handle, state_conv[state]);
+	}
+
+	return -EINVAL;
 }

Did you account for the fact that PCI works on a per-function basis, but ACPI power management works on a per-slot basis?

We had a bug[1] a while back where e1000 would suspend a device and call pci_power_state(), which used ACPI to turn off the slot. The only problem was that this was a dual-port card and the other port was still active when the lights went out.

Maybe you deal with this already; it just wasn't obvious to me from a quick glance through your patch.

Bjorn

[1] https://bugzilla.novell.com/show_bug.cgi?id=162320