Commit 0b8417c1 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull power management updates from Rafael Wysocki:
 "These rework the collection of cpufreq statistics to allow it to take
  place if fast frequency switching is enabled in the governor, rework
  the frequency invariance handling in the cpufreq core and drivers, add
  new hardware support to a couple of cpufreq drivers, fix a number of
  assorted issues and clean up the code all over.

  Specifics:

   - Rework cpufreq statistics collection to allow it to take place when
     fast frequency switching is enabled in the governor (Viresh Kumar).

   - Make the cpufreq core set the frequency scale on behalf of the
     driver and update several cpufreq drivers accordingly (Ionela
     Voinescu, Valentin Schneider).

   - Add new hardware support to the STI and qcom cpufreq drivers and
     improve them (Alain Volmat, Manivannan Sadhasivam).

   - Fix multiple assorted issues in cpufreq drivers (Jon Hunter,
     Krzysztof Kozlowski, Matthias Kaehlcke, Pali Rohár, Stephan
     Gerhold, Viresh Kumar).

   - Fix several assorted issues in the operating performance points
     (OPP) framework (Stephan Gerhold, Viresh Kumar).

   - Allow devfreq drivers to fetch devfreq instances by DT enumeration
     instead of using explicit phandles and modify the devfreq core code
     to support driver-specific devfreq DT bindings (Leonard Crestez,
     Chanwoo Choi).

   - Improve initial hardware resetting in the tegra30 devfreq driver
     and clean up the tegra cpuidle driver (Dmitry Osipenko).

   - Update the cpuidle core to collect state entry rejection statistics
     and expose them via sysfs (Lina Iyer).

   - Improve the ACPI _CST code handling diagnostics (Chen Yu).

   - Update the PSCI cpuidle driver to allow the PM domain
     initialization to occur in the OSI mode as well as in the PC mode
     (Ulf Hansson).

   - Rework the generic power domains (genpd) core code to allow domain
     power off transition to be aborted in the absence of the "power
     off" domain callback (Ulf Hansson).

   - Fix two suspend-to-idle issues in the ACPI EC driver (Rafael
     Wysocki).

   - Fix the handling of timer_expires in the PM-runtime framework on
     32-bit systems and the handling of device links in it (Grygorii
     Strashko, Xiang Chen).

   - Add IO requests batching support to the hibernate image saving and
     reading code and drop a bogus get_gendisk() from there (Xiaoyi
     Chen, Christoph Hellwig).

   - Allow PCIe ports to be put into the D3cold power state if they are
     power-manageable via ACPI (Lukas Wunner).

   - Add missing header file include to a power capping driver (Pujin
     Shi).

   - Clean up the qcom-cpr AVS driver a bit (Liu Shixin).

   - Kevin Hilman steps down as designated reviwer of adaptive voltage
     scaling (AVS) drivers (Kevin Hilman)"

* tag 'pm-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (65 commits)
  cpufreq: stats: Fix string format specifier mismatch
  arm: disable frequency invariance for CONFIG_BL_SWITCHER
  cpufreq,arm,arm64: restructure definitions of arch_set_freq_scale()
  cpufreq: stats: Add memory barrier to store_reset()
  cpufreq: schedutil: Simplify sugov_fast_switch()
  ACPI: EC: PM: Drop ec_no_wakeup check from acpi_ec_dispatch_gpe()
  ACPI: EC: PM: Flush EC work unconditionally after wakeup
  PCI/ACPI: Whitelist hotplug ports for D3 if power managed by ACPI
  PM: hibernate: remove the bogus call to get_gendisk() in software_resume()
  cpufreq: Move traces and update to policy->cur to cpufreq core
  cpufreq: stats: Enable stats for fast-switch as well
  cpufreq: stats: Mark few conditionals with unlikely()
  cpufreq: stats: Remove locking
  cpufreq: stats: Defer stats update to cpufreq_stats_record_transition()
  PM: domains: Allow to abort power off when no ->power_off() callback
  PM: domains: Rename power state enums for genpd
  PM / devfreq: tegra30: Improve initial hardware resetting
  PM / devfreq: event: Change prototype of devfreq_event_get_edev_by_phandle function
  PM / devfreq: Change prototype of devfreq_get_devfreq_by_phandle function
  PM / devfreq: Add devfreq_get_devfreq_by_node function
  ...
