ACPI / adxl: Address translation interface using ACPI DSM
Borislav Petkov
maintainerPATCH v2 1/3 ACPI / adxl: Address translation interface using ACPI DSM
Quoted 1 line
Subject: Re: [PATCH v2 1/3] ACPI / adxl: Address translation interface using ...
Commit name needs a verb: "Add address translation..."
Quoted 10 lines · Tony Luck
Some new servers provide an interface so that the OS can ask the BIOS to translate a system physical address to a memory address (socket, memory controller, channel, rank, dimm, etc.). This is useful for EDAC drivers that want to take the address of an error reported in a machine check bank and let the user know which DIMM may need to be replaced.
Specification for this interface is available at:
https://cdrdv2.intel.com/v1/dl/getContent/603354
What do we do when that link dies?
(And I've seen them die).
Normally we upload those docs in bugzilla.kernel.org but that link wants me to "Accept".
Quoted 48 lines
[Based on earlier code by Qiuxu Zhuo <[email protected]>]
Tested-by Qiuxu Zhuo <[email protected]>Signed-off-by Tony Luck <[email protected]>--- drivers/acpi/Kconfig | 3 + drivers/acpi/Makefile | 3 + drivers/acpi/acpi_adxl.c | 199 +++++++++++++++++++++++++++++++++++++++ include/linux/adxl.h | 25 +++++ 4 files changed, 230 insertions(+) create mode 100644 drivers/acpi/acpi_adxl.c create mode 100644 include/linux/adxl.hdrivers/acpi/Kconfig +3
-0@@ -498,6 +498,9 @@ config ACPI_EXTLOG driver adds support for that functionality with corresponding tracepoint which carries that information to userspace. +config ACPI_ADXL + bool + menuconfig PMIC_OPREGION bool "PMIC (Power Management Integrated Circuit) operation region support" helpdrivers/acpi/Makefile +3
-0@@ -61,6 +61,9 @@ acpi-$(CONFIG_ACPI_LPIT) += acpi_lpit.o acpi-$(CONFIG_ACPI_GENERIC_GSI) += irq.o acpi-$(CONFIG_ACPI_WATCHDOG) += acpi_watchdog.o +# Address translation +acpi-$(CONFIG_ACPI_ADXL) += acpi_adxl.o + # These are (potentially) separate modules # IPMI may be used by other drivers, so it has to initialise before themdrivers/acpi/acpi_adxl.c new file +1
-0@@ -0,0 +1,199 @@ +// SPDX-License-Identifier: GPL-2.0
drivers/acpi/acpi_adxl.c line 11
Quoted 10 lines
drivers/acpi/acpi_adxl.c new file +10
-0+/* +* Address translation interface via ACPI DSM. +* Copyright (C) 2018 Intel Corporation +* +* Specification for this interface is available at: +* +* https://cdrdv2.intel.com/v1/dl/getContent/603354 +*/ + +#ifdef CONFIG_ACPI_ADXL
This can go now.
Quoted 27 lines
drivers/acpi/acpi_adxl.c new file +27
-0+#include <linux/acpi.h> +#include <linux/adxl.h> + +#define ADXL_REVISION 0x1 +#define ADXL_IDX_GET_ADDR_PARAMS 0x1 +#define ADXL_IDX_FORWARD_TRANSLATE 0x2 +#define ACPI_ADXL_PATH "\\_SB.ADXL" + +/* +* The specification doesn't provide a limit on how many +* components are in a memory address. But since we allocate +* memory based on the number the BIOS tells us, we should +* defend against insane values. +*/ +#define ADXL_MAX_COMPONENTS 500 + +#undef pr_fmt +#define pr_fmt (fmt) "ADXL: " fmt + +static acpi_handle handle; +static union acpi_object *params; +static const guid_t adxl_guid = +GUID_INIT (0xAA3C050A ,0x7EA4 ,0x4C1F , +0xAF ,0xDA ,0x12 ,0x67 ,0xDF ,0xD3 ,0xD4 ,0x8D ); + +static int adxl_count; +static char **adxl_component_names;
...
Quoted 30 lines
drivers/acpi/acpi_adxl.c new file +30
-0+static bool adxl_detect (void ) +{ +char *path =ACPI_ADXL_PATH ; +union acpi_object *p; +acpi_status status; +int i; + + status =acpi_get_handle (NULL , path, &handle); +if (ACPI_FAILURE (status)) { +pr_info ("No ACPI handle for path %s\n" , path); +return false; + } + +if (!acpi_has_method (handle,"_DSM" )) { +pr_info ("No DSM method\n" ); +return false; + } + +if (!acpi_check_dsm (handle, &adxl_guid,ADXL_REVISION , +ADXL_IDX_GET_ADDR_PARAMS | +ADXL_IDX_FORWARD_TRANSLATE )) { +pr_info ("No ADXL DSM methods\n" ); +return false; + } + + params =adxl_dsm (ADXL_IDX_GET_ADDR_PARAMS ,NULL ); +if (!params) { +pr_info ("Failed to get params\n" ); +return false; + }
drivers/acpi/acpi_adxl.c
Quoted 10 lines
drivers/acpi/acpi_adxl.c new file +10
-0+ + p = params->package.elements +1 ; + adxl_count = p->package.count; +if (adxl_count >ADXL_MAX_COMPONENTS ) { +pr_info ("Insane number of address component names %d\n" , adxl_count); +ACPI_FREE (params); +return false; + } + p = p->package.elements; +
/* * Allocate one more for NULL termination. */
drivers/acpi/acpi_adxl.c
Quoted 2 lines
drivers/acpi/acpi_adxl.c new file +2
-0+ adxl_component_names =kcalloc (adxl_count +1 ,sizeof (char *),GFP_KERNEL ); +if (!adxl_component_names) {
pr_err("Error allocating... "
drivers/acpi/acpi_adxl.c
Quoted 13 lines
drivers/acpi/acpi_adxl.c new file +13
-0+ACPI_FREE (params); +return false; + } + +for (i =0 ; i < adxl_count; i++) + adxl_component_names[i] = p[i].string.pointer; + +return true; +} + +static int __init adxl_init (void ) +{ +if (!adxl_detect ())
I guess you don't need that adxl_detect() function and can move its body in here.
Quoted 40 lines
drivers/acpi/acpi_adxl.c new file +6
-0+return -ENODEV ; + return 0; +} +subsys_initcall (adxl_init); + +#endif /* CONFIG_ACPI_ADXL */ include/linux/adxl.h new file +25
-0@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Address translation interface via ACPI DSM. +* Copyright (C) 2018 Intel Corporation +*/ + +#ifndef _LINUX_ADXL_H +#define _LINUX_ADXL_H + +#ifdef CONFIG_ACPI_ADXL +const char *const *adxl_get_component_names (void ); +int adxl_decode (u64 addr,u64 component_values[]); +#else +static inline const char *const *adxl_get_component_names (void ) +{ +return NULL ; +} + +static inline int adxl_decode (u64 addr,u64 component_values[]) +{ +return -EOPNOTSUPP ; +} +#endif + +#endif /* _LINUX_ADXL_H */ Signature · 1 line
2.17.1