diff mbox series

[v1] acpi: processor_throttling: Add supprt for System Memory

Message ID 20201001132623.172-1-kuldip.dwivedi@puresoftware.com
State New
Headers show
Series [v1] acpi: processor_throttling: Add supprt for System Memory | expand

Commit Message

kuldip dwivedi Oct. 1, 2020, 1:26 p.m. UTC
The existing driver does not support System Memory so
adding support of system meory so that this can be used
on platforms which has ACPI_ADR_SPACE_SYSTEM_MEMORY type
system registers.

Function that creates sysfs entries in processor_driver in Linux,
is enabled to be compiled for arm64 platform

Signed-off-by: Tanveer <tanveer.alam@puresoftware.com>
Signed-off-by: kuldip dwivedi <kuldip.dwivedi@puresoftware.com>
---

Notes:
    1.  Added package in CPU.asl in edk2-platform to support
        _PCT: Performance Control and provide cluster status/control
        register like below..
    
        Name(_PTC, Package () {
          ResourceTemplate() {Register(SystemMemory, 32, 0, CPU_CLK_CSSR_REG,
                              CPU_DWORD_ACCESS)},
          ResourceTemplate() {Register(SystemMemory, 32, 0, CPU_CLK_CSSR_REG,
                              CPU_DWORD_ACCESS)}
        })
      for reference please see line:100 to line:105
    https://source.codeaurora.org/external/qoriq/qoriq-components/edk2-platforms/tree/Platform/NXP/LS1046aRdbPkg/AcpiTables/Dsdt/CPU.asl?h=LX2160_UEFI_ACPI_EAR3
    2. This feature is tested on LS1046A platform

 drivers/acpi/Kconfig                |  2 +-
 drivers/acpi/processor_throttling.c | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

Comments

kernel test robot Oct. 2, 2020, 1 p.m. UTC | #1
Hi kuldip,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v5.9-rc7 next-20201001]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/kuldip-dwivedi/acpi-processor_throttling-Add-supprt-for-System-Memory/20201001-212807
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-randconfig-s021-20200930 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-201-g24bdaac6-dirty
        # https://github.com/0day-ci/linux/commit/c9fca3508dc7664cf0e8728f3902e9b8f88cd1d8
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review kuldip-dwivedi/acpi-processor_throttling-Add-supprt-for-System-Memory/20201001-212807
        git checkout c9fca3508dc7664cf0e8728f3902e9b8f88cd1d8
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "acpi_os_write_memory" [drivers/acpi/processor.ko] undefined!
>> ERROR: modpost: "acpi_os_read_memory" [drivers/acpi/processor.ko] undefined!

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 7540a5179a47..78b3e45f05e0 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -274,7 +274,7 @@  config ACPI_PROCESSOR
 	tristate "Processor"
 	depends on X86 || IA64 || ARM64
 	select ACPI_PROCESSOR_IDLE
-	select ACPI_CPU_FREQ_PSS if X86 || IA64
+	select ACPI_CPU_FREQ_PSS if X86 || IA64 || ARM64
 	default y
 	help
 	  This driver adds support for the ACPI Processor package. It is required
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index a0bd56ece3ff..8ace1fb76712 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -767,6 +767,7 @@  static int acpi_read_throttling_status(struct acpi_processor *pr,
 {
 	u32 bit_width, bit_offset;
 	u32 ptc_value;
+	u64 ptc_value_64;
 	u64 ptc_mask;
 	struct acpi_processor_throttling *throttling;
 	int ret = -1;
@@ -784,6 +785,17 @@  static int acpi_read_throttling_status(struct acpi_processor *pr,
 		*value = (u64) ((ptc_value >> bit_offset) & ptc_mask);
 		ret = 0;
 		break;
+	case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+		bit_width = throttling->status_register.bit_width;
+		bit_offset = throttling->status_register.bit_offset;
+
+		acpi_os_read_memory((acpi_physical_address)
+				throttling->status_register.address,
+				&ptc_value_64, (u32) (bit_width + bit_offset));
+		ptc_mask = (1UL << bit_width) - 1;
+		*value = (u64) ((ptc_value_64 >> bit_offset) & ptc_mask);
+		ret = 0;
+		break;
 	case ACPI_ADR_SPACE_FIXED_HARDWARE:
 		ret = acpi_throttling_rdmsr(value);
 		break;
@@ -817,6 +829,18 @@  static int acpi_write_throttling_state(struct acpi_processor *pr,
 					(u32) (bit_width + bit_offset));
 		ret = 0;
 		break;
+	case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+		bit_width = throttling->control_register.bit_width;
+		bit_offset = throttling->control_register.bit_offset;
+		ptc_mask = (1UL << bit_width) - 1;
+		ptc_value = value & ptc_mask;
+
+		acpi_os_write_memory((acpi_physical_address)
+				throttling->control_register.address,
+					(u64) (ptc_value << bit_offset),
+					(u32) (bit_width + bit_offset));
+		ret = 0;
+		break;
 	case ACPI_ADR_SPACE_FIXED_HARDWARE:
 		ret = acpi_throttling_wrmsr(value);
 		break;