Skip to contentSkip to conversation

CPUFreq driver using CPPC methods

PATCH Superseded Ashwin Chaugule 4 participants 46 messages Jul 9, 2015 – Aug 5, 2015

Subsystems (9)

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v7 cover CPUFreq driver using CPPC methods

CPPC:
====

CPPC (Collaborative Processor Performance Control) is a new way to control CPU performance using an abstract continous scale as against a discretized P-state scale which is tied to CPU frequency only. It is defined in the ACPI 5.0+ spec. In brief, the basic operation involves:
- OS makes a CPU performance request. (Can provide min and max tolerable bounds)

- Platform (such as BMC) is free to optimize request within requested bounds depending on power/thermal budgets etc.

- Platform conveys its decision back to OS

The communication between OS and platform occurs through another medium called (PCC) Platform communication Channel. This is a generic mailbox like mechanism which includes doorbell semantics to indicate register updates. See drivers/mailbox/pcc.c

This patchset introduces a CPPC based CPUFreq driver that works with existing governors such as ondemand. The CPPC table parsing and the CPPC communication semantics are abstracted into separate files to allow future CPPC based drivers to implement their own governors if required.

Initial patchsets included an adaptation of the PID governor from intel_pstate.c. However recent experiments led to extensive modifications of the algorithm to calculate CPU busyness. Until it is verified that these changes are worthwhile, the existing governors should provide for a good enough starting point for ARM64 servers.

Finer details about the PCC and CPPC spec are available in the latest ACPI 5.1 specification.[2]

Testing:
=======

This was tested on an SBSA compatible ARMv8 server with CPPCv2 firmware running on a remote processor. I verified that each CPUs performance limits were detected and that new performance requests were made by the on-demand governor proportional to the load on each CPU. I also verified that using the acpi_processor driver correctly maps the physical CPU ids to logical CPU ids, which helps in picking up the proper _CPC details from a processor object, in the case where CPU physical ids may not be contiguous.

Changes since V6:
- Separated PSS and CST from ACPI processor driver in two patches.
- Made new Kconfig symbols auto selectable from Arch Kconfigs.

Changes since V5:
- Checkpatch cleanups.
- Change pss_init to pss_perf_init. Rec by Srinivas Pandruvada.
- Explicit comment explaining why postcore_initcall to pcc mailbox.
- Fold acpi_processor_syscore_init/exit into CONFIG_ACPI_CST.
- Added patch with dummy functions used by ACPI_HOTPLUG_CPU.

Changes since V4:
- Misc cleanups. Addressed feedback from Rafael.
- Made acpi_processor.c independent of C-states, P-states and others.
- Per CPU scanning for _CPC is now made from acpi_processor.c
- Added new Kconfig options for legacy C states and P states to enable future support for newer alternatives as defined in the ACPI spec 6.0.

Changes since V3:
- Split CPPC backend methods into separate files.
- Add frontend driver which plugs into existing CPUfreq governors.
- Simplify PCC driver by moving communication space mapping and read/write into client drivers.

Changes since V2:
- Select driver if !X86, since intel_pstate will use HWP extensions instead.
- Added more comments.
- Added Freq domain awareness and PSD parsing.

Changes since V1:
- Create a new driver based on Dirks suggestion.
- Fold in CPPC backend hooks into main driver.

Changes since V0: [1]
- Split intel_pstate.c into a generic PID governor and platform specific backend.
- Add CPPC accessors as PID backend.

[1] - http://lwn.net/Articles/608715/
[2] - http://www.uefi.org/sites/default/files/resources/ACPI_5_1release.pdf
[3] - https://patches.linaro.org/40705/

Ashwin Chaugule (8):
PCC: Initialize PCC Mailbox earlier at boot
ACPI: Split out ACPI PSS from ACPI Processor driver
ACPI: Decouple ACPI idle and ACPI processor drivers
ACPI: Introduce CPU performance controls using CPPC
CPPC: Add a CPUFreq driver for use with CPPC
ACPI: Add weak routines for ACPI CPU Hotplug
CPPC: Probe for CPPC tables for each ACPI Processor object
PCC: Enable PCC only when needed

 arch/arm64/Kconfig              |   1 +
 arch/x86/Kconfig                |   1 +
 drivers/acpi/Kconfig            |  41 +-
 drivers/acpi/Makefile           |   8 +-
 drivers/acpi/acpi_processor.c   |  18 +
 drivers/acpi/cppc_acpi.c        | 812 ++++++++++++++++++++++++++++++++++++++++
 drivers/acpi/processor_driver.c |  90 +++--
 drivers/cpufreq/Kconfig         |   2 +-
 drivers/cpufreq/Kconfig.arm     |  16 +
 drivers/cpufreq/Kconfig.x86     |   2 +
 drivers/cpufreq/Makefile        |   2 +
 drivers/cpufreq/cppc_cpufreq.c  | 197 ++++++++++
 drivers/mailbox/Kconfig         |   2 +-
 drivers/mailbox/pcc.c           |   8 +-
 include/acpi/cppc_acpi.h        | 137 +++++++
 include/acpi/processor.h        | 129 +++++--
 16 files changed, 1392 insertions(+), 74 deletions(-)
 create mode 100644 drivers/acpi/cppc_acpi.c
 create mode 100644 drivers/cpufreq/cppc_cpufreq.c
 create mode 100644 include/acpi/cppc_acpi.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v7 1/8 PCC: Initialize PCC Mailbox earlier at boot

This change initializes the PCC Mailbox earlier than the ACPI processor driver. This enables drivers introduced in follow up patches (e.g. CPPC) to be probed via the ACPI processor driver interface. The CPPC probe requires the PCC channel to be initialized for it to query each CPUs performance capabilities.

---
 drivers/mailbox/pcc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +7 -1
index 7e91d68..fcda63e 100644
@@ -352,4 +352,10 @@ static int __init pcc_init(void)
 
 	return 0;
 }
-device_initcall(pcc_init);
+
+/*
+ * Make pcc init postcore so that users of this mailbox
+ * such as the ACPI Processor driver have it available
+ * at their init.
+ */
+postcore_initcall(pcc_init);
Signature · 1 line
1.9.1
#4 lore raw

PATCH v7 2/8 ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
 arch/x86/Kconfig                |  1 +
 drivers/acpi/Kconfig            | 19 ++++++---
 drivers/acpi/Makefile           |  6 +--
 drivers/acpi/processor_driver.c | 86 +++++++++++++++++++++++++------------
 drivers/cpufreq/Kconfig         |  2 +-
 drivers/cpufreq/Kconfig.x86     |  2 +
 include/acpi/processor.h        | 94 +++++++++++++++++++++++++++--------------
 7 files changed, 142 insertions(+), 68 deletions(-)
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
 	select ACPI_LEGACY_TABLES_LOOKUP if ACPI
 	select X86_FEATURE_NAMES if PROC_FS
 	select SRCU
+	select ACPI_CPU_FREQ_PSS if ACPI
 
 config INSTRUCTION_DECODER
 	def_bool y
drivers/acpi/Kconfig +14 -5
index ab2cbb5..00748dc 100644
@@ -166,17 +166,26 @@ config ACPI_DOCK
 	  This driver supports ACPI-controlled docking stations and removable
 	  drive bays such as the IBM Ultrabay and the Dell Module Bay.
 
+config ACPI_CPU_FREQ_PSS
+	bool
+	depends on ACPI_PROCESSOR && CPU_FREQ
+	select THERMAL
+	help
+	  This driver implements ACPI methods for controlling CPU performance
+	  using PSS methods as described in the ACPI spec. It also enables support
+	  for ACPI based performance throttling (TSS) and ACPI based thermal
+	  monitoring. It is required by several flavors of cpufreq
+	  performance-state drivers.
+
 config ACPI_PROCESSOR
 	tristate "Processor"
-	select THERMAL
 	select CPU_IDLE
 	depends on X86 || IA64
 	default y
 	help
-	  This driver installs ACPI as the idle handler for Linux and uses
-	  ACPI C2 and C3 processor states to save power on systems that
-	  support it.  It is required by several flavors of cpufreq
-	  performance-state drivers.
+	  This driver adds support for the ACPI Processor package. It is required
+	  by several flavors of cpufreq performance-state, thermal, throttling and
+	  idle drivers.
 
 	  To compile this driver as a module, choose M here:
 	  the module will be called processor.
drivers/acpi/Makefile +3 -3
index 8a063e2..62e32bd 100644
@@ -82,9 +82,9 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
 obj-$(CONFIG_ACPI_BGRT)		+= bgrt.o
 
 # processor has its own "processor." module_param namespace
-processor-y			:= processor_driver.o processor_throttling.o
-processor-y			+= processor_idle.o processor_thermal.o
-processor-$(CONFIG_CPU_FREQ)	+= processor_perflib.o
+processor-y			:= processor_driver.o processor_idle.o
+processor-$(CONFIG_ACPI_CPU_FREQ_PSS)	+= processor_perflib.o	\
+	processor_throttling.o processor_thermal.o
 
 obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o
 
drivers/acpi/processor_driver.c +58 -28

130 lines not on this page · raw message

drivers/cpufreq/Kconfig +1 -1
index 659879a..0aba0e6 100644
@@ -223,7 +223,7 @@ endif
 if IA64
 config IA64_ACPI_CPUFREQ
 	tristate "ACPI Processor P-States driver"
-	depends on ACPI_PROCESSOR
+	depends on ACPI_PROCESSOR && ACPI_CPU_FREQ_PSS
 	help
 	This driver adds a CPUFreq driver which utilizes the ACPI
 	Processor Performance States.
drivers/cpufreq/Kconfig.x86 +2 -0
index c59bdcb..e24388a 100644
@@ -18,6 +18,7 @@ config X86_INTEL_PSTATE
 config X86_PCC_CPUFREQ
 	tristate "Processor Clocking Control interface driver"
 	depends on ACPI && ACPI_PROCESSOR
+	depends on ACPI_CPU_FREQ_PSS
 	help
 	  This driver adds support for the PCC interface.
 
@@ -32,6 +33,7 @@ config X86_PCC_CPUFREQ
 config X86_ACPI_CPUFREQ
 	tristate "ACPI Processor P-States driver"
 	depends on ACPI_PROCESSOR
+	depends on ACPI_CPU_FREQ_PSS
 	help
 	  This driver adds a CPUFreq driver which utilizes the ACPI
 	  Processor Performance States.
include/acpi/processor.h +63 -31

150 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

PATCH v7 3/8 ACPI: Decouple ACPI idle and ACPI processor drivers

In reply to Ashwin Chaugule

This patch introduces a new Kconfig symbol, ACPI_PROCESSOR_IDLE, which is auto selected by architectures which support the ACPI based C states for CPU Idle management.

The processor_idle driver in its present form contains declarations specific to X86 and IA64. Since there are no reasonable defaults for other architectures e.g. ARM64, the driver is selected only by the arch/x86/Kconfig.

This helps in decoupling the ACPI processor_driver from the ACPI processor_idle driver which is useful for the upcoming alternative patchwork for controlling CPU Performance (CPPC) and CPU Idle (LPI).

---
 drivers/acpi/Kconfig     |  6 +++++-
 drivers/acpi/Makefile    |  3 ++-
 include/acpi/processor.h | 26 ++++++++++++++++++++++++--
 3 files changed, 31 insertions(+), 4 deletions(-)
drivers/acpi/Kconfig +5 -1
index 00748dc..8a60b6e 100644
@@ -177,9 +177,13 @@ config ACPI_CPU_FREQ_PSS
 	  monitoring. It is required by several flavors of cpufreq
 	  performance-state drivers.
 
+config ACPI_PROCESSOR_IDLE
+	def_bool y
+	depends on X86 || IA64
+
 config ACPI_PROCESSOR
 	tristate "Processor"
-	select CPU_IDLE
+	select CPU_IDLE if ACPI_PROCESSOR_IDLE
 	depends on X86 || IA64
 	default y
 	help
drivers/acpi/Makefile +2 -1
index 62e32bd..0633af6 100644
@@ -82,7 +82,8 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
 obj-$(CONFIG_ACPI_BGRT)		+= bgrt.o
 
 # processor has its own "processor." module_param namespace
-processor-y			:= processor_driver.o processor_idle.o
+processor-y			:= processor_driver.o
+processor-$(CONFIG_ACPI_PROCESSOR_IDLE)	+= processor_idle.o
 processor-$(CONFIG_ACPI_CPU_FREQ_PSS)	+= processor_perflib.o	\
 	processor_throttling.o processor_thermal.o
 
