Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pm-fixes-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
"These fix a recently exposed issue in the PCI device wakeup code and
one older problem related to PCI device wakeup that has been reported
recently, modify one more piece of computations in intel_pstate to get
rid of a rounding error, fix a possible race in the schedutil cpufreq
governor, fix the device PM QoS sysfs interface to correctly handle
invalid user input, fix return values of two probe routines in devfreq
drivers and constify an attribute_group structure in devfreq.

Specifics:

- Avoid clearing the PCI PME Enable bit for devices as a result of
config space restoration which confuses AML executed afterward and
causes wakeup events to be lost on some systems (Rafael Wysocki).

- Fix the native PCIe PME interrupts handling in the cases when the
PME IRQ is set up as a system wakeup one so that runtime PM remote
wakeup works as expected after system resume on systems where that
happens (Rafael Wysocki).

- Fix the device PM QoS sysfs interface to handle invalid user input
correctly instead of using an unititialized variable value as the
latency tolerance for the device at hand (Dan Carpenter).

- Get rid of one more rounding error from intel_pstate computations
(Srinivas Pandruvada).

- Fix the schedutil cpufreq governor to prevent it from possibly
accessing unititialized data structures from governor callbacks in
some cases on systems when multiple CPUs share a single cpufreq
policy object (Vikram Mulukutla).

- Fix the return values of probe routines in two devfreq drivers
(Gustavo Silva).

- Constify an attribute_group structure in devfreq (Arvind Yadav)"

* tag 'pm-fixes-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
PCI / PM: Fix native PME handling during system suspend/resume
PCI / PM: Restore PME Enable after config space restoration
cpufreq: schedutil: Fix sugov_start() versus sugov_update_shared() race
PM / QoS: return -EINVAL for bogus strings
cpufreq: intel_pstate: Fix ratio setting for min_perf_pct
PM / devfreq: constify attribute_group structures.
PM / devfreq: tegra: fix error return code in tegra_devfreq_probe()
PM / devfreq: rk3399_dmc: fix error return code in rk3399_dmcfreq_probe()

