Skip to content

Commit

Permalink
Merge tag 'pm+acpi-4.6-rc1-2' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/rafael/linux-pm

Pull more power management and ACPI updates from Rafael Wysocki:
 "The second batch of power management and ACPI updates for v4.6.

  Included are fixups on top of the previous PM/ACPI pull request and
  other material that didn't make into it but still should go into 4.6.

  Among other things, there's a fix for an intel_pstate driver issue
  uncovered by recent cpufreq changes, a workaround for a boot hang on
  Skylake-H related to the handling of deep C-states by the platform and
  a PCI/ACPI fix for the handling of IO port resources on non-x86
  architectures plus some new device IDs and similar.

  Specifics:

   - Fix for an intel_pstate driver issue related to the handling of MSR
     updates uncovered by the recent cpufreq rework (Rafael Wysocki).

   - cpufreq core cleanups related to starting governors and frequency
     synchronization during resume from system suspend and a locking fix
     for cpufreq_quick_get() (Rafael Wysocki, Richard Cochran).

   - acpi-cpufreq and powernv cpufreq driver updates (Jisheng Zhang,
     Michael Neuling, Richard Cochran, Shilpasri Bhat).

   - intel_idle driver update preventing some Skylake-H systems from
     hanging during initialization by disabling deep C-states mishandled
     by the platform in the problematic configurations (Len Brown).

   - Intel Xeon Phi Processor x200 support for intel_idle
     (Dasaratharaman Chandramouli).

   - cpuidle menu governor updates to make it always honor PM QoS
     latency constraints (and prevent C1 from being used as the fallback
     C-state on x86 when they are set below its exit latency) and to
     restore the previous behavior to fall back to C1 if the next timer
     event is set far enough in the future that was changed in 4.4 which
     led to an energy consumption regression (Rik van Riel, Rafael
     Wysocki).

   - New device ID for a future AMD UART controller in the ACPI driver
     for AMD SoCs (Wang Hongcheng).

   - Rockchip rk3399 support for the rockchip-io-domain adaptive voltage
     scaling (AVS) driver (David Wu).

   - ACPI PCI resources management fix for the handling of IO space
     resources on architectures where the IO space is memory mapped
     (IA64 and ARM64) broken by the introduction of common ACPI
     resources parsing for PCI host bridges in 4.4 (Lorenzo Pieralisi).

   - Fix for the ACPI backend of the generic device properties API to
     make it parse non-device (data node only) children of an ACPI
     device correctly (Irina Tirdea).

   - Fixes for the handling of global suspend flags (introduced in 4.4)
     during hibernation and resume from it (Lukas Wunner).

   - Support for obtaining configuration information from Device Trees
     in the PM clocks framework (Jon Hunter).

   - ACPI _DSM helper code and devfreq framework cleanups (Colin Ian
     King, Geert Uytterhoeven)"

* tag 'pm+acpi-4.6-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (23 commits)
  PM / AVS: rockchip-io: add io selectors and supplies for rk3399
  intel_idle: Support for Intel Xeon Phi Processor x200 Product Family
  intel_idle: prevent SKL-H boot failure when C8+C9+C10 enabled
  ACPI / PM: Runtime resume devices when waking from hibernate
  PM / sleep: Clear pm_suspend_global_flags upon hibernate
  cpufreq: governor: Always schedule work on the CPU running update
  cpufreq: Always update current frequency before startig governor
  cpufreq: Introduce cpufreq_update_current_freq()
  cpufreq: Introduce cpufreq_start_governor()
  cpufreq: powernv: Add sysfs attributes to show throttle stats
  cpufreq: acpi-cpufreq: make Intel/AMD MSR access, io port access static
  PCI: ACPI: IA64: fix IO port generic range check
  ACPI / util: cast data to u64 before shifting to fix sign extension
  cpufreq: powernv: Define per_cpu chip pointer to optimize hot-path
  cpuidle: menu: Fall back to polling if next timer event is near
  cpufreq: acpi-cpufreq: Clean up hot plug notifier callback
  intel_pstate: Do not call wrmsrl_on_cpu() with disabled interrupts
  cpufreq: Make cpufreq_quick_get() safe to call
  ACPI / property: fix data node parsing in acpi_get_next_subnode()
  ACPI / APD: Add device HID for future AMD UART controller
  ...
  • Loading branch information