include/acpi/processor.h +24 -2
index bedcab3..c071a92 100644
@@ -369,13 +369,35 @@ static inline void acpi_processor_throttling_init(void) {}
 #endif	/* CONFIG_ACPI_CPU_FREQ_PSS */
 
 /* in processor_idle.c */
+extern struct cpuidle_driver acpi_idle_driver;
+#ifdef CONFIG_ACPI_PROCESSOR_IDLE
 int acpi_processor_power_init(struct acpi_processor *pr);
 int acpi_processor_power_exit(struct acpi_processor *pr);
 int acpi_processor_cst_has_changed(struct acpi_processor *pr);
 int acpi_processor_hotplug(struct acpi_processor *pr);
-extern struct cpuidle_driver acpi_idle_driver;
+#else
+static inline int acpi_processor_power_init(struct acpi_processor *pr)
+{
+	return -ENODEV;
+}
+
+static inline int acpi_processor_power_exit(struct acpi_processor *pr)
+{
+	return -ENODEV;
+}
+
+static inline int acpi_processor_cst_has_changed(struct acpi_processor *pr)
+{
+	return -ENODEV;
+}
+
+static inline int acpi_processor_hotplug(struct acpi_processor *pr)
+{
+	return -ENODEV;
+}
+#endif /* CONFIG_ACPI_PROCESSOR_IDLE */
 
-#ifdef CONFIG_PM_SLEEP
+#if defined(CONFIG_PM_SLEEP) & defined(CONFIG_ACPI_PROCESSOR_IDLE)
 void acpi_processor_syscore_init(void);
 void acpi_processor_syscore_exit(void);
 #else
Signature · 1 line
1.9.1
#23 lore raw

PATCH v7 4/8 ACPI: Introduce CPU performance controls using CPPC

In reply to Ashwin Chaugule

CPPC stands for Collaborative Processor Performance Controls and is defined in the ACPI v5.0+ spec. It describes CPU performance controls on an abstract and continuous scale allowing the platform (e.g. remote power processor) to flexibly optimize CPU performance with its knowledge of power budgets and other architecture specific knowledge.

This patch adds a shim which exports commonly used functions to get and set CPPC specific controls for each CPU. This enables CPUFreq drivers to gather per CPU performance data and use with exisiting governors or even allows for customized governors which are implemented inside CPUFreq drivers.

---
 drivers/acpi/Kconfig     |  14 +
 drivers/acpi/Makefile    |   1 +
 drivers/acpi/cppc_acpi.c | 812 +++++++++++++++++++++++++++++++++++++++++++++++
 include/acpi/cppc_acpi.h | 137 ++++++++
 4 files changed, 964 insertions(+)
 create mode 100644 drivers/acpi/cppc_acpi.c
 create mode 100644 include/acpi/cppc_acpi.h
drivers/acpi/Kconfig +14 -0
index 8a60b6e..54d73bb 100644
@@ -181,6 +181,20 @@ config ACPI_PROCESSOR_IDLE
 	def_bool y
 	depends on X86 || IA64
 
+config ACPI_CPPC_LIB
+	bool
+	depends on ACPI_PROCESSOR
+	depends on !ACPI_CPU_FREQ_PSS
+	select MAILBOX
+	select PCC
+	help
+	  This file implements common functionality to parse
+	  CPPC tables as described in the ACPI 5.1+ spec. The
+	  routines implemented are meant to be used by other
+	  drivers to control CPU performance using CPPC semantics.
+	  If your platform does not support CPPC in firmware,
+	  leave this option disabled.
+
 config ACPI_PROCESSOR
 	tristate "Processor"
 	select CPU_IDLE if ACPI_PROCESSOR_IDLE
drivers/acpi/Makefile +1 -0
index 0633af6..da520cb 100644
@@ -80,6 +80,7 @@ obj-$(CONFIG_ACPI_HED)		+= hed.o
 obj-$(CONFIG_ACPI_EC_DEBUGFS)	+= ec_sys.o
 obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
 obj-$(CONFIG_ACPI_BGRT)		+= bgrt.o
+obj-$(CONFIG_ACPI_CPPC_LIB)	+= cppc_acpi.o
 
 # processor has its own "processor." module_param namespace
 processor-y			:= processor_driver.o
drivers/acpi/cppc_acpi.c new file +812 -0

812 lines not on this page · raw message

include/acpi/cppc_acpi.h new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
1.9.1
#27 lore raw

PATCH v7 5/8 CPPC: Add a CPUFreq driver for use with CPPC

In reply to Ashwin Chaugule

This driver utilizes the methods introduced in the previous patch - "ACPI: Introduce CPU performance controls using CPPC" and enables usage with existing CPUFreq governors.

---
 drivers/cpufreq/Kconfig.arm    |  16 ++++
 drivers/cpufreq/Makefile       |   2 +
 drivers/cpufreq/cppc_cpufreq.c | 197 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 215 insertions(+)
 create mode 100644 drivers/cpufreq/cppc_cpufreq.c
drivers/cpufreq/Kconfig.arm +16 -0
index 4f3dbc8..578384d 100644
@@ -272,3 +272,19 @@ config ARM_PXA2xx_CPUFREQ
 	  This add the CPUFreq driver support for Intel PXA2xx SOCs.
 
 	  If in doubt, say N.
+
+config ACPI_CPPC_CPUFREQ
+	tristate "CPUFreq driver based on the ACPI CPPC spec"
+	depends on ACPI_CPPC_LIB
+	default n
+	help
+	  This adds a CPUFreq driver which uses CPPC methods
+	  as described in the ACPIv5.1 spec. CPPC stands for
+	  Collaborative Processor Performance Controls. It
+	  is based on an abstract continuous scale of CPU
+	  performance values which allows the remote power
+	  processor to flexibly optimize for power and
+	  performance. CPPC relies on power management firmware
+	  for its operation.
+
+	  If in doubt, say N.
drivers/cpufreq/Makefile +2 -0
index cdce92a..ef3779b 100644
@@ -79,6 +79,8 @@ obj-$(CONFIG_ARM_SA1110_CPUFREQ)	+= sa1110-cpufreq.o
 obj-$(CONFIG_ARM_SPEAR_CPUFREQ)		+= spear-cpufreq.o
 obj-$(CONFIG_ARM_TEGRA_CPUFREQ)		+= tegra-cpufreq.o
 obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ)	+= vexpress-spc-cpufreq.o
+obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o
+
 
 ##################################################################################
 # PowerPC platform drivers
drivers/cpufreq/cppc_cpufreq.c new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
1.9.1
#33 lore raw

PATCH v7 6/8 ACPI: Add weak routines for ACPI CPU Hotplug

In reply to Ashwin Chaugule

Add weak functions for architectures which do not support hot-adding and removing CPUs which aren't detected at bootup. (e.g. via MADT).

This helps preserve the Kconfig dependency from:

commit cbfc1bae55bb ("[ACPI] ACPI_HOTPLUG_CPU Kconfig dependency update")

prevent:

HOTPLUG_CPU=y
ACPI_PROCESSOR=y
ACPI_HOTPLUG_CPU=n

---
 drivers/acpi/acpi_processor.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/acpi/acpi_processor.c +18 -0
index 58f335c..1fbf252 100644
@@ -164,6 +164,24 @@ static int acpi_processor_errata(void)
    -------------------------------------------------------------------------- */
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
+int __weak acpi_map_cpu(acpi_handle handle,
+		phys_cpuid_t physid, int *pcpu)
+{
+	return -ENODEV;
+}
+
+int __weak acpi_unmap_cpu(int cpu)
+{
+	return -ENODEV;
+}
+
+int __weak arch_register_cpu(int cpu)
+{
+	return -ENODEV;
+}
+
+void __weak arch_unregister_cpu(int cpu) {}
+
 static int acpi_processor_hotadd_init(struct acpi_processor *pr)
 {
 	unsigned long long sta;
Signature · 1 line
1.9.1
#34 lore raw

PATCH v7 7/8 CPPC: Probe for CPPC tables for each ACPI Processor object

In reply to Ashwin Chaugule

For each detected ACPI Processor object (ACPI0007), search its device handle for CPPC specific tables (i.e. _CPC) and extract CPU specific performance capabilities.

---
 arch/arm64/Kconfig              | 1 +
 drivers/acpi/Kconfig            | 2 +-
 drivers/acpi/processor_driver.c | 4 ++++
 include/acpi/processor.h        | 9 +++++++++
 4 files changed, 15 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +1 -0
index 7796af4..feff114 100644
@@ -83,6 +83,7 @@ config ARM64
 	select SPARSE_IRQ
 	select SYSCTL_EXCEPTION_TRACE
 	select HAVE_CONTEXT_TRACKING
+	select ACPI_CPPC_LIB if ACPI
 	help
 	  ARM 64-bit (AArch64) Linux support.
 
drivers/acpi/Kconfig +1 -1
index 54d73bb..097c02a 100644
@@ -198,7 +198,7 @@ config ACPI_CPPC_LIB
 config ACPI_PROCESSOR
 	tristate "Processor"
 	select CPU_IDLE if ACPI_PROCESSOR_IDLE
-	depends on X86 || IA64
+	depends on X86 || IA64 || ARM64
 	default y
 	help
 	  This driver adds support for the ACPI Processor package. It is required
drivers/acpi/processor_driver.c +4 -0
index 16d44ad..ac3dd51 100644
@@ -246,6 +246,10 @@ static int __acpi_processor_start(struct acpi_device *device)
 	if (pr->flags.need_hotplug_init)
 		return 0;
 
+	result = acpi_cppc_processor_probe(pr);
+	if (result)
+		return -ENODEV;
+
 	if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver)
 		acpi_processor_power_init(pr);
 
include/acpi/processor.h +9 -0
index c071a92..6e53b5e 100644
@@ -328,6 +328,15 @@ phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
 int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id);
 int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
 
+#ifdef CONFIG_ACPI_CPPC_LIB
+extern int acpi_cppc_processor_probe(struct acpi_processor *pr);
+#else
+static inline int acpi_cppc_processor_probe(struct acpi_processor *pr)
+{
+	return 0;
+}
+#endif	/* CONFIG_ACPI_CPPC_LIB */
+
 /* in processor_pdc.c */
 void acpi_processor_set_pdc(acpi_handle handle);
 
Signature · 1 line
1.9.1
#36 lore raw

PATCH v7 8/8 PCC: Enable PCC only when needed

In reply to Ashwin Chaugule

CPPC is the first client to make use of the PCC Mailbox channel. So enable it only when CPPC is also enabled.

---
 drivers/mailbox/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/Kconfig +1 -1
index 84b0a2d..f2c30cc 100644
@@ -45,7 +45,7 @@ config OMAP_MBOX_KFIFO_SIZE
 
 config PCC
 	bool "Platform Communication Channel Driver"
-	depends on ACPI
+	depends on ACPI && ACPI_CPPC_LIB
 	help
 	  ACPI 5.0+ spec defines a generic mode of communication
 	  between the OS and a platform such as the BMC. This medium
Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Ashwin Chaugule
Quoted 49 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
 arch/x86/Kconfig                |  1 +
 drivers/acpi/Kconfig            | 19 ++++++---
 drivers/acpi/Makefile           |  6 +--
 drivers/acpi/processor_driver.c | 86 +++++++++++++++++++++++++------------
 drivers/cpufreq/Kconfig         |  2 +-
 drivers/cpufreq/Kconfig.x86     |  2 +
 include/acpi/processor.h        | 94 +++++++++++++++++++++++++++--------------
 7 files changed, 142 insertions(+), 68 deletions(-)
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
 	select ACPI_LEGACY_TABLES_LOOKUP if ACPI
 	select X86_FEATURE_NAMES if PROC_FS
 	select SRCU
+	select ACPI_CPU_FREQ_PSS if ACPI
 
 config INSTRUCTION_DECODER
 	def_bool y
drivers/acpi/Kconfig +0 -0
index ab2cbb5..00748dc 100644
@@ -166,17 +166,26 @@ config ACPI_DOCK
 	  This driver supports ACPI-controlled docking stations and removable
 	  drive bays such as the IBM Ultrabay and the Dell Module Bay.
 

drivers/acpi/Kconfig config ACPI_DOCK · line 178

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+config ACPI_CPU_FREQ_PSS
+	bool
+	depends on ACPI_PROCESSOR && CPU_FREQ
+	select THERMAL
+	help
+	  This driver implements ACPI methods for controlling CPU performance
+	  using PSS methods as described in the ACPI spec. It also enables support
+	  for ACPI based performance throttling (TSS) and ACPI based thermal
+	  monitoring. It is required by several flavors of cpufreq
+	  performance-state drivers.

