diff mbox

[U-Boot,2/5] arm: Disable HVC PSCI calls by default

Message ID 1471374529-61610-3-git-send-email-agraf@suse.de
State Accepted
Commit 51bfb5b6f522b1fbe453c18df03648d72b08131f
Delegated to: Alexander Graf
Headers show

Commit Message

Alexander Graf Aug. 16, 2016, 7:08 p.m. UTC
All systems that are running on armv8 are running bare metal with firmware
that implements PSCI running in EL3. That means we don't really need to expose
the hypercall variants of them.

This patch leaves the code in, but makes the code explicit enough to have the
compiler optimize it out. With this we don't need to worry about hvc vs smc
calling convention when calling psci helper functions.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/arm/cpu/armv8/fwcall.c   | 14 +++++++++++---
 arch/arm/include/asm/system.h | 11 +----------
 arch/arm/mach-meson/board.c   |  2 +-
 board/xilinx/zynqmp/zynqmp.c  |  2 +-
 4 files changed, 14 insertions(+), 15 deletions(-)

Comments

Simon Glass Aug. 18, 2016, 3:44 a.m. UTC | #1
On 16 August 2016 at 13:08, Alexander Graf <agraf@suse.de> wrote:
> All systems that are running on armv8 are running bare metal with firmware
> that implements PSCI running in EL3. That means we don't really need to expose
> the hypercall variants of them.
>
> This patch leaves the code in, but makes the code explicit enough to have the
> compiler optimize it out. With this we don't need to worry about hvc vs smc
> calling convention when calling psci helper functions.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  arch/arm/cpu/armv8/fwcall.c   | 14 +++++++++++---
>  arch/arm/include/asm/system.h | 11 +----------
>  arch/arm/mach-meson/board.c   |  2 +-
>  board/xilinx/zynqmp/zynqmp.c  |  2 +-
>  4 files changed, 14 insertions(+), 15 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Alexander Graf Oct. 13, 2016, 2:34 p.m. UTC | #2
> All systems that are running on armv8 are running bare metal with firmware
> that implements PSCI running in EL3. That means we don't really need to expose
> the hypercall variants of them.
> 
> This patch leaves the code in, but makes the code explicit enough to have the
> compiler optimize it out. With this we don't need to worry about hvc vs smc
> calling convention when calling psci helper functions.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Thanks, applied to
diff mbox

Patch

diff --git a/arch/arm/cpu/armv8/fwcall.c b/arch/arm/cpu/armv8/fwcall.c
index 079e250..6bb68f2 100644
--- a/arch/arm/cpu/armv8/fwcall.c
+++ b/arch/arm/cpu/armv8/fwcall.c
@@ -17,7 +17,7 @@ 
  * x0~x7: input arguments
  * x0~x3: output arguments
  */
-void hvc_call(struct pt_regs *args)
+static void hvc_call(struct pt_regs *args)
 {
 	asm volatile(
 		"ldr x0, %0\n"
@@ -75,13 +75,21 @@  void smc_call(struct pt_regs *args)
 		  "x16", "x17");
 }
 
-void __noreturn psci_system_reset(bool conduit_smc)
+/*
+ * For now, all systems we support run at least in EL2 and thus
+ * trigger PSCI calls to EL3 using SMC. If anyone ever wants to
+ * use PSCI on U-Boot running below a hypervisor, please detect
+ * this and set the flag accordingly.
+ */
+static const bool use_smc_for_psci = true;
+
+void __noreturn psci_system_reset(void)
 {
 	struct pt_regs regs;
 
 	regs.regs[0] = ARM_PSCI_0_2_FN_SYSTEM_RESET;
 
-	if (conduit_smc)
+	if (use_smc_for_psci)
 		smc_call(&regs);
 	else
 		hvc_call(&regs);
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 7b7b867..96f3912 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -107,15 +107,6 @@  void smp_kick_all_cpus(void);
 void flush_l3_cache(void);
 
 /*
- *Issue a hypervisor call in accordance with ARM "SMC Calling convention",
- * DEN0028A
- *
- * @args: input and output arguments
- *
- */
-void hvc_call(struct pt_regs *args);
-
-/*
  *Issue a secure monitor call in accordance with ARM "SMC Calling convention",
  * DEN0028A
  *
@@ -124,7 +115,7 @@  void hvc_call(struct pt_regs *args);
  */
 void smc_call(struct pt_regs *args);
 
-void __noreturn psci_system_reset(bool smc);
+void __noreturn psci_system_reset(void);
 
 #endif	/* __ASSEMBLY__ */
 
diff --git a/arch/arm/mach-meson/board.c b/arch/arm/mach-meson/board.c
index 1dd53e2..f159cbf 100644
--- a/arch/arm/mach-meson/board.c
+++ b/arch/arm/mach-meson/board.c
@@ -43,7 +43,7 @@  void dram_init_banksize(void)
 
 void reset_cpu(ulong addr)
 {
-	psci_system_reset(true);
+	psci_system_reset();
 }
 
 static struct mm_region gxbb_mem_map[] = {
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 0c5d997..5108b94 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -310,5 +310,5 @@  int board_usb_cleanup(int index, enum usb_init_type init)
 
 void reset_misc(void)
 {
-	psci_system_reset(true);
+	psci_system_reset();
 }