arm64 xilinx zynqmp firmware interface
Subsystems (2)
cover arm64 xilinx zynqmp firmware interface
Hi,
xilinx is using this interface for very long time and we can't merge our driver changes to Linux because of missing communication layer with firmware. This interface was developed before scpi and scmi was available. In connection to power management scpi and scmi are missing pieces which we already use. There is a separate discussion how to extend scmi to support all our use cases.
This simply patch is not adding any power management features but only adding minimum functionality which are needed for drivers.
Thanks,
Michal
Michal Simek (1):
soc: xilinx: zynqmp: Add firmware interface
Soren Brinkmann (2):
dt: xilinx: zynqmp: Add bindings for PM firmware
arm64: zynqmp: dt: Add PM firmware node
.../bindings/soc/xilinx/xlnx,zynqmp-pm.txt | 19 + arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 7 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/xilinx/Kconfig | 6 + drivers/soc/xilinx/zynqmp/Makefile | 1 + drivers/soc/xilinx/zynqmp/firmware.c | 419 +++++++++++++++++++++ include/linux/soc/xilinx/zynqmp/firmware.h | 246 ++++++++++++ 8 files changed, 700 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt create mode 100644 drivers/soc/xilinx/Kconfig create mode 100644 drivers/soc/xilinx/zynqmp/Makefile create mode 100644 drivers/soc/xilinx/zynqmp/firmware.c create mode 100644 include/linux/soc/xilinx/zynqmp/firmware.h
Signature · 1 line
1.9.1
PATCH 1/3 dt: xilinx: zynqmp: Add bindings for PM firmware
From: Soren Brinkmann <[email protected]>
Document the DT bindings for the Zynq UltraScale+ PM Firmware.
---
.../devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +19 -0
@@ -0,0 +1,19 @@ +Xilinx Zynq MPSoC Firmware Device Tree Bindings + +The zynqmp-pm node describes the interface to platform firmware. + +Required properties: + - compatible: Must contain: "xlnx,zynqmp-pm" + - method: The method of calling the PM-API firmware layer. + Permitted values are: + - "smc" : To be used in configurations without a hypervisor + - "hvc" : To be used when hypervisor is present + - interrupts: Interrupt specifier + +Examples: + zynqmp-firmware { + compatible = "xlnx,zynqmp-pm"; + method = "smc"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + };
Signature · 1 line
1.9.1
PATCH 2/3 arm64: zynqmp: dt: Add PM firmware node
In reply to Michal SimekFrom: Soren Brinkmann <[email protected]>
Add node for the power management firmware.
---
arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +7 -0
@@ -63,6 +63,13 @@ method = "smc"; }; + pmufw: firmware { + compatible = "xlnx,zynqmp-pm"; + method = "smc"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + }; + timer { compatible = "arm,armv8-timer"; interrupt-parent = <&gic>;
Signature · 1 line
1.9.1
PATCH 3/3 soc: xilinx: zynqmp: Add firmware interface
In reply to Michal SimekThis patch is adding communication layer with firmware.
The most of request are coming thought ATF to PMUFW (platform management unit).
---
drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/xilinx/Kconfig | 6 + drivers/soc/xilinx/zynqmp/Makefile | 1 + drivers/soc/xilinx/zynqmp/firmware.c | 419 +++++++++++++++++++++++++++++ include/linux/soc/xilinx/zynqmp/firmware.h | 246 +++++++++++++++++ 6 files changed, 674 insertions(+) create mode 100644 drivers/soc/xilinx/Kconfig create mode 100644 drivers/soc/xilinx/zynqmp/Makefile create mode 100644 drivers/soc/xilinx/zynqmp/firmware.c create mode 100644 include/linux/soc/xilinx/zynqmp/firmware.h
drivers/soc/Kconfig +1 -0
@@ -15,6 +15,7 @@ source "drivers/soc/tegra/Kconfig" source "drivers/soc/ti/Kconfig" source "drivers/soc/ux500/Kconfig" source "drivers/soc/versatile/Kconfig" +source "drivers/soc/xilinx/Kconfig" source "drivers/soc/zte/Kconfig" endmenu
drivers/soc/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ obj-$(CONFIG_SOC_SAMSUNG) += samsung/ obj-$(CONFIG_ARCH_SUNXI) += sunxi/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ +obj-$(CONFIG_ARCH_ZYNQMP) += xilinx/zynqmp/ obj-$(CONFIG_SOC_TI) += ti/ obj-$(CONFIG_ARCH_U8500) += ux500/ obj-$(CONFIG_PLAT_VERSATILE) += versatile/
drivers/soc/xilinx/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +# +# Xilinx ZYNQ MPSoC configuration +# +menuconfig SOC_XILINX_ZYNQMP + bool "Xilinx Zynq MPSoC driver support" + depends on ARCH_ZYNQMP
drivers/soc/xilinx/zynqmp/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_SOC_XILINX_ZYNQMP) += firmware.o
drivers/soc/xilinx/zynqmp/firmware.c new file +419 -0
419 lines not on this page · raw message
include/linux/soc/xilinx/zynqmp/firmware.h new file +246 -0
246 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 6 lines
Am 04.08.2017 um 15:45 schrieb Michal Simek <[email protected]>:
Hi,
Quoted 8 lines
xilinx is using this interface for very long time and we can't merge our driver changes to Linux because of missing communication layer with firmware. This interface was developed before scpi and scmi was available. In connection to power management scpi and scmi are missing pieces which we already use. There is a separate discussion how to extend scmi to support all our use cases.
This simply patch is not adding any power management features but only adding minimum functionality which are needed for drivers.
If you're thinking of changing the interface later down the road, wouldn't it make sense to probe EL3 for its existence? You could then expose this interface on today's EL3 and something scpi/scmi based on tomorrow's.
Alex
Quoted 30 lines
Thanks,
MichalMichal Simek (1):
soc: xilinx: zynqmp: Add firmware interfaceSoren Brinkmann (2):
dt: xilinx: zynqmp: Add bindings for PM firmware
arm64: zynqmp: dt: Add PM firmware node.../bindings/soc/xilinx/xlnx,zynqmp-pm.txt | 19 + arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 7 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/xilinx/Kconfig | 6 + drivers/soc/xilinx/zynqmp/Makefile | 1 + drivers/soc/xilinx/zynqmp/firmware.c | 419 +++++++++++++++++++++ include/linux/soc/xilinx/zynqmp/firmware.h | 246 ++++++++++++ 8 files changed, 700 insertions(+)create mode 100644
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txtcreate mode 100644drivers/soc/xilinx/Kconfig
create mode 100644drivers/soc/xilinx/zynqmp/Makefile
create mode 100644drivers/soc/xilinx/zynqmp/firmware.c
create mode 100644include/linux/soc/xilinx/zynqmp/firmware.hSignature · 1 line
1.9.1
Quoted 15 lines · Alexander Graf
Quoted 6 lines
Am 04.08.2017 um 15:45 schrieb Michal Simek <[email protected]>:
Hi,
Quoted 8 lines
xilinx is using this interface for very long time and we can't merge our driver changes to Linux because of missing communication layer with firmware. This interface was developed before scpi and scmi was available. In connection to power management scpi and scmi are missing pieces which we already use. There is a separate discussion how to extend scmi to support all our use cases.
This simply patch is not adding any power management features but only adding minimum functionality which are needed for drivers.
Quoted 1 line
If you're thinking of changing the interface later down the road, wouldn't it make sense to probe EL3 for its existence?
You could then expose this interface on today's EL3 and something scpi/scmi based on tomorrow's.
Right now driver is checking pmu firmware version. Based on this it is clear how to communicate with it. The same checking could be there for ATF version. Both of these should tell you exactly what's the communication channel.
If we decide to use scmi or any other implementation we will increase versions.
Thanks,
Michal
Rob Herring
maintainerRe: [PATCH 1/3] dt: xilinx: zynqmp: Add bindings for PM firmware
In reply to Michal SimekQuoted 9 lines · Michal Simek
From: Soren Brinkmann <[email protected]>
Document the DT bindings for the Zynq UltraScale+ PM Firmware.
Signed-off-by Soren Brinkmann <[email protected]>Signed-off-by Michal Simek <[email protected]>---
.../devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt | 19 +++++++++++++++++++
bindings/firmware/
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 3
Quoted 12 lines
1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txtDocumentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +3
-0@@ -0,0 +1,19 @@ +Xilinx Zynq MPSoC Firmware Device Tree Bindings + +The zynqmp-pm node describes the interface to platform firmware.
Please define this should be under /firmware node.
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 10
Quoted 6 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +6
-0+Required properties: + - compatible: Must contain: "xlnx,zynqmp-pm" + - method: The method of calling the PM-API firmware layer. + Permitted values are: + - "smc" : To be used in configurations without a hypervisor + - "hvc" : To be used when hypervisor is present
Do you really use both?
Quoted 12 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +9
-0+ - interrupts: Interrupt specifier + +Examples: + zynqmp-firmware { + compatible = "xlnx,zynqmp-pm"; + method = "smc"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + };Signature · 1 line
1.9.1
Re: [PATCH 1/3] dt: xilinx: zynqmp: Add bindings for PM firmware
Hi Rob, +Edgar,
Quoted 5 lines · Rob Herring
Quoted 4 lines · Michal Simek
From: Soren Brinkmann <[email protected]>
Document the DT bindings for the Zynq UltraScale+ PM Firmware.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Soren Brinkmann <[email protected]>Signed-off-by Michal Simek <[email protected]>---
.../devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt | 19 +++++++++++++++++++bindings/firmware/
will move.
Quoted 16 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 3
Quoted 13 lines
1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txtDocumentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +3
-0@@ -0,0 +1,19 @@ +Xilinx Zynq MPSoC Firmware Device Tree Bindings + +The zynqmp-pm node describes the interface to platform firmware.Please define this should be under /firmware node.
Quoted 9 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 10
Quoted 6 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +6
-0+Required properties: + - compatible: Must contain: "xlnx,zynqmp-pm" + - method: The method of calling the PM-API firmware layer. + Permitted values are: + - "smc" : To be used in configurations without a hypervisor + - "hvc" : To be used when hypervisor is presentDo you really use both?
SMCs definitely yes.
Interface was designed in that way and I don't know if people are using it or not.
Not sure if Xen is blocking SMCs. I know we have discussed it but not sure if this is enabled by default or only for certain configurations. Also not sure if xen contains handler for hvc.
Edgar: Do you know?
Thanks,
Michal
Re: [PATCH 1/3] dt: xilinx: zynqmp: Add bindings for PM firmware
Quoted 46 lines · Michal Simek
Hi Rob, +Edgar,
Quoted 5 lines · Rob Herring
Quoted 4 lines · Michal Simek
From: Soren Brinkmann <[email protected]>
Document the DT bindings for the Zynq UltraScale+ PM Firmware.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Soren Brinkmann <[email protected]>Signed-off-by Michal Simek <[email protected]>---
.../devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt | 19 +++++++++++++++++++bindings/firmware/
will move.
Quoted 16 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 3
Quoted 13 lines
1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txtDocumentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +3
-0@@ -0,0 +1,19 @@ +Xilinx Zynq MPSoC Firmware Device Tree Bindings + +The zynqmp-pm node describes the interface to platform firmware.Please define this should be under /firmware node.
Quoted 9 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 10
Quoted 6 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +6
-0+Required properties: + - compatible: Must contain: "xlnx,zynqmp-pm" + - method: The method of calling the PM-API firmware layer. + Permitted values are: + - "smc" : To be used in configurations without a hypervisor + - "hvc" : To be used when hypervisor is presentDo you really use both?
SMCs definitely yes.
Quoted 7 lines
Interface was designed in that way and I don't know if people are using it or not.
Not sure if Xen is blocking SMCs. I know we have discussed it but not sure if this is enabled by default or only for certain configurations. Also not sure if xen contains handler for hvc.
Edgar: Do you know?
We have patches for Xen that implement a power-management mediator. That implementation handles PM calls over both SMC and HVC insns. Patches are on the Xen mailing list.
Other hypervisors may work differently.
I think we should support both but I don't have a strong opinion on it.
Cheers,
Edgar
Re: [PATCH 1/3] dt: xilinx: zynqmp: Add bindings for PM firmware
Quoted 55 lines · Edgar E. Iglesias
Quoted 46 lines · Michal Simek
Hi Rob, +Edgar,
Quoted 5 lines · Rob Herring
Quoted 4 lines · Michal Simek
From: Soren Brinkmann <[email protected]>
Document the DT bindings for the Zynq UltraScale+ PM Firmware.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Soren Brinkmann <[email protected]>Signed-off-by Michal Simek <[email protected]>---
.../devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt | 19 +++++++++++++++++++bindings/firmware/
will move.
Quoted 16 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 3
Quoted 13 lines
1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txtDocumentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +3
-0@@ -0,0 +1,19 @@ +Xilinx Zynq MPSoC Firmware Device Tree Bindings + +The zynqmp-pm node describes the interface to platform firmware.Please define this should be under /firmware node.
Quoted 9 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 10
Quoted 6 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +6
-0+Required properties: + - compatible: Must contain: "xlnx,zynqmp-pm" + - method: The method of calling the PM-API firmware layer. + Permitted values are: + - "smc" : To be used in configurations without a hypervisor + - "hvc" : To be used when hypervisor is presentDo you really use both?
SMCs definitely yes.
Quoted 7 lines
Interface was designed in that way and I don't know if people are using it or not.
Not sure if Xen is blocking SMCs. I know we have discussed it but not sure if this is enabled by default or only for certain configurations. Also not sure if xen contains handler for hvc.
Edgar: Do you know?
Quoted 7 lines
We have patches for Xen that implement a power-management mediator. That implementation handles PM calls over both SMC and HVC insns. Patches are on the Xen mailing list.
Other hypervisors may work differently.
I think we should support both but I don't have a strong opinion on it.
Rob: Are you ok with having it there?
Thanks,
Michal
Rob Herring
maintainerRe: [PATCH 1/3] dt: xilinx: zynqmp: Add bindings for PM firmware
Quoted 9 lines · Michal Simek
Quoted 8 lines · Edgar E. Iglesias
Quoted 7 lines · Michal Simek
Hi Rob, +Edgar,
Quoted 4 lines · Rob Herring
Quoted 3 lines · Michal Simek
From: Soren Brinkmann <[email protected]>
Document the DT bindings for the Zynq UltraScale+ PM Firmware.
[...]
Quoted 22 lines
Quoted 22 lines
Quoted 10 lines
Quoted 7 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 10
Quoted 4 lines
+ - method: The method of calling the PM-API firmware layer.
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +3
-0+ Permitted values are: + - "smc" : To be used in configurations without a hypervisor + - "hvc" : To be used when hypervisor is presentDo you really use both?
SMCs definitely yes.
Quoted 7 lines
Interface was designed in that way and I don't know if people are using it or not.
Not sure if Xen is blocking SMCs. I know we have discussed it but not sure if this is enabled by default or only for certain configurations. Also not sure if xen contains handler for hvc.
Edgar: Do you know?We have patches for Xen that implement a power-management mediator. That implementation handles PM calls over both SMC and HVC insns. Patches are on the Xen mailing list.
Quoted 5 lines
Quoted 3 lines
Other hypervisors may work differently.
I think we should support both but I don't have a strong opinion on it.
Rob: Are you ok with having it there?
Yes.
Rob
Re: [PATCH 1/3] dt: xilinx: zynqmp: Add bindings for PM firmware
Quoted 35 lines · Rob Herring
Quoted 9 lines · Michal Simek
Quoted 8 lines · Edgar E. Iglesias
Quoted 7 lines · Michal Simek
Hi Rob, +Edgar,
Quoted 4 lines · Rob Herring
Quoted 3 lines · Michal Simek
From: Soren Brinkmann <[email protected]>
Document the DT bindings for the Zynq UltraScale+ PM Firmware.
[...]
Quoted 22 lines
Quoted 22 lines
Quoted 10 lines
Quoted 7 lines
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt line 10
Quoted 4 lines
+ - method: The method of calling the PM-API firmware layer.
Documentation/devicetree/bindings/soc/xilinx/xlnx,zynqmp-pm.txt new file +3
-0+ Permitted values are: + - "smc" : To be used in configurations without a hypervisor + - "hvc" : To be used when hypervisor is presentDo you really use both?
SMCs definitely yes.
Quoted 7 lines
Interface was designed in that way and I don't know if people are using it or not.
Not sure if Xen is blocking SMCs. I know we have discussed it but not sure if this is enabled by default or only for certain configurations. Also not sure if xen contains handler for hvc.
Edgar: Do you know?We have patches for Xen that implement a power-management mediator. That implementation handles PM calls over both SMC and HVC insns. Patches are on the Xen mailing list.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Other hypervisors may work differently.
I think we should support both but I don't have a strong opinion on it.
Rob: Are you ok with having it there?
Yes.
Ok. Let me send v2 then.
Thanks,
Michal
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
In reply to Michal SimekQuoted 7 lines · Michal Simek
drivers/soc/xilinx/zynqmp/firmware.c new file +7
-0+static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, +u32 *ret_payload) +{ +struct arm_smccc_res res; + +arm_smccc_smc (arg0, arg1, arg2,0 ,0 ,0 ,0 ,0 , &res); +
drivers/soc/xilinx/zynqmp/firmware.c line 99
Quoted 10 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +10
-0+if (ret_payload) { + ret_payload[0 ] = (u32 )res.a0; + ret_payload[1 ] = (u32)(res.a0 >>32 ); + ret_payload[2 ] = (u32 )res.a1; + ret_payload[3 ] = (u32)(res.a1 >>32 ); + ret_payload[4 ] = (u32 )res.a2; + } + +return zynqmp_pm_ret_code ((enum pm_ret_status )res.a0); +}
It looks like you forgot to add the cpu_to_le32/le32_to_cpu conversions here to make this work on big-endian kernels.
Quoted 17 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +17
-0+ +static u32 pm_api_version; + +/** +* zynqmp_pm_get_api_version - Get version number of PMU PM firmware +* @version: Returned version value +* +* Return: Returns status, either success or error+reason +*/ +int zynqmp_pm_get_api_version (u32 *version) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; + +if (!version) +return zynqmp_pm_ret_code (XST_PM_CONFLICT ); + +/* Check is PM API version already verified */
drivers/soc/xilinx/zynqmp/firmware.c line 198
Quoted 10 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +10
-0+if (pm_api_version >0 ) { + *version = pm_api_version; +return XST_PM_SUCCESS ; + } +invoke_pm_fn (GET_API_VERSION ,0 ,0 ,0 ,0 , ret_payload); + *version = ret_payload[1 ]; + +return zynqmp_pm_ret_code ((enum pm_ret_status )ret_payload[0 ]); +} +EXPORT_SYMBOL_GPL (zynqmp_pm_get_api_version);
How is this supposed to be used? API version number interfaces are generally problematic, as you don't have that interface any more if you change the version.
Normally this should be based on the "compatible" string in DT to find our what you are talking to, in combination with a list of features that you can query to find out if something is available that you can't just try out by calling.
include/linux/soc/xilinx/zynqmp/firmware.h line 6
Quoted 12 lines
include/linux/soc/xilinx/zynqmp/firmware.h new file +6
-0@@ -0,0 +1,246 @@ + +#ifndef __SOC_ZYNQMP_FIRMWARE_H__ +#define __SOC_ZYNQMP_FIRMWARE_H__ + +#define ZYNQMP_PM_VERSION_MAJOR 0 +#define ZYNQMP_PM_VERSION_MINOR 3
Again, having the version number hardcoded in a global constant seems pointless. If you expect to have to support different incompatible versions in the future, name the header file firmware-0-3.h and prefix the constants with the current version.
include/linux/soc/xilinx/zynqmp/firmware.h line 232
Quoted 10 lines
include/linux/soc/xilinx/zynqmp/firmware.h new file +10
-0+/* +* Internal functions +*/ +int invoke_pm_fn (u32 pm_api_id,u32 arg0,u32 arg1,u32 arg2,u32 arg3, +u32 *ret_payload); +int zynqmp_pm_ret_code (u32 ret_status); + +/* Miscellaneous API functions */ +int zynqmp_pm_get_api_version (u32 *version); +int zynqmp_pm_get_chipid (u32 *idcode,u32 *version);
The "internal" functions probably shouldn't be declared in a global header file.
Arnd
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · Michal Simek
drivers/soc/xilinx/zynqmp/firmware.c new file +12
-0+static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, +u32 *ret_payload) +{ +struct arm_smccc_res res; + +arm_smccc_smc (arg0, arg1, arg2,0 ,0 ,0 ,0 ,0 , &res); + +if (ret_payload) { + ret_payload[0 ] = (u32 )res.a0; + ret_payload[1 ] = (u32)(res.a0 >>32 ); + ret_payload[2 ] = (u32 )res.a1; + ret_payload[3 ] = (u32)(res.a1 >>32 );
Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 99
Quoted 5 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +5
-0+ ret_payload[4 ] = (u32 )res.a2; + } + +return zynqmp_pm_ret_code ((enum pm_ret_status )res.a0); +}It looks like you forgot to add the cpu_to_le32/le32_to_cpu conversions here to make this work on big-endian kernels.
We have discussed support for big endian kernels in past and discussion end up with that there is no customer for this. It means I can change this but none will use this.
Quoted 24 lines
Quoted 24 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +23
-0+ +static u32 pm_api_version; + +/** +* zynqmp_pm_get_api_version - Get version number of PMU PM firmware +* @version: Returned version value +* +* Return: Returns status, either success or error+reason +*/ +int zynqmp_pm_get_api_version (u32 *version) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; + +if (!version) +return zynqmp_pm_ret_code (XST_PM_CONFLICT ); + +/* Check is PM API version already verified */ +if (pm_api_version >0 ) { + *version = pm_api_version; +return XST_PM_SUCCESS ; + } +invoke_pm_fn (GET_API_VERSION ,0 ,0 ,0 ,0 , ret_payload); + *version = ret_payload[1 ];
Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 198
Quoted 4 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +4
-0+ +return zynqmp_pm_ret_code ((enum pm_ret_status )ret_payload[0 ]); +} +EXPORT_SYMBOL_GPL (zynqmp_pm_get_api_version);How is this supposed to be used? API version number interfaces are generally problematic, as you don't have that interface any more if you change the version.
This function is called from power management driver to find out a version of PMUFW. It is not a problem to save version in the driver and provide another function to access it instead of asking firmware again. Or also remove this completely because it is more for power management then for communication. And this patch is just about communication.
Quoted 5 lines
Normally this should be based on the "compatible" string in DT to find our what you are talking to, in combination with a list of features that you can query to find out if something is available that you can't just try out by calling.
How can you find out what you are talking to without asking for version?
It should be probably be based on some sort of list of services and based on that enabled features.
Anyway I don't need this function to be in this interface driver that's why I will remove this part in v2.
Quoted 9 lines
Quoted 9 lines
include/linux/soc/xilinx/zynqmp/firmware.h new file +3
-0@@ -0,0 +1,246 @@ + +#ifndef __SOC_ZYNQMP_FIRMWARE_H__ +#define __SOC_ZYNQMP_FIRMWARE_H__
Quoted 8 lines
include/linux/soc/xilinx/zynqmp/firmware.h line 27
Quoted 3 lines
include/linux/soc/xilinx/zynqmp/firmware.h new file +3
-0+ +#define ZYNQMP_PM_VERSION_MAJOR 0 +#define ZYNQMP_PM_VERSION_MINOR 3Again, having the version number hardcoded in a global constant seems pointless. If you expect to have to support different incompatible versions in the future, name the header file
firmware-0-3.hand prefix the constants with the current version.
Will remove.
Quoted 10 lines
include/linux/soc/xilinx/zynqmp/firmware.h line 231
Quoted 10 lines
include/linux/soc/xilinx/zynqmp/firmware.h new file +9
-0+/* +* Internal functions +*/ +int invoke_pm_fn (u32 pm_api_id,u32 arg0,u32 arg1,u32 arg2,u32 arg3, +u32 *ret_payload); +int zynqmp_pm_ret_code (u32 ret_status); + +/* Miscellaneous API functions */ +int zynqmp_pm_get_api_version (u32 *version);
This will go out too.
Quoted 4 lines
include/linux/soc/xilinx/zynqmp/firmware.h line 232
Quoted 1 line
include/linux/soc/xilinx/zynqmp/firmware.h new file +1
-0+int zynqmp_pm_get_chipid (u32 *idcode,u32 *version);The "internal" functions probably shouldn't be declared in a global header file.
Ok. This function will be called by nvmem driver which provides an option to expose chip id to kernel and user space.
I can call this function just once internally and then expose another function which will simply just provide access to that static variable. Please let me know what you prefer.
Thanks,
Michal
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
Quoted 103 lines · Michal Simek
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · Michal Simek
drivers/soc/xilinx/zynqmp/firmware.c new file +12
-0+static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, +u32 *ret_payload) +{ +struct arm_smccc_res res; + +arm_smccc_smc (arg0, arg1, arg2,0 ,0 ,0 ,0 ,0 , &res); + +if (ret_payload) { + ret_payload[0 ] = (u32 )res.a0; + ret_payload[1 ] = (u32)(res.a0 >>32 ); + ret_payload[2 ] = (u32 )res.a1; + ret_payload[3 ] = (u32)(res.a1 >>32 );Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 99
Quoted 5 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +5
-0+ ret_payload[4 ] = (u32 )res.a2; + } + +return zynqmp_pm_ret_code ((enum pm_ret_status )res.a0); +}It looks like you forgot to add the cpu_to_le32/le32_to_cpu conversions here to make this work on big-endian kernels.
We have discussed support for big endian kernels in past and discussion end up with that there is no customer for this. It means I can change this but none will use this.
Quoted 24 lines
Quoted 24 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +23
-0+ +static u32 pm_api_version; + +/** +* zynqmp_pm_get_api_version - Get version number of PMU PM firmware +* @version: Returned version value +* +* Return: Returns status, either success or error+reason +*/ +int zynqmp_pm_get_api_version (u32 *version) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; + +if (!version) +return zynqmp_pm_ret_code (XST_PM_CONFLICT ); + +/* Check is PM API version already verified */ +if (pm_api_version >0 ) { + *version = pm_api_version; +return XST_PM_SUCCESS ; + } +invoke_pm_fn (GET_API_VERSION ,0 ,0 ,0 ,0 , ret_payload); + *version = ret_payload[1 ];Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 198
Quoted 4 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +4
-0+ +return zynqmp_pm_ret_code ((enum pm_ret_status )ret_payload[0 ]); +} +EXPORT_SYMBOL_GPL (zynqmp_pm_get_api_version);How is this supposed to be used? API version number interfaces are generally problematic, as you don't have that interface any more if you change the version.
This function is called from power management driver to find out a version of PMUFW. It is not a problem to save version in the driver and provide another function to access it instead of asking firmware again. Or also remove this completely because it is more for power management then for communication. And this patch is just about communication.
Quoted 5 lines
Normally this should be based on the "compatible" string in DT to find our what you are talking to, in combination with a list of features that you can query to find out if something is available that you can't just try out by calling.
How can you find out what you are talking to without asking for version?
It should be probably be based on some sort of list of services and based on that enabled features.
Anyway I don't need this function to be in this interface driver that's why I will remove this part in v2.
Quoted 9 lines
Quoted 9 lines
include/linux/soc/xilinx/zynqmp/firmware.h new file +3
-0@@ -0,0 +1,246 @@ + +#ifndef __SOC_ZYNQMP_FIRMWARE_H__ +#define __SOC_ZYNQMP_FIRMWARE_H__Quoted 8 lines
include/linux/soc/xilinx/zynqmp/firmware.h line 27
Quoted 3 lines
include/linux/soc/xilinx/zynqmp/firmware.h new file +3
-0+ +#define ZYNQMP_PM_VERSION_MAJOR 0 +#define ZYNQMP_PM_VERSION_MINOR 3Again, having the version number hardcoded in a global constant seems pointless. If you expect to have to support different incompatible versions in the future, name the header file
firmware-0-3.hand prefix the constants with the current version.Will remove.
Quoted 1 line
Quoted 16 lines
Quoted 9 lines
include/linux/soc/xilinx/zynqmp/firmware.h line 231
Quoted 9 lines
include/linux/soc/xilinx/zynqmp/firmware.h new file +9
-0+/* +* Internal functions +*/ +int invoke_pm_fn (u32 pm_api_id,u32 arg0,u32 arg1,u32 arg2,u32 arg3, +u32 *ret_payload); +int zynqmp_pm_ret_code (u32 ret_status); + +/* Miscellaneous API functions */ +int zynqmp_pm_get_api_version (u32 *version);This will go out too.
Quoted 4 lines
include/linux/soc/xilinx/zynqmp/firmware.h line 232
Quoted 1 line
include/linux/soc/xilinx/zynqmp/firmware.h new file +1
-0+int zynqmp_pm_get_chipid (u32 *idcode,u32 *version);The "internal" functions probably shouldn't be declared in a global header file.
Sorry got your comment now - will mark that internal functions as static to get them out of this header.
Thanks,
Michal
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
In reply to Michal SimekQuoted 23 lines · Michal Simek
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · Michal Simek
drivers/soc/xilinx/zynqmp/firmware.c new file +12
-0+static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, +u32 *ret_payload) +{ +struct arm_smccc_res res; + +arm_smccc_smc (arg0, arg1, arg2,0 ,0 ,0 ,0 ,0 , &res); + +if (ret_payload) { + ret_payload[0 ] = (u32 )res.a0; + ret_payload[1 ] = (u32)(res.a0 >>32 ); + ret_payload[2 ] = (u32 )res.a1; + ret_payload[3 ] = (u32)(res.a1 >>32 );Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 99
Quoted 5 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +5
-0+ ret_payload[4 ] = (u32 )res.a2; + } + +return zynqmp_pm_ret_code ((enum pm_ret_status )res.a0); +}It looks like you forgot to add the cpu_to_le32/le32_to_cpu conversions here to make this work on big-endian kernels.
Quoted 3 lines
We have discussed support for big endian kernels in past and discussion end up with that there is no customer for this. It means I can change this but none will use this.
Ok, thanks. As a general rule, I prefer kernel code to be written in a portable way even when you assume that is not necessary.
Besides the obvious problem of users that end up wanting to do something you don't expect, there is the more general issue of copying code into another driver that may need to be more portable.
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +22
-0+static u32 pm_api_version; + +/** +* zynqmp_pm_get_api_version - Get version number of PMU PM firmware +* @version: Returned version value +* +* Return: Returns status, either success or error+reason +*/ +int zynqmp_pm_get_api_version (u32 *version) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; + +if (!version) +return zynqmp_pm_ret_code (XST_PM_CONFLICT ); + +/* Check is PM API version already verified */ +if (pm_api_version >0 ) { + *version = pm_api_version; +return XST_PM_SUCCESS ; + } +invoke_pm_fn (GET_API_VERSION ,0 ,0 ,0 ,0 , ret_payload); + *version = ret_payload[1 ];Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 198
Quoted 4 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +4
-0+ +return zynqmp_pm_ret_code ((enum pm_ret_status )ret_payload[0 ]); +} +EXPORT_SYMBOL_GPL (zynqmp_pm_get_api_version);How is this supposed to be used? API version number interfaces are generally problematic, as you don't have that interface any more if you change the version.
Quoted 5 lines
This function is called from power management driver to find out a version of PMUFW. It is not a problem to save version in the driver and provide another function to access it instead of asking firmware again. Or also remove this completely because it is more for power management then for communication. And this patch is just about communication.
Ok. For the purpose of the power management driver, you probably also want a different name, as what you are interested in is not the API version but the firmware version.
Quoted 9 lines
Quoted 4 lines
Normally this should be based on the "compatible" string in DT to find our what you are talking to, in combination with a list of features that you can query to find out if something is available that you can't just try out by calling.
How can you find out what you are talking to without asking for version?
It should be probably be based on some sort of list of services and based on that enabled features.
My point was that you can't even ask for a version number without first knowing what you are talking to, and that information comes from the DT node describing the interface.
Arnd
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
Quoted 28 lines · Arnd Bergmann
Quoted 23 lines · Michal Simek
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · Michal Simek
drivers/soc/xilinx/zynqmp/firmware.c new file +12
-0+static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, +u32 *ret_payload) +{ +struct arm_smccc_res res; + +arm_smccc_smc (arg0, arg1, arg2,0 ,0 ,0 ,0 ,0 , &res); + +if (ret_payload) { + ret_payload[0 ] = (u32 )res.a0; + ret_payload[1 ] = (u32)(res.a0 >>32 ); + ret_payload[2 ] = (u32 )res.a1; + ret_payload[3 ] = (u32)(res.a1 >>32 );Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 99
Quoted 5 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +5
-0+ ret_payload[4 ] = (u32 )res.a2; + } + +return zynqmp_pm_ret_code ((enum pm_ret_status )res.a0); +}It looks like you forgot to add the cpu_to_le32/le32_to_cpu conversions here to make this work on big-endian kernels.
Quoted 3 lines
We have discussed support for big endian kernels in past and discussion end up with that there is no customer for this. It means I can change this but none will use this.
Quoted 6 lines
Ok, thanks. As a general rule, I prefer kernel code to be written in a portable way even when you assume that is not necessary.
Besides the obvious problem of users that end up wanting to do something you don't expect, there is the more general issue of copying code into another driver that may need to be more portable.
I fully understand this. Let me play with it but I expect there will be different issues then just this.
Quoted 38 lines
Quoted 32 lines
Quoted 23 lines
Quoted 23 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +22
-0+static u32 pm_api_version; + +/** +* zynqmp_pm_get_api_version - Get version number of PMU PM firmware +* @version: Returned version value +* +* Return: Returns status, either success or error+reason +*/ +int zynqmp_pm_get_api_version (u32 *version) +{ +u32 ret_payload[PAYLOAD_ARG_CNT ]; + +if (!version) +return zynqmp_pm_ret_code (XST_PM_CONFLICT ); + +/* Check is PM API version already verified */ +if (pm_api_version >0 ) { + *version = pm_api_version; +return XST_PM_SUCCESS ; + } +invoke_pm_fn (GET_API_VERSION ,0 ,0 ,0 ,0 , ret_payload); + *version = ret_payload[1 ];Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 198
Quoted 4 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +4
-0+ +return zynqmp_pm_ret_code ((enum pm_ret_status )ret_payload[0 ]); +} +EXPORT_SYMBOL_GPL (zynqmp_pm_get_api_version);How is this supposed to be used? API version number interfaces are generally problematic, as you don't have that interface any more if you change the version.
Quoted 5 lines
This function is called from power management driver to find out a version of PMUFW. It is not a problem to save version in the driver and provide another function to access it instead of asking firmware again. Or also remove this completely because it is more for power management then for communication. And this patch is just about communication.
Quoted 3 lines
Ok. For the purpose of the power management driver, you probably also want a different name, as what you are interested in is not the API version but the firmware version.
I am really looking forward to see xilinx PM guys to start to upstream their code. And they most likely need this API version.
But for that stuff which are the part of this patch all functions should be there. If function is not implemented then you get error back which is sign that firmware doesn't support it.
Definitely we can consider to add compatible string with version suffix in future when the same SMCs will be used for different purpose.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Normally this should be based on the "compatible" string in DT to find our what you are talking to, in combination with a list of features that you can query to find out if something is available that you can't just try out by calling.
Quoted 8 lines
Quoted 4 lines
How can you find out what you are talking to without asking for version?
It should be probably be based on some sort of list of services and based on that enabled features.
My point was that you can't even ask for a version number without first knowing what you are talking to, and that information comes from the DT node describing the interface.
Ok. Got you and yes there must be at least any node.
Thanks,
Michal
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
Quoted 32 lines · Michal Simek
Quoted 31 lines · Arnd Bergmann
Quoted 23 lines · Michal Simek
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · Michal Simek
drivers/soc/xilinx/zynqmp/firmware.c new file +12
-0+static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, +u32 *ret_payload) +{ +struct arm_smccc_res res; + +arm_smccc_smc (arg0, arg1, arg2,0 ,0 ,0 ,0 ,0 , &res); + +if (ret_payload) { + ret_payload[0 ] = (u32 )res.a0; + ret_payload[1 ] = (u32)(res.a0 >>32 ); + ret_payload[2 ] = (u32 )res.a1; + ret_payload[3 ] = (u32)(res.a1 >>32 );Quoted 8 lines
drivers/soc/xilinx/zynqmp/firmware.c line 99
Quoted 5 lines
drivers/soc/xilinx/zynqmp/firmware.c new file +5
-0+ ret_payload[4 ] = (u32 )res.a2; + } + +return zynqmp_pm_ret_code ((enum pm_ret_status )res.a0); +}It looks like you forgot to add the cpu_to_le32/le32_to_cpu conversions here to make this work on big-endian kernels.
Quoted 3 lines
We have discussed support for big endian kernels in past and discussion end up with that there is no customer for this. It means I can change this but none will use this.
Ok, thanks. As a general rule, I prefer kernel code to be written in a portable way even when you assume that is not necessary.
Quoted 8 lines
Quoted 3 lines
Besides the obvious problem of users that end up wanting to do something you don't expect, there is the more general issue of copying code into another driver that may need to be more portable.
I fully understand this. Let me play with it but I expect there will be different issues then just this.
What do you think?
ret_payload[0] = lower_32_bits(le64_to_cpu(res.a0)); ret_payload[1] = upper_32_bits(le64_to_cpu(res.a0)); ret_payload[2] = lower_32_bits(le64_to_cpu(res.a1)); ret_payload[3] = upper_32_bits(le64_to_cpu(res.a1)); ret_payload[4] = lower_32_bits(le64_to_cpu(res.a2));
There should be probably also change in invoke_pm_fn to do conversion from cpu to le64.
int invoke_pm_fn(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3,
u32 *ret_payload)
{
/*
* Added SIP service call Function Identifier
* Make sure to stay in x0 register
*/
u64 smc_arg[4];
smc_arg[0] = cpu_to_le64(PM_SIP_SVC | pm_api_id);
smc_arg[1] = cpu_to_le64(((u64)arg1 << 32) | arg0);
smc_arg[2] = cpu_to_le64(((u64)arg3 << 32) | arg2);
return do_fw_call(smc_arg[0], smc_arg[1], smc_arg[2], ret_payload);
}This is not tested on BE just on LE.
Thanks,
Michal
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
Quoted 30 lines · Michal Simek
Quoted 2 lines · Michal Simek
On 16.8.2017 14:41, Arnd Bergmann wrote:
What do you think?
ret_payload[0] = lower_32_bits(le64_to_cpu(res.a0)); ret_payload[1] = upper_32_bits(le64_to_cpu(res.a0)); ret_payload[2] = lower_32_bits(le64_to_cpu(res.a1)); ret_payload[3] = upper_32_bits(le64_to_cpu(res.a1)); ret_payload[4] = lower_32_bits(le64_to_cpu(res.a2));There should be probably also change in
invoke_pm_fnto do conversion from cpu to le64.int invoke_pm_fn(u32
pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3,u32 *ret_payload) { /* * Added SIP service call Function Identifier * Make sure to stay in x0 register */ u64 smc_arg[4]; smc_arg[0] = cpu_to_le64(PM_SIP_SVC | pm_api_id); smc_arg[1] = cpu_to_le64(((u64)arg1 << 32) | arg0); smc_arg[2] = cpu_to_le64(((u64)arg3 << 32) | arg2); return do_fw_call(smc_arg[0], smc_arg[1], smc_arg[2], ret_payload); }
Quoted 1 line
This is not tested on BE just on LE.
Looks good, just make sure you also check with sparse (make C=1) to ensure you have the right __le64/__le32 types everywhere.
Arnd
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
Quoted 28 lines · Arnd Bergmann
Quoted 27 lines · Michal Simek
Quoted 2 lines · Michal Simek
On 16.8.2017 14:41, Arnd Bergmann wrote:
What do you think?
ret_payload[0] = lower_32_bits(le64_to_cpu(res.a0)); ret_payload[1] = upper_32_bits(le64_to_cpu(res.a0)); ret_payload[2] = lower_32_bits(le64_to_cpu(res.a1)); ret_payload[3] = upper_32_bits(le64_to_cpu(res.a1)); ret_payload[4] = lower_32_bits(le64_to_cpu(res.a2));There should be probably also change in
invoke_pm_fnto do conversion from cpu to le64.int invoke_pm_fn(u32
pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3,u32 *ret_payload) { /* * Added SIP service call Function Identifier * Make sure to stay in x0 register */ u64 smc_arg[4]; smc_arg[0] = cpu_to_le64(PM_SIP_SVC | pm_api_id); smc_arg[1] = cpu_to_le64(((u64)arg1 << 32) | arg0); smc_arg[2] = cpu_to_le64(((u64)arg3 << 32) | arg2);
Quoted 7 lines
Quoted 4 lines
return do_fw_call(smc_arg[0], smc_arg[1], smc_arg[2], ret_payload); }This is not tested on BE just on LE.
Looks good, just make sure you also check with sparse (make C=1) to ensure you have the right __le64/__le32 types everywhere.
Are you aware about any doc where it is written that data should be passed as little endian?
I was playing with it a little bit and this means that these 2(3 with hvc) needs to be changed.
asmlinkage void __arm_smccc_smc(__le64 a0, __le64 a1, __le64 a2,
__le64 a3,__le64 a4, __le64 a5, __le64 a6, __le64 a7,
struct arm_smccc_res *res, struct arm_smccc_quirk *quirk);
struct arm_smccc_res {
- unsigned long a0; - unsigned long a1; - unsigned long a2; - unsigned long a3; + __le64 a0; + __le64 a1; + __le64 a2; + __le64 a3;
};
Thanks,
Michal
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
Quoted 8 lines · Michal Simek
Quoted 4 lines · Arnd Bergmann
On Wed, Aug 16, 2017 at 4:34 PM, Michal Simek <[email protected]> wrote:
Looks good, just make sure you also check with sparse (make C=1) to ensure you have the right __le64/__le32 types everywhere.
Are you aware about any doc where it is written that data should be passed as little endian?
Looking at http://infocenter.arm.com/help/topic/com.arm.doc.den0028b/ARM_DEN0028B_SMC_Calling_Convention.pdf
now, I think that the structure above is endian-neutral as the arguments
get passed in registers rather than memory.
However, if you pass pointers to data structures in memory, those data structures would have to be defined with __le32/__le64 types.
Quoted 8 lines
I was playing with it a little bit and this means that these 2(3 with hvc) needs to be changed.
asmlinkage void __arm_smccc_smc(__le64 a0,
__le64a1,__le64a2,
__le64a3,__le64 a4,__le64a5,__le64a6,__le64a7,
structarm_smccc_res*res, structarm_smccc_quirk*quirk);struct
arm_smccc_res{
Review
Quoted 9 lines
(quoted diff) +4
-4- unsigned long a0; - unsigned long a1; - unsigned long a2; - unsigned long a3; + __le64 a0; + __le64 a1; + __le64 a2; + __le64 a3; };
This is clearly wrong on 32-bit machines, I think this is intentionally defined as 'unsigned long' to have register sized arguments.
Arnd
Re: [PATCH 3/3] soc: xilinx: zynqmp: Add firmware interface
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · Michal Simek
Quoted 4 lines · Arnd Bergmann
On Wed, Aug 16, 2017 at 4:34 PM, Michal Simek <[email protected]> wrote:
Looks good, just make sure you also check with sparse (make C=1) to ensure you have the right __le64/__le32 types everywhere.
Are you aware about any doc where it is written that data should be passed as little endian?
Quoted 6 lines
Looking at http://infocenter.arm.com/help/topic/com.arm.doc.den0028b/ARM_DEN0028B_SMC_Calling_Convention.pdf
now, I think that the structure above is endian-neutral as the arguments
get passed in registers rather than memory.However, if you pass pointers to data structures in memory, those data structures would have to be defined with __le32/__le64 types.
ok.
Quoted 19 lines
Quoted 9 lines
I was playing with it a little bit and this means that these 2(3 with hvc) needs to be changed.
asmlinkage void __arm_smccc_smc(__le64 a0,
__le64a1,__le64a2,
__le64a3,__le64 a4,__le64a5,__le64a6,__le64a7,
structarm_smccc_res*res, structarm_smccc_quirk*quirk);struct
arm_smccc_res{Review
Quoted 9 lines
(quoted diff) +4
-4- unsigned long a0; - unsigned long a1; - unsigned long a2; - unsigned long a3; + __le64 a0; + __le64 a1; + __le64 a2; + __le64 a3; };
Quoted 2 lines
This is clearly wrong on 32-bit machines, I think this is intentionally defined as 'unsigned long' to have register sized arguments.
Yep, I know.
Let me integrate that changes which Marc wanted and will send next version.
Thanks,
Michal