So are you not agreeing with what I've said for a few times already or are you just not listening?

This option should *not* be user-selectable. So please drop the help part and make it look like ACPI_SLEEP, for example.

Thanks,
Rafael

#6 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

Quoted 30 lines · Rafael J. Wysocki
Quoted 29 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
 arch/x86/Kconfig                |  1 +
 drivers/acpi/Kconfig            | 19 ++++++---
 drivers/acpi/Makefile           |  6 +--
 drivers/acpi/processor_driver.c | 86 +++++++++++++++++++++++++------------
 drivers/cpufreq/Kconfig         |  2 +-
 drivers/cpufreq/Kconfig.x86     |  2 +
 include/acpi/processor.h        | 94 +++++++++++++++++++++++++++--------------
 7 files changed, 142 insertions(+), 68 deletions(-)
Quoted 9 lines

arch/x86/Kconfig config X86 · line 146

Quoted 9 lines
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
 	select ACPI_LEGACY_TABLES_LOOKUP if ACPI
 	select X86_FEATURE_NAMES if PROC_FS
 	select SRCU
+	select ACPI_CPU_FREQ_PSS if ACPI

Also, does ia64 not use _PSS-based cpufreq?

Thanks,
Rafael

#2 lore raw

Re: [PATCH v7 1/8] PCC: Initialize PCC Mailbox earlier at boot

In reply to Ashwin Chaugule
Quoted 20 lines · Ashwin Chaugule

This change initializes the PCC Mailbox earlier than the ACPI processor driver. This enables drivers introduced in follow up patches (e.g. CPPC) to be probed via the ACPI processor driver interface. The CPPC probe requires the PCC channel to be initialized for it to query each CPUs performance capabilities.

---
  drivers/mailbox/pcc.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +0 -0
index 7e91d68..fcda63e 100644
@@ -352,4 +352,10 @@ static int __init pcc_init(void)
 

drivers/mailbox/pcc.c static int __init pcc_init(void) · line 361

Quoted 10 lines
drivers/mailbox/pcc.c +7 -1
  	return 0;
  }
-device_initcall(pcc_init);
+
+/*
+ * Make pcc init postcore so that users of this mailbox
+ * such as the ACPI Processor driver have it available
+ * at their init.
+ */
+postcore_initcall(pcc_init);

I assumed you have explored other options like deferred probe and finally resorted to this as they are not feasible ? Because setting up these kind of dependency are prone to create issues later on.

Regards,
Sudeep

#9 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Ashwin Chaugule
Quoted 50 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
  arch/x86/Kconfig                |  1 +
  drivers/acpi/Kconfig            | 19 ++++++---
  drivers/acpi/Makefile           |  6 +--
  drivers/acpi/processor_driver.c | 86 +++++++++++++++++++++++++------------
  drivers/cpufreq/Kconfig         |  2 +-
  drivers/cpufreq/Kconfig.x86     |  2 +
  include/acpi/processor.h        | 94 +++++++++++++++++++++++++++--------------
  7 files changed, 142 insertions(+), 68 deletions(-)
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
         select ACPI_LEGACY_TABLES_LOOKUP if ACPI
         select X86_FEATURE_NAMES if PROC_FS
         select SRCU
+       select ACPI_CPU_FREQ_PSS if ACPI
 
  config INSTRUCTION_DECODER
         def_bool y
drivers/acpi/Kconfig +1 -0
index ab2cbb5..00748dc 100644
@@ -166,17 +166,26 @@ config ACPI_DOCK
           This driver supports ACPI-controlled docking stations and removable
           drive bays such as the IBM Ultrabay and the Dell Module Bay.
 
+config ACPI_CPU_FREQ_PSS

drivers/acpi/Kconfig config ACPI_DOCK · line 179

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+       bool
+       depends on ACPI_PROCESSOR && CPU_FREQ
+       select THERMAL
+       help
+         This driver implements ACPI methods for controlling CPU performance
+         using PSS methods as described in the ACPI spec. It also enables support
+         for ACPI based performance throttling (TSS) and ACPI based thermal
+         monitoring. It is required by several flavors of cpufreq
+         performance-state drivers.
+

Though I agree CPUFreq and the thermal control are related, having _PSS in config name shouldn't match well IMO. You can have more generic name.

You are selecting one config while depending on the other, any particular reason ?

I don't like adding these, but I leave it to Rafael.

Regards,
Sudeep

#15 lore raw

Re: [PATCH v7 3/8] ACPI: Decouple ACPI idle and ACPI processor drivers

In reply to Ashwin Chaugule
Quoted 25 lines · Ashwin Chaugule

This patch introduces a new Kconfig symbol, ACPI_PROCESSOR_IDLE, which is auto selected by architectures which support the ACPI based C states for CPU Idle management.

The processor_idle driver in its present form contains declarations specific to X86 and IA64. Since there are no reasonable defaults for other architectures e.g. ARM64, the driver is selected only by the arch/x86/Kconfig.

This helps in decoupling the ACPI processor_driver from the ACPI processor_idle driver which is useful for the upcoming alternative patchwork for controlling CPU Performance (CPPC) and CPU Idle (LPI).

---
  drivers/acpi/Kconfig     |  6 +++++-
  drivers/acpi/Makefile    |  3 ++-
  include/acpi/processor.h | 26 ++++++++++++++++++++++++--
  3 files changed, 31 insertions(+), 4 deletions(-)
drivers/acpi/Kconfig +0 -0
index 00748dc..8a60b6e 100644

drivers/acpi/Kconfig config ACPI_CPU_FREQ_PSS · line 183

Quoted 7 lines
drivers/acpi/Kconfig +4 -0
@@ -177,9 +177,13 @@ config ACPI_CPU_FREQ_PSS
  	  monitoring. It is required by several flavors of cpufreq
  	  performance-state drivers.
 
+config ACPI_PROCESSOR_IDLE
+	def_bool y
+	depends on X86 || IA64
+

In general, you need to split this series so that initially few patches deal with all the existing Kconfig fix-ups and then introduce PCC/PSS/CPPC related stuffs. That would help me rebase and test _LPI support.

Regards,
Sudeep

#28 lore raw

Re: [PATCH v7 5/8] CPPC: Add a CPUFreq driver for use with CPPC

In reply to Ashwin Chaugule
Quoted 25 lines · Ashwin Chaugule

This driver utilizes the methods introduced in the previous patch - "ACPI: Introduce CPU performance controls using CPPC" and enables usage with existing CPUFreq governors.

---
  drivers/cpufreq/Kconfig.arm    |  16 ++++
  drivers/cpufreq/Makefile       |   2 +
  drivers/cpufreq/cppc_cpufreq.c | 197 +++++++++++++++++++++++++++++++++++++++++
  3 files changed, 215 insertions(+)

create mode 100644 drivers/cpufreq/cppc_cpufreq.c

drivers/cpufreq/Kconfig.arm +4 -0
index 4f3dbc8..578384d 100644
@@ -272,3 +272,19 @@ config ARM_PXA2xx_CPUFREQ
  	  This add the CPUFreq driver support for Intel PXA2xx SOCs.
 
  	  If in doubt, say N.
+
+config ACPI_CPPC_CPUFREQ
+	tristate "CPUFreq driver based on the ACPI CPPC spec"
+	depends on ACPI_CPPC_LIB

drivers/cpufreq/Kconfig.arm config ARM_PXA2xx_CPUFREQ · line 288

Quoted 10 lines
drivers/cpufreq/Kconfig.arm +10 -0
+	default n
+	help
+	  This adds a CPUFreq driver which uses CPPC methods
+	  as described in the ACPIv5.1 spec. CPPC stands for
+	  Collaborative Processor Performance Controls. It
+	  is based on an abstract continuous scale of CPU
+	  performance values which allows the remote power
+	  processor to flexibly optimize for power and
+	  performance. CPPC relies on power management firmware
+	  for its operation.

Why is this ARM specific ? It might be used only on ARM but doesn't mean it should be visible only on ARM ACPI systems.

Regards,
Sudeep

#35 lore raw

Re: [PATCH v7 7/8] CPPC: Probe for CPPC tables for each ACPI Processor object

In reply to Ashwin Chaugule
Quoted 18 lines · Ashwin Chaugule

For each detected ACPI Processor object (ACPI0007), search its device handle for CPPC specific tables (i.e. _CPC) and extract CPU specific performance capabilities.

---
  arch/arm64/Kconfig              | 1 +
  drivers/acpi/Kconfig            | 2 +-
  drivers/acpi/processor_driver.c | 4 ++++
  include/acpi/processor.h        | 9 +++++++++
  4 files changed, 15 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +0 -0
index 7796af4..feff114 100644

arch/arm64/Kconfig config ARM64 · line 86

Quoted 4 lines
arch/arm64/Kconfig +1 -0
@@ -83,6 +83,7 @@ config ARM64
  	select SPARSE_IRQ
  	select SYSCTL_EXCEPTION_TRACE
  	select HAVE_CONTEXT_TRACKING
+	select ACPI_CPPC_LIB if ACPI

This could be separate patch. It's doesn't match with $subject and usually better to keep arm64 specific changes separate.

drivers/acpi/Kconfig config ACPI_CPPC_LIB · line 201

Quoted 13 lines
arch/arm64/Kconfig +0 -0
  	help
  	  ARM 64-bit (AArch64) Linux support.
 
drivers/acpi/Kconfig +1 -1
index 54d73bb..097c02a 100644
@@ -198,7 +198,7 @@ config ACPI_CPPC_LIB
  config ACPI_PROCESSOR
  	tristate "Processor"
  	select CPU_IDLE if ACPI_PROCESSOR_IDLE
-	depends on X86 || IA64
+	depends on X86 || IA64 || ARM64

Ditto

Regards,
Sudeep

#37 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

In reply to Ashwin Chaugule
Quoted 3 lines · Ashwin Chaugule

CPPC is the first client to make use of the PCC Mailbox channel. So enable it only when CPPC is also enabled.

This sounds like a reverse dependency to me. So if there's some client unrelated to CPPC using PCC, CPPC_LIB needs to be selected to enable PCC ?

Regards,
Sudeep

#10 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Sudeep Holla
Quoted 66 lines · Sudeep Holla
Quoted 50 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
  arch/x86/Kconfig                |  1 +
  drivers/acpi/Kconfig            | 19 ++++++---
  drivers/acpi/Makefile           |  6 +--
  drivers/acpi/processor_driver.c | 86 +++++++++++++++++++++++++------------
  drivers/cpufreq/Kconfig         |  2 +-
  drivers/cpufreq/Kconfig.x86     |  2 +
  include/acpi/processor.h        | 94 +++++++++++++++++++++++++++--------------
  7 files changed, 142 insertions(+), 68 deletions(-)
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
         select ACPI_LEGACY_TABLES_LOOKUP if ACPI
         select X86_FEATURE_NAMES if PROC_FS
         select SRCU
+       select ACPI_CPU_FREQ_PSS if ACPI
 
  config INSTRUCTION_DECODER
         def_bool y
drivers/acpi/Kconfig +1 -0
index ab2cbb5..00748dc 100644
@@ -166,17 +166,26 @@ config ACPI_DOCK
           This driver supports ACPI-controlled docking stations and removable
           drive bays such as the IBM Ultrabay and the Dell Module Bay.
 
+config ACPI_CPU_FREQ_PSS

drivers/acpi/Kconfig config ACPI_DOCK · line 179

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+       bool
+       depends on ACPI_PROCESSOR && CPU_FREQ
+       select THERMAL
+       help
+         This driver implements ACPI methods for controlling CPU performance
+         using PSS methods as described in the ACPI spec. It also enables support
+         for ACPI based performance throttling (TSS) and ACPI based thermal
+         monitoring. It is required by several flavors of cpufreq
+         performance-state drivers.
+

Though I agree CPUFreq and the thermal control are related, having _PSS in config name shouldn't match well IMO. You can have more generic name.

Quoted 4 lines

You are selecting one config while depending on the other, any particular reason ?

I don't like adding these, but I leave it to Rafael.

My opinion is analogous. :-)

I *guess* the idea was to avoid selecting ACPI_CPU_FREQ_PSS withouth ACPI_PROCESSOR so we don't build unnecessary code. That's a good point, but I would also like to keep they way ACPI_PROCESSOR works on x86 and ia64 without adding new user-selectable Kconfig options.

So, what about this:

config ACPI_PROCESSOR
tristate "Processor"
select THERMAL
select CPU_IDLE
- depends on X86 || IA64
+ select ACPI_CPU_FREQ_PSS if X86 || IA64
default y
help
This driver installs ACPI as the idle handler for Linux and uses

