Skip to contentSkip to conversation

Print PCI device in power management warning.

PATCH NAK Dave Jones 4 participants 5 messages Dec 23, 2011 PCI

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

When the WARN_ON in pci_has_legacy_pm_support() triggers, we get users filing backtraces, but it's not obvious which driver is triggering the trace. This adds a printk before the BUG. This still isn't perfect (automated tools like abrt will still miss it) but we can at least ask the user to look through their dmesg when we get these traces reported.

drivers/pci/pci-driver.c +6 -1
index 12d1e81..b638244 100644
@@ -604,7 +604,12 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
 	 * supported as well.  Drivers are supposed to support either the
 	 * former, or the latter, but not both at the same time.
 	 */
-	WARN_ON(ret && drv->driver.pm);
+	if (ret && drv->driver.pm) {
+		printk(KERN_WARNING "pci: %s has both legacy and new PM support.\n",
+			drv->name);
+		BUG();
+	}
+
 
 	return ret;
 }
#1 lore raw
Quoted 3 lines · Dave Jones

When the WARN_ON in pci_has_legacy_pm_support() triggers, we get users filing backtraces, but it's not obvious which driver is triggering the trace. This adds a printk before the BUG.

Well, and adds a BUG!

Quoted 11 lines

This still isn't perfect (automated tools like abrt will still miss it) but we can at least ask the user to look through their dmesg when we get these traces reported.

drivers/pci/pci-driver.c +0 -0
index 12d1e81..b638244 100644

drivers/pci/pci-driver.c static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) · line 610

Quoted 8 lines
drivers/pci/pci-driver.c +4 -1
@@ -604,7 +604,12 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
 	 * supported as well.  Drivers are supposed to support either the
 	 * former, or the latter, but not both at the same time.
 	 */
-	WARN_ON(ret && drv->driver.pm);
+	if (ret && drv->driver.pm) {
+		printk(KERN_WARNING "pci: %s has both legacy and new PM support.\n",
+			drv->name);
+		BUG();

Um, so this will hang the machine.

don't you just want:

	WARN(ret && drv->driver.pm, "pci: %s Has both legacy and new PM

support!\n", drv_name(drv));

which will do what it previously does and also add the message you wanted to add?

Quoted 10 lines
drivers/pci/pci-driver.c +2 -1
+	}
+
 
 	return ret;
 }
--

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/

author
#2 lore raw
Quoted 7 lines · Konrad Rzeszutek Wilk

don't you just want:

	WARN(ret && drv->driver.pm, "pci: %s Has both legacy and new PM

support!\n", drv_name(drv));

which will do what it previously does and also add the message you wanted to add?

close. Not sure what drv_name() is, but I don't seem to have it in my tree. This works though..

---

When the WARN_ON in pci_has_legacy_pm_support() triggers, we get users filing backtraces, but it's not obvious which driver is triggering the trace. Printing the driver name in addition to the trace should make these easier to debug.

drivers/pci/pci-driver.c +1 -1
index 12d1e81..8af9ff2 100644
@@ -604,7 +604,7 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
 	 * supported as well.  Drivers are supposed to support either the
 	 * former, or the latter, but not both at the same time.
 	 */
-	WARN_ON(ret && drv->driver.pm);
+	WARN(ret && drv->driver.pm, "pci: %s Has both legacy and new PM support!\n", drv->name);
 
 	return ret;
 }
#3 lore raw
Quoted 27 lines · Dave Jones
Quoted 7 lines · Konrad Rzeszutek Wilk

don't you just want:

	WARN(ret && drv->driver.pm, "pci: %s Has both legacy and new PM

support!\n", drv_name(drv));

which will do what it previously does and also add the message you wanted to add?

close. Not sure what drv_name() is, but I don't seem to have it in my tree. This works though..

---

When the WARN_ON in pci_has_legacy_pm_support() triggers, we get users filing backtraces, but it's not obvious which driver is triggering the trace. Printing the driver name in addition to the trace should make these easier to debug.

drivers/pci/pci-driver.c +0 -0
index 12d1e81..8af9ff2 100644

drivers/pci/pci-driver.c static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) · line 607

Quoted 5 lines
drivers/pci/pci-driver.c +1 -1
@@ -604,7 +604,7 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
 	 * supported as well.  Drivers are supposed to support either the
 	 * former, or the latter, but not both at the same time.
 	 */
-	WARN_ON(ret && drv->driver.pm);
+	WARN(ret && drv->driver.pm, "pci: %s Has both legacy and new PM support!\n", drv->name);

has

and why not cc: linux-pci?

Quoted 4 lines
drivers/pci/pci-driver.c +0 -1
 	return ret;
 }
--
Signature · 2 lines
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
#4 lore raw
In reply to Dave Jones
Quoted 8 lines · On Fri, 23 Dec 2011 13:16:26 -0500 Dave Jones <[email protected]> wrote:

When the WARN_ON in pci_has_legacy_pm_support() triggers, we get users filing backtraces, but it's not obvious which driver is triggering the trace. This adds a printk before the BUG. This still isn't perfect (automated tools like abrt will still miss it) but we can at least ask the user to look through their dmesg when we get these traces reported.

NAK

The old code did a WARN() the new code BUG() which in practice means in many cases the user will get a crash and hang at boot and not even be able to catch the trap.

At the very least your changelog should warn people it changes from WARN_ON noise to system crash and burn.

Alan