+39 -37
+2
drivers/base/power/sysfs.c
··· 272 272 value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT; 273 273 else if (!strcmp(buf, "any") || !strcmp(buf, "any\n")) 274 274 value = PM_QOS_LATENCY_ANY; 275 + else 276 + return -EINVAL; 275 277 } 276 278 ret = dev_pm_qos_update_user_latency_tolerance(dev, value); 277 279 return ret < 0 ? ret : n;
+1 -1
drivers/cpufreq/intel_pstate.c
··· 572 572 int turbo_pstate = cpu->pstate.turbo_pstate; 573 573 574 574 return turbo_pstate ? 575 - DIV_ROUND_UP(cpu->pstate.min_pstate * 100, turbo_pstate) : 0; 575 + (cpu->pstate.min_pstate * 100 / turbo_pstate) : 0; 576 576 } 577 577 578 578 static s16 intel_pstate_get_epb(struct cpudata *cpu_data)
+1 -1
drivers/devfreq/governor_userspace.c
··· 86 86 &dev_attr_set_freq.attr, 87 87 NULL, 88 88 }; 89 - static struct attribute_group dev_attr_group = { 89 + static const struct attribute_group dev_attr_group = { 90 90 .name = "userspace", 91 91 .attrs = dev_entries, 92 92 };
+3 -2
drivers/devfreq/rk3399_dmc.c
··· 336 336 337 337 irq = platform_get_irq(pdev, 0); 338 338 if (irq < 0) { 339 - dev_err(&pdev->dev, "Cannot get the dmc interrupt resource\n"); 340 - return -EINVAL; 339 + dev_err(&pdev->dev, 340 + "Cannot get the dmc interrupt resource: %d\n", irq); 341 + return irq; 341 342 } 342 343 data = devm_kzalloc(dev, sizeof(struct rk3399_dmcfreq), GFP_KERNEL); 343 344 if (!data)
+3 -3
drivers/devfreq/tegra-devfreq.c
··· 688 688 } 689 689 690 690 irq = platform_get_irq(pdev, 0); 691 - if (irq <= 0) { 692 - dev_err(&pdev->dev, "Failed to get IRQ\n"); 693 - return -ENODEV; 691 + if (irq < 0) { 692 + dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq); 693 + return irq; 694 694 } 695 695 696 696 platform_set_drvdata(pdev, tegra);
+2
drivers/pci/pci-driver.c
··· 511 511 } 512 512 513 513 pci_restore_state(pci_dev); 514 + pci_pme_restore(pci_dev); 514 515 return 0; 515 516 } 516 517 ··· 523 522 { 524 523 pci_power_up(pci_dev); 525 524 pci_restore_state(pci_dev); 525 + pci_pme_restore(pci_dev); 526 526 pci_fixup_device(pci_fixup_resume_early, pci_dev); 527 527 } 528 528
+8 -8
drivers/pci/pci.c
··· 1801 1801 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); 1802 1802 } 1803 1803 1804 - static void pci_pme_restore(struct pci_dev *dev) 1804 + /** 1805 + * pci_pme_restore - Restore PME configuration after config space restore. 1806 + * @dev: PCI device to update. 1807 + */ 1808 + void pci_pme_restore(struct pci_dev *dev) 1805 1809 { 1806 1810 u16 pmcsr; 1807 1811 ··· 1815 1811 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); 1816 1812 if (dev->wakeup_prepared) { 1817 1813 pmcsr |= PCI_PM_CTRL_PME_ENABLE; 1814 + pmcsr &= ~PCI_PM_CTRL_PME_STATUS; 1818 1815 } else { 1819 1816 pmcsr &= ~PCI_PM_CTRL_PME_ENABLE; 1820 1817 pmcsr |= PCI_PM_CTRL_PME_STATUS; ··· 1912 1907 { 1913 1908 int ret = 0; 1914 1909 1915 - /* 1916 - * Don't do the same thing twice in a row for one device, but restore 1917 - * PME Enable in case it has been updated by config space restoration. 1918 - */ 1919 - if (!!enable == !!dev->wakeup_prepared) { 1920 - pci_pme_restore(dev); 1910 + /* Don't do the same thing twice in a row for one device. */ 1911 + if (!!enable == !!dev->wakeup_prepared) 1921 1912 return 0; 1922 - } 1923 1913 1924 1914 /* 1925 1915 * According to "PCI System Architecture" 4th ed. by Tom Shanley & Don
+1
drivers/pci/pci.h
··· 71 71 void pci_disable_enabled_device(struct pci_dev *dev); 72 72 int pci_finish_runtime_suspend(struct pci_dev *dev); 73 73 int __pci_pme_wakeup(struct pci_dev *dev, void *ign); 74 + void pci_pme_restore(struct pci_dev *dev); 74 75 bool pci_dev_keep_suspended(struct pci_dev *dev); 75 76 void pci_dev_complete_resume(struct pci_dev *pci_dev); 76 77 void pci_config_pm_runtime_get(struct pci_dev *dev);
+13 -22
drivers/pci/pcie/pme.c
··· 40 40 } 41 41 __setup("pcie_pme=", pcie_pme_setup); 42 42 43 - enum pme_suspend_level { 44 - PME_SUSPEND_NONE = 0, 45 - PME_SUSPEND_WAKEUP, 46 - PME_SUSPEND_NOIRQ, 47 - }; 48 - 49 43 struct pcie_pme_service_data { 50 44 spinlock_t lock; 51 45 struct pcie_device *srv; 52 46 struct work_struct work; 53 - enum pme_suspend_level suspend_level; 47 + bool noirq; /* If set, keep the PME interrupt disabled. */ 54 48 }; 55 49 56 50 /** ··· 222 228 spin_lock_irq(&data->lock); 223 229 224 230 for (;;) { 225 - if (data->suspend_level != PME_SUSPEND_NONE) 231 + if (data->noirq) 226 232 break; 227 233 228 234 pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); ··· 249 255 spin_lock_irq(&data->lock); 250 256 } 251 257 252 - if (data->suspend_level == PME_SUSPEND_NONE) 258 + if (!data->noirq) 253 259 pcie_pme_interrupt_enable(port, true); 254 260 255 261 spin_unlock_irq(&data->lock); ··· 372 378 { 373 379 struct pcie_pme_service_data *data = get_service_data(srv); 374 380 struct pci_dev *port = srv->port; 375 - bool wakeup, wake_irq_enabled = false; 381 + bool wakeup; 376 382 int ret; 377 383 378 384 if (device_may_wakeup(&port->dev)) { ··· 382 388 wakeup = pcie_pme_check_wakeup(port->subordinate); 383 389 up_read(&pci_bus_sem); 384 390 } 385 - spin_lock_irq(&data->lock); 386 391 if (wakeup) { 387 392 ret = enable_irq_wake(srv->irq); 388 - if (ret == 0) { 389 - data->suspend_level = PME_SUSPEND_WAKEUP; 390 - wake_irq_enabled = true; 391 - } 393 + if (!ret) 394 + return 0; 392 395 } 393 - if (!wake_irq_enabled) { 394 - pcie_pme_interrupt_enable(port, false); 395 - pcie_clear_root_pme_status(port); 396 - data->suspend_level = PME_SUSPEND_NOIRQ; 397 - } 396 + 397 + spin_lock_irq(&data->lock); 398 + pcie_pme_interrupt_enable(port, false); 399 + pcie_clear_root_pme_status(port); 400 + data->noirq = true; 398 401 spin_unlock_irq(&data->lock); 399 402 400 403 synchronize_irq(srv->irq); ··· 408 417 struct pcie_pme_service_data *data = get_service_data(srv); 409 418 410 419 spin_lock_irq(&data->lock); 411 - if (data->suspend_level == PME_SUSPEND_NOIRQ) { 420 + if (data->noirq) { 412 421 struct pci_dev *port = srv->port; 413 422 414 423 pcie_clear_root_pme_status(port); 415 424 pcie_pme_interrupt_enable(port, true); 425 + data->noirq = false; 416 426 } else { 417 427 disable_irq_wake(srv->irq); 418 428 } 419 - data->suspend_level = PME_SUSPEND_NONE; 420 429 spin_unlock_irq(&data->lock); 421 430 422 431 return 0;
+5
kernel/sched/cpufreq_schedutil.c
··· 610 610 sg_cpu->sg_policy = sg_policy; 611 611 sg_cpu->flags = SCHED_CPUFREQ_RT; 612 612 sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq; 613 + } 614 + 615 + for_each_cpu(cpu, policy->cpus) { 616 + struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu); 617 + 613 618 cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, 614 619 policy_is_shared(policy) ? 615 620 sugov_update_shared :