and define ACPI_CPU_FREQ_PSS in analogy with ACPI_CCA_REQUIRED for example?

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#38 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

In reply to Sudeep Holla
Quoted 7 lines · Sudeep Holla
Quoted 3 lines · Ashwin Chaugule

CPPC is the first client to make use of the PCC Mailbox channel. So enable it only when CPPC is also enabled.

This sounds like a reverse dependency to me. So if there's some client unrelated to CPPC using PCC, CPPC_LIB needs to be selected to enable PCC ?

No. The other client will need to select PCC too.

I requested that change, because I'm slightly bothered by the fact that we build code used by no one by default.

Thanks,
Rafael

#29 lore raw

Re: [PATCH v7 5/8] CPPC: Add a CPUFreq driver for use with CPPC

In reply to Sudeep Holla
Quoted 32 lines · Sudeep Holla
Quoted 30 lines · Ashwin Chaugule

This driver utilizes the methods introduced in the previous patch - "ACPI: Introduce CPU performance controls using CPPC" and enables usage with existing CPUFreq governors.

---
  drivers/cpufreq/Kconfig.arm    |  16 ++++
  drivers/cpufreq/Makefile       |   2 +
  drivers/cpufreq/cppc_cpufreq.c | 197 +++++++++++++++++++++++++++++++++++++++++
  3 files changed, 215 insertions(+)

create mode 100644 drivers/cpufreq/cppc_cpufreq.c

drivers/cpufreq/Kconfig.arm +9 -0
index 4f3dbc8..578384d 100644
@@ -272,3 +272,19 @@ config ARM_PXA2xx_CPUFREQ
  	  This add the CPUFreq driver support for Intel PXA2xx SOCs.
 
  	  If in doubt, say N.
+
+config ACPI_CPPC_CPUFREQ
+	tristate "CPUFreq driver based on the ACPI CPPC spec"
+	depends on ACPI_CPPC_LIB
+	default n
+	help
+	  This adds a CPUFreq driver which uses CPPC methods
+	  as described in the ACPIv5.1 spec. CPPC stands for
+	  Collaborative Processor Performance Controls. It
Quoted 8 lines

drivers/cpufreq/Kconfig.arm config ARM_PXA2xx_CPUFREQ · line 288

Quoted 5 lines
drivers/cpufreq/Kconfig.arm +5 -0
+	  is based on an abstract continuous scale of CPU
+	  performance values which allows the remote power
+	  processor to flexibly optimize for power and
+	  performance. CPPC relies on power management firmware
+	  for its operation.

Why is this ARM specific ? It might be used only on ARM but doesn't mean it should be visible only on ARM ACPI systems.

Why bother people with considering Kconfig options that are useless to them?

Thanks,
Rafael

#30 lore raw

Re: [PATCH v7 5/8] CPPC: Add a CPUFreq driver for use with CPPC

Quoted 42 lines · Rafael J. Wysocki
Quoted 32 lines · Sudeep Holla
Quoted 30 lines · Ashwin Chaugule

This driver utilizes the methods introduced in the previous patch - "ACPI: Introduce CPU performance controls using CPPC" and enables usage with existing CPUFreq governors.

---
   drivers/cpufreq/Kconfig.arm    |  16 ++++
   drivers/cpufreq/Makefile       |   2 +
   drivers/cpufreq/cppc_cpufreq.c | 197 +++++++++++++++++++++++++++++++++++++++++
   3 files changed, 215 insertions(+)

create mode 100644 drivers/cpufreq/cppc_cpufreq.c

drivers/cpufreq/Kconfig.arm +9 -0
index 4f3dbc8..578384d 100644
@@ -272,3 +272,19 @@ config ARM_PXA2xx_CPUFREQ
   	  This add the CPUFreq driver support for Intel PXA2xx SOCs.
 
   	  If in doubt, say N.
+
+config ACPI_CPPC_CPUFREQ
+	tristate "CPUFreq driver based on the ACPI CPPC spec"
+	depends on ACPI_CPPC_LIB
+	default n
+	help
+	  This adds a CPUFreq driver which uses CPPC methods
+	  as described in the ACPIv5.1 spec. CPPC stands for
+	  Collaborative Processor Performance Controls. It
Quoted 8 lines

drivers/cpufreq/Kconfig.arm config ARM_PXA2xx_CPUFREQ · line 288

Quoted 5 lines
drivers/cpufreq/Kconfig.arm +5 -0
+	  is based on an abstract continuous scale of CPU
+	  performance values which allows the remote power
+	  processor to flexibly optimize for power and
+	  performance. CPPC relies on power management firmware
+	  for its operation.

Why is this ARM specific ? It might be used only on ARM but doesn't mean it should be visible only on ARM ACPI systems.

Quoted 2 lines

Why bother people with considering Kconfig options that are useless to them?

I agree to some extent, but main worry is that we are then making these features architecture specific while ACPI is supposed to be architecture agnostic. I was just trying to avoid doing so.

Regards,
Sudeep

#39 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

In reply to Rafael J. Wysocki
Quoted 10 lines · Rafael J. Wysocki
Quoted 7 lines · Sudeep Holla
Quoted 3 lines · Ashwin Chaugule

CPPC is the first client to make use of the PCC Mailbox channel. So enable it only when CPPC is also enabled.

This sounds like a reverse dependency to me. So if there's some client unrelated to CPPC using PCC, CPPC_LIB needs to be selected to enable PCC ?

No. The other client will need to select PCC too.

Yes the PCC users/clients selecting PCC is fine and that's already done(i.e. ACPI_CPPC_LIB selects PCC). I still don't understand the need for this change, also how will other clients possibly select PCC which now depends on CPPC_LIB ? e.g. if we have

config ACPI_XYZ_LIB
select PCC

config ACPI_XYZ
select ACPI_XYZ_LIB

Won't this shout warning: (ACPI_XYZ_LIB && ACPI_CPPC_LIB) selects PCC which has unmet direct dependencies (MAILBOX && ACPI && ACPI_CPPC_LIB) if ACPI_CPPC_LIB is not selected ?

OK, for now we enable ACPI_CPPC_LIB on ARM64 and not on x86. When x86 has a PCC client how will that select PCC without ACPI_CPPC_LIB. Sorry if I am missing to understand something.

Quoted 4 lines

I requested that change, because I'm slightly bothered by the fact that we build code used by no one by default.

I understand, but will keeping them default off should suffice ? No ?

Regards,
Sudeep

#31 lore raw

Re: [PATCH v7 5/8] CPPC: Add a CPUFreq driver for use with CPPC

In reply to Sudeep Holla

Hi Sudeep,

Quoted 52 lines · Sudeep Holla
Quoted 49 lines · Rafael J. Wysocki
Quoted 45 lines · Sudeep Holla
Quoted 28 lines · Ashwin Chaugule

This driver utilizes the methods introduced in the previous patch - "ACPI: Introduce CPU performance controls using CPPC" and enables usage with existing CPUFreq governors.

---
   drivers/cpufreq/Kconfig.arm    |  16 ++++
   drivers/cpufreq/Makefile       |   2 +
   drivers/cpufreq/cppc_cpufreq.c | 197
+++++++++++++++++++++++++++++++++++++++++
   3 files changed, 215 insertions(+)

create mode 100644 drivers/cpufreq/cppc_cpufreq.c

drivers/cpufreq/Kconfig.arm +4 -0
index 4f3dbc8..578384d 100644
@@ -272,3 +272,19 @@ config ARM_PXA2xx_CPUFREQ
          This add the CPUFreq driver support for Intel PXA2xx SOCs.
 
          If in doubt, say N.
+
+config ACPI_CPPC_CPUFREQ
+       tristate "CPUFreq driver based on the ACPI CPPC spec"
+       depends on ACPI_CPPC_LIB

drivers/cpufreq/Kconfig.arm config ARM_PXA2xx_CPUFREQ · line 288

Quoted 10 lines
drivers/cpufreq/Kconfig.arm +10 -0
+       default n
+       help
+         This adds a CPUFreq driver which uses CPPC methods
+         as described in the ACPIv5.1 spec. CPPC stands for
+         Collaborative Processor Performance Controls. It
+         is based on an abstract continuous scale of CPU
+         performance values which allows the remote power
+         processor to flexibly optimize for power and
+         performance. CPPC relies on power management firmware
+         for its operation.

Why is this ARM specific ? It might be used only on ARM but doesn't mean it should be visible only on ARM ACPI systems.

Quoted 7 lines
Quoted 3 lines

Why bother people with considering Kconfig options that are useless to them?

I agree to some extent, but main worry is that we are then making these features architecture specific while ACPI is supposed to be architecture agnostic. I was just trying to avoid doing so.

Problem is, there are no plans to support CPPC on x86 in Linux I'm aware of and so we should not use it even if it is exposed by the firmware (Windows may be using it, though).

I'm also not aware of plans to support _PSS on ARM.

So, even though on the spec level they are arch-independent, the way we use those interfaces in the kernel isn't.

Thanks,
Rafael

#40 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

In reply to Sudeep Holla

Hi Sudeep,

Quoted 28 lines · Sudeep Holla
Quoted 9 lines · Rafael J. Wysocki
Quoted 7 lines · Sudeep Holla
Quoted 4 lines · Ashwin Chaugule

CPPC is the first client to make use of the PCC Mailbox channel. So enable it only when CPPC is also enabled.

Quoted 6 lines
Quoted 3 lines

This sounds like a reverse dependency to me. So if there's some client unrelated to CPPC using PCC, CPPC_LIB needs to be selected to enable PCC ?

No. The other client will need to select PCC too.

Yes the PCC users/clients selecting PCC is fine and that's already done(i.e. ACPI_CPPC_LIB selects PCC). I still don't understand the need for this change, also how will other clients possibly select PCC which now depends on CPPC_LIB ? e.g. if we have

config ACPI_XYZ_LIB
select PCC

Quoted 6 lines

config ACPI_XYZ
select ACPI_XYZ_LIB

Won't this shout warning: (ACPI_XYZ_LIB && ACPI_CPPC_LIB) selects PCC which has unmet direct dependencies (MAILBOX && ACPI && ACPI_CPPC_LIB) if ACPI_CPPC_LIB is not selected ?

That depends on the "depends on" clauses used. Selecting itself doesn't cause any dependencies to appear.

Quoted 3 lines

OK, for now we enable ACPI_CPPC_LIB on ARM64 and not on x86. When x86 has a PCC client how will that select PCC without ACPI_CPPC_LIB. Sorry if I am missing to understand something.

Presumably, the new feature will have a Kconfig option associated with it and it will do "select PCC" too.

Quoted 6 lines
Quoted 4 lines

I requested that change, because I'm slightly bothered by the fact that we build code used by no one by default.

I understand, but will keeping them default off should suffice ? No ?

Yes, it should. But is it the case now?

Thanks,
Rafael

#41 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

Hi Rafael,

Quoted 34 lines · Rafael J. Wysocki

Hi Sudeep,

Quoted 31 lines · Sudeep Holla
Quoted 9 lines · Rafael J. Wysocki
Quoted 7 lines · Sudeep Holla
Quoted 4 lines · Ashwin Chaugule

CPPC is the first client to make use of the PCC Mailbox channel. So enable it only when CPPC is also enabled.

Quoted 6 lines
Quoted 3 lines

This sounds like a reverse dependency to me. So if there's some client unrelated to CPPC using PCC, CPPC_LIB needs to be selected to enable PCC ?

No. The other client will need to select PCC too.

Yes the PCC users/clients selecting PCC is fine and that's already done(i.e. ACPI_CPPC_LIB selects PCC). I still don't understand the need for this change, also how will other clients possibly select PCC which now depends on CPPC_LIB ? e.g. if we have

config ACPI_XYZ_LIB
select PCC

config ACPI_XYZ
select ACPI_XYZ_LIB

Quoted 7 lines
Quoted 3 lines

Won't this shout warning: (ACPI_XYZ_LIB && ACPI_CPPC_LIB) selects PCC which has unmet direct dependencies (MAILBOX && ACPI && ACPI_CPPC_LIB) if ACPI_CPPC_LIB is not selected ?

That depends on the "depends on" clauses used. Selecting itself doesn't cause any dependencies to appear.

Agreed and I am absolutely fine with that. But if you look at this patch, it does

config PCC

	bool "Platform Communication Channel Driver"
	depends on ACPI && ACPI_CPPC_LIB

I am fine with ACPI_CPPC_LIB selecting PCC which is already done in earlier patch. I am against making PCC depend on ACPI_CPPC_LIB.