torvalds committed Mar 25, 2016
2 parents 8407ef4 + ee0140d commit 3d66c6b
Show file tree
Hide file tree
Showing 19 changed files with 593 additions and 163 deletions.
69 changes: 69 additions & 0 deletions Documentation/ABI/testing/sysfs-devices-system-cpu
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,72 @@ Description: Parameters for the CPU cache attributes
- WriteBack: data is written only to the cache line and
the modified cache line is written to main
memory only when it is replaced

What: /sys/devices/system/cpu/cpuX/cpufreq/throttle_stats
/sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/turbo_stat
/sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/sub_turbo_stat
/sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/unthrottle
/sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/powercap
/sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/overtemp
/sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/supply_fault
/sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/overcurrent
/sys/devices/system/cpu/cpuX/cpufreq/throttle_stats/occ_reset
Date: March 2016
Contact: Linux kernel mailing list <[email protected]>
Linux for PowerPC mailing list <[email protected]>
Description: POWERNV CPUFreq driver's frequency throttle stats directory and
attributes

'cpuX/cpufreq/throttle_stats' directory contains the CPU frequency
throttle stat attributes for the chip. The throttle stats of a cpu
is common across all the cpus belonging to a chip. Below are the
throttle attributes exported in the 'throttle_stats' directory:

- turbo_stat : This file gives the total number of times the max
frequency is throttled to lower frequency in turbo (at and above
nominal frequency) range of frequencies.

- sub_turbo_stat : This file gives the total number of times the
max frequency is throttled to lower frequency in sub-turbo(below
nominal frequency) range of frequencies.

- unthrottle : This file gives the total number of times the max
frequency is unthrottled after being throttled.

- powercap : This file gives the total number of times the max
frequency is throttled due to 'Power Capping'.

- overtemp : This file gives the total number of times the max
frequency is throttled due to 'CPU Over Temperature'.

- supply_fault : This file gives the total number of times the
max frequency is throttled due to 'Power Supply Failure'.

- overcurrent : This file gives the total number of times the
max frequency is throttled due to 'Overcurrent'.

- occ_reset : This file gives the total number of times the max
frequency is throttled due to 'OCC Reset'.

The sysfs attributes representing different throttle reasons like
powercap, overtemp, supply_fault, overcurrent and occ_reset map to
the reasons provided by OCC firmware for throttling the frequency.

What: /sys/devices/system/cpu/cpufreq/policyX/throttle_stats
/sys/devices/system/cpu/cpufreq/policyX/throttle_stats/turbo_stat
/sys/devices/system/cpu/cpufreq/policyX/throttle_stats/sub_turbo_stat
/sys/devices/system/cpu/cpufreq/policyX/throttle_stats/unthrottle
/sys/devices/system/cpu/cpufreq/policyX/throttle_stats/powercap
/sys/devices/system/cpu/cpufreq/policyX/throttle_stats/overtemp
/sys/devices/system/cpu/cpufreq/policyX/throttle_stats/supply_fault
/sys/devices/system/cpu/cpufreq/policyX/throttle_stats/overcurrent
/sys/devices/system/cpu/cpufreq/policyX/throttle_stats/occ_reset
Date: March 2016
Contact: Linux kernel mailing list <[email protected]>
Linux for PowerPC mailing list <[email protected]>
Description: POWERNV CPUFreq driver's frequency throttle stats directory and
attributes

'policyX/throttle_stats' directory and all the attributes are same as
the /sys/devices/system/cpu/cpuX/cpufreq/throttle_stats directory and
attributes which give the frequency throttle information of the chip.
11 changes: 11 additions & 0 deletions Documentation/devicetree/bindings/power/rockchip-io-domain.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Required properties:
- "rockchip,rk3288-io-voltage-domain" for rk3288
- "rockchip,rk3368-io-voltage-domain" for rk3368
- "rockchip,rk3368-pmu-io-voltage-domain" for rk3368 pmu-domains
- "rockchip,rk3399-io-voltage-domain" for rk3399
- "rockchip,rk3399-pmu-io-voltage-domain" for rk3399 pmu-domains
- rockchip,grf: phandle to the syscon managing the "general register files"


