diff mbox

[v3,4/4] drivers: psci: replace psci firmware calls

Message ID 1448449461-5043-5-git-send-email-jens.wiklander@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jens Wiklander Nov. 25, 2015, 11:04 a.m. UTC
Switch to use a generic interface for issuing SMC/HVC based on ARM SMC
Calling Convention. Removes now the now unused psci-call.S.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm/kernel/Makefile      |  1 -
 arch/arm/kernel/psci-call.S   | 31 -------------------------------
 arch/arm64/kernel/Makefile    |  2 +-
 arch/arm64/kernel/psci-call.S | 28 ----------------------------
 drivers/firmware/psci.c       | 23 +++++++++++++++++++++--
 5 files changed, 22 insertions(+), 63 deletions(-)
 delete mode 100644 arch/arm/kernel/psci-call.S
 delete mode 100644 arch/arm64/kernel/psci-call.S

Comments

Jens Wiklander Dec. 1, 2015, 8:46 a.m. UTC | #1
+lorenzo.pieralisi@arm.com

On Wed, Nov 25, 2015 at 12:04:21PM +0100, Jens Wiklander wrote:
> Switch to use a generic interface for issuing SMC/HVC based on ARM SMC
> Calling Convention. Removes now the now unused psci-call.S.
> 
> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> Acked-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm/kernel/Makefile      |  1 -
>  arch/arm/kernel/psci-call.S   | 31 -------------------------------
>  arch/arm64/kernel/Makefile    |  2 +-
>  arch/arm64/kernel/psci-call.S | 28 ----------------------------
>  drivers/firmware/psci.c       | 23 +++++++++++++++++++++--
>  5 files changed, 22 insertions(+), 63 deletions(-)
>  delete mode 100644 arch/arm/kernel/psci-call.S
>  delete mode 100644 arch/arm64/kernel/psci-call.S
> 
> diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
> index d2d0042..80856de 100644
> --- a/arch/arm/kernel/Makefile
> +++ b/arch/arm/kernel/Makefile
> @@ -88,7 +88,6 @@ obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
>  
>  obj-$(CONFIG_ARM_VIRT_EXT)	+= hyp-stub.o
>  ifeq ($(CONFIG_ARM_PSCI),y)
> -obj-y				+= psci-call.o
>  obj-$(CONFIG_SMP)		+= psci_smp.o
>  endif
>  
> diff --git a/arch/arm/kernel/psci-call.S b/arch/arm/kernel/psci-call.S
> deleted file mode 100644
> index a78e9e1..0000000
> --- a/arch/arm/kernel/psci-call.S
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/*
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * Copyright (C) 2015 ARM Limited
> - *
> - * Author: Mark Rutland <mark.rutland@arm.com>
> - */
> -
> -#include <linux/linkage.h>
> -
> -#include <asm/opcodes-sec.h>
> -#include <asm/opcodes-virt.h>
> -
> -/* int __invoke_psci_fn_hvc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
> -ENTRY(__invoke_psci_fn_hvc)
> -	__HVC(0)
> -	bx	lr
> -ENDPROC(__invoke_psci_fn_hvc)
> -
> -/* int __invoke_psci_fn_smc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
> -ENTRY(__invoke_psci_fn_smc)
> -	__SMC(0)
> -	bx	lr
> -ENDPROC(__invoke_psci_fn_smc)
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index 16d24a4..02893fa 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -15,7 +15,7 @@ CFLAGS_REMOVE_return_address.o = -pg
>  arm64-obj-y		:= debug-monitors.o entry.o irq.o fpsimd.o		\
>  			   entry-fpsimd.o process.o ptrace.o setup.o signal.o	\
>  			   sys.o stacktrace.o time.o traps.o io.o vdso.o	\
> -			   hyp-stub.o psci.o psci-call.o cpu_ops.o insn.o	\
> +			   hyp-stub.o psci.o cpu_ops.o insn.o	\
>  			   return_address.o cpuinfo.o cpu_errata.o		\
>  			   cpufeature.o alternative.o cacheinfo.o		\
>  			   smp.o smp_spin_table.o topology.o smccc-call.o
> diff --git a/arch/arm64/kernel/psci-call.S b/arch/arm64/kernel/psci-call.S
> deleted file mode 100644
> index cf83e61..0000000
> --- a/arch/arm64/kernel/psci-call.S
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/*
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * Copyright (C) 2015 ARM Limited
> - *
> - * Author: Will Deacon <will.deacon@arm.com>
> - */
> -
> -#include <linux/linkage.h>
> -
> -/* int __invoke_psci_fn_hvc(u64 function_id, u64 arg0, u64 arg1, u64 arg2) */
> -ENTRY(__invoke_psci_fn_hvc)
> -	hvc	#0
> -	ret
> -ENDPROC(__invoke_psci_fn_hvc)
> -
> -/* int __invoke_psci_fn_smc(u64 function_id, u64 arg0, u64 arg1, u64 arg2) */
> -ENTRY(__invoke_psci_fn_smc)
> -	smc	#0
> -	ret
> -ENDPROC(__invoke_psci_fn_smc)
> diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> index 42700f0..9c55d11 100644
> --- a/drivers/firmware/psci.c
> +++ b/drivers/firmware/psci.c
> @@ -19,6 +19,7 @@
>  #include <linux/pm.h>
>  #include <linux/printk.h>
>  #include <linux/psci.h>
> +#include <linux/arm-smccc.h>
>  #include <linux/reboot.h>
>  
>  #include <uapi/linux/psci.h>
> @@ -56,8 +57,6 @@ struct psci_operations psci_ops;
>  
>  typedef unsigned long (psci_fn)(unsigned long, unsigned long,
>  				unsigned long, unsigned long);
> -asmlinkage psci_fn __invoke_psci_fn_hvc;
> -asmlinkage psci_fn __invoke_psci_fn_smc;
>  static psci_fn *invoke_psci_fn;
>  
>  enum psci_function {
> @@ -70,6 +69,26 @@ enum psci_function {
>  
>  static u32 psci_function_id[PSCI_FN_MAX];
>  
> +static unsigned long __invoke_psci_fn_hvc(unsigned long function_id,
> +			unsigned long arg0, unsigned long arg1,
> +			unsigned long arg2)
> +{
> +	struct arm_smccc_res res;
> +
> +	arm_smccc_hvc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
> +	return res.a0;
> +}
> +
> +static unsigned long __invoke_psci_fn_smc(unsigned long function_id,
> +			unsigned long arg0, unsigned long arg1,
> +			unsigned long arg2)
> +{
> +	struct arm_smccc_res res;
> +
> +	arm_smccc_smc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
> +	return res.a0;
> +}
> +
>  static int psci_to_linux_errno(int errno)
>  {
>  	switch (errno) {
> -- 
> 1.9.1
>
Mark Rutland Dec. 1, 2015, 6:47 p.m. UTC | #2
Hi Jens,

On Wed, Nov 25, 2015 at 12:04:21PM +0100, Jens Wiklander wrote:
> Switch to use a generic interface for issuing SMC/HVC based on ARM SMC
> Calling Convention. Removes now the now unused psci-call.S.
> 
> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> Acked-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm/kernel/Makefile      |  1 -
>  arch/arm/kernel/psci-call.S   | 31 -------------------------------
>  arch/arm64/kernel/Makefile    |  2 +-
>  arch/arm64/kernel/psci-call.S | 28 ----------------------------
>  drivers/firmware/psci.c       | 23 +++++++++++++++++++++--
>  5 files changed, 22 insertions(+), 63 deletions(-)
>  delete mode 100644 arch/arm/kernel/psci-call.S
>  delete mode 100644 arch/arm64/kernel/psci-call.S

As a heads-up, this conflicts with changes in drivers/firmware/psci.c
that appeared in for v4.4-rc1.

The conflict is trivial (upstream some functions were added to the same
location as the invocation functions), but even git am -3 doesn't seem
to be able to fix that up automatically, so it would be good if you
could rebase this to v4.4-rc1 so as to avoid that conflict.

> diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> index 42700f0..9c55d11 100644
> --- a/drivers/firmware/psci.c
> +++ b/drivers/firmware/psci.c
> @@ -19,6 +19,7 @@
>  #include <linux/pm.h>
>  #include <linux/printk.h>
>  #include <linux/psci.h>
> +#include <linux/arm-smccc.h>
>  #include <linux/reboot.h>

Nit: please move the arm-smccc.h include to the start of the list to
keep this ordered alphabetically.

> +static unsigned long __invoke_psci_fn_hvc(unsigned long function_id,
> +			unsigned long arg0, unsigned long arg1,
> +			unsigned long arg2)
> +{
> +	struct arm_smccc_res res;
> +
> +	arm_smccc_hvc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
> +	return res.a0;
> +}
> +
> +static unsigned long __invoke_psci_fn_smc(unsigned long function_id,
> +			unsigned long arg0, unsigned long arg1,
> +			unsigned long arg2)
> +{
> +	struct arm_smccc_res res;
> +
> +	arm_smccc_smc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
> +	return res.a0;
> +}
> +

As mentioned above, this part needs to be rebased to v4.4-rc1 to avoid
conflicts.

I've given this a spin on arm64 (native and virtual) and arm (virtual).
SMP bringup, hotplug, and reboot worked as expected in all cases.

Assuming you apply the fixes requested above, for the PSCI parts:

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>

What's the plan for merging this? I assume this'll go via arm-soc?

Thanks,
Mark.
Jens Wiklander Dec. 1, 2015, 7:44 p.m. UTC | #3
+Lorenzo

On Tue, Dec 01, 2015 at 06:47:42PM +0000, Mark Rutland wrote:
> Hi Jens,
> 
> On Wed, Nov 25, 2015 at 12:04:21PM +0100, Jens Wiklander wrote:
> > Switch to use a generic interface for issuing SMC/HVC based on ARM SMC
> > Calling Convention. Removes now the now unused psci-call.S.
> > 
> > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> > Acked-by: Will Deacon <will.deacon@arm.com>
> > ---
> >  arch/arm/kernel/Makefile      |  1 -
> >  arch/arm/kernel/psci-call.S   | 31 -------------------------------
> >  arch/arm64/kernel/Makefile    |  2 +-
> >  arch/arm64/kernel/psci-call.S | 28 ----------------------------
> >  drivers/firmware/psci.c       | 23 +++++++++++++++++++++--
> >  5 files changed, 22 insertions(+), 63 deletions(-)
> >  delete mode 100644 arch/arm/kernel/psci-call.S
> >  delete mode 100644 arch/arm64/kernel/psci-call.S
> 
> As a heads-up, this conflicts with changes in drivers/firmware/psci.c
> that appeared in for v4.4-rc1.
> 
> The conflict is trivial (upstream some functions were added to the same
> location as the invocation functions), but even git am -3 doesn't seem
> to be able to fix that up automatically, so it would be good if you
> could rebase this to v4.4-rc1 so as to avoid that conflict.
> 
> > diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> > index 42700f0..9c55d11 100644
> > --- a/drivers/firmware/psci.c
> > +++ b/drivers/firmware/psci.c
> > @@ -19,6 +19,7 @@
> >  #include <linux/pm.h>
> >  #include <linux/printk.h>
> >  #include <linux/psci.h>
> > +#include <linux/arm-smccc.h>
> >  #include <linux/reboot.h>
> 
> Nit: please move the arm-smccc.h include to the start of the list to
> keep this ordered alphabetically.
> 
> > +static unsigned long __invoke_psci_fn_hvc(unsigned long function_id,
> > +			unsigned long arg0, unsigned long arg1,
> > +			unsigned long arg2)
> > +{
> > +	struct arm_smccc_res res;
> > +
> > +	arm_smccc_hvc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
> > +	return res.a0;
> > +}
> > +
> > +static unsigned long __invoke_psci_fn_smc(unsigned long function_id,
> > +			unsigned long arg0, unsigned long arg1,
> > +			unsigned long arg2)
> > +{
> > +	struct arm_smccc_res res;
> > +
> > +	arm_smccc_smc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
> > +	return res.a0;
> > +}
> > +
> 
> As mentioned above, this part needs to be rebased to v4.4-rc1 to avoid
> conflicts.
> 
> I've given this a spin on arm64 (native and virtual) and arm (virtual).
> SMP bringup, hotplug, and reboot worked as expected in all cases.
> 
> Assuming you apply the fixes requested above, for the PSCI parts:
> 
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> Tested-by: Mark Rutland <mark.rutland@arm.com>

Thanks for the feeback and heads up, I'll fix.

> 
> What's the plan for merging this? I assume this'll go via arm-soc?

I talked to Arnd about this and he suggested to go via Russel.

Thanks,
Jens
Lorenzo Pieralisi Dec. 16, 2015, 10:55 a.m. UTC | #4
[CC'ed Daniel]

On Tue, Dec 01, 2015 at 08:44:22PM +0100, Jens Wiklander wrote:

[...]

> > What's the plan for merging this? I assume this'll go via arm-soc?
> 
> I talked to Arnd about this and he suggested to go via Russel.

Heads-up, this patch will conflict with:

https://patchwork.kernel.org/patch/7418351/

that goes via linux-pm tree, please let me and Daniel know how
you want us to sort this out.

Thanks,
Lorenzo
Jens Wiklander Dec. 16, 2015, 12:55 p.m. UTC | #5
On Wed, Dec 16, 2015 at 10:55:29AM +0000, Lorenzo Pieralisi wrote:
> [CC'ed Daniel]
> 
> On Tue, Dec 01, 2015 at 08:44:22PM +0100, Jens Wiklander wrote:
> 
> [...]
> 
> > > What's the plan for merging this? I assume this'll go via arm-soc?
> > 
> > I talked to Arnd about this and he suggested to go via Russel.
> 
> Heads-up, this patch will conflict with:
> 
> https://patchwork.kernel.org/patch/7418351/
> 
> that goes via linux-pm tree, please let me and Daniel know how
> you want us to sort this out.

I guess this arm-smccc patchset need to go together with that patch in
some way. I've just uploaded my patches in Russels patch system, but I
can stop that and try to go via the linux-pm tree instead if you think
the maintainer would accept that. I'll need to ask Russel if he can ack
the patches "arm/arm64: add arm-smccc" and
"arm: add implementation for arm-smccc" first though.

Would that work or do you have another idea? I'm of course happy either
way as long as the patches get through. I'm new to this so any advice is
appreciated.

Thanks,
Jens
Lorenzo Pieralisi Dec. 16, 2015, 1:47 p.m. UTC | #6
On Wed, Dec 16, 2015 at 01:55:11PM +0100, Jens Wiklander wrote:
> On Wed, Dec 16, 2015 at 10:55:29AM +0000, Lorenzo Pieralisi wrote:
> > [CC'ed Daniel]
> > 
> > On Tue, Dec 01, 2015 at 08:44:22PM +0100, Jens Wiklander wrote:
> > 
> > [...]
> > 
> > > > What's the plan for merging this? I assume this'll go via arm-soc?
> > > 
> > > I talked to Arnd about this and he suggested to go via Russel.
> > 
> > Heads-up, this patch will conflict with:
> > 
> > https://patchwork.kernel.org/patch/7418351/
> > 
> > that goes via linux-pm tree, please let me and Daniel know how
> > you want us to sort this out.
> 
> I guess this arm-smccc patchset need to go together with that patch in
> some way. I've just uploaded my patches in Russels patch system, but I
> can stop that and try to go via the linux-pm tree instead if you think
> the maintainer would accept that. I'll need to ask Russel if he can ack
> the patches "arm/arm64: add arm-smccc" and
> "arm: add implementation for arm-smccc" first though.
> 
> Would that work or do you have another idea? I'm of course happy either
> way as long as the patches get through. I'm new to this so any advice is
> appreciated.

It is really up to Daniel and Russell. If Daniel acks:

https://patchwork.kernel.org/patch/7418351/

I can easily rebase it and send it to RMK patch system (as things stand
it seems the easier option), otherwise the merge conflict (which will show
up in -next anyway) has to be sorted out, I am open to suggestions.

Thanks,
Lorenzo
Jens Wiklander Dec. 17, 2015, 7:07 a.m. UTC | #7
On Wed, Dec 16, 2015 at 01:47:40PM +0000, Lorenzo Pieralisi wrote:
> On Wed, Dec 16, 2015 at 01:55:11PM +0100, Jens Wiklander wrote:
> > On Wed, Dec 16, 2015 at 10:55:29AM +0000, Lorenzo Pieralisi wrote:
> > > [CC'ed Daniel]
> > > 
> > > On Tue, Dec 01, 2015 at 08:44:22PM +0100, Jens Wiklander wrote:
> > > 
> > > [...]
> > > 
> > > > > What's the plan for merging this? I assume this'll go via arm-soc?
> > > > 
> > > > I talked to Arnd about this and he suggested to go via Russel.
> > > 
> > > Heads-up, this patch will conflict with:
> > > 
> > > https://patchwork.kernel.org/patch/7418351/
> > > 
> > > that goes via linux-pm tree, please let me and Daniel know how
> > > you want us to sort this out.
> > 
> > I guess this arm-smccc patchset need to go together with that patch in
> > some way. I've just uploaded my patches in Russels patch system, but I
> > can stop that and try to go via the linux-pm tree instead if you think
> > the maintainer would accept that. I'll need to ask Russel if he can ack
> > the patches "arm/arm64: add arm-smccc" and
> > "arm: add implementation for arm-smccc" first though.
> > 
> > Would that work or do you have another idea? I'm of course happy either
> > way as long as the patches get through. I'm new to this so any advice is
> > appreciated.
> 
> It is really up to Daniel and Russell. If Daniel acks:
> 
> https://patchwork.kernel.org/patch/7418351/
> 
> I can easily rebase it and send it to RMK patch system (as things stand
> it seems the easier option), otherwise the merge conflict (which will show
> up in -next anyway) has to be sorted out, I am open to suggestions.

What you're suggesting sounds good to me.

Thanks,
Jens
Russell King - ARM Linux Dec. 21, 2015, 9:11 a.m. UTC | #8
On Wed, Dec 16, 2015 at 01:47:40PM +0000, Lorenzo Pieralisi wrote:
> It is really up to Daniel and Russell. If Daniel acks:
> 
> https://patchwork.kernel.org/patch/7418351/
> 
> I can easily rebase it and send it to RMK patch system (as things stand
> it seems the easier option), otherwise the merge conflict (which will show
> up in -next anyway) has to be sorted out, I am open to suggestions.

I notice that no one has acked or apparently reviewd the first patch at
all.  It would be good to get something on that.
diff mbox

Patch

diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index d2d0042..80856de 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -88,7 +88,6 @@  obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
 obj-$(CONFIG_ARM_VIRT_EXT)	+= hyp-stub.o
 ifeq ($(CONFIG_ARM_PSCI),y)
-obj-y				+= psci-call.o
 obj-$(CONFIG_SMP)		+= psci_smp.o
 endif
 
diff --git a/arch/arm/kernel/psci-call.S b/arch/arm/kernel/psci-call.S
deleted file mode 100644
index a78e9e1..0000000
--- a/arch/arm/kernel/psci-call.S
+++ /dev/null
@@ -1,31 +0,0 @@ 
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Copyright (C) 2015 ARM Limited
- *
- * Author: Mark Rutland <mark.rutland@arm.com>
- */
-
-#include <linux/linkage.h>
-
-#include <asm/opcodes-sec.h>
-#include <asm/opcodes-virt.h>
-
-/* int __invoke_psci_fn_hvc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
-ENTRY(__invoke_psci_fn_hvc)
-	__HVC(0)
-	bx	lr
-ENDPROC(__invoke_psci_fn_hvc)
-
-/* int __invoke_psci_fn_smc(u32 function_id, u32 arg0, u32 arg1, u32 arg2) */
-ENTRY(__invoke_psci_fn_smc)
-	__SMC(0)
-	bx	lr
-ENDPROC(__invoke_psci_fn_smc)
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 16d24a4..02893fa 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -15,7 +15,7 @@  CFLAGS_REMOVE_return_address.o = -pg
 arm64-obj-y		:= debug-monitors.o entry.o irq.o fpsimd.o		\
 			   entry-fpsimd.o process.o ptrace.o setup.o signal.o	\
 			   sys.o stacktrace.o time.o traps.o io.o vdso.o	\
-			   hyp-stub.o psci.o psci-call.o cpu_ops.o insn.o	\
+			   hyp-stub.o psci.o cpu_ops.o insn.o	\
 			   return_address.o cpuinfo.o cpu_errata.o		\
 			   cpufeature.o alternative.o cacheinfo.o		\
 			   smp.o smp_spin_table.o topology.o smccc-call.o
diff --git a/arch/arm64/kernel/psci-call.S b/arch/arm64/kernel/psci-call.S
deleted file mode 100644
index cf83e61..0000000
--- a/arch/arm64/kernel/psci-call.S
+++ /dev/null
@@ -1,28 +0,0 @@ 
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Copyright (C) 2015 ARM Limited
- *
- * Author: Will Deacon <will.deacon@arm.com>
- */
-
-#include <linux/linkage.h>
-
-/* int __invoke_psci_fn_hvc(u64 function_id, u64 arg0, u64 arg1, u64 arg2) */
-ENTRY(__invoke_psci_fn_hvc)
-	hvc	#0
-	ret
-ENDPROC(__invoke_psci_fn_hvc)
-
-/* int __invoke_psci_fn_smc(u64 function_id, u64 arg0, u64 arg1, u64 arg2) */
-ENTRY(__invoke_psci_fn_smc)
-	smc	#0
-	ret
-ENDPROC(__invoke_psci_fn_smc)
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 42700f0..9c55d11 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -19,6 +19,7 @@ 
 #include <linux/pm.h>
 #include <linux/printk.h>
 #include <linux/psci.h>
+#include <linux/arm-smccc.h>
 #include <linux/reboot.h>
 
 #include <uapi/linux/psci.h>
@@ -56,8 +57,6 @@  struct psci_operations psci_ops;
 
 typedef unsigned long (psci_fn)(unsigned long, unsigned long,
 				unsigned long, unsigned long);
-asmlinkage psci_fn __invoke_psci_fn_hvc;
-asmlinkage psci_fn __invoke_psci_fn_smc;
 static psci_fn *invoke_psci_fn;
 
 enum psci_function {
@@ -70,6 +69,26 @@  enum psci_function {
 
 static u32 psci_function_id[PSCI_FN_MAX];
 
+static unsigned long __invoke_psci_fn_hvc(unsigned long function_id,
+			unsigned long arg0, unsigned long arg1,
+			unsigned long arg2)
+{
+	struct arm_smccc_res res;
+
+	arm_smccc_hvc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
+	return res.a0;
+}
+
+static unsigned long __invoke_psci_fn_smc(unsigned long function_id,
+			unsigned long arg0, unsigned long arg1,
+			unsigned long arg2)
+{
+	struct arm_smccc_res res;
+
+	arm_smccc_smc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res);
+	return res.a0;
+}
+
 static int psci_to_linux_errno(int errno)
 {
 	switch (errno) {