Lets assume it's fine to do that. Now if another feature XYZ as in my example say on x86 selects PCC then you will *get warnings* as we will not able to select PCC without selecting ACPI_CPPC_LIB after this patch and x86 will never select ACPI_CPPC_LIB. I did test something like my XYZ example and it did trigger the warning as I suspected.

I am sorry either I am missing to understand again or unable to express the problem here :(

Quoted 7 lines
Quoted 3 lines

OK, for now we enable ACPI_CPPC_LIB on ARM64 and not on x86. When x86 has a PCC client how will that select PCC without ACPI_CPPC_LIB. Sorry if I am missing to understand something.

Presumably, the new feature will have a Kconfig option associated with it and it will do "select PCC" too.

As I say I am fine with that and no arguments there.

Regards,
Sudeep

#32 lore raw

Re: [PATCH v7 5/8] CPPC: Add a CPUFreq driver for use with CPPC

In reply to Rafael J. Wysocki

Hi Rafael,

Quoted 59 lines · Rafael J. Wysocki

Hi Sudeep,

Quoted 56 lines · Sudeep Holla
Quoted 52 lines · Rafael J. Wysocki
Quoted 37 lines · Sudeep Holla
Quoted 34 lines · Ashwin Chaugule

This driver utilizes the methods introduced in the previous patch - "ACPI: Introduce CPU performance controls using CPPC" and enables usage with existing CPUFreq governors.

---
    drivers/cpufreq/Kconfig.arm    |  16 ++++
    drivers/cpufreq/Makefile       |   2 +
    drivers/cpufreq/cppc_cpufreq.c | 197
+++++++++++++++++++++++++++++++++++++++++
    3 files changed, 215 insertions(+)

create mode 100644 drivers/cpufreq/cppc_cpufreq.c

drivers/cpufreq/Kconfig.arm +10 -0
index 4f3dbc8..578384d 100644
@@ -272,3 +272,19 @@ config ARM_PXA2xx_CPUFREQ
           This add the CPUFreq driver support for Intel PXA2xx SOCs.
 
           If in doubt, say N.
+
+config ACPI_CPPC_CPUFREQ
+       tristate "CPUFreq driver based on the ACPI CPPC spec"
+       depends on ACPI_CPPC_LIB
+       default n
+       help
+         This adds a CPUFreq driver which uses CPPC methods
+         as described in the ACPIv5.1 spec. CPPC stands for
+         Collaborative Processor Performance Controls. It
+         is based on an abstract continuous scale of CPU
Quoted 8 lines

drivers/cpufreq/Kconfig.arm config ARM_PXA2xx_CPUFREQ · line 288

Quoted 4 lines
drivers/cpufreq/Kconfig.arm +4 -0
+         performance values which allows the remote power
+         processor to flexibly optimize for power and
+         performance. CPPC relies on power management firmware
+         for its operation.

Why is this ARM specific ? It might be used only on ARM but doesn't mean it should be visible only on ARM ACPI systems.

Why bother people with considering Kconfig options that are useless to them?

Quoted 8 lines
Quoted 3 lines

I agree to some extent, but main worry is that we are then making these features architecture specific while ACPI is supposed to be architecture agnostic. I was just trying to avoid doing so.

Problem is, there are no plans to support CPPC on x86 in Linux I'm aware of and so we should not use it even if it is exposed by the firmware (Windows may be using it, though).

Ah that makes sense.

Quoted 1 line

I'm also not aware of plans to support _PSS on ARM.

Agreed, but you never know what ARM vendors can do :)

Quoted 4 lines

So, even though on the spec level they are arch-independent, the way we use those interfaces in the kernel isn't.

Understood.

Regards,
Sudeep

#42 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

In reply to Sudeep Holla
Quoted 45 lines · Sudeep Holla

Hi Rafael,

Quoted 34 lines · Rafael J. Wysocki

Hi Sudeep,

Quoted 31 lines · Sudeep Holla
Quoted 9 lines · Rafael J. Wysocki
Quoted 7 lines · Sudeep Holla
Quoted 4 lines · Ashwin Chaugule

CPPC is the first client to make use of the PCC Mailbox channel. So enable it only when CPPC is also enabled.

Quoted 6 lines
Quoted 3 lines

This sounds like a reverse dependency to me. So if there's some client unrelated to CPPC using PCC, CPPC_LIB needs to be selected to enable PCC ?

No. The other client will need to select PCC too.

Yes the PCC users/clients selecting PCC is fine and that's already done(i.e. ACPI_CPPC_LIB selects PCC). I still don't understand the need for this change, also how will other clients possibly select PCC which now depends on CPPC_LIB ? e.g. if we have

config ACPI_XYZ_LIB
select PCC

config ACPI_XYZ
select ACPI_XYZ_LIB

Quoted 7 lines
Quoted 3 lines

Won't this shout warning: (ACPI_XYZ_LIB && ACPI_CPPC_LIB) selects PCC which has unmet direct dependencies (MAILBOX && ACPI && ACPI_CPPC_LIB) if ACPI_CPPC_LIB is not selected ?

That depends on the "depends on" clauses used. Selecting itself doesn't cause any dependencies to appear.

Quoted 6 lines

Agreed and I am absolutely fine with that. But if you look at this patch, it does

config PCC

	bool "Platform Communication Channel Driver"
	depends on ACPI && ACPI_CPPC_LIB

My bad, I've evidently overlooked that.

If PPC is selected from ACPI_CPPC_LIB, the "depends on" above is obviously not needed.

Quoted 2 lines

I am fine with ACPI_CPPC_LIB selecting PCC which is already done in earlier patch. I am against making PCC depend on ACPI_CPPC_LIB.

OK, makes sense. Sorry for the misunderstanding.

Thanks,
Rafael

#43 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Sudeep Holla

Hi Rafael,

Quoted 6 lines · Rafael J. Wysocki

Hi Sudeep,

Quoted 3 lines · Sudeep Holla

On 20/07/15 23:04, Rafael J. Wysocki wrote:

[..]

Quoted 27 lines
Quoted 27 lines
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines

No. The other client will need to select PCC too.

Yes the PCC users/clients selecting PCC is fine and that's already done(i.e. ACPI_CPPC_LIB selects PCC). I still don't understand the need for this change, also how will other clients possibly select PCC which now depends on CPPC_LIB ? e.g. if we have

config ACPI_XYZ_LIB
select PCC

config ACPI_XYZ
select ACPI_XYZ_LIB

Quoted 7 lines
Quoted 3 lines

Won't this shout warning: (ACPI_XYZ_LIB && ACPI_CPPC_LIB) selects PCC which has unmet direct dependencies (MAILBOX && ACPI && ACPI_CPPC_LIB) if ACPI_CPPC_LIB is not selected ?

That depends on the "depends on" clauses used. Selecting itself doesn't cause any dependencies to appear.

Agreed and I am absolutely fine with that. But if you look at this patch, it does

Quoted 9 lines
Quoted 3 lines

config PCC

	bool "Platform Communication Channel Driver"
	depends on ACPI && ACPI_CPPC_LIB

My bad, I've evidently overlooked that.

If PPC is selected from ACPI_CPPC_LIB, the "depends on" above is obviously not needed.

Thanks for the confirmation.

Quoted 5 lines
Quoted 2 lines

I am fine with ACPI_CPPC_LIB selecting PCC which is already done in earlier patch. I am against making PCC depend on ACPI_CPPC_LIB.

OK, makes sense. Sorry for the misunderstanding.

It's okay, I just wanted to make sure that I am not missing to understand some kind of dependency.

Regards,
Sudeep

#8 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Rafael J. Wysocki
Quoted 64 lines · Rafael J. Wysocki
Quoted 49 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
 arch/x86/Kconfig                |  1 +
 drivers/acpi/Kconfig            | 19 ++++++---
 drivers/acpi/Makefile           |  6 +--
 drivers/acpi/processor_driver.c | 86 +++++++++++++++++++++++++------------
 drivers/cpufreq/Kconfig         |  2 +-
 drivers/cpufreq/Kconfig.x86     |  2 +
 include/acpi/processor.h        | 94 +++++++++++++++++++++++++++--------------
 7 files changed, 142 insertions(+), 68 deletions(-)
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
      select ACPI_LEGACY_TABLES_LOOKUP if ACPI
      select X86_FEATURE_NAMES if PROC_FS
      select SRCU
+     select ACPI_CPU_FREQ_PSS if ACPI
 
 config INSTRUCTION_DECODER
      def_bool y
drivers/acpi/Kconfig +0 -0
index ab2cbb5..00748dc 100644
@@ -166,17 +166,26 @@ config ACPI_DOCK
        This driver supports ACPI-controlled docking stations and removable
        drive bays such as the IBM Ultrabay and the Dell Module Bay.
 

drivers/acpi/Kconfig config ACPI_DOCK · line 178

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+config ACPI_CPU_FREQ_PSS
+     bool
+     depends on ACPI_PROCESSOR && CPU_FREQ
+     select THERMAL
+     help
+       This driver implements ACPI methods for controlling CPU performance
+       using PSS methods as described in the ACPI spec. It also enables support
+       for ACPI based performance throttling (TSS) and ACPI based thermal
+       monitoring. It is required by several flavors of cpufreq
+       performance-state drivers.

So are you not agreeing with what I've said for a few times already or are you just not listening?

Quoted 2 lines

This option should *not* be user-selectable. So please drop the help part and make it look like ACPI_SLEEP, for example.

Fine. I followed some other examples in the kernel. As long as there is no text after the 'bool', it doesn't show up as a user configurable option in the menuconfig. Having some help text even in such cases seemed helpful to me.

Thanks,
Ashwin.

#7 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Rafael J. Wysocki
Quoted 31 lines · Rafael J. Wysocki
Quoted 30 lines · Rafael J. Wysocki
Quoted 29 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
 arch/x86/Kconfig                |  1 +
 drivers/acpi/Kconfig            | 19 ++++++---
 drivers/acpi/Makefile           |  6 +--
 drivers/acpi/processor_driver.c | 86 +++++++++++++++++++++++++------------
 drivers/cpufreq/Kconfig         |  2 +-
 drivers/cpufreq/Kconfig.x86     |  2 +
 include/acpi/processor.h        | 94 +++++++++++++++++++++++++++--------------
 7 files changed, 142 insertions(+), 68 deletions(-)
Quoted 11 lines
Quoted 9 lines

arch/x86/Kconfig config X86 · line 146

Quoted 9 lines
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
    select ACPI_LEGACY_TABLES_LOOKUP if ACPI
    select X86_FEATURE_NAMES if PROC_FS
    select SRCU
+   select ACPI_CPU_FREQ_PSS if ACPI

Also, does ia64 not use _PSS-based cpufreq?

True. Will add to the IA64 Kconfig.

Thanks,
Ashwin.

#12 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Sudeep Holla
Quoted 66 lines · Sudeep Holla
Quoted 63 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
  arch/x86/Kconfig                |  1 +
  drivers/acpi/Kconfig            | 19 ++++++---
  drivers/acpi/Makefile           |  6 +--
  drivers/acpi/processor_driver.c | 86
+++++++++++++++++++++++++------------
  drivers/cpufreq/Kconfig         |  2 +-
  drivers/cpufreq/Kconfig.x86     |  2 +
  include/acpi/processor.h        | 94
+++++++++++++++++++++++++++--------------
  7 files changed, 142 insertions(+), 68 deletions(-)
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
         select ACPI_LEGACY_TABLES_LOOKUP if ACPI
         select X86_FEATURE_NAMES if PROC_FS
         select SRCU
+       select ACPI_CPU_FREQ_PSS if ACPI
 
  config INSTRUCTION_DECODER
         def_bool y
drivers/acpi/Kconfig +0 -0
index ab2cbb5..00748dc 100644
@@ -166,17 +166,26 @@ config ACPI_DOCK
           This driver supports ACPI-controlled docking stations and

removable
drive bays such as the IBM Ultrabay and the Dell Module Bay.

drivers/acpi/Kconfig +6 -0
+config ACPI_CPU_FREQ_PSS
+       bool
+       depends on ACPI_PROCESSOR && CPU_FREQ
+       select THERMAL
+       help
+         This driver implements ACPI methods for controlling CPU

performance
+ using PSS methods as described in the ACPI spec. It also enables
support
+ for ACPI based performance throttling (TSS) and ACPI based

Quoted 8 lines

drivers/acpi/Kconfig config ACPI_DOCK · line 179

Quoted 4 lines

thermal

drivers/acpi/Kconfig +3 -0
+         monitoring. It is required by several flavors of cpufreq
+         performance-state drivers.
+

Though I agree CPUFreq and the thermal control are related, having _PSS in config name shouldn't match well IMO. You can have more generic name.

