Merge tag '3.6-pci-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull PCI updates from Bjorn Helgaas:
"Power management
- PCI/PM: Enable D3/D3cold by default for most devices
- PCI/PM: Keep parent bridge active when probing device
- PCI/PM: Fix config reg access for D3cold and bridge suspending
- PCI/PM: Add ABI document for sysfs file d3cold_allowed
Core
- PCI: Don't print anything while decoding is disabled"

* tag '3.6-pci-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
PCI: Don't print anything while decoding is disabled
PCI/PM: Add ABI document for sysfs file d3cold_allowed
PCI/PM: Fix config reg access for D3cold and bridge suspending
PCI/PM: Keep parent bridge active when probing device
PCI/PM: Enable D3/D3cold by default for most devices

Changed files
+92 -14
Documentation
ABI
testing
drivers
+12
Documentation/ABI/testing/sysfs-bus-pci
··· 210 210 firmware assigned instance number of the PCI 211 211 device that can help in understanding the firmware 212 212 intended order of the PCI device. 213 + 214 + What: /sys/bus/pci/devices/.../d3cold_allowed 215 + Date: July 2012 216 + Contact: Huang Ying <ying.huang@intel.com> 217 + Description: 218 + d3cold_allowed is bit to control whether the corresponding PCI 219 + device can be put into D3Cold state. If it is cleared, the 220 + device will never be put into D3Cold state. If it is set, the 221 + device may be put into D3Cold state if other requirements are 222 + satisfied too. Reading this attribute will show the current 223 + value of d3cold_allowed bit. Writing this attribute will set 224 + the value of d3cold_allowed bit.
+6
drivers/pci/pci-driver.c
··· 280 280 { 281 281 struct drv_dev_and_id *ddi = _ddi; 282 282 struct device *dev = &ddi->dev->dev; 283 + struct device *parent = dev->parent; 283 284 int rc; 284 285 286 + /* The parent bridge must be in active state when probing */ 287 + if (parent) 288 + pm_runtime_get_sync(parent); 285 289 /* Unbound PCI devices are always set to disabled and suspended. 286 290 * During probe, the device is set to enabled and active and the 287 291 * usage count is incremented. If the driver supports runtime PM, ··· 302 298 pm_runtime_set_suspended(dev); 303 299 pm_runtime_put_noidle(dev); 304 300 } 301 + if (parent) 302 + pm_runtime_put(parent); 305 303 return rc; 306 304 } 307 305
+42
drivers/pci/pci-sysfs.c
··· 458 458 } 459 459 struct device_attribute vga_attr = __ATTR_RO(boot_vga); 460 460 461 + static void 462 + pci_config_pm_runtime_get(struct pci_dev *pdev) 463 + { 464 + struct device *dev = &pdev->dev; 465 + struct device *parent = dev->parent; 466 + 467 + if (parent) 468 + pm_runtime_get_sync(parent); 469 + pm_runtime_get_noresume(dev); 470 + /* 471 + * pdev->current_state is set to PCI_D3cold during suspending, 472 + * so wait until suspending completes 473 + */ 474 + pm_runtime_barrier(dev); 475 + /* 476 + * Only need to resume devices in D3cold, because config 477 + * registers are still accessible for devices suspended but 478 + * not in D3cold. 479 + */ 480 + if (pdev->current_state == PCI_D3cold) 481 + pm_runtime_resume(dev); 482 + } 483 + 484 + static void 485 + pci_config_pm_runtime_put(struct pci_dev *pdev) 486 + { 487 + struct device *dev = &pdev->dev; 488 + struct device *parent = dev->parent; 489 + 490 + pm_runtime_put(dev); 491 + if (parent) 492 + pm_runtime_put_sync(parent); 493 + } 494 + 461 495 static ssize_t 462 496 pci_read_config(struct file *filp, struct kobject *kobj, 463 497 struct bin_attribute *bin_attr, ··· 517 483 } else { 518 484 size = count; 519 485 } 486 + 487 + pci_config_pm_runtime_get(dev); 520 488 521 489 if ((off & 1) && size) { 522 490 u8 val; ··· 565 529 --size; 566 530 } 567 531 532 + pci_config_pm_runtime_put(dev); 533 + 568 534 return count; 569 535 } 570 536 ··· 587 549 count = size; 588 550 } 589 551 552 + pci_config_pm_runtime_get(dev); 553 + 590 554 if ((off & 1) && size) { 591 555 pci_user_write_config_byte(dev, off, data[off - init_off]); 592 556 off++; ··· 626 586 off++; 627 587 --size; 628 588 } 589 + 590 + pci_config_pm_runtime_put(dev); 629 591 630 592 return count; 631 593 }
+1
drivers/pci/pci.c
··· 1941 1941 dev->pm_cap = pm; 1942 1942 dev->d3_delay = PCI_PM_D3_WAIT; 1943 1943 dev->d3cold_delay = PCI_PM_D3COLD_WAIT; 1944 + dev->d3cold_allowed = true; 1944 1945 1945 1946 dev->d1_support = false; 1946 1947 dev->d2_support = false;
+14
drivers/pci/pcie/portdrv_pci.c
··· 140 140 { 141 141 return 0; 142 142 } 143 + 144 + static int pcie_port_runtime_idle(struct device *dev) 145 + { 146 + /* Delay for a short while to prevent too frequent suspend/resume */ 147 + pm_schedule_suspend(dev, 10); 148 + return -EBUSY; 149 + } 143 150 #else 144 151 #define pcie_port_runtime_suspend NULL 145 152 #define pcie_port_runtime_resume NULL 153 + #define pcie_port_runtime_idle NULL 146 154 #endif 147 155 148 156 static const struct dev_pm_ops pcie_portdrv_pm_ops = { ··· 163 155 .resume_noirq = pcie_port_resume_noirq, 164 156 .runtime_suspend = pcie_port_runtime_suspend, 165 157 .runtime_resume = pcie_port_runtime_resume, 158 + .runtime_idle = pcie_port_runtime_idle, 166 159 }; 167 160 168 161 #define PCIE_PORTDRV_PM_OPS (&pcie_portdrv_pm_ops) ··· 209 200 return status; 210 201 211 202 pci_save_state(dev); 203 + /* 204 + * D3cold may not work properly on some PCIe port, so disable 205 + * it by default. 206 + */ 207 + dev->d3cold_allowed = false; 212 208 if (!pci_match_id(port_runtime_pm_black_list, dev)) 213 209 pm_runtime_put_noidle(&dev->dev); 214 210
+17 -14
drivers/pci/probe.c
··· 144 144 case PCI_BASE_ADDRESS_MEM_TYPE_32: 145 145 break; 146 146 case PCI_BASE_ADDRESS_MEM_TYPE_1M: 147 - dev_info(&dev->dev, "1M mem BAR treated as 32-bit BAR\n"); 147 + /* 1M mem BAR treated as 32-bit BAR */ 148 148 break; 149 149 case PCI_BASE_ADDRESS_MEM_TYPE_64: 150 150 flags |= IORESOURCE_MEM_64; 151 151 break; 152 152 default: 153 - dev_warn(&dev->dev, 154 - "mem unknown type %x treated as 32-bit BAR\n", 155 - mem_type); 153 + /* mem unknown type treated as 32-bit BAR */ 156 154 break; 157 155 } 158 156 return flags; ··· 171 173 u32 l, sz, mask; 172 174 u16 orig_cmd; 173 175 struct pci_bus_region region; 176 + bool bar_too_big = false, bar_disabled = false; 174 177 175 178 mask = type ? PCI_ROM_ADDRESS_MASK : ~0; 176 179 180 + /* No printks while decoding is disabled! */ 177 181 if (!dev->mmio_always_on) { 178 182 pci_read_config_word(dev, PCI_COMMAND, &orig_cmd); 179 183 pci_write_config_word(dev, PCI_COMMAND, ··· 240 240 goto fail; 241 241 242 242 if ((sizeof(resource_size_t) < 8) && (sz64 > 0x100000000ULL)) { 243 - dev_err(&dev->dev, "reg %x: can't handle 64-bit BAR\n", 244 - pos); 243 + bar_too_big = true; 245 244 goto fail; 246 245 } 247 246 ··· 251 252 region.start = 0; 252 253 region.end = sz64; 253 254 pcibios_bus_to_resource(dev, res, &region); 255 + bar_disabled = true; 254 256 } else { 255 257 region.start = l64; 256 258 region.end = l64 + sz64; 257 259 pcibios_bus_to_resource(dev, res, &region); 258 - dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", 259 - pos, res); 260 260 } 261 261 } else { 262 262 sz = pci_size(l, sz, mask); ··· 266 268 region.start = l; 267 269 region.end = l + sz; 268 270 pcibios_bus_to_resource(dev, res, &region); 269 - 270 - dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res); 271 271 } 272 272 273 - out: 273 + goto out; 274 + 275 + 276 + fail: 277 + res->flags = 0; 278 + out: 274 279 if (!dev->mmio_always_on) 275 280 pci_write_config_word(dev, PCI_COMMAND, orig_cmd); 276 281 282 + if (bar_too_big) 283 + dev_err(&dev->dev, "reg %x: can't handle 64-bit BAR\n", pos); 284 + if (res->flags && !bar_disabled) 285 + dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res); 286 + 277 287 return (res->flags & IORESOURCE_MEM_64) ? 1 : 0; 278 - fail: 279 - res->flags = 0; 280 - goto out; 281 288 } 282 289 283 290 static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)