Re: [PATCH v11 05/10] arm_ffa: introduce armffa command

2023-05-12 Thread Abdellatif El Khlifi
Hi Simon,

> 
> On Wed, 12 Apr 2023 at 03:43, Abdellatif El Khlifi
>  wrote:
> >
> > Provide armffa command showcasing the use of the U-Boot FF-A support
> >
> > armffa is a command showcasing how to invoke FF-A operations.
> > This provides a guidance to the client developers on how to
> > call the FF-A bus interfaces. The command also allows to gather secure
> > partitions information and ping these  partitions. The command is also
> > helpful in testing the communication with secure partitions.
> >
> > For more details please refer to the command documentation [1].
> >
> > [1]: doc/usage/cmd/armffa.rst
> >
> > Signed-off-by: Abdellatif El Khlifi 
> > Cc: Tom Rini 
> > Cc: Simon Glass 
> > Cc: Ilias Apalodimas 
> > Cc: Jens Wiklander 
> > Cc: Heinrich Schuchardt 
> >
> > ---
> > Changelog:
> > ===
> >
> > v11:
> >
> > * use U_BOOT_CMD_WITH_SUBCMDS
> > * address nits
> >
> > v10:
> >
> > * use the FF-A driver Uclass operations
> > * use uclass_first_device()
> > * address nits
> >
> > v9:
> >
> > * remove manual FF-A discovery and use DM
> > * use DM class APIs to probe and interact with the FF-A bus
> > * add doc/usage/cmd/armffa.rst
> >
> > v8:
> >
> > * update partition_info_get() second argument to be an SP count
> > * pass NULL device pointer to the FF-A bus discovery and operations
> >
> > v7:
> >
> > * adapt do_ffa_dev_list() following the recent update on
> >   uclass_first_device/uclass_next_device functions (they return void now)
> > * set armffa command to use 64-bit direct messaging
> >
> > v4:
> >
> > * remove pattern data in do_ffa_msg_send_direct_req
> >
> > v3:
> >
> > * use the new driver interfaces (partition_info_get, sync_send_receive)
> >   in armffa command
> >
> > v2:
> >
> > * replace use of ffa_helper_init_device function by
> >  ffa_helper_bus_discover
> >
> > v1:
> >
> > * introduce armffa command
> >
> >  MAINTAINERS  |   2 +
> >  cmd/Kconfig  |  10 ++
> >  cmd/Makefile |   2 +
> >  cmd/armffa.c | 212 +++
> >  doc/arch/arm64.ffa.rst   |   7 +
> >  doc/usage/cmd/armffa.rst | 105 +++
> >  doc/usage/index.rst  |   1 +
> >  drivers/firmware/arm-ffa/Kconfig |   1 +
> >  8 files changed, 340 insertions(+)
> >  create mode 100644 cmd/armffa.c
> >  create mode 100644 doc/usage/cmd/armffa.rst
> >
> 
> Reviewed-by: Simon Glass 
> 
> with nits below
> 
> For your docs, please use a proper rST link for
> doc/usage/cmd/armffa.rst so people can click on it and view the
> command docs.
> 
> Also:
> 
> armffa is an implementation-defined command
> 
> (add hyphen)
> 
> although I'm not sure how an implementation can define the command?
> 
> The example output in your 'example' docs is very, very verbose.
> Shouldn't it just report problems?

Thanks, addressed in v12.

Cheers,
Abdellatif