Do you have any suggestions?

Quoted 4 lines

You are selecting one config while depending on the other, any particular reason ?

What is the problem? Sorry, I didn't follow.

Regards,
Ashwin.

#44 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

In reply to Rafael J. Wysocki
Quoted 49 lines · Rafael J. Wysocki
Quoted 48 lines · Sudeep Holla

Hi Rafael,

Quoted 34 lines · Rafael J. Wysocki

Hi Sudeep,

Quoted 31 lines · Sudeep Holla
Quoted 9 lines · Rafael J. Wysocki
Quoted 7 lines · Sudeep Holla
Quoted 4 lines · Ashwin Chaugule

CPPC is the first client to make use of the PCC Mailbox channel. So enable it only when CPPC is also enabled.

Quoted 6 lines
Quoted 3 lines

This sounds like a reverse dependency to me. So if there's some client unrelated to CPPC using PCC, CPPC_LIB needs to be selected to enable PCC ?

No. The other client will need to select PCC too.

Yes the PCC users/clients selecting PCC is fine and that's already done(i.e. ACPI_CPPC_LIB selects PCC). I still don't understand the need for this change, also how will other clients possibly select PCC which now depends on CPPC_LIB ? e.g. if we have

config ACPI_XYZ_LIB
select PCC

config ACPI_XYZ
select ACPI_XYZ_LIB

Quoted 7 lines
Quoted 3 lines

Won't this shout warning: (ACPI_XYZ_LIB && ACPI_CPPC_LIB) selects PCC which has unmet direct dependencies (MAILBOX && ACPI && ACPI_CPPC_LIB) if ACPI_CPPC_LIB is not selected ?

That depends on the "depends on" clauses used. Selecting itself doesn't cause any dependencies to appear.

Agreed and I am absolutely fine with that. But if you look at this patch, it does

Quoted 8 lines
Quoted 3 lines

config PCC
bool "Platform Communication Channel Driver" depends on ACPI && ACPI_CPPC_LIB

My bad, I've evidently overlooked that.

If PPC is selected from ACPI_CPPC_LIB, the "depends on" above is obviously not needed.

Thanks Sudeep.
So I'll take this dependency out and default PCC to 'n'. Think that should work for all cases. Agree?

Thanks,
Ashwin.

#3 lore raw

Re: [PATCH v7 1/8] PCC: Initialize PCC Mailbox earlier at boot

In reply to Sudeep Holla
Quoted 23 lines · Sudeep Holla
Quoted 20 lines · Ashwin Chaugule

This change initializes the PCC Mailbox earlier than the ACPI processor driver. This enables drivers introduced in follow up patches (e.g. CPPC) to be probed via the ACPI processor driver interface. The CPPC probe requires the PCC channel to be initialized for it to query each CPUs performance capabilities.

---
  drivers/mailbox/pcc.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +0 -0
index 7e91d68..fcda63e 100644
@@ -352,4 +352,10 @@ static int __init pcc_init(void)
 
Quoted 14 lines

drivers/mailbox/pcc.c static int __init pcc_init(void) · line 361

Quoted 11 lines
drivers/mailbox/pcc.c +7 -1
        return 0;
  }
-device_initcall(pcc_init);
+
+/*
+ * Make pcc init postcore so that users of this mailbox
+ * such as the ACPI Processor driver have it available
+ * at their init.
+ */
+postcore_initcall(pcc_init);

I assumed you have explored other options like deferred probe and finally resorted to this as they are not feasible ?

Yes, and this is the only one that works as expected. :)

Quoted 5 lines

Because setting up
these kind of dependency are prone to create issues later on.

Regards,
Sudeep

#16 lore raw

Re: [PATCH v7 3/8] ACPI: Decouple ACPI idle and ACPI processor drivers

In reply to Sudeep Holla
Quoted 32 lines · Sudeep Holla
Quoted 29 lines · Ashwin Chaugule

This patch introduces a new Kconfig symbol, ACPI_PROCESSOR_IDLE, which is auto selected by architectures which support the ACPI based C states for CPU Idle management.

The processor_idle driver in its present form contains declarations specific to X86 and IA64. Since there are no reasonable defaults for other architectures e.g. ARM64, the driver is selected only by the arch/x86/Kconfig.

This helps in decoupling the ACPI processor_driver from the ACPI processor_idle driver which is useful for the upcoming alternative patchwork for controlling CPU Performance (CPPC) and CPU Idle (LPI).

---
  drivers/acpi/Kconfig     |  6 +++++-
  drivers/acpi/Makefile    |  3 ++-
  include/acpi/processor.h | 26 ++++++++++++++++++++++++--
  3 files changed, 31 insertions(+), 4 deletions(-)
drivers/acpi/Kconfig +0 -0
index 00748dc..8a60b6e 100644
@@ -177,9 +177,13 @@ config ACPI_CPU_FREQ_PSS
          monitoring. It is required by several flavors of cpufreq
          performance-state drivers.
 
Quoted 10 lines

drivers/acpi/Kconfig config ACPI_CPU_FREQ_PSS · line 183

Quoted 4 lines
drivers/acpi/Kconfig +4 -0
+config ACPI_PROCESSOR_IDLE
+       def_bool y
+       depends on X86 || IA64
+

In general, you need to split this series so that initially few patches deal with all the existing Kconfig fix-ups and then introduce PCC/PSS/CPPC related stuffs. That would help me rebase and test _LPI support.

Hm. I tried to maintain bisectability and make it easier for you to rebase LPI patchwork too. Let me see if I can revisit now that I'm back from vacation. :)

Quoted 3 lines

Regards,
Sudeep

#11 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Rafael J. Wysocki
Quoted 67 lines · Rafael J. Wysocki
Quoted 66 lines · Sudeep Holla
Quoted 50 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
  arch/x86/Kconfig                |  1 +
  drivers/acpi/Kconfig            | 19 ++++++---
  drivers/acpi/Makefile           |  6 +--
  drivers/acpi/processor_driver.c | 86 +++++++++++++++++++++++++------------
  drivers/cpufreq/Kconfig         |  2 +-
  drivers/cpufreq/Kconfig.x86     |  2 +
  include/acpi/processor.h        | 94 +++++++++++++++++++++++++++--------------
  7 files changed, 142 insertions(+), 68 deletions(-)
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
         select ACPI_LEGACY_TABLES_LOOKUP if ACPI
         select X86_FEATURE_NAMES if PROC_FS
         select SRCU
+       select ACPI_CPU_FREQ_PSS if ACPI
 
  config INSTRUCTION_DECODER
         def_bool y
drivers/acpi/Kconfig +1 -0
index ab2cbb5..00748dc 100644
@@ -166,17 +166,26 @@ config ACPI_DOCK
           This driver supports ACPI-controlled docking stations and removable
           drive bays such as the IBM Ultrabay and the Dell Module Bay.
 
+config ACPI_CPU_FREQ_PSS

drivers/acpi/Kconfig config ACPI_DOCK · line 179

Quoted 10 lines
drivers/acpi/Kconfig +10 -0
+       bool
+       depends on ACPI_PROCESSOR && CPU_FREQ
+       select THERMAL
+       help
+         This driver implements ACPI methods for controlling CPU performance
+         using PSS methods as described in the ACPI spec. It also enables support
+         for ACPI based performance throttling (TSS) and ACPI based thermal
+         monitoring. It is required by several flavors of cpufreq
+         performance-state drivers.
+

Though I agree CPUFreq and the thermal control are related, having _PSS in config name shouldn't match well IMO. You can have more generic name.

Quoted 6 lines
Quoted 4 lines

You are selecting one config while depending on the other, any particular reason ?

I don't like adding these, but I leave it to Rafael.

My opinion is analogous. :-)

I dont like bloating Kconfigs either, but its slim pickings in this case.

Quoted 18 lines

I *guess* the idea was to avoid selecting ACPI_CPU_FREQ_PSS withouth ACPI_PROCESSOR so we don't build unnecessary code. That's a good point, but I would also like to keep they way ACPI_PROCESSOR works on x86 and ia64 without adding new user-selectable Kconfig options.

So, what about this:

config ACPI_PROCESSOR
tristate "Processor"
select THERMAL
select CPU_IDLE

(quoted diff) +1 -1
-       depends on X86 || IA64
+       select ACPI_CPU_FREQ_PSS if X86 || IA64
        default y
        help
          This driver installs ACPI as the idle handler for Linux and uses
Quoted 1 line

and define ACPI_CPU_FREQ_PSS in analogy with ACPI_CCA_REQUIRED for example?

Seems better. I'll respin this series with the feedback so far.

Thanks,
Ashwin.

#13 lore raw

Re: [PATCH v7 2/8] ACPI: Split out ACPI PSS from ACPI Processor driver

In reply to Ashwin Chaugule
Quoted 76 lines · Ashwin Chaugule
Quoted 66 lines · Sudeep Holla
Quoted 63 lines · Ashwin Chaugule

The ACPI processor driver is currently tied too closely to the ACPI P-states (PSS) and other related constructs for controlling CPU performance.

The newer ACPI specification (v5.1 onwards) introduces alternative methods to PSS. These new mechanisms are described within each ACPI Processor object and so they need to be scanned whenever a new Processor object is detected. This patch introduces a new Kconfig symbol to allow for finer configurability among the two options for controlling performance states. There is no change in functionality and the option is auto-selected by the architecture Kconfig files.

The following patchwork introduces CPPC: A newer method of controlling CPU performance. The OS is not expected to support CPPC and PSS at runtime. So the kconfig option lets us make these two mutually exclusive at compile time.

---
   arch/x86/Kconfig                |  1 +
   drivers/acpi/Kconfig            | 19 ++++++---
   drivers/acpi/Makefile           |  6 +--
   drivers/acpi/processor_driver.c | 86
+++++++++++++++++++++++++------------
   drivers/cpufreq/Kconfig         |  2 +-
   drivers/cpufreq/Kconfig.x86     |  2 +
   include/acpi/processor.h        | 94
+++++++++++++++++++++++++++--------------
   7 files changed, 142 insertions(+), 68 deletions(-)
arch/x86/Kconfig +1 -0
index 226d569..93d150d 100644
@@ -143,6 +143,7 @@ config X86
          select ACPI_LEGACY_TABLES_LOOKUP if ACPI
          select X86_FEATURE_NAMES if PROC_FS
          select SRCU
+       select ACPI_CPU_FREQ_PSS if ACPI
 
   config INSTRUCTION_DECODER
          def_bool y
drivers/acpi/Kconfig +0 -0
index ab2cbb5..00748dc 100644
@@ -166,17 +166,26 @@ config ACPI_DOCK
            This driver supports ACPI-controlled docking stations and

removable
drive bays such as the IBM Ultrabay and the Dell Module Bay.

drivers/acpi/Kconfig +6 -0
+config ACPI_CPU_FREQ_PSS
+       bool
+       depends on ACPI_PROCESSOR && CPU_FREQ
+       select THERMAL
+       help
+         This driver implements ACPI methods for controlling CPU

performance
+ using PSS methods as described in the ACPI spec. It also enables
support
+ for ACPI based performance throttling (TSS) and ACPI based

Quoted 8 lines

drivers/acpi/Kconfig config ACPI_DOCK · line 179

Quoted 4 lines

thermal

drivers/acpi/Kconfig +3 -0
+         monitoring. It is required by several flavors of cpufreq
+         performance-state drivers.
+

Though I agree CPUFreq and the thermal control are related, having _PSS in config name shouldn't match well IMO. You can have more generic name.

Quoted 2 lines

Do you have any suggestions?

No, so I am fine with ACPI_CPU_FREQ_PSS for now, we can change later if required as along as it's not user-selectable I suppose.

Quoted 7 lines
Quoted 4 lines

You are selecting one config while depending on the other, any particular reason ?

What is the problem? Sorry, I didn't follow.

Just follow what Rafael said, he explained it better than me, I was bit vague here but implied same thing.

Regards,
Sudeep

#17 lore raw

Re: [PATCH v7 3/8] ACPI: Decouple ACPI idle and ACPI processor drivers

In reply to Ashwin Chaugule
Quoted 44 lines · Ashwin Chaugule
Quoted 32 lines · Sudeep Holla
Quoted 29 lines · Ashwin Chaugule

This patch introduces a new Kconfig symbol, ACPI_PROCESSOR_IDLE, which is auto selected by architectures which support the ACPI based C states for CPU Idle management.

The processor_idle driver in its present form contains declarations specific to X86 and IA64. Since there are no reasonable defaults for other architectures e.g. ARM64, the driver is selected only by the arch/x86/Kconfig.