parents 15cb5469 16641d81
...@@ -528,6 +528,10 @@ object corresponding to it, as follows: ...@@ -528,6 +528,10 @@ object corresponding to it, as follows:
Total number of times the hardware has been asked by the given CPU to Total number of times the hardware has been asked by the given CPU to
enter this idle state. enter this idle state.
``rejected``
Total number of times a request to enter this idle state on the given
CPU was rejected.
The :file:`desc` and :file:`name` files both contain strings. The difference The :file:`desc` and :file:`name` files both contain strings. The difference
between them is that the name is expected to be more concise, while the between them is that the name is expected to be more concise, while the
description may be longer and it may contain white space or special characters. description may be longer and it may contain white space or special characters.
...@@ -572,6 +576,11 @@ particular case. For these reasons, the only reliable way to find out how ...@@ -572,6 +576,11 @@ particular case. For these reasons, the only reliable way to find out how
much time has been spent by the hardware in different idle states supported by much time has been spent by the hardware in different idle states supported by
it is to use idle state residency counters in the hardware, if available. it is to use idle state residency counters in the hardware, if available.
Generally, an interrupt received when trying to enter an idle state causes the
idle state entry request to be rejected, in which case the ``CPUIdle`` driver
may return an error code to indicate that this was the case. The :file:`usage`
and :file:`rejected` files report the number of times the given idle state
was entered successfully or rejected, respectively.
.. _cpu-pm-qos: .. _cpu-pm-qos:
......
...@@ -8,7 +8,7 @@ Properties: ...@@ -8,7 +8,7 @@ Properties:
- compatible - compatible
Usage: required Usage: required
Value type: <string> Value type: <string>
Definition: must be "qcom,cpufreq-hw". Definition: must be "qcom,cpufreq-hw" or "qcom,cpufreq-epss".
- clocks - clocks
Usage: required Usage: required
......
...@@ -154,25 +154,27 @@ Optional properties: ...@@ -154,25 +154,27 @@ Optional properties:
- opp-suspend: Marks the OPP to be used during device suspend. If multiple OPPs - opp-suspend: Marks the OPP to be used during device suspend. If multiple OPPs
in the table have this, the OPP with highest opp-hz will be used. in the table have this, the OPP with highest opp-hz will be used.
- opp-supported-hw: This enables us to select only a subset of OPPs from the - opp-supported-hw: This property allows a platform to enable only a subset of
larger OPP table, based on what version of the hardware we are running on. We the OPPs from the larger set present in the OPP table, based on the current
still can't have multiple nodes with the same opp-hz value in OPP table. version of the hardware (already known to the operating system).
It's a user defined array containing a hierarchy of hardware version numbers, Each block present in the array of blocks in this property, represents a
supported by the OPP. For example: a platform with hierarchy of three levels sub-group of hardware versions supported by the OPP. i.e. <sub-group A>,
of versions (A, B and C), this field should be like <X Y Z>, where X <sub-group B>, etc. The OPP will be enabled if _any_ of these sub-groups match
corresponds to Version hierarchy A, Y corresponds to version hierarchy B and Z the hardware's version.
corresponds to version hierarchy C.
Each sub-group is a platform defined array representing the hierarchy of
Each level of hierarchy is represented by a 32 bit value, and so there can be hardware versions supported by the platform. For a platform with three
only 32 different supported version per hierarchy. i.e. 1 bit per version. A hierarchical levels of version (X.Y.Z), this field shall look like
value of 0xFFFFFFFF will enable the OPP for all versions for that hierarchy
level. And a value of 0x00000000 will disable the OPP completely, and so we opp-supported-hw = <X1 Y1 Z1>, <X2 Y2 Z2>, <X3 Y3 Z3>.
never want that to happen.
Each level (eg. X1) in version hierarchy is represented by a 32 bit value, one
If 32 values aren't sufficient for a version hierarchy, than that version bit per version and so there can be maximum 32 versions per level. Logical AND
hierarchy can be contained in multiple 32 bit values. i.e. <X Y Z1 Z2> in the (&) operation is performed for each level with the hardware's level version
above example, Z1 & Z2 refer to the version hierarchy Z. and a non-zero output for _all_ the levels in a sub-group means the OPP is
supported by hardware. A value of 0xFFFFFFFF for each level in the sub-group
will enable the OPP for all versions for the hardware.
- status: Marks the node enabled/disabled. - status: Marks the node enabled/disabled.
...@@ -503,7 +505,6 @@ Example 5: opp-supported-hw ...@@ -503,7 +505,6 @@ Example 5: opp-supported-hw
*/ */
opp-supported-hw = <0xF 0xFFFFFFFF 0xFFFFFFFF> opp-supported-hw = <0xF 0xFFFFFFFF 0xFFFFFFFF>
opp-hz = /bits/ 64 <600000000>; opp-hz = /bits/ 64 <600000000>;
opp-microvolt = <915000 900000 925000>;
... ...
}; };
...@@ -516,7 +517,17 @@ Example 5: opp-supported-hw ...@@ -516,7 +517,17 @@ Example 5: opp-supported-hw
*/ */
opp-supported-hw = <0x20 0xff0000ff 0x0000f4f0> opp-supported-hw = <0x20 0xff0000ff 0x0000f4f0>
opp-hz = /bits/ 64 <800000000>; opp-hz = /bits/ 64 <800000000>;
opp-microvolt = <915000 900000 925000>; ...
};
opp-900000000 {
/*
* Supports:
* - All cuts and substrate where process version is 0x2.
* - All cuts and process where substrate version is 0x2.
*/
opp-supported-hw = <0xFFFFFFFF 0xFFFFFFFF 0x02>, <0xFFFFFFFF 0x01 0xFFFFFFFF>
opp-hz = /bits/ 64 <900000000>;
... ...
}; };
}; };
......
...@@ -5388,7 +5388,6 @@ F: include/linux/kobj* ...@@ -5388,7 +5388,6 @@ F: include/linux/kobj*
F: lib/kobj* F: lib/kobj*
DRIVERS FOR ADAPTIVE VOLTAGE SCALING (AVS) DRIVERS FOR ADAPTIVE VOLTAGE SCALING (AVS)
M: Kevin Hilman <khilman@kernel.org>
M: Nishanth Menon <nm@ti.com> M: Nishanth Menon <nm@ti.com>
L: linux-pm@vger.kernel.org L: linux-pm@vger.kernel.org
S: Maintained S: Maintained
......
...@@ -26,14 +26,6 @@ opp@456000000,800 { ...@@ -26,14 +26,6 @@ opp@456000000,800 {
opp-microvolt = <800000 800000 1125000>; opp-microvolt = <800000 800000 1125000>;
}; };
opp@456000000,800,2,2 {
opp-microvolt = <800000 800000 1125000>;
};
opp@456000000,800,3,2 {
opp-microvolt = <800000 800000 1125000>;
};
opp@456000000,825 { opp@456000000,825 {
opp-microvolt = <825000 825000 1125000>; opp-microvolt = <825000 825000 1125000>;
}; };
...@@ -46,10 +38,6 @@ opp@608000000,800 { ...@@ -46,10 +38,6 @@ opp@608000000,800 {
opp-microvolt = <800000 800000 1125000>; opp-microvolt = <800000 800000 1125000>;
}; };
opp@608000000,800,3,2 {
opp-microvolt = <800000 800000 1125000>;
};
opp@608000000,825 { opp@608000000,825 {
opp-microvolt = <825000 825000 1125000>; opp-microvolt = <825000 825000 1125000>;
}; };
...@@ -78,18 +66,6 @@ opp@760000000,875 { ...@@ -78,18 +66,6 @@ opp@760000000,875 {
opp-microvolt = <875000 875000 1125000>; opp-microvolt = <875000 875000 1125000>;
}; };
opp@760000000,875,1,1 {
opp-microvolt = <875000 875000 1125000>;
};
opp@760000000,875,0,2 {
opp-microvolt = <875000 875000 1125000>;
};
opp@760000000,875,1,2 {
opp-microvolt = <875000 875000 1125000>;
};
opp@760000000,900 { opp@760000000,900 {
opp-microvolt = <900000 900000 1125000>; opp-microvolt = <900000 900000 1125000>;
}; };
...@@ -134,14 +110,6 @@ opp@912000000,950 { ...@@ -134,14 +110,6 @@ opp@912000000,950 {
opp-microvolt = <950000 950000 1125000>; opp-microvolt = <950000 950000 1125000>;
}; };
opp@912000000,950,0,2 {
opp-microvolt = <950000 950000 1125000>;
};
opp@912000000,950,2,2 {
opp-microvolt = <950000 950000 1125000>;
};
opp@912000000,1000 { opp@912000000,1000 {
opp-microvolt = <1000000 1000000 1125000>; opp-microvolt = <1000000 1000000 1125000>;
}; };
...@@ -170,10 +138,6 @@ opp@1000000000,1000 { ...@@ -170,10 +138,6 @@ opp@1000000000,1000 {
opp-microvolt = <1000000 1000000 1125000>; opp-microvolt = <1000000 1000000 1125000>;
}; };
opp@1000000000,1000,0,2 {
opp-microvolt = <1000000 1000000 1125000>;
};
opp@1000000000,1025 { opp@1000000000,1025 {
opp-microvolt = <1025000 1025000 1125000>; opp-microvolt = <1025000 1025000 1125000>;
}; };
......
...@@ -37,19 +37,8 @@ opp@456000000,750 { ...@@ -37,19 +37,8 @@ opp@456000000,750 {
opp@456000000,800 { opp@456000000,800 {
clock-latency-ns = <400000>; clock-latency-ns = <400000>;
opp-supported-hw = <0x03 0x0006>; opp-supported-hw = <0x03 0x0006>, <0x04 0x0004>,
opp-hz = /bits/ 64 <456000000>; <0x08 0x0004>;
};
opp@456000000,800,2,2 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x04 0x0004>;
opp-hz = /bits/ 64 <456000000>;
};
opp@456000000,800,3,2 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x08 0x0004>;
opp-hz = /bits/ 64 <456000000>; opp-hz = /bits/ 64 <456000000>;
}; };
...@@ -67,13 +56,7 @@ opp@608000000,750 { ...@@ -67,13 +56,7 @@ opp@608000000,750 {
opp@608000000,800 { opp@608000000,800 {
clock-latency-ns = <400000>; clock-latency-ns = <400000>;
opp-supported-hw = <0x04 0x0006>; opp-supported-hw = <0x04 0x0006>, <0x08 0x0004>;
opp-hz = /bits/ 64 <608000000>;
};
opp@608000000,800,3,2 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x08 0x0004>;
opp-hz = /bits/ 64 <608000000>; opp-hz = /bits/ 64 <608000000>;
}; };
...@@ -115,25 +98,8 @@ opp@760000000,850 { ...@@ -115,25 +98,8 @@ opp@760000000,850 {
opp@760000000,875 { opp@760000000,875 {
clock-latency-ns = <400000>; clock-latency-ns = <400000>;
opp-supported-hw = <0x04 0x0001>; opp-supported-hw = <0x04 0x0001>, <0x02 0x0002>,
opp-hz = /bits/ 64 <760000000>; <0x01 0x0004>, <0x02 0x0004>;
};
opp@760000000,875,1,1 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x02 0x0002>;
opp-hz = /bits/ 64 <760000000>;
};
opp@760000000,875,0,2 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x01 0x0004>;
opp-hz = /bits/ 64 <760000000>;
};
opp@760000000,875,1,2 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x02 0x0004>;
opp-hz = /bits/ 64 <760000000>; opp-hz = /bits/ 64 <760000000>;
}; };
...@@ -199,19 +165,8 @@ opp@912000000,925 { ...@@ -199,19 +165,8 @@ opp@912000000,925 {
opp@912000000,950 { opp@912000000,950 {
clock-latency-ns = <400000>; clock-latency-ns = <400000>;
opp-supported-hw = <0x02 0x0006>; opp-supported-hw = <0x02 0x0006>, <0x01 0x0004>,
opp-hz = /bits/ 64 <912000000>; <0x04 0x0004>;
};
opp@912000000,950,0,2 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x01 0x0004>;
opp-hz = /bits/ 64 <912000000>;
};
opp@912000000,950,2,2 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x04 0x0004>;
opp-hz = /bits/ 64 <912000000>; opp-hz = /bits/ 64 <912000000>;
}; };
...@@ -253,13 +208,7 @@ opp@1000000000,975 { ...@@ -253,13 +208,7 @@ opp@1000000000,975 {
opp@1000000000,1000 { opp@1000000000,1000 {
clock-latency-ns = <400000>; clock-latency-ns = <400000>;
opp-supported-hw = <0x02 0x0006>; opp-supported-hw = <0x02 0x0006>, <0x01 0x0004>;
opp-hz = /bits/ 64 <1000000000>;
};
opp@1000000000,1000,0,2 {
clock-latency-ns = <400000>;
opp-supported-hw = <0x01 0x0004>;
opp-hz = /bits/ 64 <1000000000>; opp-hz = /bits/ 64 <1000000000>;
}; };
......
This diff is collapsed.
...@@ -7,8 +7,13 @@ ...@@ -7,8 +7,13 @@
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/arch_topology.h> #include <linux/arch_topology.h>
/* big.LITTLE switcher is incompatible with frequency invariance */
#ifndef CONFIG_BL_SWITCHER
/* Replace task scheduler's default frequency-invariant accounting */ /* Replace task scheduler's default frequency-invariant accounting */
#define arch_set_freq_scale topology_set_freq_scale
#define arch_scale_freq_capacity topology_get_freq_scale #define arch_scale_freq_capacity topology_get_freq_scale
#define arch_scale_freq_invariant topology_scale_freq_invariant
#endif
/* Replace task scheduler's default cpu-invariant accounting */ /* Replace task scheduler's default cpu-invariant accounting */
#define arch_scale_cpu_capacity topology_get_cpu_scale #define arch_scale_cpu_capacity topology_get_cpu_scale
......
...@@ -26,7 +26,9 @@ void topology_scale_freq_tick(void); ...@@ -26,7 +26,9 @@ void topology_scale_freq_tick(void);
#endif /* CONFIG_ARM64_AMU_EXTN */ #endif /* CONFIG_ARM64_AMU_EXTN */
/* Replace task scheduler's default frequency-invariant accounting */ /* Replace task scheduler's default frequency-invariant accounting */
#define arch_set_freq_scale topology_set_freq_scale
#define arch_scale_freq_capacity topology_get_freq_scale #define arch_scale_freq_capacity topology_get_freq_scale
#define arch_scale_freq_invariant topology_scale_freq_invariant
/* Replace task scheduler's default cpu-invariant accounting */ /* Replace task scheduler's default cpu-invariant accounting */
#define arch_scale_cpu_capacity topology_get_cpu_scale #define arch_scale_cpu_capacity topology_get_cpu_scale
......
...@@ -248,6 +248,13 @@ static int __init init_amu_fie(void) ...@@ -248,6 +248,13 @@ static int __init init_amu_fie(void)
static_branch_enable(&amu_fie_key); static_branch_enable(&amu_fie_key);
} }
/*
* If the system is not fully invariant after AMU init, disable
* partial use of counters for frequency invariance.
*/
if (!topology_scale_freq_invariant())
static_branch_disable(&amu_fie_key);
free_valid_mask: free_valid_mask:
free_cpumask_var(valid_cpus); free_cpumask_var(valid_cpus);
...@@ -255,7 +262,7 @@ static int __init init_amu_fie(void) ...@@ -255,7 +262,7 @@ static int __init init_amu_fie(void)
} }
late_initcall_sync(init_amu_fie); late_initcall_sync(init_amu_fie);
bool arch_freq_counters_available(struct cpumask *cpus) bool arch_freq_counters_available(const struct cpumask *cpus)
{ {
return amu_freq_invariant() && return amu_freq_invariant() &&
cpumask_subset(cpus, amu_fie_cpus); cpumask_subset(cpus, amu_fie_cpus);
......
...@@ -798,22 +798,34 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, ...@@ -798,22 +798,34 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
memset(&cx, 0, sizeof(cx)); memset(&cx, 0, sizeof(cx));
element = &cst->package.elements[i]; element = &cst->package.elements[i];
if (element->type != ACPI_TYPE_PACKAGE) if (element->type != ACPI_TYPE_PACKAGE) {
acpi_handle_info(handle, "_CST C%d type(%x) is not package, skip...\n",
i, element->type);
continue; continue;
}
if (element->package.count != 4) if (element->package.count != 4) {
acpi_handle_info(handle, "_CST C%d package count(%d) is not 4, skip...\n",
i, element->package.count);
continue; continue;
}
obj = &element->package.elements[0]; obj = &element->package.elements[0];
if (obj->type != ACPI_TYPE_BUFFER) if (obj->type != ACPI_TYPE_BUFFER) {
acpi_handle_info(handle, "_CST C%d package element[0] type(%x) is not buffer, skip...\n",
i, obj->type);
continue; continue;
}
reg = (struct acpi_power_register *)obj->buffer.pointer; reg = (struct acpi_power_register *)obj->buffer.pointer;
obj = &element->package.elements[1]; obj = &element->package.elements[1];
if (obj->type != ACPI_TYPE_INTEGER) if (obj->type != ACPI_TYPE_INTEGER) {
acpi_handle_info(handle, "_CST C[%d] package element[1] type(%x) is not integer, skip...\n",
i, obj->type);
continue; continue;
}
cx.type = obj->integer.value; cx.type = obj->integer.value;
/* /*
...@@ -850,6 +862,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, ...@@ -850,6 +862,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
cx.entry_method = ACPI_CSTATE_HALT; cx.entry_method = ACPI_CSTATE_HALT;
snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT"); snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT");
} else { } else {
acpi_handle_info(handle, "_CST C%d declares FIXED_HARDWARE C-state but not supported in hardware, skip...\n",
i);
continue; continue;
} }
} else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { } else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
...@@ -857,6 +871,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, ...@@ -857,6 +871,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x", snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x",
cx.address); cx.address);
} else { } else {
acpi_handle_info(handle, "_CST C%d space_id(%x) neither FIXED_HARDWARE nor SYSTEM_IO, skip...\n",
i, reg->space_id);
continue; continue;
} }
...@@ -864,14 +880,20 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, ...@@ -864,14 +880,20 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
cx.valid = 1; cx.valid = 1;
obj = &element->package.elements[2]; obj = &element->package.elements[2];
if (obj->type != ACPI_TYPE_INTEGER) if (obj->type != ACPI_TYPE_INTEGER) {
acpi_handle_info(handle, "_CST C%d package element[2] type(%x) not integer, skip...\n",
i, obj->type);
continue; continue;
}
cx.latency = obj->integer.value; cx.latency = obj->integer.value;
obj = &element->package.elements[3]; obj = &element->package.elements[3];
if (obj->type != ACPI_TYPE_INTEGER) if (obj->type != ACPI_TYPE_INTEGER) {
acpi_handle_info(handle, "_CST C%d package element[3] type(%x) not integer, skip...\n",
i, obj->type);
continue; continue;
}
memcpy(&info->states[++last_index], &cx, sizeof(cx)); memcpy(&info->states[++last_index], &cx, sizeof(cx));
} }
......
...@@ -2011,20 +2011,16 @@ bool acpi_ec_dispatch_gpe(void) ...@@ -2011,20 +2011,16 @@ bool acpi_ec_dispatch_gpe(void)
if (acpi_any_gpe_status_set(first_ec->gpe)) if (acpi_any_gpe_status_set(first_ec->gpe))
return true; return true;
if (ec_no_wakeup)
return false;
/* /*
* Dispatch the EC GPE in-band, but do not report wakeup in any case * Dispatch the EC GPE in-band, but do not report wakeup in any case
* to allow the caller to process events properly after that. * to allow the caller to process events properly after that.
*/ */
ret = acpi_dispatch_gpe(NULL, first_ec->gpe); ret = acpi_dispatch_gpe(NULL, first_ec->gpe);
if (ret == ACPI_INTERRUPT_HANDLED) { if (ret == ACPI_INTERRUPT_HANDLED)
pm_pr_dbg("ACPI EC GPE dispatched\n"); pm_pr_dbg("ACPI EC GPE dispatched\n");
/* Flush the event and query workqueues. */ /* Flush the event and query workqueues. */
acpi_ec_flush_work(); acpi_ec_flush_work();
}
return false; return false;
} }
......
...@@ -21,18 +21,27 @@ ...@@ -21,18 +21,27 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/smp.h> #include <linux/smp.h>
__weak bool arch_freq_counters_available(struct cpumask *cpus) bool topology_scale_freq_invariant(void)
{
return cpufreq_supports_freq_invariance() ||
arch_freq_counters_available(cpu_online_mask);
}
__weak bool arch_freq_counters_available(const struct cpumask *cpus)
{ {
return false; return false;
} }
DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE; DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE;
void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, void topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq,
unsigned long max_freq) unsigned long max_freq)
{ {
unsigned long scale; unsigned long scale;
int i; int i;
if (WARN_ON_ONCE(!cur_freq || !max_freq))
return;
/* /*
* If the use of counters for FIE is enabled, just return as we don't * If the use of counters for FIE is enabled, just return as we don't
* want to update the scale factor with information from CPUFREQ. * want to update the scale factor with information from CPUFREQ.
......
...@@ -123,7 +123,7 @@ static const struct genpd_lock_ops genpd_spin_ops = { ...@@ -123,7 +123,7 @@ static const struct genpd_lock_ops genpd_spin_ops = {
#define genpd_lock_interruptible(p) p->lock_ops->lock_interruptible(p) #define genpd_lock_interruptible(p) p->lock_ops->lock_interruptible(p)
#define genpd_unlock(p) p->lock_ops->unlock(p) #define genpd_unlock(p) p->lock_ops->unlock(p)
#define genpd_status_on(genpd) (genpd->status == GPD_STATE_ACTIVE) #define genpd_status_on(genpd) (genpd->status == GENPD_STATE_ON)
#define genpd_is_irq_safe(genpd) (genpd->flags & GENPD_FLAG_IRQ_SAFE) #define genpd_is_irq_safe(genpd) (genpd->flags & GENPD_FLAG_IRQ_SAFE)
#define genpd_is_always_on(genpd) (genpd->flags & GENPD_FLAG_ALWAYS_ON) #define genpd_is_always_on(genpd) (genpd->flags & GENPD_FLAG_ALWAYS_ON)
#define genpd_is_active_wakeup(genpd) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP) #define genpd_is_active_wakeup(genpd) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP)
...@@ -222,7 +222,7 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd) ...@@ -222,7 +222,7 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd)
* out of off and so update the idle time and vice * out of off and so update the idle time and vice
* versa. * versa.
*/ */
if (genpd->status == GPD_STATE_ACTIVE) { if (genpd->status == GENPD_STATE_ON) {
int state_idx = genpd->state_idx; int state_idx = genpd->state_idx;
genpd->states[state_idx].idle_time = genpd->states[state_idx].idle_time =
...@@ -497,6 +497,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, ...@@ -497,6 +497,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
struct pm_domain_data *pdd; struct pm_domain_data *pdd;
struct gpd_link *link; struct gpd_link *link;
unsigned int not_suspended = 0; unsigned int not_suspended = 0;
int ret;
/* /*
* Do not try to power off the domain in the following situations: * Do not try to power off the domain in the following situations:
...@@ -544,26 +545,15 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, ...@@ -544,26 +545,15 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
if (!genpd->gov) if (!genpd->gov)
genpd->state_idx = 0; genpd->state_idx = 0;
if (genpd->power_off) { /* Don't power off, if a child domain is waiting to power on. */
int ret; if (atomic_read(&genpd->sd_count) > 0)
return -EBUSY;
if (atomic_read(&genpd->sd_count) > 0)
return -EBUSY;
/* ret = _genpd_power_off(genpd, true);
* If sd_count > 0 at this point, one of the subdomains hasn't if (ret)
* managed to call genpd_power_on() for the parent yet after return ret;
* incrementing it. In that case genpd_power_on() will wait
* for us to drop the lock, so we can call .power_off() and let
* the genpd_power_on() restore power for us (this shouldn't
* happen very often).
*/
ret = _genpd_power_off(genpd, true);
if (ret)
return ret;
}
genpd->status = GPD_STATE_POWER_OFF; genpd->status = GENPD_STATE_OFF;
genpd_update_accounting(genpd); genpd_update_accounting(genpd);
list_for_each_entry(link, &genpd->child_links, child_node) { list_for_each_entry(link, &genpd->child_links, child_node) {
...@@ -616,7 +606,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth) ...@@ -616,7 +606,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth)
if (ret) if (ret)
goto err; goto err;
genpd->status = GPD_STATE_ACTIVE; genpd->status = GENPD_STATE_ON;
genpd_update_accounting(genpd); genpd_update_accounting(genpd);
return 0; return 0;
...@@ -961,7 +951,7 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock, ...@@ -961,7 +951,7 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
if (_genpd_power_off(genpd, false)) if (_genpd_power_off(genpd, false))
return; return;
genpd->status = GPD_STATE_POWER_OFF; genpd->status = GENPD_STATE_OFF;
list_for_each_entry(link, &genpd->child_links, child_node) { list_for_each_entry(link, &genpd->child_links, child_node) {
genpd_sd_counter_dec(link->parent); genpd_sd_counter_dec(link->parent);
...@@ -1007,8 +997,7 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock, ...@@ -1007,8 +997,7 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
} }
_genpd_power_on(genpd, false); _genpd_power_on(genpd, false);
genpd->status = GENPD_STATE_ON;
genpd->status = GPD_STATE_ACTIVE;
} }
/** /**
...@@ -1287,7 +1276,7 @@ static int genpd_restore_noirq(struct device *dev) ...@@ -1287,7 +1276,7 @@ static int genpd_restore_noirq(struct device *dev)
* so make it appear as powered off to genpd_sync_power_on(), * so make it appear as powered off to genpd_sync_power_on(),
* so that it tries to power it on in case it was really off. * so that it tries to power it on in case it was really off.
*/ */
genpd->status = GPD_STATE_POWER_OFF; genpd->status = GENPD_STATE_OFF;
genpd_sync_power_on(genpd, true, 0); genpd_sync_power_on(genpd, true, 0);
genpd_unlock(genpd); genpd_unlock(genpd);
...@@ -1777,7 +1766,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd, ...@@ -1777,7 +1766,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
genpd->gov = gov; genpd->gov = gov;
INIT_WORK(&genpd->power_off_work, genpd_power_off_work_fn); INIT_WORK(&genpd->power_off_work, genpd_power_off_work_fn);
atomic_set(&genpd->sd_count, 0); atomic_set(&genpd->sd_count, 0);
genpd->status = is_off ? GPD_STATE_POWER_OFF : GPD_STATE_ACTIVE; genpd->status = is_off ? GENPD_STATE_OFF : GENPD_STATE_ON;
genpd->device_count = 0; genpd->device_count = 0;
genpd->max_off_time_ns = -1; genpd->max_off_time_ns = -1;
genpd->max_off_time_changed = true; genpd->max_off_time_changed = true;
...@@ -2044,8 +2033,9 @@ int of_genpd_add_provider_simple(struct device_node *np, ...@@ -2044,8 +2033,9 @@ int of_genpd_add_provider_simple(struct device_node *np,
if (genpd->set_performance_state) { if (genpd->set_performance_state) {
ret = dev_pm_opp_of_add_table(&genpd->dev); ret = dev_pm_opp_of_add_table(&genpd->dev);
if (ret) { if (ret) {
dev_err(&genpd->dev, "Failed to add OPP table: %d\n", if (ret != -EPROBE_DEFER)
ret); dev_err(&genpd->dev, "Failed to add OPP table: %d\n",
ret);
goto unlock; goto unlock;
} }
...@@ -2054,7 +2044,7 @@ int of_genpd_add_provider_simple(struct device_node *np, ...@@ -2054,7 +2044,7 @@ int of_genpd_add_provider_simple(struct device_node *np,
* state. * state.
*/ */
genpd->opp_table = dev_pm_opp_get_opp_table(&genpd->dev); genpd->opp_table = dev_pm_opp_get_opp_table(&genpd->dev);
WARN_ON(!genpd->opp_table); WARN_ON(IS_ERR(genpd->opp_table));
} }
ret = genpd_add_provider(np, genpd_xlate_simple, genpd); ret = genpd_add_provider(np, genpd_xlate_simple, genpd);
...@@ -2111,8 +2101,9 @@ int of_genpd_add_provider_onecell(struct device_node *np, ...@@ -2111,8 +2101,9 @@ int of_genpd_add_provider_onecell(struct device_node *np,
if (genpd->set_performance_state) { if (genpd->set_performance_state) {
ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i); ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i);
if (ret) { if (ret) {
dev_err(&genpd->dev, "Failed to add OPP table for index %d: %d\n", if (ret != -EPROBE_DEFER)
i, ret); dev_err(&genpd->dev, "Failed to add OPP table for index %d: %d\n",
i, ret);
goto error; goto error;
} }
...@@ -2121,7 +2112,7 @@ int of_genpd_add_provider_onecell(struct device_node *np, ...@@ -2121,7 +2112,7 @@ int of_genpd_add_provider_onecell(struct device_node *np,
* performance state. * performance state.
*/ */
genpd->opp_table = dev_pm_opp_get_opp_table_indexed(&genpd->dev, i); genpd->opp_table = dev_pm_opp_get_opp_table_indexed(&genpd->dev, i);
WARN_ON(!genpd->opp_table); WARN_ON(IS_ERR(genpd->opp_table));
} }
genpd->provider = &np->fwnode; genpd->provider = &np->fwnode;
...@@ -2802,8 +2793,8 @@ static int genpd_summary_one(struct seq_file *s, ...@@ -2802,8 +2793,8 @@ static int genpd_summary_one(struct seq_file *s,
struct generic_pm_domain *genpd) struct generic_pm_domain *genpd)
{ {
static const char * const status_lookup[] = { static const char * const status_lookup[] = {
[GPD_STATE_ACTIVE] = "on", [GENPD_STATE_ON] = "on",
[GPD_STATE_POWER_OFF] = "off" [GENPD_STATE_OFF] = "off"
}; };
struct pm_domain_data *pm_data; struct pm_domain_data *pm_data;
const char *kobj_path; const char *kobj_path;
...@@ -2881,8 +2872,8 @@ static int summary_show(struct seq_file *s, void *data) ...@@ -2881,8 +2872,8 @@ static int summary_show(struct seq_file *s, void *data)
static int status_show(struct seq_file *s, void *data) static int status_show(struct seq_file *s, void *data)
{ {
static const char * const status_lookup[] = { static const char * const status_lookup[] = {
[GPD_STATE_ACTIVE] = "on", [GENPD_STATE_ON] = "on",
[GPD_STATE_POWER_OFF] = "off" [GENPD_STATE_OFF] = "off"
}; };
struct generic_pm_domain *genpd = s->private; struct generic_pm_domain *genpd = s->private;
...@@ -2895,7 +2886,7 @@ static int status_show(struct seq_file *s, void *data) ...@@ -2895,7 +2886,7 @@ static int status_show(struct seq_file *s, void *data)
if (WARN_ON_ONCE(genpd->status >= ARRAY_SIZE(status_lookup))) if (WARN_ON_ONCE(genpd->status >= ARRAY_SIZE(status_lookup)))
goto exit; goto exit;
if (genpd->status == GPD_STATE_POWER_OFF) if (genpd->status == GENPD_STATE_OFF)
seq_printf(s, "%s-%u\n", status_lookup[genpd->status], seq_printf(s, "%s-%u\n", status_lookup[genpd->status],
genpd->state_idx); genpd->state_idx);
else else
...@@ -2938,7 +2929,7 @@ static int idle_states_show(struct seq_file *s, void *data) ...@@ -2938,7 +2929,7 @@ static int idle_states_show(struct seq_file *s, void *data)
ktime_t delta = 0; ktime_t delta = 0;
s64 msecs; s64 msecs;
if ((genpd->status == GPD_STATE_POWER_OFF) && if ((genpd->status == GENPD_STATE_OFF) &&
(genpd->state_idx == i)) (genpd->state_idx == i))
delta = ktime_sub(ktime_get(), genpd->accounting_time); delta = ktime_sub(ktime_get(), genpd->accounting_time);
...@@ -2961,7 +2952,7 @@ static int active_time_show(struct seq_file *s, void *data) ...@@ -2961,7 +2952,7 @@ static int active_time_show(struct seq_file *s, void *data)
if (ret) if (ret)
return -ERESTARTSYS; return -ERESTARTSYS;
if (genpd->status == GPD_STATE_ACTIVE) if (genpd->status == GENPD_STATE_ON)
delta = ktime_sub(ktime_get(), genpd->accounting_time); delta = ktime_sub(ktime_get(), genpd->accounting_time);
seq_printf(s, "%lld ms\n", ktime_to_ms( seq_printf(s, "%lld ms\n", ktime_to_ms(
...@@ -2984,7 +2975,7 @@ static int total_idle_time_show(struct seq_file *s, void *data) ...@@ -2984,7 +2975,7 @@ static int total_idle_time_show(struct seq_file *s, void *data)
for (i = 0; i < genpd->state_count; i++) { for (i = 0; i < genpd->state_count; i++) {
if ((genpd->status == GPD_STATE_POWER_OFF) && if ((genpd->status == GENPD_STATE_OFF) &&
(genpd->state_idx == i)) (genpd->state_idx == i))
delta = ktime_sub(ktime_get(), genpd->accounting_time); delta = ktime_sub(ktime_get(), genpd->accounting_time);
......
...@@ -291,8 +291,7 @@ static int rpm_get_suppliers(struct device *dev) ...@@ -291,8 +291,7 @@ static int rpm_get_suppliers(struct device *dev)
device_links_read_lock_held()) { device_links_read_lock_held()) {
int retval; int retval;
if (!(link->flags & DL_FLAG_PM_RUNTIME) || if (!(link->flags & DL_FLAG_PM_RUNTIME))
READ_ONCE(link->status) == DL_STATE_SUPPLIER_UNBIND)
continue; continue;
retval = pm_runtime_get_sync(link->supplier); retval = pm_runtime_get_sync(link->supplier);
...@@ -312,8 +311,6 @@ static void rpm_put_suppliers(struct device *dev) ...@@ -312,8 +311,6 @@ static void rpm_put_suppliers(struct device *dev)
list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, list_for_each_entry_rcu(link, &dev->links.suppliers, c_node,
device_links_read_lock_held()) { device_links_read_lock_held()) {
if (READ_ONCE(link->status) == DL_STATE_SUPPLIER_UNBIND)
continue;
while (refcount_dec_not_one(&link->rpm_active)) while (refcount_dec_not_one(&link->rpm_active))
pm_runtime_put(link->supplier); pm_runtime_put(link->supplier);
......
...@@ -283,7 +283,7 @@ config ARM_SPEAR_CPUFREQ ...@@ -283,7 +283,7 @@ config ARM_SPEAR_CPUFREQ
config ARM_STI_CPUFREQ config ARM_STI_CPUFREQ
tristate "STi CPUFreq support" tristate "STi CPUFreq support"
depends on SOC_STIH407 depends on CPUFREQ_DT && SOC_STIH407
help help
This driver uses the generic OPP framework to match the running This driver uses the generic OPP framework to match the running
platform with a predefined set of suitable values. If not provided platform with a predefined set of suitable values. If not provided
......
...@@ -484,6 +484,12 @@ static int __init armada37xx_cpufreq_driver_init(void) ...@@ -484,6 +484,12 @@ static int __init armada37xx_cpufreq_driver_init(void)
/* late_initcall, to guarantee the driver is loaded after A37xx clock driver */ /* late_initcall, to guarantee the driver is loaded after A37xx clock driver */
late_initcall(armada37xx_cpufreq_driver_init); late_initcall(armada37xx_cpufreq_driver_init);
static const struct of_device_id __maybe_unused armada37xx_cpufreq_of_match[] = {
{ .compatible = "marvell,armada-3700-nb-pm" },
{ },
};
MODULE_DEVICE_TABLE(of, armada37xx_cpufreq_of_match);
MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>"); MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
MODULE_DESCRIPTION("Armada 37xx cpufreq driver"); MODULE_DESCRIPTION("Armada 37xx cpufreq driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -137,6 +137,7 @@ static const struct of_device_id blacklist[] __initconst = { ...@@ -137,6 +137,7 @@ static const struct of_device_id blacklist[] __initconst = {
{ .compatible = "st,stih407", }, { .compatible = "st,stih407", },
{ .compatible = "st,stih410", }, { .compatible = "st,stih410", },
{ .compatible = "st,stih418", },
{ .compatible = "sigma,tango4", }, { .compatible = "sigma,tango4", },
......
This diff is collapsed.
...@@ -61,6 +61,12 @@ static struct cpufreq_driver *cpufreq_driver; ...@@ -61,6 +61,12 @@ static struct cpufreq_driver *cpufreq_driver;
static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
static DEFINE_RWLOCK(cpufreq_driver_lock); static DEFINE_RWLOCK(cpufreq_driver_lock);
static DEFINE_STATIC_KEY_FALSE(cpufreq_freq_invariance);
bool cpufreq_supports_freq_invariance(void)
{
return static_branch_likely(&cpufreq_freq_invariance);
}
/* Flag to suspend/resume CPUFreq governors */ /* Flag to suspend/resume CPUFreq governors */
static bool cpufreq_suspended; static bool cpufreq_suspended;
...@@ -154,12 +160,6 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) ...@@ -154,12 +160,6 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy)
} }
EXPORT_SYMBOL_GPL(get_cpu_idle_time); EXPORT_SYMBOL_GPL(get_cpu_idle_time);
__weak void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq,
unsigned long max_freq)
{
}
EXPORT_SYMBOL_GPL(arch_set_freq_scale);
/* /*
* This is a generic cpufreq init() routine which can be used by cpufreq * This is a generic cpufreq init() routine which can be used by cpufreq
* drivers of SMP systems. It will do following: * drivers of SMP systems. It will do following:
...@@ -446,6 +446,10 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy, ...@@ -446,6 +446,10 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy,
cpufreq_notify_post_transition(policy, freqs, transition_failed); cpufreq_notify_post_transition(policy, freqs, transition_failed);
arch_set_freq_scale(policy->related_cpus,
policy->cur,
policy->cpuinfo.max_freq);
policy->transition_ongoing = false; policy->transition_ongoing = false;
policy->transition_task = NULL; policy->transition_task = NULL;
...@@ -2056,9 +2060,26 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); ...@@ -2056,9 +2060,26 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier);
unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
unsigned int target_freq) unsigned int target_freq)
{ {
unsigned int freq;
int cpu;
target_freq = clamp_val(target_freq, policy->min, policy->max); target_freq = clamp_val(target_freq, policy->min, policy->max);
freq = cpufreq_driver->fast_switch(policy, target_freq);
return cpufreq_driver->fast_switch(policy, target_freq); if (!freq)
return 0;
policy->cur = freq;
arch_set_freq_scale(policy->related_cpus, freq,
policy->cpuinfo.max_freq);
cpufreq_stats_record_transition(policy, freq);
if (trace_cpu_frequency_enabled()) {
for_each_cpu(cpu, policy->cpus)
trace_cpu_frequency(freq, cpu);
}
return freq;
} }
EXPORT_SYMBOL_GPL(cpufreq_driver_fast_switch); EXPORT_SYMBOL_GPL(cpufreq_driver_fast_switch);
...@@ -2710,6 +2731,15 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) ...@@ -2710,6 +2731,15 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
cpufreq_driver = driver_data; cpufreq_driver = driver_data;
write_unlock_irqrestore(&cpufreq_driver_lock, flags); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
/*
* Mark support for the scheduler's frequency invariance engine for
* drivers that implement target(), target_index() or fast_switch().
*/
if (!cpufreq_driver->setpolicy) {
static_branch_enable_cpuslocked(&cpufreq_freq_invariance);
pr_debug("supports frequency invariance");
}
if (driver_data->setpolicy) if (driver_data->setpolicy)
driver_data->flags |= CPUFREQ_CONST_LOOPS; driver_data->flags |= CPUFREQ_CONST_LOOPS;
...@@ -2779,6 +2809,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) ...@@ -2779,6 +2809,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
cpus_read_lock(); cpus_read_lock();
subsys_interface_unregister(&cpufreq_interface); subsys_interface_unregister(&cpufreq_interface);
remove_boost_sysfs_file(); remove_boost_sysfs_file();
static_branch_disable_cpuslocked(&cpufreq_freq_invariance);
cpuhp_remove_state_nocalls_cpuslocked(hp_online); cpuhp_remove_state_nocalls_cpuslocked(hp_online);
write_lock_irqsave(&cpufreq_driver_lock, flags); write_lock_irqsave(&cpufreq_driver_lock, flags);
......
...@@ -19,64 +19,104 @@ struct cpufreq_stats { ...@@ -19,64 +19,104 @@ struct cpufreq_stats {
unsigned int state_num; unsigned int state_num;
unsigned int last_index; unsigned int last_index;
u64 *time_in_state; u64 *time_in_state;
spinlock_t lock;
unsigned int *freq_table; unsigned int *freq_table;
unsigned int *trans_table; unsigned int *trans_table;
/* Deferred reset */
unsigned int reset_pending;
unsigned long long reset_time;
}; };
static void cpufreq_stats_update(struct cpufreq_stats *stats) static void cpufreq_stats_update(struct cpufreq_stats *stats,
unsigned long long time)
{ {
unsigned long long cur_time = get_jiffies_64(); unsigned long long cur_time = get_jiffies_64();
stats->time_in_state[stats->last_index] += cur_time - stats->last_time; stats->time_in_state[stats->last_index] += cur_time - time;
stats->last_time = cur_time; stats->last_time = cur_time;
} }
static void cpufreq_stats_clear_table(struct cpufreq_stats *stats) static void cpufreq_stats_reset_table(struct cpufreq_stats *stats)
{ {
unsigned int count = stats->max_state; unsigned int count = stats->max_state;
spin_lock(&stats->lock);
memset(stats->time_in_state, 0, count * sizeof(u64)); memset(stats->time_in_state, 0, count * sizeof(u64));
memset(stats->trans_table, 0, count * count * sizeof(int)); memset(stats->trans_table, 0, count * count * sizeof(int));
stats->last_time = get_jiffies_64(); stats->last_time = get_jiffies_64();
stats->total_trans = 0; stats->total_trans = 0;
spin_unlock(&stats->lock);
/* Adjust for the time elapsed since reset was requested */
WRITE_ONCE(stats->reset_pending, 0);
/*
* Prevent the reset_time read from being reordered before the
* reset_pending accesses in cpufreq_stats_record_transition().
*/
smp_rmb();
cpufreq_stats_update(stats, READ_ONCE(stats->reset_time));
} }
static ssize_t show_total_trans(struct cpufreq_policy *policy, char *buf) static ssize_t show_total_trans(struct cpufreq_policy *policy, char *buf)
{ {
return sprintf(buf, "%d\n", policy->stats->total_trans); struct cpufreq_stats *stats = policy->stats;
if (READ_ONCE(stats->reset_pending))
return sprintf(buf, "%d\n", 0);
else
return sprintf(buf, "%u\n", stats->total_trans);
} }
cpufreq_freq_attr_ro(total_trans); cpufreq_freq_attr_ro(total_trans);
static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf) static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
{ {
struct cpufreq_stats *stats = policy->stats; struct cpufreq_stats *stats = policy->stats;
bool pending = READ_ONCE(stats->reset_pending);
unsigned long long time;
ssize_t len = 0; ssize_t len = 0;
int i; int i;
if (policy->fast_switch_enabled)
return 0;
spin_lock(&stats->lock);
cpufreq_stats_update(stats);
spin_unlock(&stats->lock);
for (i = 0; i < stats->state_num; i++) { for (i = 0; i < stats->state_num; i++) {
if (pending) {
if (i == stats->last_index) {
/*
* Prevent the reset_time read from occurring
* before the reset_pending read above.
*/
smp_rmb();
time = get_jiffies_64() - READ_ONCE(stats->reset_time);
} else {
time = 0;
}
} else {
time = stats->time_in_state[i];
if (i == stats->last_index)
time += get_jiffies_64() - stats->last_time;
}
len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i], len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i],
(unsigned long long) jiffies_64_to_clock_t(time));
jiffies_64_to_clock_t(stats->time_in_state[i]));
} }
return len; return len;
} }
cpufreq_freq_attr_ro(time_in_state); cpufreq_freq_attr_ro(time_in_state);
/* We don't care what is written to the attribute */
static ssize_t store_reset(struct cpufreq_policy *policy, const char *buf, static ssize_t store_reset(struct cpufreq_policy *policy, const char *buf,
size_t count) size_t count)
{ {
/* We don't care what is written to the attribute. */ struct cpufreq_stats *stats = policy->stats;
cpufreq_stats_clear_table(policy->stats);
/*
* Defer resetting of stats to cpufreq_stats_record_transition() to
* avoid races.
*/
WRITE_ONCE(stats->reset_time, get_jiffies_64());
/*
* The memory barrier below is to prevent the readers of reset_time from
* seeing a stale or partially updated value.
*/
smp_wmb();
WRITE_ONCE(stats->reset_pending, 1);
return count; return count;
} }
cpufreq_freq_attr_wo(reset); cpufreq_freq_attr_wo(reset);
...@@ -84,11 +124,9 @@ cpufreq_freq_attr_wo(reset); ...@@ -84,11 +124,9 @@ cpufreq_freq_attr_wo(reset);
static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
{ {
struct cpufreq_stats *stats = policy->stats; struct cpufreq_stats *stats = policy->stats;
bool pending = READ_ONCE(stats->reset_pending);
ssize_t len = 0; ssize_t len = 0;
int i, j; int i, j, count;
if (policy->fast_switch_enabled)
return 0;
len += scnprintf(buf + len, PAGE_SIZE - len, " From : To\n"); len += scnprintf(buf + len, PAGE_SIZE - len, " From : To\n");
len += scnprintf(buf + len, PAGE_SIZE - len, " : "); len += scnprintf(buf + len, PAGE_SIZE - len, " : ");
...@@ -113,8 +151,13 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) ...@@ -113,8 +151,13 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
for (j = 0; j < stats->state_num; j++) { for (j = 0; j < stats->state_num; j++) {
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
break; break;
len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ",
stats->trans_table[i*stats->max_state+j]); if (pending)
count = 0;
else
count = stats->trans_table[i * stats->max_state + j];
len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ", count);
} }
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
break; break;
...@@ -208,7 +251,6 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy) ...@@ -208,7 +251,6 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
stats->state_num = i; stats->state_num = i;
stats->last_time = get_jiffies_64(); stats->last_time = get_jiffies_64();
stats->last_index = freq_table_get_index(stats, policy->cur); stats->last_index = freq_table_get_index(stats, policy->cur);
spin_lock_init(&stats->lock);
policy->stats = stats; policy->stats = stats;
ret = sysfs_create_group(&policy->kobj, &stats_attr_group); ret = sysfs_create_group(&policy->kobj, &stats_attr_group);
...@@ -228,23 +270,22 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy, ...@@ -228,23 +270,22 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
struct cpufreq_stats *stats = policy->stats; struct cpufreq_stats *stats = policy->stats;
int old_index, new_index; int old_index, new_index;
if (!stats) { if (unlikely(!stats))
pr_debug("%s: No stats found\n", __func__);
return; return;
}
if (unlikely(READ_ONCE(stats->reset_pending)))
cpufreq_stats_reset_table(stats);
old_index = stats->last_index; old_index = stats->last_index;
new_index = freq_table_get_index(stats, new_freq); new_index = freq_table_get_index(stats, new_freq);
/* We can't do stats->time_in_state[-1]= .. */ /* We can't do stats->time_in_state[-1]= .. */
if (old_index == -1 || new_index == -1 || old_index == new_index) if (unlikely(old_index == -1 || new_index == -1 || old_index == new_index))
return; return;
spin_lock(&stats->lock); cpufreq_stats_update(stats, stats->last_time);
cpufreq_stats_update(stats);
stats->last_index = new_index; stats->last_index = new_index;
stats->trans_table[old_index * stats->max_state + new_index]++; stats->trans_table[old_index * stats->max_state + new_index]++;
stats->total_trans++; stats->total_trans++;
spin_unlock(&stats->lock);
} }
...@@ -48,7 +48,6 @@ static struct clk_bulk_data clks[] = { ...@@ -48,7 +48,6 @@ static struct clk_bulk_data clks[] = {
}; };
static struct device *cpu_dev; static struct device *cpu_dev;
static bool free_opp;
static struct cpufreq_frequency_table *freq_table; static struct cpufreq_frequency_table *freq_table;
static unsigned int max_freq; static unsigned int max_freq;
static unsigned int transition_latency; static unsigned int transition_latency;
...@@ -390,9 +389,6 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) ...@@ -390,9 +389,6 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
goto put_reg; goto put_reg;
} }
/* Because we have added the OPPs here, we must free them */
free_opp = true;
if (of_machine_is_compatible("fsl,imx6ul") || if (of_machine_is_compatible("fsl,imx6ul") ||
of_machine_is_compatible("fsl,imx6ull")) { of_machine_is_compatible("fsl,imx6ull")) {
ret = imx6ul_opp_check_speed_grading(cpu_dev); ret = imx6ul_opp_check_speed_grading(cpu_dev);
...@@ -507,8 +503,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) ...@@ -507,8 +503,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
free_freq_table: free_freq_table:
dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
out_free_opp: out_free_opp:
if (free_opp) dev_pm_opp_of_remove_table(cpu_dev);
dev_pm_opp_of_remove_table(cpu_dev);
put_reg: put_reg:
if (!IS_ERR(arm_reg)) if (!IS_ERR(arm_reg))
regulator_put(arm_reg); regulator_put(arm_reg);
...@@ -528,8 +523,7 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev) ...@@ -528,8 +523,7 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev)
{ {
cpufreq_unregister_driver(&imx6q_cpufreq_driver); cpufreq_unregister_driver(&imx6q_cpufreq_driver);
dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
if (free_opp) dev_pm_opp_of_remove_table(cpu_dev);
dev_pm_opp_of_remove_table(cpu_dev);
regulator_put(arm_reg); regulator_put(arm_reg);
if (!IS_ERR(pu_reg)) if (!IS_ERR(pu_reg))
regulator_put(pu_reg); regulator_put(pu_reg);
......
...@@ -19,18 +19,23 @@ ...@@ -19,18 +19,23 @@
#define LUT_L_VAL GENMASK(7, 0) #define LUT_L_VAL GENMASK(7, 0)
#define LUT_CORE_COUNT GENMASK(18, 16) #define LUT_CORE_COUNT GENMASK(18, 16)
#define LUT_VOLT GENMASK(11, 0) #define LUT_VOLT GENMASK(11, 0)
#define LUT_ROW_SIZE 32
#define CLK_HW_DIV 2 #define CLK_HW_DIV 2
#define LUT_TURBO_IND 1 #define LUT_TURBO_IND 1
/* Register offsets */ struct qcom_cpufreq_soc_data {
#define REG_ENABLE 0x0 u32 reg_enable;
#define REG_FREQ_LUT 0x110 u32 reg_freq_lut;
#define REG_VOLT_LUT 0x114 u32 reg_volt_lut;
#define REG_PERF_STATE 0x920 u32 reg_perf_state;
u8 lut_row_size;
};
struct qcom_cpufreq_data {
void __iomem *base;
const struct qcom_cpufreq_soc_data *soc_data;
};
static unsigned long cpu_hw_rate, xo_rate; static unsigned long cpu_hw_rate, xo_rate;
static struct platform_device *global_pdev;
static bool icc_scaling_enabled; static bool icc_scaling_enabled;
static int qcom_cpufreq_set_bw(struct cpufreq_policy *policy, static int qcom_cpufreq_set_bw(struct cpufreq_policy *policy,
...@@ -77,22 +82,22 @@ static int qcom_cpufreq_update_opp(struct device *cpu_dev, ...@@ -77,22 +82,22 @@ static int qcom_cpufreq_update_opp(struct device *cpu_dev,
static int qcom_cpufreq_hw_target_index(struct cpufreq_policy *policy, static int qcom_cpufreq_hw_target_index(struct cpufreq_policy *policy,
unsigned int index) unsigned int index)
{ {
void __iomem *perf_state_reg = policy->driver_data; struct qcom_cpufreq_data *data = policy->driver_data;
const struct qcom_cpufreq_soc_data *soc_data = data->soc_data;
unsigned long freq = policy->freq_table[index].frequency; unsigned long freq = policy->freq_table[index].frequency;
writel_relaxed(index, perf_state_reg); writel_relaxed(index, data->base + soc_data->reg_perf_state);
if (icc_scaling_enabled) if (icc_scaling_enabled)
qcom_cpufreq_set_bw(policy, freq); qcom_cpufreq_set_bw(policy, freq);
arch_set_freq_scale(policy->related_cpus, freq,
policy->cpuinfo.max_freq);
return 0; return 0;
} }
static unsigned int qcom_cpufreq_hw_get(unsigned int cpu) static unsigned int qcom_cpufreq_hw_get(unsigned int cpu)
{ {
void __iomem *perf_state_reg; struct qcom_cpufreq_data *data;
const struct qcom_cpufreq_soc_data *soc_data;
struct cpufreq_policy *policy; struct cpufreq_policy *policy;
unsigned int index; unsigned int index;
...@@ -100,9 +105,10 @@ static unsigned int qcom_cpufreq_hw_get(unsigned int cpu) ...@@ -100,9 +105,10 @@ static unsigned int qcom_cpufreq_hw_get(unsigned int cpu)
if (!policy) if (!policy)
return 0; return 0;
perf_state_reg = policy->driver_data; data = policy->driver_data;
soc_data = data->soc_data;
index = readl_relaxed(perf_state_reg); index = readl_relaxed(data->base + soc_data->reg_perf_state);
index = min(index, LUT_MAX_ENTRIES - 1); index = min(index, LUT_MAX_ENTRIES - 1);
return policy->freq_table[index].frequency; return policy->freq_table[index].frequency;
...@@ -111,23 +117,18 @@ static unsigned int qcom_cpufreq_hw_get(unsigned int cpu) ...@@ -111,23 +117,18 @@ static unsigned int qcom_cpufreq_hw_get(unsigned int cpu)
static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy, static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy,
unsigned int target_freq) unsigned int target_freq)
{ {
void __iomem *perf_state_reg = policy->driver_data; struct qcom_cpufreq_data *data = policy->driver_data;
const struct qcom_cpufreq_soc_data *soc_data = data->soc_data;
unsigned int index; unsigned int index;
unsigned long freq;
index = policy->cached_resolved_idx; index = policy->cached_resolved_idx;
writel_relaxed(index, perf_state_reg); writel_relaxed(index, data->base + soc_data->reg_perf_state);
freq = policy->freq_table[index].frequency; return policy->freq_table[index].frequency;
arch_set_freq_scale(policy->related_cpus, freq,
policy->cpuinfo.max_freq);
return freq;
} }
static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev,
struct cpufreq_policy *policy, struct cpufreq_policy *policy)
void __iomem *base)
{ {
u32 data, src, lval, i, core_count, prev_freq = 0, freq; u32 data, src, lval, i, core_count, prev_freq = 0, freq;
u32 volt; u32 volt;
...@@ -135,6 +136,8 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, ...@@ -135,6 +136,8 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev,
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
unsigned long rate; unsigned long rate;
int ret; int ret;
struct qcom_cpufreq_data *drv_data = policy->driver_data;
const struct qcom_cpufreq_soc_data *soc_data = drv_data->soc_data;
table = kcalloc(LUT_MAX_ENTRIES + 1, sizeof(*table), GFP_KERNEL); table = kcalloc(LUT_MAX_ENTRIES + 1, sizeof(*table), GFP_KERNEL);
if (!table) if (!table)
...@@ -161,14 +164,14 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, ...@@ -161,14 +164,14 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev,
} }
for (i = 0; i < LUT_MAX_ENTRIES; i++) { for (i = 0; i < LUT_MAX_ENTRIES; i++) {
data = readl_relaxed(base + REG_FREQ_LUT + data = readl_relaxed(drv_data->base + soc_data->reg_freq_lut +
i * LUT_ROW_SIZE); i * soc_data->lut_row_size);
src = FIELD_GET(LUT_SRC, data); src = FIELD_GET(LUT_SRC, data);
lval = FIELD_GET(LUT_L_VAL, data); lval = FIELD_GET(LUT_L_VAL, data);
core_count = FIELD_GET(LUT_CORE_COUNT, data); core_count = FIELD_GET(LUT_CORE_COUNT, data);
data = readl_relaxed(base + REG_VOLT_LUT + data = readl_relaxed(drv_data->base + soc_data->reg_volt_lut +
i * LUT_ROW_SIZE); i * soc_data->lut_row_size);
volt = FIELD_GET(LUT_VOLT, data) * 1000; volt = FIELD_GET(LUT_VOLT, data) * 1000;
if (src) if (src)
...@@ -177,10 +180,15 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, ...@@ -177,10 +180,15 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev,
freq = cpu_hw_rate / 1000; freq = cpu_hw_rate / 1000;
if (freq != prev_freq && core_count != LUT_TURBO_IND) { if (freq != prev_freq && core_count != LUT_TURBO_IND) {
table[i].frequency = freq; if (!qcom_cpufreq_update_opp(cpu_dev, freq, volt)) {
qcom_cpufreq_update_opp(cpu_dev, freq, volt); table[i].frequency = freq;
dev_dbg(cpu_dev, "index=%d freq=%d, core_count %d\n", i, dev_dbg(cpu_dev, "index=%d freq=%d, core_count %d\n", i,
freq, core_count); freq, core_count);
} else {
dev_warn(cpu_dev, "failed to update OPP for freq=%d\n", freq);
table[i].frequency = CPUFREQ_ENTRY_INVALID;
}
} else if (core_count == LUT_TURBO_IND) { } else if (core_count == LUT_TURBO_IND) {
table[i].frequency = CPUFREQ_ENTRY_INVALID; table[i].frequency = CPUFREQ_ENTRY_INVALID;
} }
...@@ -197,9 +205,13 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, ...@@ -197,9 +205,13 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev,
* as the boost frequency * as the boost frequency
*/ */
if (prev->frequency == CPUFREQ_ENTRY_INVALID) { if (prev->frequency == CPUFREQ_ENTRY_INVALID) {
prev->frequency = prev_freq; if (!qcom_cpufreq_update_opp(cpu_dev, prev_freq, volt)) {
prev->flags = CPUFREQ_BOOST_FREQ; prev->frequency = prev_freq;
qcom_cpufreq_update_opp(cpu_dev, prev_freq, volt); prev->flags = CPUFREQ_BOOST_FREQ;
} else {
dev_warn(cpu_dev, "failed to update OPP for freq=%d\n",
freq);
}
} }
break; break;
...@@ -238,14 +250,38 @@ static void qcom_get_related_cpus(int index, struct cpumask *m) ...@@ -238,14 +250,38 @@ static void qcom_get_related_cpus(int index, struct cpumask *m)
} }
} }
static const struct qcom_cpufreq_soc_data qcom_soc_data = {
.reg_enable = 0x0,
.reg_freq_lut = 0x110,
.reg_volt_lut = 0x114,
.reg_perf_state = 0x920,
.lut_row_size = 32,
};
static const struct qcom_cpufreq_soc_data epss_soc_data = {
.reg_enable = 0x0,
.reg_freq_lut = 0x100,
.reg_volt_lut = 0x200,
.reg_perf_state = 0x320,
.lut_row_size = 4,
};
static const struct of_device_id qcom_cpufreq_hw_match[] = {
{ .compatible = "qcom,cpufreq-hw", .data = &qcom_soc_data },
{ .compatible = "qcom,cpufreq-epss", .data = &epss_soc_data },
{}
};
MODULE_DEVICE_TABLE(of, qcom_cpufreq_hw_match);
static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
{ {
struct device *dev = &global_pdev->dev; struct platform_device *pdev = cpufreq_get_driver_data();
struct device *dev = &pdev->dev;
struct of_phandle_args args; struct of_phandle_args args;
struct device_node *cpu_np; struct device_node *cpu_np;
struct device *cpu_dev; struct device *cpu_dev;
struct resource *res;
void __iomem *base; void __iomem *base;
struct qcom_cpufreq_data *data;
int ret, index; int ret, index;
cpu_dev = get_cpu_device(policy->cpu); cpu_dev = get_cpu_device(policy->cpu);
...@@ -267,16 +303,21 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) ...@@ -267,16 +303,21 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
index = args.args[0]; index = args.args[0];
res = platform_get_resource(global_pdev, IORESOURCE_MEM, index); base = devm_platform_ioremap_resource(pdev, index);
if (!res) if (IS_ERR(base))
return -ENODEV; return PTR_ERR(base);
base = devm_ioremap(dev, res->start, resource_size(res)); data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!base) if (!data) {
return -ENOMEM; ret = -ENOMEM;
goto error;
}
data->soc_data = of_device_get_match_data(&pdev->dev);
data->base = base;
/* HW should be in enabled state to proceed */ /* HW should be in enabled state to proceed */
if (!(readl_relaxed(base + REG_ENABLE) & 0x1)) { if (!(readl_relaxed(base + data->soc_data->reg_enable) & 0x1)) {
dev_err(dev, "Domain-%d cpufreq hardware not enabled\n", index); dev_err(dev, "Domain-%d cpufreq hardware not enabled\n", index);
ret = -ENODEV; ret = -ENODEV;
goto error; goto error;
...@@ -289,9 +330,9 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) ...@@ -289,9 +330,9 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
goto error; goto error;
} }
policy->driver_data = base + REG_PERF_STATE; policy->driver_data = data;
ret = qcom_cpufreq_hw_read_lut(cpu_dev, policy, base); ret = qcom_cpufreq_hw_read_lut(cpu_dev, policy);
if (ret) { if (ret) {
dev_err(dev, "Domain-%d failed to read LUT\n", index); dev_err(dev, "Domain-%d failed to read LUT\n", index);
goto error; goto error;
...@@ -315,12 +356,13 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) ...@@ -315,12 +356,13 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
static int qcom_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy) static int qcom_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy)
{ {
struct device *cpu_dev = get_cpu_device(policy->cpu); struct device *cpu_dev = get_cpu_device(policy->cpu);
void __iomem *base = policy->driver_data - REG_PERF_STATE; struct qcom_cpufreq_data *data = policy->driver_data;
struct platform_device *pdev = cpufreq_get_driver_data();
dev_pm_opp_remove_all_dynamic(cpu_dev); dev_pm_opp_remove_all_dynamic(cpu_dev);
dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
kfree(policy->freq_table); kfree(policy->freq_table);
devm_iounmap(&global_pdev->dev, base); devm_iounmap(&pdev->dev, data->base);
return 0; return 0;
} }
...@@ -365,7 +407,7 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) ...@@ -365,7 +407,7 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)
cpu_hw_rate = clk_get_rate(clk) / CLK_HW_DIV; cpu_hw_rate = clk_get_rate(clk) / CLK_HW_DIV;
clk_put(clk); clk_put(clk);
global_pdev = pdev; cpufreq_qcom_hw_driver.driver_data = pdev;
/* Check for optional interconnect paths on CPU0 */ /* Check for optional interconnect paths on CPU0 */
cpu_dev = get_cpu_device(0); cpu_dev = get_cpu_device(0);
...@@ -390,12 +432,6 @@ static int qcom_cpufreq_hw_driver_remove(struct platform_device *pdev) ...@@ -390,12 +432,6 @@ static int qcom_cpufreq_hw_driver_remove(struct platform_device *pdev)
return cpufreq_unregister_driver(&cpufreq_qcom_hw_driver); return cpufreq_unregister_driver(&cpufreq_qcom_hw_driver);
} }
static const struct of_device_id qcom_cpufreq_hw_match[] = {
{ .compatible = "qcom,cpufreq-hw" },
{}
};
MODULE_DEVICE_TABLE(of, qcom_cpufreq_hw_match);
static struct platform_driver qcom_cpufreq_hw_driver = { static struct platform_driver qcom_cpufreq_hw_driver = {
.probe = qcom_cpufreq_hw_driver_probe, .probe = qcom_cpufreq_hw_driver_probe,
.remove = qcom_cpufreq_hw_driver_remove, .remove = qcom_cpufreq_hw_driver_remove,
......
...@@ -590,6 +590,7 @@ static struct notifier_block s5pv210_cpufreq_reboot_notifier = { ...@@ -590,6 +590,7 @@ static struct notifier_block s5pv210_cpufreq_reboot_notifier = {
static int s5pv210_cpufreq_probe(struct platform_device *pdev) static int s5pv210_cpufreq_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
struct device_node *np; struct device_node *np;
int id, result = 0; int id, result = 0;
...@@ -602,28 +603,20 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) ...@@ -602,28 +603,20 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
* cpufreq-dt driver. * cpufreq-dt driver.
*/ */
arm_regulator = regulator_get(NULL, "vddarm"); arm_regulator = regulator_get(NULL, "vddarm");
if (IS_ERR(arm_regulator)) { if (IS_ERR(arm_regulator))
if (PTR_ERR(arm_regulator) == -EPROBE_DEFER) return dev_err_probe(dev, PTR_ERR(arm_regulator),
pr_debug("vddarm regulator not ready, defer\n"); "failed to get regulator vddarm\n");
else
pr_err("failed to get regulator vddarm\n");
return PTR_ERR(arm_regulator);
}
int_regulator = regulator_get(NULL, "vddint"); int_regulator = regulator_get(NULL, "vddint");
if (IS_ERR(int_regulator)) { if (IS_ERR(int_regulator)) {
if (PTR_ERR(int_regulator) == -EPROBE_DEFER) result = dev_err_probe(dev, PTR_ERR(int_regulator),
pr_debug("vddint regulator not ready, defer\n"); "failed to get regulator vddint\n");
else
pr_err("failed to get regulator vddint\n");
result = PTR_ERR(int_regulator);
goto err_int_regulator; goto err_int_regulator;
} }
np = of_find_compatible_node(NULL, NULL, "samsung,s5pv210-clock"); np = of_find_compatible_node(NULL, NULL, "samsung,s5pv210-clock");
if (!np) { if (!np) {
pr_err("%s: failed to find clock controller DT node\n", dev_err(dev, "failed to find clock controller DT node\n");
__func__);
result = -ENODEV; result = -ENODEV;
goto err_clock; goto err_clock;
} }
...@@ -631,7 +624,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) ...@@ -631,7 +624,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
clk_base = of_iomap(np, 0); clk_base = of_iomap(np, 0);
of_node_put(np); of_node_put(np);
if (!clk_base) { if (!clk_base) {
pr_err("%s: failed to map clock registers\n", __func__); dev_err(dev, "failed to map clock registers\n");
result = -EFAULT; result = -EFAULT;
goto err_clock; goto err_clock;
} }
...@@ -639,8 +632,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) ...@@ -639,8 +632,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
for_each_compatible_node(np, NULL, "samsung,s5pv210-dmc") { for_each_compatible_node(np, NULL, "samsung,s5pv210-dmc") {
id = of_alias_get_id(np, "dmc"); id = of_alias_get_id(np, "dmc");
if (id < 0 || id >= ARRAY_SIZE(dmc_base)) { if (id < 0 || id >= ARRAY_SIZE(dmc_base)) {
pr_err("%s: failed to get alias of dmc node '%pOFn'\n", dev_err(dev, "failed to get alias of dmc node '%pOFn'\n", np);
__func__, np);
of_node_put(np); of_node_put(np);
result = id; result = id;
goto err_clk_base; goto err_clk_base;
...@@ -648,8 +640,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) ...@@ -648,8 +640,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
dmc_base[id] = of_iomap(np, 0); dmc_base[id] = of_iomap(np, 0);
if (!dmc_base[id]) { if (!dmc_base[id]) {
pr_err("%s: failed to map dmc%d registers\n", dev_err(dev, "failed to map dmc%d registers\n", id);
__func__, id);
of_node_put(np); of_node_put(np);
result = -EFAULT; result = -EFAULT;
goto err_dmc; goto err_dmc;
...@@ -658,7 +649,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev) ...@@ -658,7 +649,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
for (id = 0; id < ARRAY_SIZE(dmc_base); ++id) { for (id = 0; id < ARRAY_SIZE(dmc_base); ++id) {
if (!dmc_base[id]) { if (!dmc_base[id]) {
pr_err("%s: failed to find dmc%d node\n", __func__, id); dev_err(dev, "failed to find dmc%d node\n", id);
result = -ENODEV; result = -ENODEV;
goto err_dmc; goto err_dmc;
} }
......
...@@ -48,16 +48,11 @@ static unsigned int scmi_cpufreq_get_rate(unsigned int cpu) ...@@ -48,16 +48,11 @@ static unsigned int scmi_cpufreq_get_rate(unsigned int cpu)
static int static int
scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
{ {
int ret;
struct scmi_data *priv = policy->driver_data; struct scmi_data *priv = policy->driver_data;
struct scmi_perf_ops *perf_ops = handle->perf_ops; struct scmi_perf_ops *perf_ops = handle->perf_ops;
u64 freq = policy->freq_table[index].frequency; u64 freq = policy->freq_table[index].frequency;
ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false); return perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
if (!ret)
arch_set_freq_scale(policy->related_cpus, freq,
policy->cpuinfo.max_freq);
return ret;
} }
static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy, static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy,
...@@ -67,11 +62,8 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy, ...@@ -67,11 +62,8 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy,
struct scmi_perf_ops *perf_ops = handle->perf_ops; struct scmi_perf_ops *perf_ops = handle->perf_ops;
if (!perf_ops->freq_set(handle, priv->domain_id, if (!perf_ops->freq_set(handle, priv->domain_id,
target_freq * 1000, true)) { target_freq * 1000, true))
arch_set_freq_scale(policy->related_cpus, target_freq,
policy->cpuinfo.max_freq);
return target_freq; return target_freq;
}
return 0; return 0;
} }
......
...@@ -47,9 +47,8 @@ static unsigned int scpi_cpufreq_get_rate(unsigned int cpu) ...@@ -47,9 +47,8 @@ static unsigned int scpi_cpufreq_get_rate(unsigned int cpu)
static int static int
scpi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) scpi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
{ {
unsigned long freq = policy->freq_table[index].frequency; u64 rate = policy->freq_table[index].frequency * 1000;
struct scpi_data *priv = policy->driver_data; struct scpi_data *priv = policy->driver_data;
u64 rate = freq * 1000;
int ret; int ret;
ret = clk_set_rate(priv->clk, rate); ret = clk_set_rate(priv->clk, rate);
...@@ -60,9 +59,6 @@ scpi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) ...@@ -60,9 +59,6 @@ scpi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
if (clk_get_rate(priv->clk) != rate) if (clk_get_rate(priv->clk) != rate)
return -EIO; return -EIO;
arch_set_freq_scale(policy->related_cpus, freq,
policy->cpuinfo.max_freq);
return 0; return 0;
} }
......
...@@ -141,7 +141,8 @@ static const struct reg_field sti_stih407_dvfs_regfields[DVFS_MAX_REGFIELDS] = { ...@@ -141,7 +141,8 @@ static const struct reg_field sti_stih407_dvfs_regfields[DVFS_MAX_REGFIELDS] = {
static const struct reg_field *sti_cpufreq_match(void) static const struct reg_field *sti_cpufreq_match(void)
{ {
if (of_machine_is_compatible("st,stih407") || if (of_machine_is_compatible("st,stih407") ||
of_machine_is_compatible("st,stih410")) of_machine_is_compatible("st,stih410") ||
of_machine_is_compatible("st,stih418"))
return sti_stih407_dvfs_regfields; return sti_stih407_dvfs_regfields;
return NULL; return NULL;
...@@ -258,7 +259,8 @@ static int sti_cpufreq_init(void) ...@@ -258,7 +259,8 @@ static int sti_cpufreq_init(void)
int ret; int ret;
if ((!of_machine_is_compatible("st,stih407")) && if ((!of_machine_is_compatible("st,stih407")) &&
(!of_machine_is_compatible("st,stih410"))) (!of_machine_is_compatible("st,stih410")) &&
(!of_machine_is_compatible("st,stih418")))
return -ENODEV; return -ENODEV;
ddata.cpu = get_cpu_device(0); ddata.cpu = get_cpu_device(0);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define EDVD_CORE_VOLT_FREQ(core) (0x20 + (core) * 0x4) #define EDVD_CORE_VOLT_FREQ(core) (0x20 + (core) * 0x4)
#define EDVD_CORE_VOLT_FREQ_F_SHIFT 0 #define EDVD_CORE_VOLT_FREQ_F_SHIFT 0
#define EDVD_CORE_VOLT_FREQ_F_MASK 0xffff
#define EDVD_CORE_VOLT_FREQ_V_SHIFT 16 #define EDVD_CORE_VOLT_FREQ_V_SHIFT 16
struct tegra186_cpufreq_cluster_info { struct tegra186_cpufreq_cluster_info {
...@@ -91,10 +92,39 @@ static int tegra186_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -91,10 +92,39 @@ static int tegra186_cpufreq_set_target(struct cpufreq_policy *policy,
return 0; return 0;
} }
static unsigned int tegra186_cpufreq_get(unsigned int cpu)
{
struct cpufreq_frequency_table *tbl;
struct cpufreq_policy *policy;
void __iomem *edvd_reg;
unsigned int i, freq = 0;
u32 ndiv;
policy = cpufreq_cpu_get(cpu);
if (!policy)
return 0;
tbl = policy->freq_table;
edvd_reg = policy->driver_data;
ndiv = readl(edvd_reg) & EDVD_CORE_VOLT_FREQ_F_MASK;
for (i = 0; tbl[i].frequency != CPUFREQ_TABLE_END; i++) {
if ((tbl[i].driver_data & EDVD_CORE_VOLT_FREQ_F_MASK) == ndiv) {
freq = tbl[i].frequency;
break;
}
}
cpufreq_cpu_put(policy);
return freq;
}
static struct cpufreq_driver tegra186_cpufreq_driver = { static struct cpufreq_driver tegra186_cpufreq_driver = {
.name = "tegra186", .name = "tegra186",
.flags = CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY | .flags = CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_NEED_INITIAL_FREQ_CHECK, CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.get = tegra186_cpufreq_get,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = tegra186_cpufreq_set_target, .target_index = tegra186_cpufreq_set_target,
.init = tegra186_cpufreq_init, .init = tegra186_cpufreq_init,
......
...@@ -182,7 +182,6 @@ static int ve_spc_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -182,7 +182,6 @@ static int ve_spc_cpufreq_set_target(struct cpufreq_policy *policy,
{ {
u32 cpu = policy->cpu, cur_cluster, new_cluster, actual_cluster; u32 cpu = policy->cpu, cur_cluster, new_cluster, actual_cluster;
unsigned int freqs_new; unsigned int freqs_new;
int ret;
cur_cluster = cpu_to_cluster(cpu); cur_cluster = cpu_to_cluster(cpu);
new_cluster = actual_cluster = per_cpu(physical_cluster, cpu); new_cluster = actual_cluster = per_cpu(physical_cluster, cpu);
...@@ -197,15 +196,8 @@ static int ve_spc_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -197,15 +196,8 @@ static int ve_spc_cpufreq_set_target(struct cpufreq_policy *policy,
new_cluster = A15_CLUSTER; new_cluster = A15_CLUSTER;
} }
ret = ve_spc_cpufreq_set_rate(cpu, actual_cluster, new_cluster, return ve_spc_cpufreq_set_rate(cpu, actual_cluster, new_cluster,
freqs_new); freqs_new);
if (!ret) {
arch_set_freq_scale(policy->related_cpus, freqs_new,
policy->cpuinfo.max_freq);
}
return ret;
} }
static inline u32 get_table_count(struct cpufreq_frequency_table *table) static inline u32 get_table_count(struct cpufreq_frequency_table *table)
......
...@@ -105,7 +105,7 @@ static void psci_pd_free_states(struct genpd_power_state *states, ...@@ -105,7 +105,7 @@ static void psci_pd_free_states(struct genpd_power_state *states,
kfree(states); kfree(states);
} }
static int psci_pd_init(struct device_node *np) static int psci_pd_init(struct device_node *np, bool use_osi)
{ {
struct generic_pm_domain *pd; struct generic_pm_domain *pd;
struct psci_pd_provider *pd_provider; struct psci_pd_provider *pd_provider;
...@@ -135,11 +135,16 @@ static int psci_pd_init(struct device_node *np) ...@@ -135,11 +135,16 @@ static int psci_pd_init(struct device_node *np)
pd->free_states = psci_pd_free_states; pd->free_states = psci_pd_free_states;
pd->name = kbasename(pd->name); pd->name = kbasename(pd->name);
pd->power_off = psci_pd_power_off;
pd->states = states; pd->states = states;
pd->state_count = state_count; pd->state_count = state_count;
pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN; pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN;
/* Allow power off when OSI has been successfully enabled. */
if (use_osi)
pd->power_off = psci_pd_power_off;
else
pd->flags |= GENPD_FLAG_ALWAYS_ON;
/* Use governor for CPU PM domains if it has some states to manage. */ /* Use governor for CPU PM domains if it has some states to manage. */
pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL; pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL;
...@@ -190,7 +195,7 @@ static void psci_pd_remove(void) ...@@ -190,7 +195,7 @@ static void psci_pd_remove(void)
} }
} }
static int psci_pd_init_topology(struct device_node *np, bool add) static int psci_pd_init_topology(struct device_node *np)
{ {
struct device_node *node; struct device_node *node;
struct of_phandle_args child, parent; struct of_phandle_args child, parent;
...@@ -203,9 +208,7 @@ static int psci_pd_init_topology(struct device_node *np, bool add) ...@@ -203,9 +208,7 @@ static int psci_pd_init_topology(struct device_node *np, bool add)
child.np = node; child.np = node;
child.args_count = 0; child.args_count = 0;
ret = of_genpd_add_subdomain(&parent, &child);
ret = add ? of_genpd_add_subdomain(&parent, &child) :
of_genpd_remove_subdomain(&parent, &child);
of_node_put(parent.np); of_node_put(parent.np);
if (ret) { if (ret) {
of_node_put(node); of_node_put(node);
...@@ -216,14 +219,20 @@ static int psci_pd_init_topology(struct device_node *np, bool add) ...@@ -216,14 +219,20 @@ static int psci_pd_init_topology(struct device_node *np, bool add)
return 0; return 0;
} }
static int psci_pd_add_topology(struct device_node *np) static bool psci_pd_try_set_osi_mode(void)
{ {
return psci_pd_init_topology(np, true); int ret;
}
static void psci_pd_remove_topology(struct device_node *np) if (!psci_has_osi_support())
{ return false;
psci_pd_init_topology(np, false);
ret = psci_set_osi_mode(true);
if (ret) {
pr_warn("failed to enable OSI mode: %d\n", ret);
return false;
}
return true;
} }
static void psci_cpuidle_domain_sync_state(struct device *dev) static void psci_cpuidle_domain_sync_state(struct device *dev)
...@@ -244,14 +253,14 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) ...@@ -244,14 +253,14 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct device_node *node; struct device_node *node;
bool use_osi;
int ret = 0, pd_count = 0; int ret = 0, pd_count = 0;
if (!np) if (!np)
return -ENODEV; return -ENODEV;
/* Currently limit the hierarchical topology to be used in OSI mode. */ /* If OSI mode is supported, let's try to enable it. */
if (!psci_has_osi_support()) use_osi = psci_pd_try_set_osi_mode();
return 0;
/* /*
* Parse child nodes for the "#power-domain-cells" property and * Parse child nodes for the "#power-domain-cells" property and
...@@ -261,7 +270,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) ...@@ -261,7 +270,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
if (!of_find_property(node, "#power-domain-cells", NULL)) if (!of_find_property(node, "#power-domain-cells", NULL))
continue; continue;
ret = psci_pd_init(node); ret = psci_pd_init(node, use_osi);
if (ret) if (ret)
goto put_node; goto put_node;
...@@ -270,30 +279,24 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) ...@@ -270,30 +279,24 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev)
/* Bail out if not using the hierarchical CPU topology. */ /* Bail out if not using the hierarchical CPU topology. */
if (!pd_count) if (!pd_count)
return 0; goto no_pd;
/* Link genpd masters/subdomains to model the CPU topology. */ /* Link genpd masters/subdomains to model the CPU topology. */
ret = psci_pd_add_topology(np); ret = psci_pd_init_topology(np);
if (ret) if (ret)
goto remove_pd; goto remove_pd;
/* Try to enable OSI mode. */
ret = psci_set_osi_mode();
if (ret) {
pr_warn("failed to enable OSI mode: %d\n", ret);
psci_pd_remove_topology(np);
goto remove_pd;
}
pr_info("Initialized CPU PM domain topology\n"); pr_info("Initialized CPU PM domain topology\n");
return 0; return 0;
put_node: put_node:
of_node_put(node); of_node_put(node);
remove_pd: remove_pd:
if (pd_count) psci_pd_remove();
psci_pd_remove();
pr_err("failed to create CPU PM domains ret=%d\n", ret); pr_err("failed to create CPU PM domains ret=%d\n", ret);
no_pd:
if (use_osi)
psci_set_osi_mode(false);
return ret; return ret;
} }
......
...@@ -172,7 +172,7 @@ static int tegra_cpuidle_coupled_barrier(struct cpuidle_device *dev) ...@@ -172,7 +172,7 @@ static int tegra_cpuidle_coupled_barrier(struct cpuidle_device *dev)
static int tegra_cpuidle_state_enter(struct cpuidle_device *dev, static int tegra_cpuidle_state_enter(struct cpuidle_device *dev,
int index, unsigned int cpu) int index, unsigned int cpu)
{ {
int ret; int err;
/* /*
* CC6 state is the "CPU cluster power-off" state. In order to * CC6 state is the "CPU cluster power-off" state. In order to
...@@ -183,9 +183,9 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev, ...@@ -183,9 +183,9 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev,
* CPU cores, GIC and L2 cache). * CPU cores, GIC and L2 cache).
*/ */
if (index == TEGRA_CC6) { if (index == TEGRA_CC6) {
ret = tegra_cpuidle_coupled_barrier(dev); err = tegra_cpuidle_coupled_barrier(dev);
if (ret) if (err)
return ret; return err;
} }
local_fiq_disable(); local_fiq_disable();
...@@ -194,15 +194,15 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev, ...@@ -194,15 +194,15 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev,
switch (index) { switch (index) {
case TEGRA_C7: case TEGRA_C7:
ret = tegra_cpuidle_c7_enter(); err = tegra_cpuidle_c7_enter();
break; break;
case TEGRA_CC6: case TEGRA_CC6:
ret = tegra_cpuidle_cc6_enter(cpu); err = tegra_cpuidle_cc6_enter(cpu);
break; break;
default: default:
ret = -EINVAL; err = -EINVAL;
break; break;
} }
...@@ -210,7 +210,7 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev, ...@@ -210,7 +210,7 @@ static int tegra_cpuidle_state_enter(struct cpuidle_device *dev,
tegra_pm_clear_cpu_in_lp2(); tegra_pm_clear_cpu_in_lp2();
local_fiq_enable(); local_fiq_enable();
return ret; return err ?: index;
} }
static int tegra_cpuidle_adjust_state_index(int index, unsigned int cpu) static int tegra_cpuidle_adjust_state_index(int index, unsigned int cpu)
...@@ -236,21 +236,27 @@ static int tegra_cpuidle_enter(struct cpuidle_device *dev, ...@@ -236,21 +236,27 @@ static int tegra_cpuidle_enter(struct cpuidle_device *dev,
int index) int index)
{ {
unsigned int cpu = cpu_logical_map(dev->cpu); unsigned int cpu = cpu_logical_map(dev->cpu);
int err; int ret;
index = tegra_cpuidle_adjust_state_index(index, cpu); index = tegra_cpuidle_adjust_state_index(index, cpu);
if (dev->states_usage[index].disable) if (dev->states_usage[index].disable)
return -1; return -1;
if (index == TEGRA_C1) if (index == TEGRA_C1)
err = arm_cpuidle_simple_enter(dev, drv, index); ret = arm_cpuidle_simple_enter(dev, drv, index);
else else
err = tegra_cpuidle_state_enter(dev, index, cpu); ret = tegra_cpuidle_state_enter(dev, index, cpu);
if (err && (err != -EINTR || index != TEGRA_CC6)) if (ret < 0) {
pr_err_once("failed to enter state %d err: %d\n", index, err); if (ret != -EINTR || index != TEGRA_CC6)
pr_err_once("failed to enter state %d err: %d\n",
index, ret);
index = -1;
} else {
index = ret;
}
return err ? -1 : index; return index;
} }
static int tegra114_enter_s2idle(struct cpuidle_device *dev, static int tegra114_enter_s2idle(struct cpuidle_device *dev,
......
...@@ -297,6 +297,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, ...@@ -297,6 +297,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
} }
} else { } else {
dev->last_residency_ns = 0; dev->last_residency_ns = 0;
dev->states_usage[index].rejected++;
} }
return entered_state; return entered_state;
......
...@@ -256,6 +256,7 @@ define_show_state_time_function(exit_latency) ...@@ -256,6 +256,7 @@ define_show_state_time_function(exit_latency)
define_show_state_time_function(target_residency) define_show_state_time_function(target_residency)
define_show_state_function(power_usage) define_show_state_function(power_usage)
define_show_state_ull_function(usage) define_show_state_ull_function(usage)
define_show_state_ull_function(rejected)
define_show_state_str_function(name) define_show_state_str_function(name)
define_show_state_str_function(desc) define_show_state_str_function(desc)
define_show_state_ull_function(above) define_show_state_ull_function(above)
...@@ -312,6 +313,7 @@ define_one_state_ro(latency, show_state_exit_latency); ...@@ -312,6 +313,7 @@ define_one_state_ro(latency, show_state_exit_latency);
define_one_state_ro(residency, show_state_target_residency); define_one_state_ro(residency, show_state_target_residency);
define_one_state_ro(power, show_state_power_usage); define_one_state_ro(power, show_state_power_usage);
define_one_state_ro(usage, show_state_usage); define_one_state_ro(usage, show_state_usage);
define_one_state_ro(rejected, show_state_rejected);
define_one_state_ro(time, show_state_time); define_one_state_ro(time, show_state_time);
define_one_state_rw(disable, show_state_disable, store_state_disable); define_one_state_rw(disable, show_state_disable, store_state_disable);
define_one_state_ro(above, show_state_above); define_one_state_ro(above, show_state_above);
...@@ -325,6 +327,7 @@ static struct attribute *cpuidle_state_default_attrs[] = { ...@@ -325,6 +327,7 @@ static struct attribute *cpuidle_state_default_attrs[] = {
&attr_residency.attr, &attr_residency.attr,
&attr_power.attr, &attr_power.attr,
&attr_usage.attr, &attr_usage.attr,
&attr_rejected.attr,
&attr_time.attr, &attr_time.attr,
&attr_disable.attr, &attr_disable.attr,
&attr_above.attr, &attr_above.attr,
......
...@@ -213,20 +213,21 @@ EXPORT_SYMBOL_GPL(devfreq_event_reset_event); ...@@ -213,20 +213,21 @@ EXPORT_SYMBOL_GPL(devfreq_event_reset_event);
* devfreq_event_get_edev_by_phandle() - Get the devfreq-event dev from * devfreq_event_get_edev_by_phandle() - Get the devfreq-event dev from
* devicetree. * devicetree.
* @dev : the pointer to the given device * @dev : the pointer to the given device
* @phandle_name: name of property holding a phandle value
* @index : the index into list of devfreq-event device * @index : the index into list of devfreq-event device
* *
* Note that this function return the pointer of devfreq-event device. * Note that this function return the pointer of devfreq-event device.
*/ */
struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev, struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev,
int index) const char *phandle_name, int index)
{ {
struct device_node *node; struct device_node *node;
struct devfreq_event_dev *edev; struct devfreq_event_dev *edev;
if (!dev->of_node) if (!dev->of_node || !phandle_name)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
node = of_parse_phandle(dev->of_node, "devfreq-events", index); node = of_parse_phandle(dev->of_node, phandle_name, index);
if (!node) if (!node)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
...@@ -258,19 +259,20 @@ EXPORT_SYMBOL_GPL(devfreq_event_get_edev_by_phandle); ...@@ -258,19 +259,20 @@ EXPORT_SYMBOL_GPL(devfreq_event_get_edev_by_phandle);
/** /**
* devfreq_event_get_edev_count() - Get the count of devfreq-event dev * devfreq_event_get_edev_count() - Get the count of devfreq-event dev
* @dev : the pointer to the given device * @dev : the pointer to the given device
* @phandle_name: name of property holding a phandle value
* *
* Note that this function return the count of devfreq-event devices. * Note that this function return the count of devfreq-event devices.
*/ */
int devfreq_event_get_edev_count(struct device *dev) int devfreq_event_get_edev_count(struct device *dev, const char *phandle_name)
{ {
int count; int count;
if (!dev->of_node) { if (!dev->of_node || !phandle_name) {
dev_err(dev, "device does not have a device node entry\n"); dev_err(dev, "device does not have a device node entry\n");
return -EINVAL; return -EINVAL;
} }
count = of_property_count_elems_of_size(dev->of_node, "devfreq-events", count = of_property_count_elems_of_size(dev->of_node, phandle_name,
sizeof(u32)); sizeof(u32));
if (count < 0) { if (count < 0) {
dev_err(dev, dev_err(dev,
......
...@@ -983,48 +983,75 @@ struct devfreq *devm_devfreq_add_device(struct device *dev, ...@@ -983,48 +983,75 @@ struct devfreq *devm_devfreq_add_device(struct device *dev,
EXPORT_SYMBOL(devm_devfreq_add_device); EXPORT_SYMBOL(devm_devfreq_add_device);
#ifdef CONFIG_OF #ifdef CONFIG_OF
/*
* devfreq_get_devfreq_by_node - Get the devfreq device from devicetree
* @node - pointer to device_node
*
* return the instance of devfreq device
*/
struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
{
struct devfreq *devfreq;
if (!node)
return ERR_PTR(-EINVAL);
mutex_lock(&devfreq_list_lock);
list_for_each_entry(devfreq, &devfreq_list, node) {
if (devfreq->dev.parent
&& devfreq->dev.parent->of_node == node) {
mutex_unlock(&devfreq_list_lock);
return devfreq;
}
}
mutex_unlock(&devfreq_list_lock);
return ERR_PTR(-ENODEV);
}
/* /*
* devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree * devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree
* @dev - instance to the given device * @dev - instance to the given device
* @phandle_name - name of property holding a phandle value
* @index - index into list of devfreq * @index - index into list of devfreq
* *
* return the instance of devfreq device * return the instance of devfreq device
*/ */
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index) struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
const char *phandle_name, int index)
{ {
struct device_node *node; struct device_node *node;
struct devfreq *devfreq; struct devfreq *devfreq;
if (!dev) if (!dev || !phandle_name)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if (!dev->of_node) if (!dev->of_node)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
node = of_parse_phandle(dev->of_node, "devfreq", index); node = of_parse_phandle(dev->of_node, phandle_name, index);
if (!node) if (!node)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
mutex_lock(&devfreq_list_lock); devfreq = devfreq_get_devfreq_by_node(node);
list_for_each_entry(devfreq, &devfreq_list, node) {
if (devfreq->dev.parent
&& devfreq->dev.parent->of_node == node) {
mutex_unlock(&devfreq_list_lock);
of_node_put(node);
return devfreq;
}
}
mutex_unlock(&devfreq_list_lock);
of_node_put(node); of_node_put(node);
return ERR_PTR(-EPROBE_DEFER); return devfreq;
} }
#else #else
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index) struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
{
return ERR_PTR(-ENODEV);
}
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
const char *phandle_name, int index)
{ {
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
#endif /* CONFIG_OF */ #endif /* CONFIG_OF */
EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_node);
EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_phandle); EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_phandle);
/** /**
......
...@@ -193,7 +193,7 @@ static int exynos_bus_parent_parse_of(struct device_node *np, ...@@ -193,7 +193,7 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
* Get the devfreq-event devices to get the current utilization of * Get the devfreq-event devices to get the current utilization of
* buses. This raw data will be used in devfreq ondemand governor. * buses. This raw data will be used in devfreq ondemand governor.
*/ */
count = devfreq_event_get_edev_count(dev); count = devfreq_event_get_edev_count(dev, "devfreq-events");
if (count < 0) { if (count < 0) {
dev_err(dev, "failed to get the count of devfreq-event dev\n"); dev_err(dev, "failed to get the count of devfreq-event dev\n");
ret = count; ret = count;
...@@ -209,7 +209,8 @@ static int exynos_bus_parent_parse_of(struct device_node *np, ...@@ -209,7 +209,8 @@ static int exynos_bus_parent_parse_of(struct device_node *np,
} }
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
bus->edev[i] = devfreq_event_get_edev_by_phandle(dev, i); bus->edev[i] = devfreq_event_get_edev_by_phandle(dev,
"devfreq-events", i);
if (IS_ERR(bus->edev[i])) { if (IS_ERR(bus->edev[i])) {
ret = -EPROBE_DEFER; ret = -EPROBE_DEFER;
goto err_regulator; goto err_regulator;
...@@ -360,7 +361,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, ...@@ -360,7 +361,7 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
profile->exit = exynos_bus_passive_exit; profile->exit = exynos_bus_passive_exit;
/* Get the instance of parent devfreq device */ /* Get the instance of parent devfreq device */
parent_devfreq = devfreq_get_devfreq_by_phandle(dev, 0); parent_devfreq = devfreq_get_devfreq_by_phandle(dev, "devfreq", 0);
if (IS_ERR(parent_devfreq)) if (IS_ERR(parent_devfreq))
return -EPROBE_DEFER; return -EPROBE_DEFER;
......
...@@ -341,7 +341,7 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev) ...@@ -341,7 +341,7 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
return PTR_ERR(data->dmc_clk); return PTR_ERR(data->dmc_clk);
} }
data->edev = devfreq_event_get_edev_by_phandle(dev, 0); data->edev = devfreq_event_get_edev_by_phandle(dev, "devfreq-events", 0);
if (IS_ERR(data->edev)) if (IS_ERR(data->edev))
return -EPROBE_DEFER; return -EPROBE_DEFER;
......
...@@ -822,8 +822,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev) ...@@ -822,8 +822,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
return err; return err;
} }
reset_control_assert(tegra->reset);
err = clk_prepare_enable(tegra->clock); err = clk_prepare_enable(tegra->clock);
if (err) { if (err) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
...@@ -831,7 +829,11 @@ static int tegra_devfreq_probe(struct platform_device *pdev) ...@@ -831,7 +829,11 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
return err; return err;
} }
reset_control_deassert(tegra->reset); err = reset_control_reset(tegra->reset);
if (err) {
dev_err(&pdev->dev, "Failed to reset hardware: %d\n", err);
goto disable_clk;
}
rate = clk_round_rate(tegra->emc_clock, ULONG_MAX); rate = clk_round_rate(tegra->emc_clock, ULONG_MAX);
if (rate < 0) { if (rate < 0) {
......
...@@ -151,12 +151,15 @@ static u32 psci_get_version(void) ...@@ -151,12 +151,15 @@ static u32 psci_get_version(void)
return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
} }
int psci_set_osi_mode(void) int psci_set_osi_mode(bool enable)
{ {
unsigned long suspend_mode;
int err; int err;
err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, suspend_mode = enable ? PSCI_1_0_SUSPEND_MODE_OSI :
PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); PSCI_1_0_SUSPEND_MODE_PC;
err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, suspend_mode, 0, 0);
return psci_to_linux_errno(err); return psci_to_linux_errno(err);
} }
...@@ -546,8 +549,7 @@ static int __init psci_1_0_init(struct device_node *np) ...@@ -546,8 +549,7 @@ static int __init psci_1_0_init(struct device_node *np)
pr_info("OSI mode supported.\n"); pr_info("OSI mode supported.\n");
/* Default to PC mode. */ /* Default to PC mode. */
invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, psci_set_osi_mode(false);
PSCI_1_0_SUSPEND_MODE_PC, 0, 0);
} }
return 0; return 0;
......
...@@ -1293,7 +1293,8 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc) ...@@ -1293,7 +1293,8 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc)
int counters_size; int counters_size;
int ret, i; int ret, i;
dmc->num_counters = devfreq_event_get_edev_count(dmc->dev); dmc->num_counters = devfreq_event_get_edev_count(dmc->dev,
"devfreq-events");
if (dmc->num_counters < 0) { if (dmc->num_counters < 0) {
dev_err(dmc->dev, "could not get devfreq-event counters\n"); dev_err(dmc->dev, "could not get devfreq-event counters\n");
return dmc->num_counters; return dmc->num_counters;
...@@ -1306,7 +1307,8 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc) ...@@ -1306,7 +1307,8 @@ static int exynos5_performance_counters_init(struct exynos5_dmc *dmc)
for (i = 0; i < dmc->num_counters; i++) { for (i = 0; i < dmc->num_counters; i++) {
dmc->counter[i] = dmc->counter[i] =
devfreq_event_get_edev_by_phandle(dmc->dev, i); devfreq_event_get_edev_by_phandle(dmc->dev,
"devfreq-events", i);
if (IS_ERR_OR_NULL(dmc->counter[i])) if (IS_ERR_OR_NULL(dmc->counter[i]))
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
......
This diff is collapsed.
...@@ -124,7 +124,7 @@ void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, ...@@ -124,7 +124,7 @@ void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask,
continue; continue;
} }
_dev_pm_opp_find_and_remove_table(cpu_dev); dev_pm_opp_remove_table(cpu_dev);
} }
} }
......
...@@ -434,9 +434,9 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_find_icc_paths); ...@@ -434,9 +434,9 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_find_icc_paths);
static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table,
struct device_node *np) struct device_node *np)
{ {
unsigned int count = opp_table->supported_hw_count; unsigned int levels = opp_table->supported_hw_count;
u32 version; int count, versions, ret, i, j;
int ret; u32 val;
if (!opp_table->supported_hw) { if (!opp_table->supported_hw) {
/* /*
...@@ -451,21 +451,40 @@ static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, ...@@ -451,21 +451,40 @@ static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table,
return true; return true;
} }
while (count--) { count = of_property_count_u32_elems(np, "opp-supported-hw");
ret = of_property_read_u32_index(np, "opp-supported-hw", count, if (count <= 0 || count % levels) {
&version); dev_err(dev, "%s: Invalid opp-supported-hw property (%d)\n",
if (ret) { __func__, count);
dev_warn(dev, "%s: failed to read opp-supported-hw property at index %d: %d\n", return false;
__func__, count, ret); }
return false;
versions = count / levels;
/* All levels in at least one of the versions should match */
for (i = 0; i < versions; i++) {
bool supported = true;
for (j = 0; j < levels; j++) {
ret = of_property_read_u32_index(np, "opp-supported-hw",
i * levels + j, &val);
if (ret) {
dev_warn(dev, "%s: failed to read opp-supported-hw property at index %d: %d\n",
__func__, i * levels + j, ret);
return false;
}
/* Check if the level is supported */
if (!(val & opp_table->supported_hw[j])) {
supported = false;
break;
}
} }
/* Both of these are bitwise masks of the versions */ if (supported)
if (!(version & opp_table->supported_hw[count])) return true;
return false;
} }
return true; return false;
} }
static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
...@@ -616,7 +635,7 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, ...@@ -616,7 +635,7 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
*/ */
void dev_pm_opp_of_remove_table(struct device *dev) void dev_pm_opp_of_remove_table(struct device *dev)
{ {
_dev_pm_opp_find_and_remove_table(dev); dev_pm_opp_remove_table(dev);
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table);
...@@ -823,7 +842,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, ...@@ -823,7 +842,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table) static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
{ {
struct device_node *np; struct device_node *np;
int ret, count = 0, pstate_count = 0; int ret, count = 0;
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
/* OPP table is already initialized for the device */ /* OPP table is already initialized for the device */
...@@ -857,20 +876,14 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table) ...@@ -857,20 +876,14 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
goto remove_static_opp; goto remove_static_opp;
} }
list_for_each_entry(opp, &opp_table->opp_list, node) list_for_each_entry(opp, &opp_table->opp_list, node) {
pstate_count += !!opp->pstate; /* Any non-zero performance state would enable the feature */
if (opp->pstate) {
/* Either all or none of the nodes shall have performance state set */ opp_table->genpd_performance_state = true;
if (pstate_count && pstate_count != count) { break;
dev_err(dev, "Not all nodes have performance state set (%d: %d)\n", }
count, pstate_count);
ret = -ENOENT;
goto remove_static_opp;
} }
if (pstate_count)
opp_table->genpd_performance_state = true;
return 0; return 0;
remove_static_opp: remove_static_opp:
...@@ -886,11 +899,25 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) ...@@ -886,11 +899,25 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
const __be32 *val; const __be32 *val;
int nr, ret = 0; int nr, ret = 0;
mutex_lock(&opp_table->lock);
if (opp_table->parsed_static_opps) {
opp_table->parsed_static_opps++;
mutex_unlock(&opp_table->lock);
return 0;
}
opp_table->parsed_static_opps = 1;
mutex_unlock(&opp_table->lock);
prop = of_find_property(dev->of_node, "operating-points", NULL); prop = of_find_property(dev->of_node, "operating-points", NULL);
if (!prop) if (!prop) {
return -ENODEV; ret = -ENODEV;
if (!prop->value) goto remove_static_opp;
return -ENODATA; }
if (!prop->value) {
ret = -ENODATA;
goto remove_static_opp;
}
/* /*
* Each OPP is a set of tuples consisting of frequency and * Each OPP is a set of tuples consisting of frequency and
...@@ -899,13 +926,10 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) ...@@ -899,13 +926,10 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
nr = prop->length / sizeof(u32); nr = prop->length / sizeof(u32);
if (nr % 2) { if (nr % 2) {
dev_err(dev, "%s: Invalid OPP table\n", __func__); dev_err(dev, "%s: Invalid OPP table\n", __func__);
return -EINVAL; ret = -EINVAL;
goto remove_static_opp;
} }
mutex_lock(&opp_table->lock);
opp_table->parsed_static_opps = 1;
mutex_unlock(&opp_table->lock);
val = prop->value; val = prop->value;
while (nr) { while (nr) {
unsigned long freq = be32_to_cpup(val++) * 1000; unsigned long freq = be32_to_cpup(val++) * 1000;
...@@ -915,12 +939,14 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) ...@@ -915,12 +939,14 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
if (ret) { if (ret) {
dev_err(dev, "%s: Failed to add OPP %ld (%d)\n", dev_err(dev, "%s: Failed to add OPP %ld (%d)\n",
__func__, freq, ret); __func__, freq, ret);
_opp_remove_all_static(opp_table); goto remove_static_opp;
return ret;
} }
nr -= 2; nr -= 2;
} }
remove_static_opp:
_opp_remove_all_static(opp_table);
return ret; return ret;
} }
...@@ -947,8 +973,8 @@ int dev_pm_opp_of_add_table(struct device *dev) ...@@ -947,8 +973,8 @@ int dev_pm_opp_of_add_table(struct device *dev)
int ret; int ret;
opp_table = dev_pm_opp_get_opp_table_indexed(dev, 0); opp_table = dev_pm_opp_get_opp_table_indexed(dev, 0);
if (!opp_table) if (IS_ERR(opp_table))
return -ENOMEM; return PTR_ERR(opp_table);
/* /*
* OPPs have two version of bindings now. Also try the old (v1) * OPPs have two version of bindings now. Also try the old (v1)
...@@ -1002,8 +1028,8 @@ int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) ...@@ -1002,8 +1028,8 @@ int dev_pm_opp_of_add_table_indexed(struct device *dev, int index)
} }
opp_table = dev_pm_opp_get_opp_table_indexed(dev, index); opp_table = dev_pm_opp_get_opp_table_indexed(dev, index);
if (!opp_table) if (IS_ERR(opp_table))
return -ENOMEM; return PTR_ERR(opp_table);
ret = _of_add_opp_table_v2(dev, opp_table); ret = _of_add_opp_table_v2(dev, opp_table);
if (ret) if (ret)
......
...@@ -147,11 +147,11 @@ enum opp_table_access { ...@@ -147,11 +147,11 @@ enum opp_table_access {
* @clk: Device's clock handle * @clk: Device's clock handle
* @regulators: Supply regulators * @regulators: Supply regulators
* @regulator_count: Number of power supply regulators. Its value can be -1 * @regulator_count: Number of power supply regulators. Its value can be -1
* @regulator_enabled: Set to true if regulators were previously enabled.
* (uninitialized), 0 (no opp-microvolt property) or > 0 (has opp-microvolt * (uninitialized), 0 (no opp-microvolt property) or > 0 (has opp-microvolt
* property). * property).
* @paths: Interconnect path handles * @paths: Interconnect path handles
* @path_count: Number of interconnect paths * @path_count: Number of interconnect paths
* @enabled: Set to true if the device's resources are enabled/configured.
* @genpd_performance_state: Device's power domain support performance state. * @genpd_performance_state: Device's power domain support performance state.
* @is_genpd: Marks if the OPP table belongs to a genpd. * @is_genpd: Marks if the OPP table belongs to a genpd.
* @set_opp: Platform specific set_opp callback * @set_opp: Platform specific set_opp callback
...@@ -195,9 +195,9 @@ struct opp_table { ...@@ -195,9 +195,9 @@ struct opp_table {
struct clk *clk; struct clk *clk;
struct regulator **regulators; struct regulator **regulators;
int regulator_count; int regulator_count;
bool regulator_enabled;
struct icc_path **paths; struct icc_path **paths;
unsigned int path_count; unsigned int path_count;
bool enabled;
bool genpd_performance_state; bool genpd_performance_state;
bool is_genpd; bool is_genpd;
...@@ -217,7 +217,6 @@ void _get_opp_table_kref(struct opp_table *opp_table); ...@@ -217,7 +217,6 @@ void _get_opp_table_kref(struct opp_table *opp_table);
int _get_opp_count(struct opp_table *opp_table); int _get_opp_count(struct opp_table *opp_table);
struct opp_table *_find_opp_table(struct device *dev); struct opp_table *_find_opp_table(struct device *dev);
struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_table); struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_table);
void _dev_pm_opp_find_and_remove_table(struct device *dev);
struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table); struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table);
void _opp_free(struct dev_pm_opp *opp); void _opp_free(struct dev_pm_opp *opp);
int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2); int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2);
......
...@@ -944,6 +944,16 @@ static bool acpi_pci_bridge_d3(struct pci_dev *dev) ...@@ -944,6 +944,16 @@ static bool acpi_pci_bridge_d3(struct pci_dev *dev)
if (!dev->is_hotplug_bridge) if (!dev->is_hotplug_bridge)
return false; return false;
/* Assume D3 support if the bridge is power-manageable by ACPI. */
adev = ACPI_COMPANION(&dev->dev);
if (!adev && !pci_dev_is_added(dev)) {
adev = acpi_pci_find_companion(&dev->dev);
ACPI_COMPANION_SET(&dev->dev, adev);
}
if (adev && acpi_device_power_manageable(adev))
return true;
/* /*
* Look for a special _DSD property for the root port and if it * Look for a special _DSD property for the root port and if it
* is set we know the hierarchy behind it supports D3 just fine. * is set we know the hierarchy behind it supports D3 just fine.
......
...@@ -665,8 +665,6 @@ static int cpr_enable(struct cpr_drv *drv) ...@@ -665,8 +665,6 @@ static int cpr_enable(struct cpr_drv *drv)
static int cpr_disable(struct cpr_drv *drv) static int cpr_disable(struct cpr_drv *drv)
{ {
int ret;
mutex_lock(&drv->lock); mutex_lock(&drv->lock);
if (cpr_is_allowed(drv)) { if (cpr_is_allowed(drv)) {
...@@ -676,11 +674,7 @@ static int cpr_disable(struct cpr_drv *drv) ...@@ -676,11 +674,7 @@ static int cpr_disable(struct cpr_drv *drv)
mutex_unlock(&drv->lock); mutex_unlock(&drv->lock);
ret = regulator_disable(drv->vdd_apc); return regulator_disable(drv->vdd_apc);
if (ret)
return ret;
return 0;
} }
static int cpr_config(struct cpr_drv *drv) static int cpr_config(struct cpr_drv *drv)
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/smpboot.h> #include <linux/smpboot.h>
#include <linux/idle_inject.h>
#include <uapi/linux/sched/types.h> #include <uapi/linux/sched/types.h>
......
...@@ -93,7 +93,7 @@ static int exynos_asv_update_opps(struct exynos_asv *asv) ...@@ -93,7 +93,7 @@ static int exynos_asv_update_opps(struct exynos_asv *asv)
continue; continue;
opp_table = dev_pm_opp_get_opp_table(cpu); opp_table = dev_pm_opp_get_opp_table(cpu);
if (IS_ERR_OR_NULL(opp_table)) if (IS_ERR(opp_table))
continue; continue;
if (!last_opp_table || opp_table != last_opp_table) { if (!last_opp_table || opp_table != last_opp_table) {
......
...@@ -30,7 +30,11 @@ static inline unsigned long topology_get_freq_scale(int cpu) ...@@ -30,7 +30,11 @@ static inline unsigned long topology_get_freq_scale(int cpu)
return per_cpu(freq_scale, cpu); return per_cpu(freq_scale, cpu);
} }
bool arch_freq_counters_available(struct cpumask *cpus); void topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq,
unsigned long max_freq);
bool topology_scale_freq_invariant(void);
bool arch_freq_counters_available(const struct cpumask *cpus);
DECLARE_PER_CPU(unsigned long, thermal_pressure); DECLARE_PER_CPU(unsigned long, thermal_pressure);
......
...@@ -217,6 +217,7 @@ void refresh_frequency_limits(struct cpufreq_policy *policy); ...@@ -217,6 +217,7 @@ void refresh_frequency_limits(struct cpufreq_policy *policy);
void cpufreq_update_policy(unsigned int cpu); void cpufreq_update_policy(unsigned int cpu);
void cpufreq_update_limits(unsigned int cpu); void cpufreq_update_limits(unsigned int cpu);
bool have_governor_per_policy(void); bool have_governor_per_policy(void);
bool cpufreq_supports_freq_invariance(void);
struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
void cpufreq_enable_fast_switch(struct cpufreq_policy *policy); void cpufreq_enable_fast_switch(struct cpufreq_policy *policy);
void cpufreq_disable_fast_switch(struct cpufreq_policy *policy); void cpufreq_disable_fast_switch(struct cpufreq_policy *policy);
...@@ -237,6 +238,10 @@ static inline unsigned int cpufreq_get_hw_max_freq(unsigned int cpu) ...@@ -237,6 +238,10 @@ static inline unsigned int cpufreq_get_hw_max_freq(unsigned int cpu)
{ {
return 0; return 0;
} }
static inline bool cpufreq_supports_freq_invariance(void)
{
return false;
}
static inline void disable_cpufreq(void) { } static inline void disable_cpufreq(void) { }
#endif #endif
...@@ -1006,8 +1011,14 @@ static inline void sched_cpufreq_governor_change(struct cpufreq_policy *policy, ...@@ -1006,8 +1011,14 @@ static inline void sched_cpufreq_governor_change(struct cpufreq_policy *policy,
extern void arch_freq_prepare_all(void); extern void arch_freq_prepare_all(void);
extern unsigned int arch_freq_get_on_cpu(int cpu); extern unsigned int arch_freq_get_on_cpu(int cpu);
extern void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, #ifndef arch_set_freq_scale
unsigned long max_freq); static __always_inline
void arch_set_freq_scale(const struct cpumask *cpus,
unsigned long cur_freq,
unsigned long max_freq)
{
}
#endif
/* the following are really really optional */ /* the following are really really optional */
extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
......
...@@ -38,6 +38,7 @@ struct cpuidle_state_usage { ...@@ -38,6 +38,7 @@ struct cpuidle_state_usage {
u64 time_ns; u64 time_ns;
unsigned long long above; /* Number of times it's been too deep */ unsigned long long above; /* Number of times it's been too deep */
unsigned long long below; /* Number of times it's been too shallow */ unsigned long long below; /* Number of times it's been too shallow */
unsigned long long rejected; /* Number of times idle entry was rejected */
#ifdef CONFIG_SUSPEND #ifdef CONFIG_SUSPEND
unsigned long long s2idle_usage; unsigned long long s2idle_usage;
unsigned long long s2idle_time; /* in US */ unsigned long long s2idle_time; /* in US */
......
...@@ -106,8 +106,11 @@ extern int devfreq_event_get_event(struct devfreq_event_dev *edev, ...@@ -106,8 +106,11 @@ extern int devfreq_event_get_event(struct devfreq_event_dev *edev,
struct devfreq_event_data *edata); struct devfreq_event_data *edata);
extern int devfreq_event_reset_event(struct devfreq_event_dev *edev); extern int devfreq_event_reset_event(struct devfreq_event_dev *edev);
extern struct devfreq_event_dev *devfreq_event_get_edev_by_phandle( extern struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
struct device *dev, int index); struct device *dev,
extern int devfreq_event_get_edev_count(struct device *dev); const char *phandle_name,
int index);
extern int devfreq_event_get_edev_count(struct device *dev,
const char *phandle_name);
extern struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev, extern struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
struct devfreq_event_desc *desc); struct devfreq_event_desc *desc);
extern int devfreq_event_remove_edev(struct devfreq_event_dev *edev); extern int devfreq_event_remove_edev(struct devfreq_event_dev *edev);
...@@ -152,12 +155,15 @@ static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev) ...@@ -152,12 +155,15 @@ static inline int devfreq_event_reset_event(struct devfreq_event_dev *edev)
} }
static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle( static inline struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(
struct device *dev, int index) struct device *dev,
const char *phandle_name,
int index)
{ {
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
static inline int devfreq_event_get_edev_count(struct device *dev) static inline int devfreq_event_get_edev_count(struct device *dev,
const char *phandle_name)
{ {
return -EINVAL; return -EINVAL;
} }
......
...@@ -261,7 +261,9 @@ void devm_devfreq_unregister_notifier(struct device *dev, ...@@ -261,7 +261,9 @@ void devm_devfreq_unregister_notifier(struct device *dev,
struct devfreq *devfreq, struct devfreq *devfreq,
struct notifier_block *nb, struct notifier_block *nb,
unsigned int list); unsigned int list);
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index); struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node);
struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
const char *phandle_name, int index);
#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND) #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
/** /**
...@@ -414,8 +416,13 @@ static inline void devm_devfreq_unregister_notifier(struct device *dev, ...@@ -414,8 +416,13 @@ static inline void devm_devfreq_unregister_notifier(struct device *dev,
{ {
} }
static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node)
{
return ERR_PTR(-ENODEV);
}
static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,
int index) const char *phandle_name, int index)
{ {
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
......
...@@ -590,7 +590,7 @@ struct dev_pm_info { ...@@ -590,7 +590,7 @@ struct dev_pm_info {
#endif #endif
#ifdef CONFIG_PM #ifdef CONFIG_PM
struct hrtimer suspend_timer; struct hrtimer suspend_timer;
unsigned long timer_expires; u64 timer_expires;
struct work_struct work; struct work_struct work;
wait_queue_head_t wait_queue; wait_queue_head_t wait_queue;
struct wake_irq *wakeirq; struct wake_irq *wakeirq;
......
...@@ -64,8 +64,8 @@ ...@@ -64,8 +64,8 @@
#define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5) #define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5)
enum gpd_status { enum gpd_status {
GPD_STATE_ACTIVE = 0, /* PM domain is active */ GENPD_STATE_ON = 0, /* PM domain is on */
GPD_STATE_POWER_OFF, /* PM domain is off */ GENPD_STATE_OFF, /* PM domain is off */
}; };
struct dev_power_governor { struct dev_power_governor {
......
...@@ -18,7 +18,7 @@ bool psci_tos_resident_on(int cpu); ...@@ -18,7 +18,7 @@ bool psci_tos_resident_on(int cpu);
int psci_cpu_suspend_enter(u32 state); int psci_cpu_suspend_enter(u32 state);
bool psci_power_state_is_valid(u32 state); bool psci_power_state_is_valid(u32 state);
int psci_set_osi_mode(void); int psci_set_osi_mode(bool enable);
bool psci_has_osi_support(void); bool psci_has_osi_support(void);
struct psci_operations { struct psci_operations {
......
...@@ -946,17 +946,6 @@ static int software_resume(void) ...@@ -946,17 +946,6 @@ static int software_resume(void)
/* Check if the device is there */ /* Check if the device is there */
swsusp_resume_device = name_to_dev_t(resume_file); swsusp_resume_device = name_to_dev_t(resume_file);
/*
* name_to_dev_t is ineffective to verify parition if resume_file is in
* integer format. (e.g. major:minor)
*/
if (isdigit(resume_file[0]) && resume_wait) {
int partno;
while (!get_gendisk(swsusp_resume_device, &partno))
msleep(10);
}
if (!swsusp_resume_device) { if (!swsusp_resume_device) {
/* /*
* Some device discovery might still be in progress; we need * Some device discovery might still be in progress; we need
......
...@@ -226,6 +226,7 @@ struct hib_bio_batch { ...@@ -226,6 +226,7 @@ struct hib_bio_batch {
atomic_t count; atomic_t count;
wait_queue_head_t wait; wait_queue_head_t wait;
blk_status_t error; blk_status_t error;
struct blk_plug plug;
}; };
static void hib_init_batch(struct hib_bio_batch *hb) static void hib_init_batch(struct hib_bio_batch *hb)
...@@ -233,6 +234,12 @@ static void hib_init_batch(struct hib_bio_batch *hb) ...@@ -233,6 +234,12 @@ static void hib_init_batch(struct hib_bio_batch *hb)
atomic_set(&hb->count, 0); atomic_set(&hb->count, 0);
init_waitqueue_head(&hb->wait); init_waitqueue_head(&hb->wait);
hb->error = BLK_STS_OK; hb->error = BLK_STS_OK;
blk_start_plug(&hb->plug);
}
static void hib_finish_batch(struct hib_bio_batch *hb)
{
blk_finish_plug(&hb->plug);
} }
static void hib_end_io(struct bio *bio) static void hib_end_io(struct bio *bio)
...@@ -294,6 +301,10 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr, ...@@ -294,6 +301,10 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,
static blk_status_t hib_wait_io(struct hib_bio_batch *hb) static blk_status_t hib_wait_io(struct hib_bio_batch *hb)
{ {
/*
* We are relying on the behavior of blk_plug that a thread with
* a plug will flush the plug list before sleeping.
*/
wait_event(hb->wait, atomic_read(&hb->count) == 0); wait_event(hb->wait, atomic_read(&hb->count) == 0);
return blk_status_to_errno(hb->error); return blk_status_to_errno(hb->error);
} }
...@@ -558,6 +569,7 @@ static int save_image(struct swap_map_handle *handle, ...@@ -558,6 +569,7 @@ static int save_image(struct swap_map_handle *handle,
nr_pages++; nr_pages++;
} }
err2 = hib_wait_io(&hb); err2 = hib_wait_io(&hb);
hib_finish_batch(&hb);
stop = ktime_get(); stop = ktime_get();
if (!ret) if (!ret)
ret = err2; ret = err2;
...@@ -851,6 +863,7 @@ static int save_image_lzo(struct swap_map_handle *handle, ...@@ -851,6 +863,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
pr_info("Image saving done\n"); pr_info("Image saving done\n");
swsusp_show_speed(start, stop, nr_to_write, "Wrote"); swsusp_show_speed(start, stop, nr_to_write, "Wrote");
out_clean: out_clean:
hib_finish_batch(&hb);
if (crc) { if (crc) {
if (crc->thr) if (crc->thr)
kthread_stop(crc->thr); kthread_stop(crc->thr);
...@@ -1081,6 +1094,7 @@ static int load_image(struct swap_map_handle *handle, ...@@ -1081,6 +1094,7 @@ static int load_image(struct swap_map_handle *handle,
nr_pages++; nr_pages++;
} }
err2 = hib_wait_io(&hb); err2 = hib_wait_io(&hb);
hib_finish_batch(&hb);
stop = ktime_get(); stop = ktime_get();
if (!ret) if (!ret)
ret = err2; ret = err2;
...@@ -1444,6 +1458,7 @@ static int load_image_lzo(struct swap_map_handle *handle, ...@@ -1444,6 +1458,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
} }
swsusp_show_speed(start, stop, nr_to_read, "Read"); swsusp_show_speed(start, stop, nr_to_read, "Read");
out_clean: out_clean:
hib_finish_batch(&hb);
for (i = 0; i < ring_size; i++) for (i = 0; i < ring_size; i++)
free_page((unsigned long)page[i]); free_page((unsigned long)page[i]);
if (crc) { if (crc) {
......
...@@ -114,22 +114,8 @@ static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time, ...@@ -114,22 +114,8 @@ static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time,
static void sugov_fast_switch(struct sugov_policy *sg_policy, u64 time, static void sugov_fast_switch(struct sugov_policy *sg_policy, u64 time,
unsigned int next_freq) unsigned int next_freq)
{ {
struct cpufreq_policy *policy = sg_policy->policy; if (sugov_update_next_freq(sg_policy, time, next_freq))
int cpu; cpufreq_driver_fast_switch(sg_policy->policy, next_freq);
if (!sugov_update_next_freq(sg_policy, time, next_freq))
return;
next_freq = cpufreq_driver_fast_switch(policy, next_freq);
if (!next_freq)
return;
policy->cur = next_freq;
if (trace_cpu_frequency_enabled()) {
for_each_cpu(cpu, policy->cpus)
trace_cpu_frequency(next_freq, cpu);
}
} }
static void sugov_deferred_update(struct sugov_policy *sg_policy, u64 time, static void sugov_deferred_update(struct sugov_policy *sg_policy, u64 time,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment