Skip to contentSkip to conversation

Runtime PM for PCI-based USB host controllers

DISCUSSION Alan Stern 1 participant 1 message Jun 2, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Alan Stern

author
#1 lore raw
Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines

Therefore the default state for unbound PCI devices should be runtime-PM-enabled.

Why do you think it should?

So that they can be put into a low-power state. If they are disabled for runtime PM then they will remain in a high-power state.

Quoted 5 lines
Quoted 2 lines

Something like the patch below, awkward though it is. Does this look reasonable?

I'm not sure if r8169 and e1000e will work with it. Probably not, but I'm too tired to check right now. :-)

You mean because they already include their own runtime power management? Then they would need to be updated to match these changes, naturally.

Quoted 8 lines
Quoted 8 lines
(quoted diff) +1 -0
@@ -365,15 +380,24 @@ static int pci_device_probe(struct devic
 
 static int pci_device_remove(struct device * dev)
 {
+	struct device_driver *driver = dev->driver;
 	struct pci_dev * pci_dev = to_pci_dev(dev);
 	struct pci_driver * drv = pci_dev->driver;
 
Quoted 11 lines

Review static int pci_device_probe(struct devic · line 394

Quoted 9 lines
(quoted diff) +4 -1
 	if (drv) {
-		if (drv->remove)
+		if (drv->remove) {
+			pm_runtime_get_sync(dev);
 			drv->remove(pci_dev);
+			pm_runtime_put_noidle(dev);
+		}
 		pci_dev->driver = NULL;
 	}

Is "else" missing here or am I missing something?

I don't think an "else" is missing. Rather, the entire "if (drv)" line should be eliminated because it can never fail.

Quoted 11 lines

Review static int pci_device_probe(struct devic · line 402

Quoted 8 lines
(quoted diff) +5 -0
+	/* Undo the pm_runtime_get_sync() in local_pci_probe() */
+	dev->driver = NULL;
+	pm_runtime_put_sync(dev);
+	dev->driver = driver;
+
 	/*
 	 * If the device is still on, set the power state as "unknown",
 	 * since it might change by the next time we load the driver.

Do PCI bus type callbacks need to be reworked to work correctly with unbound devices?

They do; I neglected to take care of them when first writing this patch. After everything is working I'll submit it for real. For now, the point was to find out whether this is going in the right direction.

Alan Stern