This helps in decoupling the ACPI processor_driver from the ACPI processor_idle driver which is useful for the upcoming alternative patchwork for controlling CPU Performance (CPPC) and CPU Idle (LPI).

---
   drivers/acpi/Kconfig     |  6 +++++-
   drivers/acpi/Makefile    |  3 ++-
   include/acpi/processor.h | 26 ++++++++++++++++++++++++--
   3 files changed, 31 insertions(+), 4 deletions(-)
drivers/acpi/Kconfig +0 -0
index 00748dc..8a60b6e 100644
@@ -177,9 +177,13 @@ config ACPI_CPU_FREQ_PSS
           monitoring. It is required by several flavors of cpufreq
           performance-state drivers.
 
Quoted 10 lines

drivers/acpi/Kconfig config ACPI_CPU_FREQ_PSS · line 183

Quoted 4 lines
drivers/acpi/Kconfig +4 -0
+config ACPI_PROCESSOR_IDLE
+       def_bool y
+       depends on X86 || IA64
+

In general, you need to split this series so that initially few patches deal with all the existing Kconfig fix-ups and then introduce PCC/PSS/CPPC related stuffs. That would help me rebase and test _LPI support.

Quoted 4 lines

Hm. I tried to maintain bisectability and make it easier for you to rebase LPI patchwork too. Let me see if I can revisit now that I'm back from vacation. :)

How about you just drop any idle related changes so that I will handle that to keep it simple.

Regards,
Sudeep

#45 lore raw

Re: [PATCH v7 8/8] PCC: Enable PCC only when needed

In reply to Ashwin Chaugule
Quoted 4 lines · Ashwin Chaugule
Quoted 3 lines · Rafael J. Wysocki
Quoted 2 lines · Sudeep Holla

Hi Rafael,

[...]

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Agreed and I am absolutely fine with that. But if you look at this patch, it does

config PCC
bool "Platform Communication Channel Driver" depends on ACPI && ACPI_CPPC_LIB

Quoted 9 lines
Quoted 4 lines

My bad, I've evidently overlooked that.

If PPC is selected from ACPI_CPPC_LIB, the "depends on" above is obviously not needed.

Thanks Sudeep.
So I'll take this dependency out and default PCC to 'n'. Think that should work for all cases. Agree?

Yes

Regards,
Sudeep

#18 lore raw

Re: [PATCH v7 3/8] ACPI: Decouple ACPI idle and ACPI processor drivers

In reply to Sudeep Holla
Quoted 12 lines · Sudeep Holla
Quoted 11 lines · Ashwin Chaugule
Quoted 7 lines · Sudeep Holla
Quoted 1 line · Ashwin Chaugule

In general, you need to split this series so that initially few patches deal with all the existing Kconfig fix-ups and then introduce PCC/PSS/CPPC related stuffs. That would help me rebase and test _LPI support.

Quoted 7 lines
Quoted 4 lines

Hm. I tried to maintain bisectability and make it easier for you to rebase LPI patchwork too. Let me see if I can revisit now that I'm back from vacation. :)

How about you just drop any idle related changes so that I will handle that to keep it simple.

Unfortunately I can't skip idle changes completely since it is tightly coupled with the acpi_processor driver as well.

Regards,
Ashwin.

#24 lore raw

Re: [PATCH v7 4/8] ACPI: Introduce CPU performance controls using CPPC

In reply to Ashwin Chaugule

Hi Ashwin,

Quoted 24 lines · Ashwin Chaugule

CPPC stands for Collaborative Processor Performance Controls and is defined in the ACPI v5.0+ spec. It describes CPU performance controls on an abstract and continuous scale allowing the platform (e.g. remote power processor) to flexibly optimize CPU performance with its knowledge of power budgets and other architecture specific knowledge.

This patch adds a shim which exports commonly used functions to get and set CPPC specific controls for each CPU. This enables CPUFreq drivers to gather per CPU performance data and use with exisiting governors or even allows for customized governors which are implemented inside CPUFreq drivers.

---
  drivers/acpi/Kconfig     |  14 +
  drivers/acpi/Makefile    |   1 +
  drivers/acpi/cppc_acpi.c | 812 +++++++++++++++++++++++++++++++++++++++++++++++
  include/acpi/cppc_acpi.h | 137 ++++++++
  4 files changed, 964 insertions(+)

create mode 100644 drivers/acpi/cppc_acpi.c
create mode 100644 include/acpi/cppc_acpi.h

[..]