> 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 76f0f276ce..c64804ca2d 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -269,7 +269,9 @@ F:  configs/cortina_presidio-asic-pnand_defconfig
> >  ARM FF-A
> >  M: Abdellatif El Khlifi 
> >  S: Maintained
> > +F: cmd/armffa.c
> >  F: doc/arch/arm64.ffa.rst
> > +F: doc/usage/cmd/armffa.rst
> >  F: drivers/firmware/arm-ffa/
> >  F: include/arm_ffa.h
> >  F: include/sandbox_arm_ffa.h
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 8c9b430f99..4cb0b2c167 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -934,6 +934,16 @@ endmenu
> >
> >  menu "Device access commands"
> >
> > +config CMD_ARMFFA
> > +   bool "Arm FF-A test command"
> > +   depends on ARM_FFA_TRANSPORT
> > +   help
> > + Provides a test command for the FF-A support
> > + supported options:
> > +   - Listing the partition(s) info
> > +   - Sending a data pattern to the specified partition
> > +   - Displaying the arm_ffa device info
> > +
> >  config CMD_ARMFLASH
> > #depends on FLASH_CFI_DRIVER
> > bool "armflash"
> > diff --git a/cmd/Makefile b/cmd/Makefile
> > index e032091621..9130b9078d 100644
> > --- a/cmd/Makefile
> > +++ b/cmd/Makefile
> > @@ -12,6 +12,8 @@ obj-y += panic.o
> >  obj-y += version.o
> >
> >  # command
> > +
> 
> Please drop blank line
> 
> > +obj-$(CONFIG_CMD_ARMFFA) += armffa.o
> >  obj-$(CONFIG_CMD_ACPI) += acpi.o
> >  obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
> >  obj-$(CONFIG_CMD_AES) += aes.o
> > diff --git a/cmd/armffa.c b/cmd/armffa.c
> > new file mode 100644
> > index 00..ab88412c7d
> > --- /dev/null
> > +++ b/cmd/armffa.c
> > @@ -0,0 +1,212 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright 2022-2023 Arm Limited and/or its affiliates 
> > 
> > + *
> > + * Authors:
> > + *   Abdellatif El Khlifi 
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/**
> > + * ffa_get_dev() - Return 

Re: [PATCH v11 05/10] arm_ffa: introduce armffa command

2023-04-18 Thread Simon Glass
Hi Abdellatif,

On Wed, 12 Apr 2023 at 03:43, Abdellatif El Khlifi
 wrote:
>
> Provide armffa command showcasing the use of the U-Boot FF-A support
>
> armffa is a command showcasing how to invoke FF-A operations.
> This provides a guidance to the client developers on how to
> call the FF-A bus interfaces. The command also allows to gather secure
> partitions information and ping these  partitions. The command is also
> helpful in testing the communication with secure partitions.
>
> For more details please refer to the command documentation [1].
>
> [1]: doc/usage/cmd/armffa.rst
>
> Signed-off-by: Abdellatif El Khlifi 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Ilias Apalodimas 
> Cc: Jens Wiklander 
> Cc: Heinrich Schuchardt 
>
> ---
> Changelog:
> ===
>
> v11:
>
> * use U_BOOT_CMD_WITH_SUBCMDS
> * address nits
>
> v10:
>
> * use the FF-A driver Uclass operations
> * use uclass_first_device()
> * address nits
>
> v9:
>
> * remove manual FF-A discovery and use DM
> * use DM class APIs to probe and interact with the FF-A bus
> * add doc/usage/cmd/armffa.rst
>
> v8:
>
> * update partition_info_get() second argument to be an SP count
> * pass NULL device pointer to the FF-A bus discovery and operations
>
> v7:
>
> * adapt do_ffa_dev_list() following the recent update on
>   uclass_first_device/uclass_next_device functions (they return void now)
> * set armffa command to use 64-bit direct messaging
>
> v4:
>
> * remove pattern data in do_ffa_msg_send_direct_req
>
> v3:
>
> * use the new driver interfaces (partition_info_get, sync_send_receive)
>   in armffa command
>
> v2:
>
> * replace use of ffa_helper_init_device function by
>  ffa_helper_bus_discover
>
> v1:
>
> * introduce armffa command
>
>  MAINTAINERS  |   2 +
>  cmd/Kconfig  |  10 ++
>  cmd/Makefile |   2 +
>  cmd/armffa.c | 212 +++
>  doc/arch/arm64.ffa.rst   |   7 +
>  doc/usage/cmd/armffa.rst | 105 +++
>  doc/usage/index.rst  |   1 +
>  drivers/firmware/arm-ffa/Kconfig |   1 +
>  8 files changed, 340 insertions(+)
>  create mode 100644 cmd/armffa.c
>  create mode 100644 doc/usage/cmd/armffa.rst
>

Reviewed-by: Simon Glass 

with nits below

For your docs, please use a proper rST link for
doc/usage/cmd/armffa.rst so people can click on it and view the
command docs.

Also:

armffa is an implementation-defined command

(add hyphen)

although I'm not sure how an implementation can define the command?

The example output in your 'example' docs is very, very verbose.
Shouldn't it just report problems?

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 76f0f276ce..c64804ca2d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -269,7 +269,9 @@ F:  configs/cortina_presidio-asic-pnand_defconfig
>  ARM FF-A
>  M: Abdellatif El Khlifi 
>  S: Maintained
> +F: cmd/armffa.c
>  F: doc/arch/arm64.ffa.rst
> +F: doc/usage/cmd/armffa.rst
>  F: drivers/firmware/arm-ffa/
>  F: include/arm_ffa.h
>  F: include/sandbox_arm_ffa.h
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 8c9b430f99..4cb0b2c167 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -934,6 +934,16 @@ endmenu
>
>  menu "Device access commands"
>
> +config CMD_ARMFFA
> +   bool "Arm FF-A test command"
> +   depends on ARM_FFA_TRANSPORT
> +   help
> + Provides a test command for the FF-A support
> + supported options:
> +   - Listing the partition(s) info
> +   - Sending a data pattern to the specified partition
> +   - Displaying the arm_ffa device info
> +
>  config CMD_ARMFLASH
> #depends on FLASH_CFI_DRIVER
> bool "armflash"
> diff --git a/cmd/Makefile b/cmd/Makefile
> index e032091621..9130b9078d 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -12,6 +12,8 @@ obj-y += panic.o
>  obj-y += version.o
>
>  # command
> +

Please drop blank line

> +obj-$(CONFIG_CMD_ARMFFA) += armffa.o
>  obj-$(CONFIG_CMD_ACPI) += acpi.o
>  obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
>  obj-$(CONFIG_CMD_AES) += aes.o
> diff --git a/cmd/armffa.c b/cmd/armffa.c
> new file mode 100644
> index 00..ab88412c7d
> --- /dev/null
> +++ b/cmd/armffa.c
> @@ -0,0 +1,212 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2022-2023 Arm Limited and/or its affiliates 
> 
> + *
> + * Authors:
> + *   Abdellatif El Khlifi 
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * ffa_get_dev() - Return the FF-A device
> + * @devp:  pointer to the FF-A device
> + *
> + * Search for the FF-A device.
> + *
> + * Return:
> + * 0 on success. Otherwise, failure
> + */
> +int ffa_get_dev(struct udevice **devp)
> +{
> +   int ret;
> +
> +   ret = uclass_first_device_err(UCLASS_FFA, devp);
> +   if (ret) {
> +   log_err("Cannot find FF-A bus device\n");
> +   return 

Re: [PATCH v11 05/10] arm_ffa: introduce armffa command

2023-04-13 Thread Abdellatif El Khlifi
On Wed, Apr 12, 2023 at 10:00:38PM +0200, Heinrich Schuchardt wrote:
> 
> 
> Am 12. April 2023 17:53:23 MESZ schrieb Abdellatif El Khlifi 
> :
> >On Wed, Apr 12, 2023 at 04:02:43PM +0200, Heinrich Schuchardt wrote:
> >> On 4/12/23 11:42, Abdellatif El Khlifi wrote:
> >> > Provide armffa command showcasing the use of the U-Boot FF-A support
> >> > 
> >> > armffa is a command showcasing how to invoke FF-A operations.
> >> > This provides a guidance to the client developers on how to
> >> > call the FF-A bus interfaces. The command also allows to gather secure
> >> > partitions information and ping these  partitions. The command is also
> >> > helpful in testing the communication with secure partitions.
> >> > 
> >> > For more details please refer to the command documentation [1].
> >> > 
> >> > [1]: doc/usage/cmd/armffa.rst
> >> > 
> >> > Signed-off-by: Abdellatif El Khlifi 
> >> > Cc: Tom Rini 
> >> > Cc: Simon Glass 
> >> > Cc: Ilias Apalodimas 
> >> > Cc: Jens Wiklander 
> >> > Cc: Heinrich Schuchardt 
> >> > 
> >> > ---
> >> > Changelog:
> >> > ===
> >> > 
> >> > v11:
> >> > 
> >> > * use U_BOOT_CMD_WITH_SUBCMDS
> >> > * address nits
> >> > 
> >> > v10:
> >> > 
> >> > * use the FF-A driver Uclass operations
> >> > * use uclass_first_device()
> >> > * address nits
> >> > 
> >> > v9:
> >> > 
> >> > * remove manual FF-A discovery and use DM
> >> > * use DM class APIs to probe and interact with the FF-A bus
> >> > * add doc/usage/cmd/armffa.rst
> >> > 
> >> > v8:
> >> > 
> >> > * update partition_info_get() second argument to be an SP count
> >> > * pass NULL device pointer to the FF-A bus discovery and operations
> >> > 
> >> > v7:
> >> > 
> >> > * adapt do_ffa_dev_list() following the recent update on
> >> >uclass_first_device/uclass_next_device functions (they return void 
> >> > now)
> >> > * set armffa command to use 64-bit direct messaging
> >> > 
> >> > v4:
> >> > 
> >> > * remove pattern data in do_ffa_msg_send_direct_req
> >> > 
> >> > v3:
> >> > 
> >> > * use the new driver interfaces (partition_info_get, sync_send_receive)
> >> >in armffa command
> >> > 
> >> > v2:
> >> > 
> >> > * replace use of ffa_helper_init_device function by
> >> >   ffa_helper_bus_discover
> >> > 
> >> > v1:
> >> > 
> >> > * introduce armffa command
> >> > 
> >> >   MAINTAINERS  |   2 +
> >> >   cmd/Kconfig  |  10 ++
> >> >   cmd/Makefile |   2 +
> >> >   cmd/armffa.c | 212 +++
> >> >   doc/arch/arm64.ffa.rst   |   7 +
> >> >   doc/usage/cmd/armffa.rst | 105 +++
> >> >   doc/usage/index.rst  |   1 +
> >> >   drivers/firmware/arm-ffa/Kconfig |   1 +
> >> >   8 files changed, 340 insertions(+)
> >> >   create mode 100644 cmd/armffa.c
> >> >   create mode 100644 doc/usage/cmd/armffa.rst
> >> > 
> >> > diff --git a/MAINTAINERS b/MAINTAINERS
> >> > index 76f0f276ce..c64804ca2d 100644
> >> > --- a/MAINTAINERS
> >> > +++ b/MAINTAINERS
> >> > @@ -269,7 +269,9 @@ F:   configs/cortina_presidio-asic-pnand_defconfig
> >> >   ARM FF-A
> >> >   M: Abdellatif El Khlifi 
> >> >   S: Maintained
> >> > +F:  cmd/armffa.c
> >> >   F: doc/arch/arm64.ffa.rst
> >> > +F:  doc/usage/cmd/armffa.rst
> >> >   F: drivers/firmware/arm-ffa/
> >> >   F: include/arm_ffa.h
> >> >   F: include/sandbox_arm_ffa.h
> >> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> >> > index 8c9b430f99..4cb0b2c167 100644
> >> > --- a/cmd/Kconfig
> >> > +++ b/cmd/Kconfig
> >> > @@ -934,6 +934,16 @@ endmenu
> >> > 
> >> >   menu "Device access commands"
> >> > 
> >> > +config CMD_ARMFFA
> >> > +bool "Arm FF-A test command"
> >> > +depends on ARM_FFA_TRANSPORT
> >> > +help
> >> > +  Provides a test command for the FF-A support
> >> > +  supported options:
> >> > +- Listing the partition(s) info
> >> > +- Sending a data pattern to the specified partition
> >> > +- Displaying the arm_ffa device info
> >> > +
> >> >   config CMD_ARMFLASH
> >> >  #depends on FLASH_CFI_DRIVER
> >> >  bool "armflash"
> >> > diff --git a/cmd/Makefile b/cmd/Makefile
> >> > index e032091621..9130b9078d 100644
> >> > --- a/cmd/Makefile
> >> > +++ b/cmd/Makefile
> >> > @@ -12,6 +12,8 @@ obj-y += panic.o
> >> >   obj-y += version.o
> >> > 
> >> >   # command
> >> > +
> >> > +obj-$(CONFIG_CMD_ARMFFA) += armffa.o
> >> >   obj-$(CONFIG_CMD_ACPI) += acpi.o
> >> >   obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
> >> >   obj-$(CONFIG_CMD_AES) += aes.o
> >> > diff --git a/cmd/armffa.c b/cmd/armffa.c
> >> > new file mode 100644
> >> > index 00..ab88412c7d
> >> > --- /dev/null
> >> > +++ b/cmd/armffa.c
> >> > @@ -0,0 +1,212 @@
> >> > +// SPDX-License-Identifier: GPL-2.0+
> >> > +/*
> >> > + * Copyright 2022-2023 Arm Limited and/or its affiliates 
> >> > 
> >> > + *
> >> > + * Authors:
> >> > + *   Abdellatif El Khlifi 
> 

Re: [PATCH v11 05/10] arm_ffa: introduce armffa command

2023-04-12 Thread Heinrich Schuchardt



Am 12. April 2023 17:53:23 MESZ schrieb Abdellatif El Khlifi 
:
>On Wed, Apr 12, 2023 at 04:02:43PM +0200, Heinrich Schuchardt wrote:
>> On 4/12/23 11:42, Abdellatif El Khlifi wrote:
>> > Provide armffa command showcasing the use of the U-Boot FF-A support
>> > 
>> > armffa is a command showcasing how to invoke FF-A operations.
>> > This provides a guidance to the client developers on how to
>> > call the FF-A bus interfaces. The command also allows to gather secure
>> > partitions information and ping these  partitions. The command is also
>> > helpful in testing the communication with secure partitions.
>> > 
>> > For more details please refer to the command documentation [1].
>> > 
>> > [1]: doc/usage/cmd/armffa.rst
>> > 
>> > Signed-off-by: Abdellatif El Khlifi 
>> > Cc: Tom Rini 
>> > Cc: Simon Glass 
>> > Cc: Ilias Apalodimas 
>> > Cc: Jens Wiklander 
>> > Cc: Heinrich Schuchardt 
>> > 
>> > ---
>> > Changelog:
>> > ===
>> > 
>> > v11:
>> > 
>> > * use U_BOOT_CMD_WITH_SUBCMDS
>> > * address nits
>> > 
>> > v10:
>> > 
>> > * use the FF-A driver Uclass operations
>> > * use uclass_first_device()
>> > * address nits
>> > 
>> > v9:
>> > 
>> > * remove manual FF-A discovery and use DM
>> > * use DM class APIs to probe and interact with the FF-A bus
>> > * add doc/usage/cmd/armffa.rst
>> > 
>> > v8:
>> > 
>> > * update partition_info_get() second argument to be an SP count
>> > * pass NULL device pointer to the FF-A bus discovery and operations
>> > 
>> > v7:
>> > 
>> > * adapt do_ffa_dev_list() following the recent update on
>> >uclass_first_device/uclass_next_device functions (they return void now)
>> > * set armffa command to use 64-bit direct messaging
>> > 
>> > v4:
>> > 
>> > * remove pattern data in do_ffa_msg_send_direct_req
>> > 
>> > v3:
>> > 
>> > * use the new driver interfaces (partition_info_get, sync_send_receive)
>> >in armffa command
>> > 
>> > v2:
>> > 
>> > * replace use of ffa_helper_init_device function by
>> >   ffa_helper_bus_discover
>> > 
>> > v1:
>> > 
>> > * introduce armffa command
>> > 
>> >   MAINTAINERS  |   2 +
>> >   cmd/Kconfig  |  10 ++
>> >   cmd/Makefile |   2 +
>> >   cmd/armffa.c | 212 +++
>> >   doc/arch/arm64.ffa.rst   |   7 +
>> >   doc/usage/cmd/armffa.rst | 105 +++
>> >   doc/usage/index.rst  |   1 +
>> >   drivers/firmware/arm-ffa/Kconfig |   1 +
>> >   8 files changed, 340 insertions(+)
>> >   create mode 100644 cmd/armffa.c
>> >   create mode 100644 doc/usage/cmd/armffa.rst
>> > 
>> > diff --git a/MAINTAINERS b/MAINTAINERS
>> > index 76f0f276ce..c64804ca2d 100644
>> > --- a/MAINTAINERS
>> > +++ b/MAINTAINERS
>> > @@ -269,7 +269,9 @@ F: configs/cortina_presidio-asic-pnand_defconfig
>> >   ARM FF-A
>> >   M:   Abdellatif El Khlifi 
>> >   S:   Maintained
>> > +F:cmd/armffa.c
>> >   F:   doc/arch/arm64.ffa.rst
>> > +F:doc/usage/cmd/armffa.rst
>> >   F:   drivers/firmware/arm-ffa/
>> >   F:   include/arm_ffa.h
>> >   F:   include/sandbox_arm_ffa.h
>> > diff --git a/cmd/Kconfig b/cmd/Kconfig
>> > index 8c9b430f99..4cb0b2c167 100644
>> > --- a/cmd/Kconfig
>> > +++ b/cmd/Kconfig
>> > @@ -934,6 +934,16 @@ endmenu
>> > 
>> >   menu "Device access commands"
>> > 
>> > +config CMD_ARMFFA
>> > +  bool "Arm FF-A test command"
>> > +  depends on ARM_FFA_TRANSPORT
>> > +  help
>> > +Provides a test command for the FF-A support
>> > +supported options:
>> > +  - Listing the partition(s) info
>> > +  - Sending a data pattern to the specified partition
>> > +  - Displaying the arm_ffa device info
>> > +
>> >   config CMD_ARMFLASH
>> >#depends on FLASH_CFI_DRIVER
>> >bool "armflash"
>> > diff --git a/cmd/Makefile b/cmd/Makefile
>> > index e032091621..9130b9078d 100644
>> > --- a/cmd/Makefile
>> > +++ b/cmd/Makefile
>> > @@ -12,6 +12,8 @@ obj-y += panic.o
>> >   obj-y += version.o
>> > 
>> >   # command
>> > +
>> > +obj-$(CONFIG_CMD_ARMFFA) += armffa.o
>> >   obj-$(CONFIG_CMD_ACPI) += acpi.o
>> >   obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
>> >   obj-$(CONFIG_CMD_AES) += aes.o
>> > diff --git a/cmd/armffa.c b/cmd/armffa.c
>> > new file mode 100644
>> > index 00..ab88412c7d
>> > --- /dev/null
>> > +++ b/cmd/armffa.c
>> > @@ -0,0 +1,212 @@
>> > +// SPDX-License-Identifier: GPL-2.0+
>> > +/*
>> > + * Copyright 2022-2023 Arm Limited and/or its affiliates 
>> > 
>> > + *
>> > + * Authors:
>> > + *   Abdellatif El Khlifi 
>> > + */
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +
>> > +/**
>> > + * ffa_get_dev() - Return the FF-A device
>> > + * @devp: pointer to the FF-A device
>> > + *
>> > + * Search for the FF-A device.
>> > + *
>> > + * Return:
>> > + * 0 on success. Otherwise, failure
>> > + */
>> > +int ffa_get_dev(struct udevice **devp)
>> > +{
>> > +  

Re: [PATCH v11 05/10] arm_ffa: introduce armffa command

2023-04-12 Thread Abdellatif El Khlifi
On Wed, Apr 12, 2023 at 04:02:43PM +0200, Heinrich Schuchardt wrote:
> On 4/12/23 11:42, Abdellatif El Khlifi wrote:
> > Provide armffa command showcasing the use of the U-Boot FF-A support
> > 
> > armffa is a command showcasing how to invoke FF-A operations.
> > This provides a guidance to the client developers on how to
> > call the FF-A bus interfaces. The command also allows to gather secure
> > partitions information and ping these  partitions. The command is also
> > helpful in testing the communication with secure partitions.
> > 
> > For more details please refer to the command documentation [1].
> > 
> > [1]: doc/usage/cmd/armffa.rst
> > 
> > Signed-off-by: Abdellatif El Khlifi 
> > Cc: Tom Rini 
> > Cc: Simon Glass 
> > Cc: Ilias Apalodimas 
> > Cc: Jens Wiklander 
> > Cc: Heinrich Schuchardt 
> > 
> > ---
> > Changelog:
> > ===
> > 
> > v11:
> > 
> > * use U_BOOT_CMD_WITH_SUBCMDS
> > * address nits
> > 
> > v10:
> > 
> > * use the FF-A driver Uclass operations
> > * use uclass_first_device()
> > * address nits
> > 
> > v9:
> > 
> > * remove manual FF-A discovery and use DM
> > * use DM class APIs to probe and interact with the FF-A bus
> > * add doc/usage/cmd/armffa.rst
> > 
> > v8:
> > 
> > * update partition_info_get() second argument to be an SP count
> > * pass NULL device pointer to the FF-A bus discovery and operations
> > 
> > v7:
> > 
> > * adapt do_ffa_dev_list() following the recent update on
> >uclass_first_device/uclass_next_device functions (they return void now)
> > * set armffa command to use 64-bit direct messaging
> > 
> > v4:
> > 
> > * remove pattern data in do_ffa_msg_send_direct_req
> > 
> > v3:
> > 
> > * use the new driver interfaces (partition_info_get, sync_send_receive)
> >in armffa command
> > 
> > v2:
> > 
> > * replace use of ffa_helper_init_device function by
> >   ffa_helper_bus_discover
> > 
> > v1:
> > 
> > * introduce armffa command
> > 
> >   MAINTAINERS  |   2 +
> >   cmd/Kconfig  |  10 ++
> >   cmd/Makefile |   2 +
> >   cmd/armffa.c | 212 +++
> >   doc/arch/arm64.ffa.rst   |   7 +
> >   doc/usage/cmd/armffa.rst | 105 +++
> >   doc/usage/index.rst  |   1 +
> >   drivers/firmware/arm-ffa/Kconfig |   1 +
> >   8 files changed, 340 insertions(+)
> >   create mode 100644 cmd/armffa.c
> >   create mode 100644 doc/usage/cmd/armffa.rst
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 76f0f276ce..c64804ca2d 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -269,7 +269,9 @@ F:  configs/cortina_presidio-asic-pnand_defconfig
> >   ARM FF-A
> >   M:Abdellatif El Khlifi 
> >   S:Maintained
> > +F: cmd/armffa.c
> >   F:doc/arch/arm64.ffa.rst
> > +F: doc/usage/cmd/armffa.rst
> >   F:drivers/firmware/arm-ffa/
> >   F:include/arm_ffa.h
> >   F:include/sandbox_arm_ffa.h
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 8c9b430f99..4cb0b2c167 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -934,6 +934,16 @@ endmenu
> > 
> >   menu "Device access commands"
> > 
> > +config CMD_ARMFFA
> > +   bool "Arm FF-A test command"
> > +   depends on ARM_FFA_TRANSPORT
> > +   help
> > + Provides a test command for the FF-A support
> > + supported options:
> > +   - Listing the partition(s) info
> > +   - Sending a data pattern to the specified partition
> > +   - Displaying the arm_ffa device info
> > +
> >   config CMD_ARMFLASH
> > #depends on FLASH_CFI_DRIVER
> > bool "armflash"
> > diff --git a/cmd/Makefile b/cmd/Makefile
> > index e032091621..9130b9078d 100644
> > --- a/cmd/Makefile
> > +++ b/cmd/Makefile
> > @@ -12,6 +12,8 @@ obj-y += panic.o
> >   obj-y += version.o
> > 
> >   # command
> > +
> > +obj-$(CONFIG_CMD_ARMFFA) += armffa.o
> >   obj-$(CONFIG_CMD_ACPI) += acpi.o
> >   obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
> >   obj-$(CONFIG_CMD_AES) += aes.o
> > diff --git a/cmd/armffa.c b/cmd/armffa.c
> > new file mode 100644
> > index 00..ab88412c7d
> > --- /dev/null
> > +++ b/cmd/armffa.c
> > @@ -0,0 +1,212 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright 2022-2023 Arm Limited and/or its affiliates 
> > 
> > + *
> > + * Authors:
> > + *   Abdellatif El Khlifi 
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/**
> > + * ffa_get_dev() - Return the FF-A device
> > + * @devp:  pointer to the FF-A device
> > + *
> > + * Search for the FF-A device.
> > + *
> > + * Return:
> > + * 0 on success. Otherwise, failure
> > + */
> > +int ffa_get_dev(struct udevice **devp)
> > +{
> > +   int ret;
> > +
> > +   ret = uclass_first_device_err(UCLASS_FFA, devp);
> > +   if (ret) {
> > +   log_err("Cannot find FF-A bus device\n");
> > +   return -ENODEV;
> > +   }
> > +
> > +   return 0;
> > +}
> > +

Re: [PATCH v11 05/10] arm_ffa: introduce armffa command

2023-04-12 Thread Heinrich Schuchardt

On 4/12/23 11:42, Abdellatif El Khlifi wrote:

Provide armffa command showcasing the use of the U-Boot FF-A support

armffa is a command showcasing how to invoke FF-A operations.
This provides a guidance to the client developers on how to
call the FF-A bus interfaces. The command also allows to gather secure
partitions information and ping these  partitions. The command is also
helpful in testing the communication with secure partitions.

For more details please refer to the command documentation [1].

[1]: doc/usage/cmd/armffa.rst

Signed-off-by: Abdellatif El Khlifi 
Cc: Tom Rini 
Cc: Simon Glass 
Cc: Ilias Apalodimas 
Cc: Jens Wiklander 
Cc: Heinrich Schuchardt 

---
Changelog:
===

v11:

* use U_BOOT_CMD_WITH_SUBCMDS
* address nits

v10:

* use the FF-A driver Uclass operations
* use uclass_first_device()
* address nits

v9:

* remove manual FF-A discovery and use DM
* use DM class APIs to probe and interact with the FF-A bus
* add doc/usage/cmd/armffa.rst

v8:

* update partition_info_get() second argument to be an SP count
* pass NULL device pointer to the FF-A bus discovery and operations

v7:

* adapt do_ffa_dev_list() following the recent update on
   uclass_first_device/uclass_next_device functions (they return void now)
* set armffa command to use 64-bit direct messaging

v4:

* remove pattern data in do_ffa_msg_send_direct_req

v3:

* use the new driver interfaces (partition_info_get, sync_send_receive)
   in armffa command

v2:

* replace use of ffa_helper_init_device function by
  ffa_helper_bus_discover

v1:

* introduce armffa command

  MAINTAINERS  |   2 +
  cmd/Kconfig  |  10 ++
  cmd/Makefile |   2 +
  cmd/armffa.c | 212 +++
  doc/arch/arm64.ffa.rst   |   7 +
  doc/usage/cmd/armffa.rst | 105 +++
  doc/usage/index.rst  |   1 +
  drivers/firmware/arm-ffa/Kconfig |   1 +
  8 files changed, 340 insertions(+)
  create mode 100644 cmd/armffa.c
  create mode 100644 doc/usage/cmd/armffa.rst

diff --git a/MAINTAINERS b/MAINTAINERS
index 76f0f276ce..c64804ca2d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -269,7 +269,9 @@ F:  configs/cortina_presidio-asic-pnand_defconfig
  ARM FF-A
  M:Abdellatif El Khlifi 
  S:Maintained
+F: cmd/armffa.c
  F:doc/arch/arm64.ffa.rst
+F: doc/usage/cmd/armffa.rst
  F:drivers/firmware/arm-ffa/
  F:include/arm_ffa.h
  F:include/sandbox_arm_ffa.h
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 8c9b430f99..4cb0b2c167 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -934,6 +934,16 @@ endmenu

  menu "Device access commands"

+config CMD_ARMFFA
+   bool "Arm FF-A test command"
+   depends on ARM_FFA_TRANSPORT
+   help
+ Provides a test command for the FF-A support
+ supported options:
+   - Listing the partition(s) info
+   - Sending a data pattern to the specified partition
+   - Displaying the arm_ffa device info
+
  config CMD_ARMFLASH
#depends on FLASH_CFI_DRIVER
bool "armflash"
diff --git a/cmd/Makefile b/cmd/Makefile
index e032091621..9130b9078d 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -12,6 +12,8 @@ obj-y += panic.o
  obj-y += version.o

  # command
+
+obj-$(CONFIG_CMD_ARMFFA) += armffa.o
  obj-$(CONFIG_CMD_ACPI) += acpi.o
  obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
  obj-$(CONFIG_CMD_AES) += aes.o
diff --git a/cmd/armffa.c b/cmd/armffa.c
new file mode 100644
index 00..ab88412c7d
--- /dev/null
+++ b/cmd/armffa.c
@@ -0,0 +1,212 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022-2023 Arm Limited and/or its affiliates 

+ *
+ * Authors:
+ *   Abdellatif El Khlifi 
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * ffa_get_dev() - Return the FF-A device
+ * @devp:  pointer to the FF-A device
+ *
+ * Search for the FF-A device.
+ *
+ * Return:
+ * 0 on success. Otherwise, failure
+ */
+int ffa_get_dev(struct udevice **devp)
+{
+   int ret;
+
+   ret = uclass_first_device_err(UCLASS_FFA, devp);
+   if (ret) {
+   log_err("Cannot find FF-A bus device\n");
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
+/**
+ * do_ffa_getpart() - implementation of the getpart subcommand
+ * @cmdtp: Command Table
+ * @flag:  flags
+ * @argc:  number of arguments
+ * @argv:  arguments
+ *
+ * Query the secure partition information which the UUID is provided
+ * as an argument. The function uses the arm_ffa driver
+ * partition_info_get operation which implements FFA_PARTITION_INFO_GET
+ * ABI to retrieve the data. The input UUID string is expected to be in big
+ * endian format.
+ *
+ * Return:
+ *
+ * CMD_RET_SUCCESS: on success, otherwise failure
+ */
+static int do_ffa_getpart(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])

[PATCH v11 05/10] arm_ffa: introduce armffa command

2023-04-12 Thread Abdellatif El Khlifi
Provide armffa command showcasing the use of the U-Boot FF-A support

armffa is a command showcasing how to invoke FF-A operations.
This provides a guidance to the client developers on how to
call the FF-A bus interfaces. The command also allows to gather secure
partitions information and ping these  partitions. The command is also
helpful in testing the communication with secure partitions.

For more details please refer to the command documentation [1].

[1]: doc/usage/cmd/armffa.rst

Signed-off-by: Abdellatif El Khlifi 
Cc: Tom Rini 
Cc: Simon Glass 
Cc: Ilias Apalodimas 
Cc: Jens Wiklander 
Cc: Heinrich Schuchardt 

---
Changelog:
===

v11:

* use U_BOOT_CMD_WITH_SUBCMDS
* address nits

v10:

* use the FF-A driver Uclass operations
* use uclass_first_device()
* address nits

v9:

* remove manual FF-A discovery and use DM
* use DM class APIs to probe and interact with the FF-A bus
* add doc/usage/cmd/armffa.rst

v8:

* update partition_info_get() second argument to be an SP count
* pass NULL device pointer to the FF-A bus discovery and operations

v7:

* adapt do_ffa_dev_list() following the recent update on
  uclass_first_device/uclass_next_device functions (they return void now)
* set armffa command to use 64-bit direct messaging

v4:

* remove pattern data in do_ffa_msg_send_direct_req

v3:

* use the new driver interfaces (partition_info_get, sync_send_receive)
  in armffa command

v2:

* replace use of ffa_helper_init_device function by
 ffa_helper_bus_discover

v1:

* introduce armffa command

 MAINTAINERS  |   2 +
 cmd/Kconfig  |  10 ++
 cmd/Makefile |   2 +
 cmd/armffa.c | 212 +++
 doc/arch/arm64.ffa.rst   |   7 +
 doc/usage/cmd/armffa.rst | 105 +++
 doc/usage/index.rst  |   1 +
 drivers/firmware/arm-ffa/Kconfig |   1 +
 8 files changed, 340 insertions(+)
 create mode 100644 cmd/armffa.c
 create mode 100644 doc/usage/cmd/armffa.rst

diff --git a/MAINTAINERS b/MAINTAINERS
index 76f0f276ce..c64804ca2d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -269,7 +269,9 @@ F:  configs/cortina_presidio-asic-pnand_defconfig
 ARM FF-A
 M: Abdellatif El Khlifi 
 S: Maintained
+F: cmd/armffa.c
 F: doc/arch/arm64.ffa.rst
+F: doc/usage/cmd/armffa.rst
 F: drivers/firmware/arm-ffa/
 F: include/arm_ffa.h
 F: include/sandbox_arm_ffa.h
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 8c9b430f99..4cb0b2c167 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -934,6 +934,16 @@ endmenu
 
 menu "Device access commands"
 
+config CMD_ARMFFA
+   bool "Arm FF-A test command"
+   depends on ARM_FFA_TRANSPORT
+   help
+ Provides a test command for the FF-A support
+ supported options:
+   - Listing the partition(s) info
+   - Sending a data pattern to the specified partition
+   - Displaying the arm_ffa device info
+
 config CMD_ARMFLASH
#depends on FLASH_CFI_DRIVER
bool "armflash"
diff --git a/cmd/Makefile b/cmd/Makefile
index e032091621..9130b9078d 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -12,6 +12,8 @@ obj-y += panic.o
 obj-y += version.o
 
 # command
+
+obj-$(CONFIG_CMD_ARMFFA) += armffa.o
 obj-$(CONFIG_CMD_ACPI) += acpi.o
 obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
 obj-$(CONFIG_CMD_AES) += aes.o
diff --git a/cmd/armffa.c b/cmd/armffa.c
new file mode 100644
index 00..ab88412c7d
--- /dev/null
+++ b/cmd/armffa.c
@@ -0,0 +1,212 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022-2023 Arm Limited and/or its affiliates 

+ *
+ * Authors:
+ *   Abdellatif El Khlifi 
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * ffa_get_dev() - Return the FF-A device
+ * @devp:  pointer to the FF-A device
+ *
+ * Search for the FF-A device.
+ *
+ * Return:
+ * 0 on success. Otherwise, failure
+ */
+int ffa_get_dev(struct udevice **devp)
+{
+   int ret;
+
+   ret = uclass_first_device_err(UCLASS_FFA, devp);
+   if (ret) {
+   log_err("Cannot find FF-A bus device\n");
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
+/**
+ * do_ffa_getpart() - implementation of the getpart subcommand
+ * @cmdtp: Command Table
+ * @flag:  flags
+ * @argc:  number of arguments
+ * @argv:  arguments
+ *
+ * Query the secure partition information which the UUID is provided
+ * as an argument. The function uses the arm_ffa driver
+ * partition_info_get operation which implements FFA_PARTITION_INFO_GET
+ * ABI to retrieve the data. The input UUID string is expected to be in big
+ * endian format.
+ *
+ * Return:
+ *
+ * CMD_RET_SUCCESS: on success, otherwise failure
+ */
+static int do_ffa_getpart(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+   u32 count = 0;
+   int ret;
+   struct