* [PATCH 0/3] ACPI: arm64: some cleanups
@ 2024-06-05 13:14 ` Sudeep Holla
0 siblings, 0 replies; 15+ messages in thread
From: Sudeep Holla @ 2024-06-05 13:14 UTC (permalink / raw)
To: linux-acpi, linux-arm-kernel
Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Lorenzo Pieralisi,
Hanjun Guo
Hi,
Couple of patches to move the ACPI arch specific code into
drivers/acpi/arm64/ as they are not strictly arch specific to
keep them under arch/arm64.
Regards,
Sudeep
Sudeep Holla (3):
ACPI: arm64: Sort entries alphabetically
arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/
arm64: FFH: Move ACPI specific code into drivers/acpi/arm64/
arch/arm64/kernel/Makefile | 1 -
arch/arm64/kernel/acpi.c | 105 -----------------
drivers/acpi/arm64/Makefile | 6 +-
.../kernel => drivers/acpi/arm64}/cpuidle.c | 4 -
drivers/acpi/arm64/ffh.c | 107 ++++++++++++++++++
5 files changed, 111 insertions(+), 112 deletions(-)
rename {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c (97%)
create mode 100644 drivers/acpi/arm64/ffh.c
--
2.45.2
^ permalink raw reply [flat|nested] 15+ messages in thread* [PATCH 0/3] ACPI: arm64: some cleanups @ 2024-06-05 13:14 ` Sudeep Holla 0 siblings, 0 replies; 15+ messages in thread From: Sudeep Holla @ 2024-06-05 13:14 UTC (permalink / raw) To: linux-acpi, linux-arm-kernel Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Lorenzo Pieralisi, Hanjun Guo Hi, Couple of patches to move the ACPI arch specific code into drivers/acpi/arm64/ as they are not strictly arch specific to keep them under arch/arm64. Regards, Sudeep Sudeep Holla (3): ACPI: arm64: Sort entries alphabetically arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ arm64: FFH: Move ACPI specific code into drivers/acpi/arm64/ arch/arm64/kernel/Makefile | 1 - arch/arm64/kernel/acpi.c | 105 ----------------- drivers/acpi/arm64/Makefile | 6 +- .../kernel => drivers/acpi/arm64}/cpuidle.c | 4 - drivers/acpi/arm64/ffh.c | 107 ++++++++++++++++++ 5 files changed, 111 insertions(+), 112 deletions(-) rename {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c (97%) create mode 100644 drivers/acpi/arm64/ffh.c -- 2.45.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/3] ACPI: arm64: Sort entries alphabetically 2024-06-05 13:14 ` Sudeep Holla @ 2024-06-05 13:14 ` Sudeep Holla -1 siblings, 0 replies; 15+ messages in thread From: Sudeep Holla @ 2024-06-05 13:14 UTC (permalink / raw) To: linux-acpi, linux-arm-kernel Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Lorenzo Pieralisi, Hanjun Guo Sort the entries in the Makefile alphabetically. Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- drivers/acpi/arm64/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/arm64/Makefile b/drivers/acpi/arm64/Makefile index 726944648c9b..7d7fd6512bca 100644 --- a/drivers/acpi/arm64/Makefile +++ b/drivers/acpi/arm64/Makefile @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_ACPI_AGDI) += agdi.o -obj-$(CONFIG_ACPI_IORT) += iort.o -obj-$(CONFIG_ACPI_GTDT) += gtdt.o obj-$(CONFIG_ACPI_APMT) += apmt.o +obj-$(CONFIG_ACPI_GTDT) += gtdt.o +obj-$(CONFIG_ACPI_IORT) += iort.o obj-$(CONFIG_ARM_AMBA) += amba.o obj-y += dma.o init.o obj-y += thermal_cpufreq.o -- 2.45.2 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 1/3] ACPI: arm64: Sort entries alphabetically @ 2024-06-05 13:14 ` Sudeep Holla 0 siblings, 0 replies; 15+ messages in thread From: Sudeep Holla @ 2024-06-05 13:14 UTC (permalink / raw) To: linux-acpi, linux-arm-kernel Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Lorenzo Pieralisi, Hanjun Guo Sort the entries in the Makefile alphabetically. Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- drivers/acpi/arm64/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/arm64/Makefile b/drivers/acpi/arm64/Makefile index 726944648c9b..7d7fd6512bca 100644 --- a/drivers/acpi/arm64/Makefile +++ b/drivers/acpi/arm64/Makefile @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_ACPI_AGDI) += agdi.o -obj-$(CONFIG_ACPI_IORT) += iort.o -obj-$(CONFIG_ACPI_GTDT) += gtdt.o obj-$(CONFIG_ACPI_APMT) += apmt.o +obj-$(CONFIG_ACPI_GTDT) += gtdt.o +obj-$(CONFIG_ACPI_IORT) += iort.o obj-$(CONFIG_ARM_AMBA) += amba.o obj-y += dma.o init.o obj-y += thermal_cpufreq.o -- 2.45.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ 2024-06-05 13:14 ` Sudeep Holla @ 2024-06-05 13:14 ` Sudeep Holla -1 siblings, 0 replies; 15+ messages in thread From: Sudeep Holla @ 2024-06-05 13:14 UTC (permalink / raw) To: linux-acpi, linux-arm-kernel Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Lorenzo Pieralisi, Hanjun Guo The ACPI cpuidle LPI FFH code can be moved out of arm64 arch code as it just uses SMCCC. Move all the ACPI cpuidle LPI FFH code into drivers/acpi/arm64/cpuidle.c Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- arch/arm64/kernel/Makefile | 1 - drivers/acpi/arm64/Makefile | 1 + {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c | 4 ---- 3 files changed, 1 insertion(+), 5 deletions(-) rename {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c (97%) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 763824963ed1..2b112f3b7510 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -46,7 +46,6 @@ obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_CPU_PM) += sleep.o suspend.o -obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_EFI) += efi.o efi-rt-wrapper.o diff --git a/drivers/acpi/arm64/Makefile b/drivers/acpi/arm64/Makefile index 7d7fd6512bca..2efee23f00b4 100644 --- a/drivers/acpi/arm64/Makefile +++ b/drivers/acpi/arm64/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_ACPI_AGDI) += agdi.o obj-$(CONFIG_ACPI_APMT) += apmt.o obj-$(CONFIG_ACPI_GTDT) += gtdt.o obj-$(CONFIG_ACPI_IORT) += iort.o +obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o obj-$(CONFIG_ARM_AMBA) += amba.o obj-y += dma.o init.o obj-y += thermal_cpufreq.o diff --git a/arch/arm64/kernel/cpuidle.c b/drivers/acpi/arm64/cpuidle.c similarity index 97% rename from arch/arm64/kernel/cpuidle.c rename to drivers/acpi/arm64/cpuidle.c index f372295207fb..801f9c450142 100644 --- a/arch/arm64/kernel/cpuidle.c +++ b/drivers/acpi/arm64/cpuidle.c @@ -10,9 +10,6 @@ #include <linux/cpuidle.h> #include <linux/cpu_pm.h> #include <linux/psci.h> - -#ifdef CONFIG_ACPI_PROCESSOR_IDLE - #include <acpi/processor.h> #define ARM64_LPI_IS_RETENTION_STATE(arch_flags) (!(arch_flags)) @@ -71,4 +68,3 @@ __cpuidle int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi) return CPU_PM_CPU_IDLE_ENTER_PARAM_RCU(psci_cpu_suspend_enter, lpi->index, state); } -#endif -- 2.45.2 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ @ 2024-06-05 13:14 ` Sudeep Holla 0 siblings, 0 replies; 15+ messages in thread From: Sudeep Holla @ 2024-06-05 13:14 UTC (permalink / raw) To: linux-acpi, linux-arm-kernel Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Lorenzo Pieralisi, Hanjun Guo The ACPI cpuidle LPI FFH code can be moved out of arm64 arch code as it just uses SMCCC. Move all the ACPI cpuidle LPI FFH code into drivers/acpi/arm64/cpuidle.c Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- arch/arm64/kernel/Makefile | 1 - drivers/acpi/arm64/Makefile | 1 + {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c | 4 ---- 3 files changed, 1 insertion(+), 5 deletions(-) rename {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c (97%) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 763824963ed1..2b112f3b7510 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -46,7 +46,6 @@ obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_CPU_PM) += sleep.o suspend.o -obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_EFI) += efi.o efi-rt-wrapper.o diff --git a/drivers/acpi/arm64/Makefile b/drivers/acpi/arm64/Makefile index 7d7fd6512bca..2efee23f00b4 100644 --- a/drivers/acpi/arm64/Makefile +++ b/drivers/acpi/arm64/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_ACPI_AGDI) += agdi.o obj-$(CONFIG_ACPI_APMT) += apmt.o obj-$(CONFIG_ACPI_GTDT) += gtdt.o obj-$(CONFIG_ACPI_IORT) += iort.o +obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o obj-$(CONFIG_ARM_AMBA) += amba.o obj-y += dma.o init.o obj-y += thermal_cpufreq.o diff --git a/arch/arm64/kernel/cpuidle.c b/drivers/acpi/arm64/cpuidle.c similarity index 97% rename from arch/arm64/kernel/cpuidle.c rename to drivers/acpi/arm64/cpuidle.c index f372295207fb..801f9c450142 100644 --- a/arch/arm64/kernel/cpuidle.c +++ b/drivers/acpi/arm64/cpuidle.c @@ -10,9 +10,6 @@ #include <linux/cpuidle.h> #include <linux/cpu_pm.h> #include <linux/psci.h> - -#ifdef CONFIG_ACPI_PROCESSOR_IDLE - #include <acpi/processor.h> #define ARM64_LPI_IS_RETENTION_STATE(arch_flags) (!(arch_flags)) @@ -71,4 +68,3 @@ __cpuidle int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi) return CPU_PM_CPU_IDLE_ENTER_PARAM_RCU(psci_cpu_suspend_enter, lpi->index, state); } -#endif -- 2.45.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ 2024-06-05 13:14 ` Sudeep Holla @ 2024-06-11 16:54 ` Catalin Marinas -1 siblings, 0 replies; 15+ messages in thread From: Catalin Marinas @ 2024-06-11 16:54 UTC (permalink / raw) To: Sudeep Holla Cc: linux-acpi, linux-arm-kernel, Will Deacon, Lorenzo Pieralisi, Hanjun Guo On Wed, Jun 05, 2024 at 02:14:57PM +0100, Sudeep Holla wrote: > The ACPI cpuidle LPI FFH code can be moved out of arm64 arch code as > it just uses SMCCC. Move all the ACPI cpuidle LPI FFH code into > drivers/acpi/arm64/cpuidle.c > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> > --- > arch/arm64/kernel/Makefile | 1 - > drivers/acpi/arm64/Makefile | 1 + > {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c | 4 ---- > 3 files changed, 1 insertion(+), 5 deletions(-) > rename {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c (97%) For arch/arm64 changes: Acked-by: Catalin Marinas <catalin.marinas@arm.com> Lorenzo, Hanjun, please let me know if you want these to go in via the arm64 tree or Raphael's one. -- Catalin ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ @ 2024-06-11 16:54 ` Catalin Marinas 0 siblings, 0 replies; 15+ messages in thread From: Catalin Marinas @ 2024-06-11 16:54 UTC (permalink / raw) To: Sudeep Holla Cc: linux-acpi, linux-arm-kernel, Will Deacon, Lorenzo Pieralisi, Hanjun Guo On Wed, Jun 05, 2024 at 02:14:57PM +0100, Sudeep Holla wrote: > The ACPI cpuidle LPI FFH code can be moved out of arm64 arch code as > it just uses SMCCC. Move all the ACPI cpuidle LPI FFH code into > drivers/acpi/arm64/cpuidle.c > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> > --- > arch/arm64/kernel/Makefile | 1 - > drivers/acpi/arm64/Makefile | 1 + > {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c | 4 ---- > 3 files changed, 1 insertion(+), 5 deletions(-) > rename {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c (97%) For arch/arm64 changes: Acked-by: Catalin Marinas <catalin.marinas@arm.com> Lorenzo, Hanjun, please let me know if you want these to go in via the arm64 tree or Raphael's one. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ 2024-06-11 16:54 ` Catalin Marinas (?) @ 2024-06-13 2:21 ` Hanjun Guo -1 siblings, 0 replies; 15+ messages in thread From: Hanjun Guo @ 2024-06-13 2:21 UTC (permalink / raw) To: Catalin Marinas, Sudeep Holla Cc: linux-acpi, linux-arm-kernel, Will Deacon, Lorenzo Pieralisi On 2024/6/12 0:54, Catalin Marinas wrote: > On Wed, Jun 05, 2024 at 02:14:57PM +0100, Sudeep Holla wrote: >> The ACPI cpuidle LPI FFH code can be moved out of arm64 arch code as >> it just uses SMCCC. Move all the ACPI cpuidle LPI FFH code into >> drivers/acpi/arm64/cpuidle.c >> >> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> >> --- >> arch/arm64/kernel/Makefile | 1 - >> drivers/acpi/arm64/Makefile | 1 + >> {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c | 4 ---- >> 3 files changed, 1 insertion(+), 5 deletions(-) >> rename {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c (97%) > > For arch/arm64 changes: > > Acked-by: Catalin Marinas <catalin.marinas@arm.com> > > Lorenzo, Hanjun, please let me know if you want these to go in via the > arm64 tree or Raphael's one. As it's arm64 related code, I would like to go via the arm64 tree. Thanks Hanjun ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/3] arm64: FFH: Move ACPI specific code into drivers/acpi/arm64/ 2024-06-05 13:14 ` Sudeep Holla @ 2024-06-05 13:14 ` Sudeep Holla -1 siblings, 0 replies; 15+ messages in thread From: Sudeep Holla @ 2024-06-05 13:14 UTC (permalink / raw) To: linux-acpi, linux-arm-kernel Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Lorenzo Pieralisi, Hanjun Guo The ACPI FFH Opregion code can be moved out of arm64 arch code as it just uses SMCCC. Move all the ACPI FFH Opregion code into drivers/acpi/arm64/ffh.c Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- arch/arm64/kernel/acpi.c | 105 ----------------------------------- drivers/acpi/arm64/Makefile | 1 + drivers/acpi/arm64/ffh.c | 107 ++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 105 deletions(-) create mode 100644 drivers/acpi/arm64/ffh.c diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index e0e7b93c16cc..fd1917336d3a 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -422,108 +422,3 @@ void arch_reserve_mem_area(acpi_physical_address addr, size_t size) { memblock_mark_nomap(addr, size); } - -#ifdef CONFIG_ACPI_FFH -/* - * Implements ARM64 specific callbacks to support ACPI FFH Operation Region as - * specified in https://developer.arm.com/docs/den0048/latest - */ -struct acpi_ffh_data { - struct acpi_ffh_info info; - void (*invoke_ffh_fn)(unsigned long a0, unsigned long a1, - unsigned long a2, unsigned long a3, - unsigned long a4, unsigned long a5, - unsigned long a6, unsigned long a7, - struct arm_smccc_res *args, - struct arm_smccc_quirk *res); - void (*invoke_ffh64_fn)(const struct arm_smccc_1_2_regs *args, - struct arm_smccc_1_2_regs *res); -}; - -int acpi_ffh_address_space_arch_setup(void *handler_ctxt, void **region_ctxt) -{ - enum arm_smccc_conduit conduit; - struct acpi_ffh_data *ffh_ctxt; - - if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2) - return -EOPNOTSUPP; - - conduit = arm_smccc_1_1_get_conduit(); - if (conduit == SMCCC_CONDUIT_NONE) { - pr_err("%s: invalid SMCCC conduit\n", __func__); - return -EOPNOTSUPP; - } - - ffh_ctxt = kzalloc(sizeof(*ffh_ctxt), GFP_KERNEL); - if (!ffh_ctxt) - return -ENOMEM; - - if (conduit == SMCCC_CONDUIT_SMC) { - ffh_ctxt->invoke_ffh_fn = __arm_smccc_smc; - ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_smc; - } else { - ffh_ctxt->invoke_ffh_fn = __arm_smccc_hvc; - ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_hvc; - } - - memcpy(ffh_ctxt, handler_ctxt, sizeof(ffh_ctxt->info)); - - *region_ctxt = ffh_ctxt; - return AE_OK; -} - -static bool acpi_ffh_smccc_owner_allowed(u32 fid) -{ - int owner = ARM_SMCCC_OWNER_NUM(fid); - - if (owner == ARM_SMCCC_OWNER_STANDARD || - owner == ARM_SMCCC_OWNER_SIP || owner == ARM_SMCCC_OWNER_OEM) - return true; - - return false; -} - -int acpi_ffh_address_space_arch_handler(acpi_integer *value, void *region_context) -{ - int ret = 0; - struct acpi_ffh_data *ffh_ctxt = region_context; - - if (ffh_ctxt->info.offset == 0) { - /* SMC/HVC 32bit call */ - struct arm_smccc_res res; - u32 a[8] = { 0 }, *ptr = (u32 *)value; - - if (!ARM_SMCCC_IS_FAST_CALL(*ptr) || ARM_SMCCC_IS_64(*ptr) || - !acpi_ffh_smccc_owner_allowed(*ptr) || - ffh_ctxt->info.length > 32) { - ret = AE_ERROR; - } else { - int idx, len = ffh_ctxt->info.length >> 2; - - for (idx = 0; idx < len; idx++) - a[idx] = *(ptr + idx); - - ffh_ctxt->invoke_ffh_fn(a[0], a[1], a[2], a[3], a[4], - a[5], a[6], a[7], &res, NULL); - memcpy(value, &res, sizeof(res)); - } - - } else if (ffh_ctxt->info.offset == 1) { - /* SMC/HVC 64bit call */ - struct arm_smccc_1_2_regs *r = (struct arm_smccc_1_2_regs *)value; - - if (!ARM_SMCCC_IS_FAST_CALL(r->a0) || !ARM_SMCCC_IS_64(r->a0) || - !acpi_ffh_smccc_owner_allowed(r->a0) || - ffh_ctxt->info.length > sizeof(*r)) { - ret = AE_ERROR; - } else { - ffh_ctxt->invoke_ffh64_fn(r, r); - memcpy(value, r, ffh_ctxt->info.length); - } - } else { - ret = AE_ERROR; - } - - return ret; -} -#endif /* CONFIG_ACPI_FFH */ diff --git a/drivers/acpi/arm64/Makefile b/drivers/acpi/arm64/Makefile index 2efee23f00b4..05ecde9eaabe 100644 --- a/drivers/acpi/arm64/Makefile +++ b/drivers/acpi/arm64/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_ACPI_AGDI) += agdi.o obj-$(CONFIG_ACPI_APMT) += apmt.o +obj-$(CONFIG_ACPI_FFH) += ffh.o obj-$(CONFIG_ACPI_GTDT) += gtdt.o obj-$(CONFIG_ACPI_IORT) += iort.o obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o diff --git a/drivers/acpi/arm64/ffh.c b/drivers/acpi/arm64/ffh.c new file mode 100644 index 000000000000..877edc6557e9 --- /dev/null +++ b/drivers/acpi/arm64/ffh.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include <linux/acpi.h> +#include <linux/arm-smccc.h> +#include <linux/slab.h> + +/* + * Implements ARM64 specific callbacks to support ACPI FFH Operation Region as + * specified in https://developer.arm.com/docs/den0048/latest + */ +struct acpi_ffh_data { + struct acpi_ffh_info info; + void (*invoke_ffh_fn)(unsigned long a0, unsigned long a1, + unsigned long a2, unsigned long a3, + unsigned long a4, unsigned long a5, + unsigned long a6, unsigned long a7, + struct arm_smccc_res *args, + struct arm_smccc_quirk *res); + void (*invoke_ffh64_fn)(const struct arm_smccc_1_2_regs *args, + struct arm_smccc_1_2_regs *res); +}; + +int acpi_ffh_address_space_arch_setup(void *handler_ctxt, void **region_ctxt) +{ + enum arm_smccc_conduit conduit; + struct acpi_ffh_data *ffh_ctxt; + + if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2) + return -EOPNOTSUPP; + + conduit = arm_smccc_1_1_get_conduit(); + if (conduit == SMCCC_CONDUIT_NONE) { + pr_err("%s: invalid SMCCC conduit\n", __func__); + return -EOPNOTSUPP; + } + + ffh_ctxt = kzalloc(sizeof(*ffh_ctxt), GFP_KERNEL); + if (!ffh_ctxt) + return -ENOMEM; + + if (conduit == SMCCC_CONDUIT_SMC) { + ffh_ctxt->invoke_ffh_fn = __arm_smccc_smc; + ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_smc; + } else { + ffh_ctxt->invoke_ffh_fn = __arm_smccc_hvc; + ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_hvc; + } + + memcpy(ffh_ctxt, handler_ctxt, sizeof(ffh_ctxt->info)); + + *region_ctxt = ffh_ctxt; + return AE_OK; +} + +static bool acpi_ffh_smccc_owner_allowed(u32 fid) +{ + int owner = ARM_SMCCC_OWNER_NUM(fid); + + if (owner == ARM_SMCCC_OWNER_STANDARD || + owner == ARM_SMCCC_OWNER_SIP || owner == ARM_SMCCC_OWNER_OEM) + return true; + + return false; +} + +int acpi_ffh_address_space_arch_handler(acpi_integer *value, void *region_context) +{ + int ret = 0; + struct acpi_ffh_data *ffh_ctxt = region_context; + + if (ffh_ctxt->info.offset == 0) { + /* SMC/HVC 32bit call */ + struct arm_smccc_res res; + u32 a[8] = { 0 }, *ptr = (u32 *)value; + + if (!ARM_SMCCC_IS_FAST_CALL(*ptr) || ARM_SMCCC_IS_64(*ptr) || + !acpi_ffh_smccc_owner_allowed(*ptr) || + ffh_ctxt->info.length > 32) { + ret = AE_ERROR; + } else { + int idx, len = ffh_ctxt->info.length >> 2; + + for (idx = 0; idx < len; idx++) + a[idx] = *(ptr + idx); + + ffh_ctxt->invoke_ffh_fn(a[0], a[1], a[2], a[3], a[4], + a[5], a[6], a[7], &res, NULL); + memcpy(value, &res, sizeof(res)); + } + + } else if (ffh_ctxt->info.offset == 1) { + /* SMC/HVC 64bit call */ + struct arm_smccc_1_2_regs *r = (struct arm_smccc_1_2_regs *)value; + + if (!ARM_SMCCC_IS_FAST_CALL(r->a0) || !ARM_SMCCC_IS_64(r->a0) || + !acpi_ffh_smccc_owner_allowed(r->a0) || + ffh_ctxt->info.length > sizeof(*r)) { + ret = AE_ERROR; + } else { + ffh_ctxt->invoke_ffh64_fn(r, r); + memcpy(value, r, ffh_ctxt->info.length); + } + } else { + ret = AE_ERROR; + } + + return ret; +} -- 2.45.2 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/3] arm64: FFH: Move ACPI specific code into drivers/acpi/arm64/ @ 2024-06-05 13:14 ` Sudeep Holla 0 siblings, 0 replies; 15+ messages in thread From: Sudeep Holla @ 2024-06-05 13:14 UTC (permalink / raw) To: linux-acpi, linux-arm-kernel Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Lorenzo Pieralisi, Hanjun Guo The ACPI FFH Opregion code can be moved out of arm64 arch code as it just uses SMCCC. Move all the ACPI FFH Opregion code into drivers/acpi/arm64/ffh.c Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- arch/arm64/kernel/acpi.c | 105 ----------------------------------- drivers/acpi/arm64/Makefile | 1 + drivers/acpi/arm64/ffh.c | 107 ++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 105 deletions(-) create mode 100644 drivers/acpi/arm64/ffh.c diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index e0e7b93c16cc..fd1917336d3a 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -422,108 +422,3 @@ void arch_reserve_mem_area(acpi_physical_address addr, size_t size) { memblock_mark_nomap(addr, size); } - -#ifdef CONFIG_ACPI_FFH -/* - * Implements ARM64 specific callbacks to support ACPI FFH Operation Region as - * specified in https://developer.arm.com/docs/den0048/latest - */ -struct acpi_ffh_data { - struct acpi_ffh_info info; - void (*invoke_ffh_fn)(unsigned long a0, unsigned long a1, - unsigned long a2, unsigned long a3, - unsigned long a4, unsigned long a5, - unsigned long a6, unsigned long a7, - struct arm_smccc_res *args, - struct arm_smccc_quirk *res); - void (*invoke_ffh64_fn)(const struct arm_smccc_1_2_regs *args, - struct arm_smccc_1_2_regs *res); -}; - -int acpi_ffh_address_space_arch_setup(void *handler_ctxt, void **region_ctxt) -{ - enum arm_smccc_conduit conduit; - struct acpi_ffh_data *ffh_ctxt; - - if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2) - return -EOPNOTSUPP; - - conduit = arm_smccc_1_1_get_conduit(); - if (conduit == SMCCC_CONDUIT_NONE) { - pr_err("%s: invalid SMCCC conduit\n", __func__); - return -EOPNOTSUPP; - } - - ffh_ctxt = kzalloc(sizeof(*ffh_ctxt), GFP_KERNEL); - if (!ffh_ctxt) - return -ENOMEM; - - if (conduit == SMCCC_CONDUIT_SMC) { - ffh_ctxt->invoke_ffh_fn = __arm_smccc_smc; - ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_smc; - } else { - ffh_ctxt->invoke_ffh_fn = __arm_smccc_hvc; - ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_hvc; - } - - memcpy(ffh_ctxt, handler_ctxt, sizeof(ffh_ctxt->info)); - - *region_ctxt = ffh_ctxt; - return AE_OK; -} - -static bool acpi_ffh_smccc_owner_allowed(u32 fid) -{ - int owner = ARM_SMCCC_OWNER_NUM(fid); - - if (owner == ARM_SMCCC_OWNER_STANDARD || - owner == ARM_SMCCC_OWNER_SIP || owner == ARM_SMCCC_OWNER_OEM) - return true; - - return false; -} - -int acpi_ffh_address_space_arch_handler(acpi_integer *value, void *region_context) -{ - int ret = 0; - struct acpi_ffh_data *ffh_ctxt = region_context; - - if (ffh_ctxt->info.offset == 0) { - /* SMC/HVC 32bit call */ - struct arm_smccc_res res; - u32 a[8] = { 0 }, *ptr = (u32 *)value; - - if (!ARM_SMCCC_IS_FAST_CALL(*ptr) || ARM_SMCCC_IS_64(*ptr) || - !acpi_ffh_smccc_owner_allowed(*ptr) || - ffh_ctxt->info.length > 32) { - ret = AE_ERROR; - } else { - int idx, len = ffh_ctxt->info.length >> 2; - - for (idx = 0; idx < len; idx++) - a[idx] = *(ptr + idx); - - ffh_ctxt->invoke_ffh_fn(a[0], a[1], a[2], a[3], a[4], - a[5], a[6], a[7], &res, NULL); - memcpy(value, &res, sizeof(res)); - } - - } else if (ffh_ctxt->info.offset == 1) { - /* SMC/HVC 64bit call */ - struct arm_smccc_1_2_regs *r = (struct arm_smccc_1_2_regs *)value; - - if (!ARM_SMCCC_IS_FAST_CALL(r->a0) || !ARM_SMCCC_IS_64(r->a0) || - !acpi_ffh_smccc_owner_allowed(r->a0) || - ffh_ctxt->info.length > sizeof(*r)) { - ret = AE_ERROR; - } else { - ffh_ctxt->invoke_ffh64_fn(r, r); - memcpy(value, r, ffh_ctxt->info.length); - } - } else { - ret = AE_ERROR; - } - - return ret; -} -#endif /* CONFIG_ACPI_FFH */ diff --git a/drivers/acpi/arm64/Makefile b/drivers/acpi/arm64/Makefile index 2efee23f00b4..05ecde9eaabe 100644 --- a/drivers/acpi/arm64/Makefile +++ b/drivers/acpi/arm64/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_ACPI_AGDI) += agdi.o obj-$(CONFIG_ACPI_APMT) += apmt.o +obj-$(CONFIG_ACPI_FFH) += ffh.o obj-$(CONFIG_ACPI_GTDT) += gtdt.o obj-$(CONFIG_ACPI_IORT) += iort.o obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o diff --git a/drivers/acpi/arm64/ffh.c b/drivers/acpi/arm64/ffh.c new file mode 100644 index 000000000000..877edc6557e9 --- /dev/null +++ b/drivers/acpi/arm64/ffh.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include <linux/acpi.h> +#include <linux/arm-smccc.h> +#include <linux/slab.h> + +/* + * Implements ARM64 specific callbacks to support ACPI FFH Operation Region as + * specified in https://developer.arm.com/docs/den0048/latest + */ +struct acpi_ffh_data { + struct acpi_ffh_info info; + void (*invoke_ffh_fn)(unsigned long a0, unsigned long a1, + unsigned long a2, unsigned long a3, + unsigned long a4, unsigned long a5, + unsigned long a6, unsigned long a7, + struct arm_smccc_res *args, + struct arm_smccc_quirk *res); + void (*invoke_ffh64_fn)(const struct arm_smccc_1_2_regs *args, + struct arm_smccc_1_2_regs *res); +}; + +int acpi_ffh_address_space_arch_setup(void *handler_ctxt, void **region_ctxt) +{ + enum arm_smccc_conduit conduit; + struct acpi_ffh_data *ffh_ctxt; + + if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2) + return -EOPNOTSUPP; + + conduit = arm_smccc_1_1_get_conduit(); + if (conduit == SMCCC_CONDUIT_NONE) { + pr_err("%s: invalid SMCCC conduit\n", __func__); + return -EOPNOTSUPP; + } + + ffh_ctxt = kzalloc(sizeof(*ffh_ctxt), GFP_KERNEL); + if (!ffh_ctxt) + return -ENOMEM; + + if (conduit == SMCCC_CONDUIT_SMC) { + ffh_ctxt->invoke_ffh_fn = __arm_smccc_smc; + ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_smc; + } else { + ffh_ctxt->invoke_ffh_fn = __arm_smccc_hvc; + ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_hvc; + } + + memcpy(ffh_ctxt, handler_ctxt, sizeof(ffh_ctxt->info)); + + *region_ctxt = ffh_ctxt; + return AE_OK; +} + +static bool acpi_ffh_smccc_owner_allowed(u32 fid) +{ + int owner = ARM_SMCCC_OWNER_NUM(fid); + + if (owner == ARM_SMCCC_OWNER_STANDARD || + owner == ARM_SMCCC_OWNER_SIP || owner == ARM_SMCCC_OWNER_OEM) + return true; + + return false; +} + +int acpi_ffh_address_space_arch_handler(acpi_integer *value, void *region_context) +{ + int ret = 0; + struct acpi_ffh_data *ffh_ctxt = region_context; + + if (ffh_ctxt->info.offset == 0) { + /* SMC/HVC 32bit call */ + struct arm_smccc_res res; + u32 a[8] = { 0 }, *ptr = (u32 *)value; + + if (!ARM_SMCCC_IS_FAST_CALL(*ptr) || ARM_SMCCC_IS_64(*ptr) || + !acpi_ffh_smccc_owner_allowed(*ptr) || + ffh_ctxt->info.length > 32) { + ret = AE_ERROR; + } else { + int idx, len = ffh_ctxt->info.length >> 2; + + for (idx = 0; idx < len; idx++) + a[idx] = *(ptr + idx); + + ffh_ctxt->invoke_ffh_fn(a[0], a[1], a[2], a[3], a[4], + a[5], a[6], a[7], &res, NULL); + memcpy(value, &res, sizeof(res)); + } + + } else if (ffh_ctxt->info.offset == 1) { + /* SMC/HVC 64bit call */ + struct arm_smccc_1_2_regs *r = (struct arm_smccc_1_2_regs *)value; + + if (!ARM_SMCCC_IS_FAST_CALL(r->a0) || !ARM_SMCCC_IS_64(r->a0) || + !acpi_ffh_smccc_owner_allowed(r->a0) || + ffh_ctxt->info.length > sizeof(*r)) { + ret = AE_ERROR; + } else { + ffh_ctxt->invoke_ffh64_fn(r, r); + memcpy(value, r, ffh_ctxt->info.length); + } + } else { + ret = AE_ERROR; + } + + return ret; +} -- 2.45.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] arm64: FFH: Move ACPI specific code into drivers/acpi/arm64/ 2024-06-05 13:14 ` Sudeep Holla @ 2024-06-11 16:54 ` Catalin Marinas -1 siblings, 0 replies; 15+ messages in thread From: Catalin Marinas @ 2024-06-11 16:54 UTC (permalink / raw) To: Sudeep Holla Cc: linux-acpi, linux-arm-kernel, Will Deacon, Lorenzo Pieralisi, Hanjun Guo On Wed, Jun 05, 2024 at 02:14:58PM +0100, Sudeep Holla wrote: > The ACPI FFH Opregion code can be moved out of arm64 arch code as > it just uses SMCCC. Move all the ACPI FFH Opregion code into > drivers/acpi/arm64/ffh.c > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] arm64: FFH: Move ACPI specific code into drivers/acpi/arm64/ @ 2024-06-11 16:54 ` Catalin Marinas 0 siblings, 0 replies; 15+ messages in thread From: Catalin Marinas @ 2024-06-11 16:54 UTC (permalink / raw) To: Sudeep Holla Cc: linux-acpi, linux-arm-kernel, Will Deacon, Lorenzo Pieralisi, Hanjun Guo On Wed, Jun 05, 2024 at 02:14:58PM +0100, Sudeep Holla wrote: > The ACPI FFH Opregion code can be moved out of arm64 arch code as > it just uses SMCCC. Move all the ACPI FFH Opregion code into > drivers/acpi/arm64/ffh.c > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/3] ACPI: arm64: some cleanups 2024-06-05 13:14 ` Sudeep Holla ` (3 preceding siblings ...) (?) @ 2024-06-13 2:19 ` Hanjun Guo -1 siblings, 0 replies; 15+ messages in thread From: Hanjun Guo @ 2024-06-13 2:19 UTC (permalink / raw) To: Sudeep Holla, linux-acpi, linux-arm-kernel Cc: Catalin Marinas, Will Deacon, Lorenzo Pieralisi On 2024/6/5 21:14, Sudeep Holla wrote: > Hi, > > Couple of patches to move the ACPI arch specific code into > drivers/acpi/arm64/ as they are not strictly arch specific to > keep them under arch/arm64. > > Regards, > Sudeep > > Sudeep Holla (3): > ACPI: arm64: Sort entries alphabetically > arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ > arm64: FFH: Move ACPI specific code into drivers/acpi/arm64/ > > arch/arm64/kernel/Makefile | 1 - > arch/arm64/kernel/acpi.c | 105 ----------------- > drivers/acpi/arm64/Makefile | 6 +- > .../kernel => drivers/acpi/arm64}/cpuidle.c | 4 - > drivers/acpi/arm64/ffh.c | 107 ++++++++++++++++++ > 5 files changed, 111 insertions(+), 112 deletions(-) > rename {arch/arm64/kernel => drivers/acpi/arm64}/cpuidle.c (97%) > create mode 100644 drivers/acpi/arm64/ffh.c Looks good to me, and I did a successful compile test, Acked-by: Hanjun Guo <guohanjun@huawei.com> Thanks Hanjun ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/3] ACPI: arm64: some cleanups 2024-06-05 13:14 ` Sudeep Holla ` (4 preceding siblings ...) (?) @ 2024-06-13 9:50 ` Catalin Marinas -1 siblings, 0 replies; 15+ messages in thread From: Catalin Marinas @ 2024-06-13 9:50 UTC (permalink / raw) To: linux-acpi, linux-arm-kernel, Sudeep Holla Cc: Will Deacon, Lorenzo Pieralisi, Hanjun Guo On Wed, 05 Jun 2024 14:14:55 +0100, Sudeep Holla wrote: > Couple of patches to move the ACPI arch specific code into > drivers/acpi/arm64/ as they are not strictly arch specific to > keep them under arch/arm64. > > Regards, > Sudeep > > [...] Applied to arm64 (for-next/acpi), thanks! [1/3] ACPI: arm64: Sort entries alphabetically https://git.kernel.org/arm64/c/f8c6c92790dd [2/3] arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ https://git.kernel.org/arm64/c/99e7a8adc0ca [3/3] arm64: FFH: Move ACPI specific code into drivers/acpi/arm64/ https://git.kernel.org/arm64/c/7a7a1cac3c2f -- Catalin ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2024-06-13 9:50 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-06-05 13:14 [PATCH 0/3] ACPI: arm64: some cleanups Sudeep Holla 2024-06-05 13:14 ` Sudeep Holla 2024-06-05 13:14 ` [PATCH 1/3] ACPI: arm64: Sort entries alphabetically Sudeep Holla 2024-06-05 13:14 ` Sudeep Holla 2024-06-05 13:14 ` [PATCH 2/3] arm64: cpuidle: Move ACPI specific code into drivers/acpi/arm64/ Sudeep Holla 2024-06-05 13:14 ` Sudeep Holla 2024-06-11 16:54 ` Catalin Marinas 2024-06-11 16:54 ` Catalin Marinas 2024-06-13 2:21 ` Hanjun Guo 2024-06-05 13:14 ` [PATCH 3/3] arm64: FFH: " Sudeep Holla 2024-06-05 13:14 ` Sudeep Holla 2024-06-11 16:54 ` Catalin Marinas 2024-06-11 16:54 ` Catalin Marinas 2024-06-13 2:19 ` [PATCH 0/3] ACPI: arm64: some cleanups Hanjun Guo 2024-06-13 9:50 ` Catalin Marinas
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.