Quoted 84 lines
drivers/acpi/cppc_acpi.c new file +78 -0
new file mode 100644
index 0000000..9c89767
@@ -0,0 +1,812 @@
+/*
+ * CPPC (Collaborative Processor Performance Control) methods used
+ * by CPUfreq drivers.
+ *
+ * (C) Copyright 2014, 2015 Linaro Ltd.
+ * Author: Ashwin Chaugule <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * CPPC describes a few methods for controlling CPU performance using
+ * information from a per CPU table called CPC. This table is described in
+ * the ACPI v5.0+ specification. The table consists of a list of
+ * registers which may be memory mapped or hardware registers and also may
+ * include some static integer values.
+ *
+ * CPU performance is on an abstract continuous scale as against a discretized
+ * P-state scale which is tied to CPU frequency only. In brief, the basic
+ * operation involves:
+ *
+ * - OS makes a CPU performance request. (Can provide min and max bounds)
+ *
+ * - Platform (such as BMC) is free to optimize request within requested bounds
+ *   depending on power/thermal budgets etc.
+ *
+ * - Platform conveys its decision back to OS
+ *
+ * The communication between OS and platform occurs through another medium
+ * called (PCC) Platform Communication Channel. This is a generic mailbox like
+ * mechanism which includes doorbell semantics to indicate register updates.
+ * See drivers/mailbox/pcc.c for details on PCC.
+ *
+ * Finer details about the PCC and CPPC spec are available in the latest
+ * ACPI 5.1 specification.
+ */
+
+#define pr_fmt(fmt)    "ACPI CPPC: " fmt
+
+#include <linux/cpufreq.h>
+#include <linux/delay.h>
+
+#include <acpi/cppc_acpi.h>
+/*
+ * Lock to provide mutually exclusive access to the PCC
+ * channel. e.g. When the remote updates the shared region
+ * with new data, the reader needs to be protected from
+ * other CPUs activity on the same channel.
+ */
+static DEFINE_SPINLOCK(pcc_lock);
+
+static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
+
+/* This layer handles all the PCC specifics for CPPC. */
+static struct mbox_chan *pcc_channel;
+static void __iomem *pcc_comm_addr;
+static u64 comm_base_addr;
+static int pcc_subspace_idx = -1;
+static u16 pcc_cmd_delay;
+static int pcc_channel_acquired;
+
+#define NUM_RETRIES 500
+
+static int send_pcc_cmd(u16 cmd)
+{
+       int err, result = 0;
+       int retries = NUM_RETRIES;
+       struct acpi_pcct_hw_reduced *pcct_ss = pcc_channel->con_priv;
+       struct acpi_pcct_shared_memory *generic_comm_base =
+               (struct acpi_pcct_shared_memory *) pcc_comm_addr;
+       u32 cmd_latency = pcct_ss->latency;
+
+       /* Write to the shared comm region. */
+       writew(cmd, &generic_comm_base->command);
+
+       /* Flip CMD COMPLETE bit */
+       writew(0, &generic_comm_base->status);

drivers/acpi/cppc_acpi.c line 88

Quoted 10 lines
drivers/acpi/cppc_acpi.c new file +10 -0
+
+       err = mbox_send_message(pcc_channel, &cmd);
+       if (err < 0) {
+               pr_err("Err sending PCC mbox message. cmd:%d, ret:%d\n",
+                               cmd, err);
+               return err;
+       }
+
+       /* Wait for a nominal time to let platform processes command. */
+       udelay(cmd_latency);

I don't think above delay belongs here. It should be part of PCC driver. I need to go through PCC again, initially I objected that some part of client code was in PCC driver which seems to be fixed now with commit 33350e6b1833 ("Mailbox: Restructure and simplify PCC mailbox code").

But now I think the controller code is getting into the client side. Ideally you shouldn't access anything related to PCC controller here.

As I started looking at PCC, I found few issue there. I will post them separately for discussion.

Regards,
Sudeep

#19 lore raw

Re: [PATCH v7 3/8] ACPI: Decouple ACPI idle and ACPI processor drivers

In reply to Ashwin Chaugule
Quoted 18 lines · Ashwin Chaugule
Quoted 17 lines · Sudeep Holla
Quoted 15 lines · Ashwin Chaugule
Quoted 7 lines · Sudeep Holla
Quoted 1 line · Ashwin Chaugule

In general, you need to split this series so that initially few patches deal with all the existing Kconfig fix-ups and then introduce PCC/PSS/CPPC related stuffs. That would help me rebase and test _LPI support.

Hm. I tried to maintain bisectability and make it easier for you to rebase LPI patchwork too. Let me see if I can revisit now that I'm back from vacation. :)

Quoted 6 lines
Quoted 2 lines

How about you just drop any idle related changes so that I will handle that to keep it simple.

Unfortunately I can't skip idle changes completely since it is tightly coupled with the acpi_processor driver as well.

True, but only for ARM64 where we haven't enabled ACPI_PROCESSOR yet in mainline. So from that perspective, it should not cause any issue for keeping changes bisectable on x86/ia64. You can keep these idle changes locally for your testing. Trying to get everything at once will definitely be problematic IMO.

Regards,
Sudeep

#25 lore raw

Re: [PATCH v7 4/8] ACPI: Introduce CPU performance controls using CPPC

In reply to Sudeep Holla
Quoted 129 lines · Sudeep Holla

Hi Ashwin,

Quoted 26 lines · Ashwin Chaugule

CPPC stands for Collaborative Processor Performance Controls and is defined in the ACPI v5.0+ spec. It describes CPU performance controls on an abstract and continuous scale allowing the platform (e.g. remote power processor) to flexibly optimize CPU performance with its knowledge of power budgets and other architecture specific knowledge.

This patch adds a shim which exports commonly used functions to get and set CPPC specific controls for each CPU. This enables CPUFreq drivers to gather per CPU performance data and use with exisiting governors or even allows for customized governors which are implemented inside CPUFreq drivers.

---
  drivers/acpi/Kconfig     |  14 +
  drivers/acpi/Makefile    |   1 +
  drivers/acpi/cppc_acpi.c | 812
+++++++++++++++++++++++++++++++++++++++++++++++
  include/acpi/cppc_acpi.h | 137 ++++++++
  4 files changed, 964 insertions(+)

create mode 100644 drivers/acpi/cppc_acpi.c
create mode 100644 include/acpi/cppc_acpi.h

[..]

Quoted 96 lines
drivers/acpi/cppc_acpi.c new file +14 -0
new file mode 100644
index 0000000..9c89767
@@ -0,0 +1,812 @@
+/*
+ * CPPC (Collaborative Processor Performance Control) methods used
+ * by CPUfreq drivers.
+ *
+ * (C) Copyright 2014, 2015 Linaro Ltd.
+ * Author: Ashwin Chaugule <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * CPPC describes a few methods for controlling CPU performance using
+ * information from a per CPU table called CPC. This table is described

in
+ * the ACPI v5.0+ specification. The table consists of a list of
+ * registers which may be memory mapped or hardware registers and also may
+ * include some static integer values.
+ *
+ * CPU performance is on an abstract continuous scale as against a discretized
+ * P-state scale which is tied to CPU frequency only. In brief, the basic
+ * operation involves:
+ *
+ * - OS makes a CPU performance request. (Can provide min and max bounds)
+ *
+ * - Platform (such as BMC) is free to optimize request within requested bounds
+ * depending on power/thermal budgets etc.
+ *
+ * - Platform conveys its decision back to OS
+ *
+ * The communication between OS and platform occurs through another medium
+ * called (PCC) Platform Communication Channel. This is a generic mailbox like
+ * mechanism which includes doorbell semantics to indicate register updates.
+ * See drivers/mailbox/pcc.c for details on PCC.
+ *
+ * Finer details about the PCC and CPPC spec are available in the latest
+ * ACPI 5.1 specification.
+ */

drivers/acpi/cppc_acpi.c new file +46 -0
+
+#define pr_fmt(fmt)    "ACPI CPPC: " fmt
+
+#include <linux/cpufreq.h>
+#include <linux/delay.h>
+
+#include <acpi/cppc_acpi.h>
+/*
+ * Lock to provide mutually exclusive access to the PCC
+ * channel. e.g. When the remote updates the shared region
+ * with new data, the reader needs to be protected from
+ * other CPUs activity on the same channel.
+ */
+static DEFINE_SPINLOCK(pcc_lock);
+
+static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
+
+/* This layer handles all the PCC specifics for CPPC. */
+static struct mbox_chan *pcc_channel;
+static void __iomem *pcc_comm_addr;
+static u64 comm_base_addr;
+static int pcc_subspace_idx = -1;
+static u16 pcc_cmd_delay;
+static int pcc_channel_acquired;
+
+#define NUM_RETRIES 500
+
+static int send_pcc_cmd(u16 cmd)
+{
+       int err, result = 0;
+       int retries = NUM_RETRIES;
+       struct acpi_pcct_hw_reduced *pcct_ss = pcc_channel->con_priv;
+       struct acpi_pcct_shared_memory *generic_comm_base =
+               (struct acpi_pcct_shared_memory *) pcc_comm_addr;
+       u32 cmd_latency = pcct_ss->latency;
+
+       /* Write to the shared comm region. */
+       writew(cmd, &generic_comm_base->command);
+
+       /* Flip CMD COMPLETE bit */
+       writew(0, &generic_comm_base->status);
+
+       err = mbox_send_message(pcc_channel, &cmd);
+       if (err < 0) {
+               pr_err("Err sending PCC mbox message. cmd:%d, ret:%d\n",
+                               cmd, err);
Quoted 8 lines

drivers/acpi/cppc_acpi.c line 88

Quoted 5 lines
drivers/acpi/cppc_acpi.c new file +5 -0
+               return err;
+       }
+
+       /* Wait for a nominal time to let platform processes command. */
+       udelay(cmd_latency);

I don't think above delay belongs here. It should be part of PCC driver.

This delay is PCC subspace specific, so I think it belongs to a client (subspace).

Quoted 6 lines

I need to go through PCC again, initially I objected that some part of client code was in PCC driver which seems to be fixed now with commit 33350e6b1833 ("Mailbox: Restructure and simplify PCC mailbox code").

But now I think the controller code is getting into the client side. Ideally you shouldn't access anything related to PCC controller here.

I think its fair to address all PCC details specific to the client in the client side code. Moreover this makes it much cleaner to handle multiple users of one subspace. e.g. multiple CPUs trying to concurrently access the CPPC subspace.

Quoted 3 lines

As I started looking at PCC, I found few issue there. I will post them separately for discussion.

Ok.

Regards,
Ashwin.

#20 lore raw

Re: [PATCH v7 3/8] ACPI: Decouple ACPI idle and ACPI processor drivers

In reply to Sudeep Holla
Quoted 35 lines · Sudeep Holla
Quoted 24 lines · Ashwin Chaugule
Quoted 22 lines · Sudeep Holla
Quoted 19 lines · Ashwin Chaugule
Quoted 9 lines · Sudeep Holla
Quoted 2 lines · Ashwin Chaugule

In general, you need to split this series so that initially few patches deal with all the existing Kconfig fix-ups and then introduce PCC/PSS/CPPC related stuffs. That would help me rebase and test _LPI support.

Hm. I tried to maintain bisectability and make it easier for you to rebase LPI patchwork too. Let me see if I can revisit now that I'm back from vacation. :)

Quoted 7 lines
Quoted 2 lines

How about you just drop any idle related changes so that I will handle that to keep it simple.

Unfortunately I can't skip idle changes completely since it is tightly coupled with the acpi_processor driver as well.

Quoted 5 lines

True, but only for ARM64 where we haven't enabled ACPI_PROCESSOR yet in mainline. So from that perspective, it should not cause any issue for keeping changes bisectable on x86/ia64. You can keep these idle changes locally for your testing. Trying to get everything at once will definitely be problematic IMO.

Bisectability aside, without the idle changes to decouple it from ACPI_PROCESSOR, the CPPC code will be non-functional. CPPC code has been around for review publicly for almost a year and we need it to be mainlined soon. So, given that we've converged on a solution for new Kconfigs for Idle and PSS and that they're separate patches, why not let it progress forwards as part of this series?

Thanks,
Ashwin.

#26 lore raw

Re: [PATCH v7 4/8] ACPI: Introduce CPU performance controls using CPPC

In reply to Ashwin Chaugule
Quoted 139 lines · Ashwin Chaugule
Quoted 129 lines · Sudeep Holla

Hi Ashwin,

Quoted 26 lines · Ashwin Chaugule

CPPC stands for Collaborative Processor Performance Controls and is defined in the ACPI v5.0+ spec. It describes CPU performance controls on an abstract and continuous scale allowing the platform (e.g. remote power processor) to flexibly optimize CPU performance with its knowledge of power budgets and other architecture specific knowledge.

This patch adds a shim which exports commonly used functions to get and set CPPC specific controls for each CPU. This enables CPUFreq drivers to gather per CPU performance data and use with exisiting governors or even allows for customized governors which are implemented inside CPUFreq drivers.

---
   drivers/acpi/Kconfig     |  14 +
   drivers/acpi/Makefile    |   1 +
   drivers/acpi/cppc_acpi.c | 812
+++++++++++++++++++++++++++++++++++++++++++++++
   include/acpi/cppc_acpi.h | 137 ++++++++
   4 files changed, 964 insertions(+)

create mode 100644 drivers/acpi/cppc_acpi.c
create mode 100644 include/acpi/cppc_acpi.h

[..]

Quoted 96 lines
drivers/acpi/cppc_acpi.c new file +14 -0
new file mode 100644
index 0000000..9c89767
@@ -0,0 +1,812 @@
+/*
+ * CPPC (Collaborative Processor Performance Control) methods used
+ * by CPUfreq drivers.
+ *
+ * (C) Copyright 2014, 2015 Linaro Ltd.
+ * Author: Ashwin Chaugule <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * CPPC describes a few methods for controlling CPU performance using
+ * information from a per CPU table called CPC. This table is described

in
+ * the ACPI v5.0+ specification. The table consists of a list of
+ * registers which may be memory mapped or hardware registers and also may
+ * include some static integer values.
+ *
+ * CPU performance is on an abstract continuous scale as against a discretized
+ * P-state scale which is tied to CPU frequency only. In brief, the basic
+ * operation involves:
+ *
+ * - OS makes a CPU performance request. (Can provide min and max bounds)
+ *
+ * - Platform (such as BMC) is free to optimize request within requested bounds
+ * depending on power/thermal budgets etc.
+ *
+ * - Platform conveys its decision back to OS
+ *
+ * The communication between OS and platform occurs through another medium
+ * called (PCC) Platform Communication Channel. This is a generic mailbox like
+ * mechanism which includes doorbell semantics to indicate register updates.
+ * See drivers/mailbox/pcc.c for details on PCC.
+ *
+ * Finer details about the PCC and CPPC spec are available in the latest
+ * ACPI 5.1 specification.
+ */

drivers/acpi/cppc_acpi.c new file +46 -0
+
+#define pr_fmt(fmt)    "ACPI CPPC: " fmt
+
+#include <linux/cpufreq.h>
+#include <linux/delay.h>
+
+#include <acpi/cppc_acpi.h>
+/*
+ * Lock to provide mutually exclusive access to the PCC
+ * channel. e.g. When the remote updates the shared region
+ * with new data, the reader needs to be protected from
+ * other CPUs activity on the same channel.
+ */
+static DEFINE_SPINLOCK(pcc_lock);
+
+static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
+
+/* This layer handles all the PCC specifics for CPPC. */
+static struct mbox_chan *pcc_channel;
+static void __iomem *pcc_comm_addr;
+static u64 comm_base_addr;
+static int pcc_subspace_idx = -1;
+static u16 pcc_cmd_delay;
+static int pcc_channel_acquired;
+
+#define NUM_RETRIES 500
+
+static int send_pcc_cmd(u16 cmd)
+{
+       int err, result = 0;
+       int retries = NUM_RETRIES;
+       struct acpi_pcct_hw_reduced *pcct_ss = pcc_channel->con_priv;
+       struct acpi_pcct_shared_memory *generic_comm_base =
+               (struct acpi_pcct_shared_memory *) pcc_comm_addr;
+       u32 cmd_latency = pcct_ss->latency;
+
+       /* Write to the shared comm region. */
+       writew(cmd, &generic_comm_base->command);
+
+       /* Flip CMD COMPLETE bit */
+       writew(0, &generic_comm_base->status);
+
+       err = mbox_send_message(pcc_channel, &cmd);
+       if (err < 0) {
+               pr_err("Err sending PCC mbox message. cmd:%d, ret:%d\n",
+                               cmd, err);
Quoted 8 lines

drivers/acpi/cppc_acpi.c line 88

Quoted 5 lines
drivers/acpi/cppc_acpi.c new file +5 -0
+               return err;
+       }
+
+       /* Wait for a nominal time to let platform processes command. */
+       udelay(cmd_latency);

I don't think above delay belongs here. It should be part of PCC driver.

Quoted 3 lines

This delay is PCC subspace specific, so I think it belongs to a client (subspace).

Sorry I overlooked at the spec, every channel specify these field so its fine. I had previously misunderstood as there's only one table for each controller rather than channel which is wrong. Sorry for the noise.

Quoted 4 lines
Quoted 4 lines

I need to go through PCC again, initially I objected that some part of client code was in PCC driver which seems to be fixed now with commit 33350e6b1833 ("Mailbox: Restructure and simplify PCC mailbox code").

Quoted 8 lines
Quoted 2 lines

But now I think the controller code is getting into the client side. Ideally you shouldn't access anything related to PCC controller here.

I think its fair to address all PCC details specific to the client in the client side code. Moreover this makes it much cleaner to handle multiple users of one subspace. e.g. multiple CPUs trying to concurrently access the CPPC subspace.

Agreed, that's exactly what I wanted to say but I clearly interpreted the tables incorrectly.

Regards,
Sudeep

#21 lore raw

Re: [PATCH v7 3/8] ACPI: Decouple ACPI idle and ACPI processor drivers

In reply to Ashwin Chaugule
Quoted 42 lines · Ashwin Chaugule
Quoted 35 lines · Sudeep Holla
Quoted 24 lines · Ashwin Chaugule
Quoted 22 lines · Sudeep Holla
Quoted 19 lines · Ashwin Chaugule
Quoted 9 lines · Sudeep Holla
Quoted 2 lines · Ashwin Chaugule

In general, you need to split this series so that initially few patches deal with all the existing Kconfig fix-ups and then introduce PCC/PSS/CPPC related stuffs. That would help me rebase and test _LPI support.

Hm. I tried to maintain bisectability and make it easier for you to rebase LPI patchwork too. Let me see if I can revisit now that I'm back from vacation. :)

Quoted 7 lines
Quoted 2 lines

How about you just drop any idle related changes so that I will handle that to keep it simple.

Unfortunately I can't skip idle changes completely since it is tightly coupled with the acpi_processor driver as well.

Quoted 5 lines

True, but only for ARM64 where we haven't enabled ACPI_PROCESSOR yet in mainline. So from that perspective, it should not cause any issue for keeping changes bisectable on x86/ia64. You can keep these idle changes locally for your testing. Trying to get everything at once will definitely be problematic IMO.

Quoted 7 lines

Bisectability aside, without the idle changes to decouple it from ACPI_PROCESSOR, the CPPC code will be non-functional. CPPC code has been around for review publicly for almost a year and we need it to be mainlined soon. So, given that we've converged on a solution for new Kconfigs for Idle and PSS and that they're separate patches, why not let it progress forwards as part of this series?

Sorry, I didn't mean to block this series in anyway. I was just thinking on how to post the preparatory changes to introduce _LPI. I prefer to base it on mainline rather than this patch series and hence I made that request.

Regards,
Sudeep

#22 lore raw

Re: [PATCH v7 3/8] ACPI: Decouple ACPI idle and ACPI processor drivers

Hi Sudeep,

Quoted 9 lines · Sudeep Holla
Quoted 8 lines · Ashwin Chaugule

On 4 August 2015 at 11:18, Sudeep Holla <[email protected]> wrote:
Bisectability aside, without the idle changes to decouple it from ACPI_PROCESSOR, the CPPC code will be non-functional. CPPC code has been around for review publicly for almost a year and we need it to be mainlined soon. So, given that we've converged on a solution for new Kconfigs for Idle and PSS and that they're separate patches, why not let it progress forwards as part of this series?

Quoted 5 lines

Sorry, I didn't mean to block this series in anyway. I was just thinking on how to post the preparatory changes to introduce _LPI. I prefer to base it on mainline rather than this patch series and hence I made that request.

Can you please try rebasing with Patch 2,3,6 and 9 of the V8 series? Those should get you going for your LPI work.

Thanks,
Ashwin.