Expand Down Expand Up @@ -79,6 +81,15 @@ Possible supplies for rk3368 pmu-domains:
- pmu-supply: The supply connected to PMUIO_VDD.
- vop-supply: The supply connected to LCDC_VDD.

Possible supplies for rk3399:
- bt656-supply: The supply connected to APIO2_VDD.
- audio-supply: The supply connected to APIO5_VDD.
- sdmmc-supply: The supply connected to SDMMC0_VDD.
- gpio1830 The supply connected to APIO4_VDD.

Possible supplies for rk3399 pmu-domains:
- pmu1830-supply:The supply connected to PMUIO2_VDD.

Example:

io-domains {
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/acpi_apd.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = {
{ "AMD0010", APD_ADDR(cz_i2c_desc) },
{ "AMDI0010", APD_ADDR(cz_i2c_desc) },
{ "AMD0020", APD_ADDR(cz_uart_desc) },
{ "AMDI0020", APD_ADDR(cz_uart_desc) },
{ "AMD0030", },
#endif
#ifdef CONFIG_ARM64
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
next = adev->node.next;
if (next == head) {
child = NULL;
adev = ACPI_COMPANION(dev);
goto nondev;
}
adev = list_entry(next, struct acpi_device, node);
Expand Down
14 changes: 13 additions & 1 deletion drivers/acpi/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,20 @@

#ifdef CONFIG_X86
#define valid_IRQ(i) (((i) != 0) && ((i) != 2))
static inline bool acpi_iospace_resource_valid(struct resource *res)
{
/* On X86 IO space is limited to the [0 - 64K] IO port range */
return res->end < 0x10003;
}
#else
#define valid_IRQ(i) (true)
/*
* ACPI IO descriptors on arches other than X86 contain MMIO CPU physical
* addresses mapping IO space in CPU physical address space, IO space
* resources can be placed anywhere in the 64-bit physical address space.
*/
static inline bool
acpi_iospace_resource_valid(struct resource *res) { return true; }
#endif

static bool acpi_dev_resource_len_valid(u64 start, u64 end, u64 len, bool io)
Expand Down Expand Up @@ -127,7 +139,7 @@ static void acpi_dev_ioresource_flags(struct resource *res, u64 len,
if (!acpi_dev_resource_len_valid(res->start, res->end, len, true))
res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;

if (res->end >= 0x10003)
if (!acpi_iospace_resource_valid(res))
res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;

if (io_decode == ACPI_DECODE_16)
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ static int acpi_hibernation_enter(void)

static void acpi_hibernation_leave(void)
{
pm_set_resume_via_firmware();
/*
* If ACPI is not enabled by the BIOS and the boot kernel, we need to
* enable it here.
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs)
mask = obj->integer.value;
else if (obj->type == ACPI_TYPE_BUFFER)
for (i = 0; i < obj->buffer.length && i < 8; i++)
mask |= (((u8)obj->buffer.pointer[i]) << (i * 8));
mask |= (((u64)obj->buffer.pointer[i]) << (i * 8));
ACPI_FREE(obj);

/*
Expand Down
89 changes: 89 additions & 0 deletions drivers/base/power/clock_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,62 @@ int pm_clk_add_clk(struct device *dev, struct clk *clk)
return __pm_clk_add(dev, NULL, clk);
}


/**
* of_pm_clk_add_clks - Start using device clock(s) for power management.
* @dev: Device whose clock(s) is going to be used for power management.
*
* Add a series of clocks described in the 'clocks' device-tree node for
* a device to the list of clocks used for the power management of @dev.
* On success, returns the number of clocks added. Returns a negative
* error code if there are no clocks in the device node for the device
* or if adding a clock fails.
*/
int of_pm_clk_add_clks(struct device *dev)
{
struct clk **clks;
unsigned int i, count;
int ret;

if (!dev || !dev->of_node)
return -EINVAL;

count = of_count_phandle_with_args(dev->of_node, "clocks",
"#clock-cells");
if (count == 0)
return -ENODEV;

clks = kcalloc(count, sizeof(*clks), GFP_KERNEL);
if (!clks)
return -ENOMEM;

for (i = 0; i < count; i++) {
clks[i] = of_clk_get(dev->of_node, i);
if (IS_ERR(clks[i])) {
ret = PTR_ERR(clks[i]);
goto error;
}

ret = pm_clk_add_clk(dev, clks[i]);
if (ret) {
clk_put(clks[i]);
goto error;
}
}

kfree(clks);

return i;

error:
while (i--)
pm_clk_remove_clk(dev, clks[i]);

kfree(clks);

return ret;
}

/**
* __pm_clk_remove - Destroy PM clock entry.
* @ce: PM clock entry to destroy.
Expand Down Expand Up @@ -197,6 +253,39 @@ void pm_clk_remove(struct device *dev, const char *con_id)
__pm_clk_remove(ce);
}

/**
* pm_clk_remove_clk - Stop using a device clock for power management.
* @dev: Device whose clock should not be used for PM any more.
* @clk: Clock pointer
*
* Remove the clock pointed to by @clk from the list of clocks used for
* the power management of @dev.
*/
void pm_clk_remove_clk(struct device *dev, struct clk *clk)
{
struct pm_subsys_data *psd = dev_to_psd(dev);
struct pm_clock_entry *ce;

if (!psd || !clk)
return;

spin_lock_irq(&psd->lock);

list_for_each_entry(ce, &psd->clock_list, node) {
if (clk == ce->clk)
goto remove;
}

spin_unlock_irq(&psd->lock);
return;

remove:
list_del(&ce->node);
spin_unlock_irq(&psd->lock);

__pm_clk_remove(ce);
}

/**
* pm_clk_init - Initialize a device's list of power management clocks.
* @dev: Device to initialize the list of PM clocks for.
Expand Down
18 changes: 10 additions & 8 deletions drivers/cpufreq/acpi-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data)
}
}

u32 cpu_freq_read_intel(struct acpi_pct_register *not_used)
static u32 cpu_freq_read_intel(struct acpi_pct_register *not_used)
{
u32 val, dummy;

rdmsr(MSR_IA32_PERF_CTL, val, dummy);
return val;
}

void cpu_freq_write_intel(struct acpi_pct_register *not_used, u32 val)
static void cpu_freq_write_intel(struct acpi_pct_register *not_used, u32 val)
{
u32 lo, hi;

Expand All @@ -262,28 +262,28 @@ void cpu_freq_write_intel(struct acpi_pct_register *not_used, u32 val)
wrmsr(MSR_IA32_PERF_CTL, lo, hi);
}

u32 cpu_freq_read_amd(struct acpi_pct_register *not_used)
static u32 cpu_freq_read_amd(struct acpi_pct_register *not_used)
{
u32 val, dummy;

rdmsr(MSR_AMD_PERF_CTL, val, dummy);
return val;
}

void cpu_freq_write_amd(struct acpi_pct_register *not_used, u32 val)
static void cpu_freq_write_amd(struct acpi_pct_register *not_used, u32 val)
{
wrmsr(MSR_AMD_PERF_CTL, val, 0);
}

u32 cpu_freq_read_io(struct acpi_pct_register *reg)
static u32 cpu_freq_read_io(struct acpi_pct_register *reg)
{
u32 val;

acpi_os_read_port(reg->address, &val, reg->bit_width);
return val;
}

void cpu_freq_write_io(struct acpi_pct_register *reg, u32 val)
static void cpu_freq_write_io(struct acpi_pct_register *reg, u32 val)
{
acpi_os_write_port(reg->address, val, reg->bit_width);
}
Expand Down Expand Up @@ -514,8 +514,10 @@ static int boost_notify(struct notifier_block *nb, unsigned long action,
*/

switch (action) {
case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN:
case CPU_DOWN_FAILED:
case CPU_DOWN_FAILED_FROZEN:
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
boost_set_msrs(acpi_cpufreq_driver.boost_enabled, cpumask);
break;

Expand Down
Loading

0 comments on commit 3d66c6b

Please sign in to comment.