Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

2020-06-10 Thread Suman Anna

On 6/10/20 3:47 PM, Rob Herring wrote:

On Tue, Jun 09, 2020 at 09:47:02AM -0600, Mathieu Poirier wrote:

On Tue, 9 Jun 2020 at 09:29, Ben Levinsky  wrote:


Hi Suman, Mathieu,

Thank you for your comments. Please see my replies inline.

Best Regards,
Ben

-Original Message-
From: Suman Anna 
Sent: Monday, June 8, 2020 5:00 PM
To: Mathieu Poirier ; Ben Levinsky 

Cc: o...@wizery.com; bjorn.anders...@linaro.org; Michal Simek ; Jolly Shah 
; Rajan Vaja ; robh...@kernel.org; mark.rutl...@arm.com; 
linux-remotep...@vger.kernel.org; linux-arm-kern...@lists.infradead.org; devicet...@vger.kernel.org; 
linux-kernel@vger.kernel.org; Jiaying Liang ; Michal Simek ; Ed T. 
Mooring ; Jason Wu 
Subject: Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

On 6/8/20 6:49 PM, Mathieu Poirier wrote:

On Wed, Jun 03, 2020 at 07:49:43AM -0700, Ben Levinsky wrote:

R5 is included in Xilinx Zynq UltraScale MPSoC so by adding this
remotproc driver, we can boot the R5 sub-system in different
configurations.

Acked-by: Stefano Stabellini 
Acked-by: Ben Levinsky 
Reviewed-by: Radhey Shyam Pandey 
Signed-off-by: Ben Levinsky 
Signed-off-by: Wendy Liang 
Signed-off-by: Michal Simek 
Signed-off-by: Ed Mooring 
Signed-off-by: Jason Wu 
Tested-by: Ben Levinsky 
---
v2:
- remove domain struct as per review from Mathieu
v3:
- add xilinx-related platform mgmt fn's instead of wrapping around
function pointer in xilinx eemi ops struct
v4:
- add default values for enums
- fix formatting as per checkpatch.pl --strict. Note that 1 warning and 1 check
are still raised as each is due to fixing the warning results in
that particular line going over 80 characters.
v5:
- parse_fw change from use of rproc_of_resm_mem_entry_init to
rproc_mem_entry_init and use of alloc/release
- var's of type zynqmp_r5_pdata all have same local variable name
- use dev_dbg instead of dev_info

---
   drivers/remoteproc/Kconfig|  10 +
   drivers/remoteproc/Makefile   |   1 +
   drivers/remoteproc/zynqmp_r5_remoteproc.c | 898 
++
   3 files changed, 909 insertions(+)
   create mode 100644 drivers/remoteproc/zynqmp_r5_remoteproc.c

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index fbaed07..735bd7f 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -240,6 +240,16 @@ config STM32_RPROC

This can be either built-in or a loadable module.

+config ZYNQMP_R5_REMOTEPROC
+tristate "ZynqMP_R5 remoteproc support"
+depends on ARM64 && PM && ARCH_ZYNQMP
+select RPMSG_VIRTIO
+select MAILBOX
+select ZYNQMP_IPI_MBOX
+help
+  Say y here to support ZynqMP R5 remote processors via the remote
+  processor framework.
+
   endif # REMOTEPROC

   endmenu
diff --git a/drivers/remoteproc/Makefile
b/drivers/remoteproc/Makefile index 0effd38..806ac3f 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -27,5 +27,6 @@ obj-$(CONFIG_QCOM_WCNSS_PIL)   += qcom_wcnss_pil.o
   qcom_wcnss_pil-y   += qcom_wcnss.o
   qcom_wcnss_pil-y   += qcom_wcnss_iris.o
   obj-$(CONFIG_ST_REMOTEPROC)+= st_remoteproc.o
+obj-$(CONFIG_ZYNQMP_R5_REMOTEPROC)  += zynqmp_r5_remoteproc.o
   obj-$(CONFIG_ST_SLIM_REMOTEPROC)   += st_slim_rproc.o
   obj-$(CONFIG_STM32_RPROC)  += stm32_rproc.o
diff --git a/drivers/remoteproc/zynqmp_r5_remoteproc.c
b/drivers/remoteproc/zynqmp_r5_remoteproc.c
new file mode 100644
index 000..0e4f3ad
--- /dev/null
+++ b/drivers/remoteproc/zynqmp_r5_remoteproc.c
@@ -0,0 +1,898 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Zynq R5 Remote Processor driver
+ *
+ * Copyright (C) 2019, 2020 Xilinx Inc. Ben Levinsky
+
+ * Copyright (C) 2015 - 2018 Xilinx Inc.
+ * Copyright (C) 2015 Jason Wu 
+ *
+ * Based on origin OMAP and Zynq Remote Processor driver
+ *
+ * Copyright (C) 2012 Michal Simek 
+ * Copyright (C) 2012 PetaLogix
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include  #include 
+#include  #include  #include
+ #include  #include
+ #include
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "remoteproc_internal.h"
+
+#define MAX_RPROCS  2 /* Support up to 2 RPU */
+#define MAX_MEM_PNODES  4 /* Max power nodes for one RPU memory instance */
+
+#define DEFAULT_FIRMWARE_NAME   "rproc-rpu-fw"
+
+/* PM proc states */
+#define PM_PROC_STATE_ACTIVE 1U
+
+/* IPI buffer MAX length */
+#define IPI_BUF_LEN_MAX 32U
+/* RX mailbox client buffer max length */
+#define RX_MBOX_CLIENT_BUF_MAX  (IPI_BUF_LEN_MAX + \
+ sizeof(struct zynqmp_ipi_message))
+
+static bool autoboot __read_mostly;
+
+/**
+ * struct zynqmp_r5_mem - zynqmp rpu memory data
+ * @pnode_id: 

Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

2020-06-10 Thread Rob Herring
On Tue, Jun 09, 2020 at 09:47:02AM -0600, Mathieu Poirier wrote:
> On Tue, 9 Jun 2020 at 09:29, Ben Levinsky  wrote:
> >
> > Hi Suman, Mathieu,
> >
> > Thank you for your comments. Please see my replies inline.
> >
> > Best Regards,
> > Ben
> >
> > -Original Message-
> > From: Suman Anna 
> > Sent: Monday, June 8, 2020 5:00 PM
> > To: Mathieu Poirier ; Ben Levinsky 
> > 
> > Cc: o...@wizery.com; bjorn.anders...@linaro.org; Michal Simek 
> > ; Jolly Shah ; Rajan Vaja 
> > ; robh...@kernel.org; mark.rutl...@arm.com; 
> > linux-remotep...@vger.kernel.org; linux-arm-kern...@lists.infradead.org; 
> > devicet...@vger.kernel.org; linux-kernel@vger.kernel.org; Jiaying Liang 
> > ; Michal Simek ; Ed T. Mooring 
> > ; Jason Wu 
> > Subject: Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc 
> > driver
> >
> > On 6/8/20 6:49 PM, Mathieu Poirier wrote:
> > > On Wed, Jun 03, 2020 at 07:49:43AM -0700, Ben Levinsky wrote:
> > >> R5 is included in Xilinx Zynq UltraScale MPSoC so by adding this
> > >> remotproc driver, we can boot the R5 sub-system in different
> > >> configurations.
> > >>
> > >> Acked-by: Stefano Stabellini 
> > >> Acked-by: Ben Levinsky 
> > >> Reviewed-by: Radhey Shyam Pandey 
> > >> Signed-off-by: Ben Levinsky 
> > >> Signed-off-by: Wendy Liang 
> > >> Signed-off-by: Michal Simek 
> > >> Signed-off-by: Ed Mooring 
> > >> Signed-off-by: Jason Wu 
> > >> Tested-by: Ben Levinsky 
> > >> ---
> > >> v2:
> > >> - remove domain struct as per review from Mathieu
> > >> v3:
> > >> - add xilinx-related platform mgmt fn's instead of wrapping around
> > >>function pointer in xilinx eemi ops struct
> > >> v4:
> > >> - add default values for enums
> > >> - fix formatting as per checkpatch.pl --strict. Note that 1 warning and 
> > >> 1 check
> > >>are still raised as each is due to fixing the warning results in
> > >> that particular line going over 80 characters.
> > >> v5:
> > >> - parse_fw change from use of rproc_of_resm_mem_entry_init to
> > >> rproc_mem_entry_init and use of alloc/release
> > >> - var's of type zynqmp_r5_pdata all have same local variable name
> > >> - use dev_dbg instead of dev_info
> > >>
> > >> ---
> > >>   drivers/remoteproc/Kconfig|  10 +
> > >>   drivers/remoteproc/Makefile   |   1 +
> > >>   drivers/remoteproc/zynqmp_r5_remoteproc.c | 898 
> > >> ++
> > >>   3 files changed, 909 insertions(+)
> > >>   create mode 100644 drivers/remoteproc/zynqmp_r5_remoteproc.c
> > >>
> > >> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> > >> index fbaed07..735bd7f 100644
> > >> --- a/drivers/remoteproc/Kconfig
> > >> +++ b/drivers/remoteproc/Kconfig
> > >> @@ -240,6 +240,16 @@ config STM32_RPROC
> > >>
> > >>This can be either built-in or a loadable module.
> > >>
> > >> +config ZYNQMP_R5_REMOTEPROC
> > >> +tristate "ZynqMP_R5 remoteproc support"
> > >> +depends on ARM64 && PM && ARCH_ZYNQMP
> > >> +select RPMSG_VIRTIO
> > >> +select MAILBOX
> > >> +select ZYNQMP_IPI_MBOX
> > >> +help
> > >> +  Say y here to support ZynqMP R5 remote processors via the remote
> > >> +  processor framework.
> > >> +
> > >>   endif # REMOTEPROC
> > >>
> > >>   endmenu
> > >> diff --git a/drivers/remoteproc/Makefile
> > >> b/drivers/remoteproc/Makefile index 0effd38..806ac3f 100644
> > >> --- a/drivers/remoteproc/Makefile
> > >> +++ b/drivers/remoteproc/Makefile
> > >> @@ -27,5 +27,6 @@ obj-$(CONFIG_QCOM_WCNSS_PIL)   += 
> > >> qcom_wcnss_pil.o
> > >>   qcom_wcnss_pil-y   += qcom_wcnss.o
> > >>   qcom_wcnss_pil-y   += qcom_wcnss_iris.o
> > >>   obj-$(CONFIG_ST_REMOTEPROC)+= st_remoteproc.o
> > >> +obj-$(CONFIG_ZYNQMP_R5_REMOTEPROC)  += zynqmp_r5_remoteproc.o
> > >>   obj-$(CONFIG_ST_SLIM_REMOTEPROC)   += st_slim_rproc.o
> > >>   obj-$(CONFIG_STM32_RPROC)  += stm32_rproc.o

Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

2020-06-09 Thread Mathieu Poirier
On Wed, Jun 03, 2020 at 07:49:43AM -0700, Ben Levinsky wrote:
> R5 is included in Xilinx Zynq UltraScale MPSoC so by adding this
> remotproc driver, we can boot the R5 sub-system in different
> configurations.
> 
> Acked-by: Stefano Stabellini 
> Acked-by: Ben Levinsky 
> Reviewed-by: Radhey Shyam Pandey 
> Signed-off-by: Ben Levinsky 
> Signed-off-by: Wendy Liang 
> Signed-off-by: Michal Simek 
> Signed-off-by: Ed Mooring 
> Signed-off-by: Jason Wu 
> Tested-by: Ben Levinsky 
> ---
> v2:
> - remove domain struct as per review from Mathieu
> v3:
> - add xilinx-related platform mgmt fn's instead of wrapping around
>   function pointer in xilinx eemi ops struct
> v4:
> - add default values for enums
> - fix formatting as per checkpatch.pl --strict. Note that 1 warning and 1 
> check
>   are still raised as each is due to fixing the warning results in that
> particular line going over 80 characters.
> v5:
> - parse_fw change from use of rproc_of_resm_mem_entry_init to 
> rproc_mem_entry_init and use of alloc/release
> - var's of type zynqmp_r5_pdata all have same local variable name
> - use dev_dbg instead of dev_info
> 
> ---
>  drivers/remoteproc/Kconfig|  10 +
>  drivers/remoteproc/Makefile   |   1 +
>  drivers/remoteproc/zynqmp_r5_remoteproc.c | 898 
> ++
>  3 files changed, 909 insertions(+)
>  create mode 100644 drivers/remoteproc/zynqmp_r5_remoteproc.c
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index fbaed07..735bd7f 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -240,6 +240,16 @@ config STM32_RPROC
>  
> This can be either built-in or a loadable module.
>  
> +config ZYNQMP_R5_REMOTEPROC
> + tristate "ZynqMP_R5 remoteproc support"
> + depends on ARM64 && PM && ARCH_ZYNQMP
> + select RPMSG_VIRTIO
> + select MAILBOX
> + select ZYNQMP_IPI_MBOX
> + help
> +   Say y here to support ZynqMP R5 remote processors via the remote
> +   processor framework.
> +
>  endif # REMOTEPROC
>  
>  endmenu
> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> index 0effd38..806ac3f 100644
> --- a/drivers/remoteproc/Makefile
> +++ b/drivers/remoteproc/Makefile
> @@ -27,5 +27,6 @@ obj-$(CONFIG_QCOM_WCNSS_PIL)+= 
> qcom_wcnss_pil.o
>  qcom_wcnss_pil-y += qcom_wcnss.o
>  qcom_wcnss_pil-y += qcom_wcnss_iris.o
>  obj-$(CONFIG_ST_REMOTEPROC)  += st_remoteproc.o
> +obj-$(CONFIG_ZYNQMP_R5_REMOTEPROC)   += zynqmp_r5_remoteproc.o
>  obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o
>  obj-$(CONFIG_STM32_RPROC)+= stm32_rproc.o
> diff --git a/drivers/remoteproc/zynqmp_r5_remoteproc.c 
> b/drivers/remoteproc/zynqmp_r5_remoteproc.c
> new file mode 100644
> index 000..0e4f3ad
> --- /dev/null
> +++ b/drivers/remoteproc/zynqmp_r5_remoteproc.c
> @@ -0,0 +1,898 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Zynq R5 Remote Processor driver
> + *
> + * Copyright (C) 2019, 2020 Xilinx Inc. Ben Levinsky 
> 
> + * Copyright (C) 2015 - 2018 Xilinx Inc.
> + * Copyright (C) 2015 Jason Wu 
> + *
> + * Based on origin OMAP and Zynq Remote Processor driver
> + *
> + * Copyright (C) 2012 Michal Simek 
> + * Copyright (C) 2012 PetaLogix
> + * Copyright (C) 2011 Texas Instruments, Inc.
> + * Copyright (C) 2011 Google, Inc.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "remoteproc_internal.h"
> +
> +#define MAX_RPROCS   2 /* Support up to 2 RPU */
> +#define MAX_MEM_PNODES   4 /* Max power nodes for one RPU memory 
> instance */
> +
> +#define DEFAULT_FIRMWARE_NAME"rproc-rpu-fw"
> +
> +/* PM proc states */
> +#define PM_PROC_STATE_ACTIVE 1U
> +
> +/* IPI buffer MAX length */
> +#define IPI_BUF_LEN_MAX  32U
> +/* RX mailbox client buffer max length */
> +#define RX_MBOX_CLIENT_BUF_MAX   (IPI_BUF_LEN_MAX + \
> +  sizeof(struct zynqmp_ipi_message))
> +
> +static bool autoboot __read_mostly;
> +
> +/**
> + * struct zynqmp_r5_mem - zynqmp rpu memory data
> + * @pnode_id: TCM power domain ids
> + * @res: memory resource
> + * @node: list node
> + */
> +struct zynqmp_r5_mem {
> + u32 pnode_id[MAX_MEM_PNODES];
> + struct resource res;
> + struct list_head node;
> +};
> +
> +/**
> + * struct zynqmp_r5_pdata - zynqmp rpu remote processor private data
> + * @dev: device of RPU instance
> + * @rproc: rproc handle
> + * @pnode_id: RPU CPU power domain id
> + * @mems: memory resources
> + * @is_r5_mode_set: indicate if r5 operation mode is set
> + * @tx_mc: tx mailbox client
> + * @rx_mc: rx mailbox client
> + * @tx_chan: tx mailbox channel
> + * @rx_

Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

2020-06-09 Thread Mathieu Poirier
Hey Ben,

On Tue, Jun 09, 2020 at 03:29:28PM +, Ben Levinsky wrote:
> Hi Suman, Mathieu,
> 
> Thank you for your comments. Please see my replies inline.
> 
> Best Regards,
> Ben
> 
> -Original Message-
> From: Suman Anna  
> Sent: Monday, June 8, 2020 5:00 PM
> To: Mathieu Poirier ; Ben Levinsky 
> 
> Cc: o...@wizery.com; bjorn.anders...@linaro.org; Michal Simek 
> ; Jolly Shah ; Rajan Vaja 
> ; robh...@kernel.org; mark.rutl...@arm.com; 
> linux-remotep...@vger.kernel.org; linux-arm-kern...@lists.infradead.org; 
> devicet...@vger.kernel.org; linux-kernel@vger.kernel.org; Jiaying Liang 
> ; Michal Simek ; Ed T. Mooring 
> ; Jason Wu 
> Subject: Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc 
> driver
> 
> On 6/8/20 6:49 PM, Mathieu Poirier wrote:
> > On Wed, Jun 03, 2020 at 07:49:43AM -0700, Ben Levinsky wrote:
> >> R5 is included in Xilinx Zynq UltraScale MPSoC so by adding this 
> >> remotproc driver, we can boot the R5 sub-system in different 
> >> configurations.
> >>
> >> Acked-by: Stefano Stabellini 
> >> Acked-by: Ben Levinsky 
> >> Reviewed-by: Radhey Shyam Pandey 
> >> Signed-off-by: Ben Levinsky 
> >> Signed-off-by: Wendy Liang 
> >> Signed-off-by: Michal Simek 
> >> Signed-off-by: Ed Mooring 
> >> Signed-off-by: Jason Wu 
> >> Tested-by: Ben Levinsky 
> >> ---
> >> v2:
> >> - remove domain struct as per review from Mathieu
> >> v3:
> >> - add xilinx-related platform mgmt fn's instead of wrapping around
> >>function pointer in xilinx eemi ops struct
> >> v4:
> >> - add default values for enums
> >> - fix formatting as per checkpatch.pl --strict. Note that 1 warning and 1 
> >> check
> >>are still raised as each is due to fixing the warning results in 
> >> that particular line going over 80 characters.
> >> v5:
> >> - parse_fw change from use of rproc_of_resm_mem_entry_init to 
> >> rproc_mem_entry_init and use of alloc/release
> >> - var's of type zynqmp_r5_pdata all have same local variable name
> >> - use dev_dbg instead of dev_info
> >>
> >> ---
> >>   drivers/remoteproc/Kconfig|  10 +
> >>   drivers/remoteproc/Makefile   |   1 +
> >>   drivers/remoteproc/zynqmp_r5_remoteproc.c | 898 
> >> ++
> >>   3 files changed, 909 insertions(+)
> >>   create mode 100644 drivers/remoteproc/zynqmp_r5_remoteproc.c
> >>
> >> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig 
> >> index fbaed07..735bd7f 100644
> >> --- a/drivers/remoteproc/Kconfig
> >> +++ b/drivers/remoteproc/Kconfig
> >> @@ -240,6 +240,16 @@ config STM32_RPROC
> >>   
> >>  This can be either built-in or a loadable module.
> >>   
> >> +config ZYNQMP_R5_REMOTEPROC
> >> +  tristate "ZynqMP_R5 remoteproc support"
> >> +  depends on ARM64 && PM && ARCH_ZYNQMP
> >> +  select RPMSG_VIRTIO
> >> +  select MAILBOX
> >> +  select ZYNQMP_IPI_MBOX
> >> +  help
> >> +Say y here to support ZynqMP R5 remote processors via the remote
> >> +processor framework.
> >> +
> >>   endif # REMOTEPROC
> >>   
> >>   endmenu
> >> diff --git a/drivers/remoteproc/Makefile 
> >> b/drivers/remoteproc/Makefile index 0effd38..806ac3f 100644
> >> --- a/drivers/remoteproc/Makefile
> >> +++ b/drivers/remoteproc/Makefile
> >> @@ -27,5 +27,6 @@ obj-$(CONFIG_QCOM_WCNSS_PIL) += 
> >> qcom_wcnss_pil.o
> >>   qcom_wcnss_pil-y += qcom_wcnss.o
> >>   qcom_wcnss_pil-y += qcom_wcnss_iris.o
> >>   obj-$(CONFIG_ST_REMOTEPROC)  += st_remoteproc.o
> >> +obj-$(CONFIG_ZYNQMP_R5_REMOTEPROC)+= zynqmp_r5_remoteproc.o
> >>   obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o
> >>   obj-$(CONFIG_STM32_RPROC)+= stm32_rproc.o
> >> diff --git a/drivers/remoteproc/zynqmp_r5_remoteproc.c 
> >> b/drivers/remoteproc/zynqmp_r5_remoteproc.c
> >> new file mode 100644
> >> index 000..0e4f3ad
> >> --- /dev/null
> >> +++ b/drivers/remoteproc/zynqmp_r5_remoteproc.c
> >> @@ -0,0 +1,898 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/*
> >> + * Zynq R5 Remote Processor driver
> >> + *
> >> + * Copyright (C) 2019, 2020 Xilinx Inc. Ben Le

Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

2020-06-09 Thread Mathieu Poirier
On Tue, 9 Jun 2020 at 09:29, Ben Levinsky  wrote:
>
> Hi Suman, Mathieu,
>
> Thank you for your comments. Please see my replies inline.
>
> Best Regards,
> Ben
>
> -Original Message-
> From: Suman Anna 
> Sent: Monday, June 8, 2020 5:00 PM
> To: Mathieu Poirier ; Ben Levinsky 
> 
> Cc: o...@wizery.com; bjorn.anders...@linaro.org; Michal Simek 
> ; Jolly Shah ; Rajan Vaja 
> ; robh...@kernel.org; mark.rutl...@arm.com; 
> linux-remotep...@vger.kernel.org; linux-arm-kern...@lists.infradead.org; 
> devicet...@vger.kernel.org; linux-kernel@vger.kernel.org; Jiaying Liang 
> ; Michal Simek ; Ed T. Mooring 
> ; Jason Wu 
> Subject: Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc 
> driver
>
> On 6/8/20 6:49 PM, Mathieu Poirier wrote:
> > On Wed, Jun 03, 2020 at 07:49:43AM -0700, Ben Levinsky wrote:
> >> R5 is included in Xilinx Zynq UltraScale MPSoC so by adding this
> >> remotproc driver, we can boot the R5 sub-system in different
> >> configurations.
> >>
> >> Acked-by: Stefano Stabellini 
> >> Acked-by: Ben Levinsky 
> >> Reviewed-by: Radhey Shyam Pandey 
> >> Signed-off-by: Ben Levinsky 
> >> Signed-off-by: Wendy Liang 
> >> Signed-off-by: Michal Simek 
> >> Signed-off-by: Ed Mooring 
> >> Signed-off-by: Jason Wu 
> >> Tested-by: Ben Levinsky 
> >> ---
> >> v2:
> >> - remove domain struct as per review from Mathieu
> >> v3:
> >> - add xilinx-related platform mgmt fn's instead of wrapping around
> >>function pointer in xilinx eemi ops struct
> >> v4:
> >> - add default values for enums
> >> - fix formatting as per checkpatch.pl --strict. Note that 1 warning and 1 
> >> check
> >>are still raised as each is due to fixing the warning results in
> >> that particular line going over 80 characters.
> >> v5:
> >> - parse_fw change from use of rproc_of_resm_mem_entry_init to
> >> rproc_mem_entry_init and use of alloc/release
> >> - var's of type zynqmp_r5_pdata all have same local variable name
> >> - use dev_dbg instead of dev_info
> >>
> >> ---
> >>   drivers/remoteproc/Kconfig|  10 +
> >>   drivers/remoteproc/Makefile   |   1 +
> >>   drivers/remoteproc/zynqmp_r5_remoteproc.c | 898 
> >> ++
> >>   3 files changed, 909 insertions(+)
> >>   create mode 100644 drivers/remoteproc/zynqmp_r5_remoteproc.c
> >>
> >> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> >> index fbaed07..735bd7f 100644
> >> --- a/drivers/remoteproc/Kconfig
> >> +++ b/drivers/remoteproc/Kconfig
> >> @@ -240,6 +240,16 @@ config STM32_RPROC
> >>
> >>This can be either built-in or a loadable module.
> >>
> >> +config ZYNQMP_R5_REMOTEPROC
> >> +tristate "ZynqMP_R5 remoteproc support"
> >> +depends on ARM64 && PM && ARCH_ZYNQMP
> >> +select RPMSG_VIRTIO
> >> +select MAILBOX
> >> +select ZYNQMP_IPI_MBOX
> >> +help
> >> +  Say y here to support ZynqMP R5 remote processors via the remote
> >> +  processor framework.
> >> +
> >>   endif # REMOTEPROC
> >>
> >>   endmenu
> >> diff --git a/drivers/remoteproc/Makefile
> >> b/drivers/remoteproc/Makefile index 0effd38..806ac3f 100644
> >> --- a/drivers/remoteproc/Makefile
> >> +++ b/drivers/remoteproc/Makefile
> >> @@ -27,5 +27,6 @@ obj-$(CONFIG_QCOM_WCNSS_PIL)   += 
> >> qcom_wcnss_pil.o
> >>   qcom_wcnss_pil-y   += qcom_wcnss.o
> >>   qcom_wcnss_pil-y   += qcom_wcnss_iris.o
> >>   obj-$(CONFIG_ST_REMOTEPROC)+= st_remoteproc.o
> >> +obj-$(CONFIG_ZYNQMP_R5_REMOTEPROC)  += zynqmp_r5_remoteproc.o
> >>   obj-$(CONFIG_ST_SLIM_REMOTEPROC)   += st_slim_rproc.o
> >>   obj-$(CONFIG_STM32_RPROC)  += stm32_rproc.o
> >> diff --git a/drivers/remoteproc/zynqmp_r5_remoteproc.c
> >> b/drivers/remoteproc/zynqmp_r5_remoteproc.c
> >> new file mode 100644
> >> index 000..0e4f3ad
> >> --- /dev/null
> >> +++ b/drivers/remoteproc/zynqmp_r5_remoteproc.c
> >> @@ -0,0 +1,898 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/*
> >> + * Zynq R5 Remote Processor driver
> >> + *
> >> + * Copyright (C) 2019, 2020 Xilinx Inc. Ben Levinsky
> >> +
> >>

RE: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

2020-06-09 Thread Ben Levinsky
Hi Suman, Mathieu,

Thank you for your comments. Please see my replies inline.

Best Regards,
Ben

-Original Message-
From: Suman Anna  
Sent: Monday, June 8, 2020 5:00 PM
To: Mathieu Poirier ; Ben Levinsky 

Cc: o...@wizery.com; bjorn.anders...@linaro.org; Michal Simek 
; Jolly Shah ; Rajan Vaja 
; robh...@kernel.org; mark.rutl...@arm.com; 
linux-remotep...@vger.kernel.org; linux-arm-kern...@lists.infradead.org; 
devicet...@vger.kernel.org; linux-kernel@vger.kernel.org; Jiaying Liang 
; Michal Simek ; Ed T. Mooring 
; Jason Wu 
Subject: Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

On 6/8/20 6:49 PM, Mathieu Poirier wrote:
> On Wed, Jun 03, 2020 at 07:49:43AM -0700, Ben Levinsky wrote:
>> R5 is included in Xilinx Zynq UltraScale MPSoC so by adding this 
>> remotproc driver, we can boot the R5 sub-system in different 
>> configurations.
>>
>> Acked-by: Stefano Stabellini 
>> Acked-by: Ben Levinsky 
>> Reviewed-by: Radhey Shyam Pandey 
>> Signed-off-by: Ben Levinsky 
>> Signed-off-by: Wendy Liang 
>> Signed-off-by: Michal Simek 
>> Signed-off-by: Ed Mooring 
>> Signed-off-by: Jason Wu 
>> Tested-by: Ben Levinsky 
>> ---
>> v2:
>> - remove domain struct as per review from Mathieu
>> v3:
>> - add xilinx-related platform mgmt fn's instead of wrapping around
>>function pointer in xilinx eemi ops struct
>> v4:
>> - add default values for enums
>> - fix formatting as per checkpatch.pl --strict. Note that 1 warning and 1 
>> check
>>are still raised as each is due to fixing the warning results in 
>> that particular line going over 80 characters.
>> v5:
>> - parse_fw change from use of rproc_of_resm_mem_entry_init to 
>> rproc_mem_entry_init and use of alloc/release
>> - var's of type zynqmp_r5_pdata all have same local variable name
>> - use dev_dbg instead of dev_info
>>
>> ---
>>   drivers/remoteproc/Kconfig|  10 +
>>   drivers/remoteproc/Makefile   |   1 +
>>   drivers/remoteproc/zynqmp_r5_remoteproc.c | 898 
>> ++
>>   3 files changed, 909 insertions(+)
>>   create mode 100644 drivers/remoteproc/zynqmp_r5_remoteproc.c
>>
>> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig 
>> index fbaed07..735bd7f 100644
>> --- a/drivers/remoteproc/Kconfig
>> +++ b/drivers/remoteproc/Kconfig
>> @@ -240,6 +240,16 @@ config STM32_RPROC
>>   
>>This can be either built-in or a loadable module.
>>   
>> +config ZYNQMP_R5_REMOTEPROC
>> +tristate "ZynqMP_R5 remoteproc support"
>> +depends on ARM64 && PM && ARCH_ZYNQMP
>> +select RPMSG_VIRTIO
>> +select MAILBOX
>> +select ZYNQMP_IPI_MBOX
>> +help
>> +  Say y here to support ZynqMP R5 remote processors via the remote
>> +  processor framework.
>> +
>>   endif # REMOTEPROC
>>   
>>   endmenu
>> diff --git a/drivers/remoteproc/Makefile 
>> b/drivers/remoteproc/Makefile index 0effd38..806ac3f 100644
>> --- a/drivers/remoteproc/Makefile
>> +++ b/drivers/remoteproc/Makefile
>> @@ -27,5 +27,6 @@ obj-$(CONFIG_QCOM_WCNSS_PIL)   += 
>> qcom_wcnss_pil.o
>>   qcom_wcnss_pil-y   += qcom_wcnss.o
>>   qcom_wcnss_pil-y   += qcom_wcnss_iris.o
>>   obj-$(CONFIG_ST_REMOTEPROC)+= st_remoteproc.o
>> +obj-$(CONFIG_ZYNQMP_R5_REMOTEPROC)  += zynqmp_r5_remoteproc.o
>>   obj-$(CONFIG_ST_SLIM_REMOTEPROC)   += st_slim_rproc.o
>>   obj-$(CONFIG_STM32_RPROC)  += stm32_rproc.o
>> diff --git a/drivers/remoteproc/zynqmp_r5_remoteproc.c 
>> b/drivers/remoteproc/zynqmp_r5_remoteproc.c
>> new file mode 100644
>> index 000..0e4f3ad
>> --- /dev/null
>> +++ b/drivers/remoteproc/zynqmp_r5_remoteproc.c
>> @@ -0,0 +1,898 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Zynq R5 Remote Processor driver
>> + *
>> + * Copyright (C) 2019, 2020 Xilinx Inc. Ben Levinsky 
>> +
>> + * Copyright (C) 2015 - 2018 Xilinx Inc.
>> + * Copyright (C) 2015 Jason Wu 
>> + *
>> + * Based on origin OMAP and Zynq Remote Processor driver
>> + *
>> + * Copyright (C) 2012 Michal Simek 
>> + * Copyright (C) 2012 PetaLogix
>> + * Copyright (C) 2011 Texas Instruments, Inc.
>> + * Copyright (C) 2011 Google, Inc.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include  #include  
>> +#include  #include  #include 
>>

Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

2020-06-08 Thread Suman Anna

On 6/8/20 6:49 PM, Mathieu Poirier wrote:

On Wed, Jun 03, 2020 at 07:49:43AM -0700, Ben Levinsky wrote:

R5 is included in Xilinx Zynq UltraScale MPSoC so by adding this
remotproc driver, we can boot the R5 sub-system in different
configurations.

Acked-by: Stefano Stabellini 
Acked-by: Ben Levinsky 
Reviewed-by: Radhey Shyam Pandey 
Signed-off-by: Ben Levinsky 
Signed-off-by: Wendy Liang 
Signed-off-by: Michal Simek 
Signed-off-by: Ed Mooring 
Signed-off-by: Jason Wu 
Tested-by: Ben Levinsky 
---
v2:
- remove domain struct as per review from Mathieu
v3:
- add xilinx-related platform mgmt fn's instead of wrapping around
   function pointer in xilinx eemi ops struct
v4:
- add default values for enums
- fix formatting as per checkpatch.pl --strict. Note that 1 warning and 1 check
   are still raised as each is due to fixing the warning results in that
particular line going over 80 characters.
v5:
- parse_fw change from use of rproc_of_resm_mem_entry_init to 
rproc_mem_entry_init and use of alloc/release
- var's of type zynqmp_r5_pdata all have same local variable name
- use dev_dbg instead of dev_info

---
  drivers/remoteproc/Kconfig|  10 +
  drivers/remoteproc/Makefile   |   1 +
  drivers/remoteproc/zynqmp_r5_remoteproc.c | 898 ++
  3 files changed, 909 insertions(+)
  create mode 100644 drivers/remoteproc/zynqmp_r5_remoteproc.c

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index fbaed07..735bd7f 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -240,6 +240,16 @@ config STM32_RPROC
  
  	  This can be either built-in or a loadable module.
  
+config ZYNQMP_R5_REMOTEPROC

+   tristate "ZynqMP_R5 remoteproc support"
+   depends on ARM64 && PM && ARCH_ZYNQMP
+   select RPMSG_VIRTIO
+   select MAILBOX
+   select ZYNQMP_IPI_MBOX
+   help
+ Say y here to support ZynqMP R5 remote processors via the remote
+ processor framework.
+
  endif # REMOTEPROC
  
  endmenu

diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 0effd38..806ac3f 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -27,5 +27,6 @@ obj-$(CONFIG_QCOM_WCNSS_PIL)  += qcom_wcnss_pil.o
  qcom_wcnss_pil-y  += qcom_wcnss.o
  qcom_wcnss_pil-y  += qcom_wcnss_iris.o
  obj-$(CONFIG_ST_REMOTEPROC)   += st_remoteproc.o
+obj-$(CONFIG_ZYNQMP_R5_REMOTEPROC) += zynqmp_r5_remoteproc.o
  obj-$(CONFIG_ST_SLIM_REMOTEPROC)  += st_slim_rproc.o
  obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o
diff --git a/drivers/remoteproc/zynqmp_r5_remoteproc.c 
b/drivers/remoteproc/zynqmp_r5_remoteproc.c
new file mode 100644
index 000..0e4f3ad
--- /dev/null
+++ b/drivers/remoteproc/zynqmp_r5_remoteproc.c
@@ -0,0 +1,898 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Zynq R5 Remote Processor driver
+ *
+ * Copyright (C) 2019, 2020 Xilinx Inc. Ben Levinsky 
+ * Copyright (C) 2015 - 2018 Xilinx Inc.
+ * Copyright (C) 2015 Jason Wu 
+ *
+ * Based on origin OMAP and Zynq Remote Processor driver
+ *
+ * Copyright (C) 2012 Michal Simek 
+ * Copyright (C) 2012 PetaLogix
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "remoteproc_internal.h"
+
+#define MAX_RPROCS 2 /* Support up to 2 RPU */
+#define MAX_MEM_PNODES 4 /* Max power nodes for one RPU memory instance */
+
+#define DEFAULT_FIRMWARE_NAME  "rproc-rpu-fw"
+
+/* PM proc states */
+#define PM_PROC_STATE_ACTIVE 1U
+
+/* IPI buffer MAX length */
+#define IPI_BUF_LEN_MAX32U
+/* RX mailbox client buffer max length */
+#define RX_MBOX_CLIENT_BUF_MAX (IPI_BUF_LEN_MAX + \
+sizeof(struct zynqmp_ipi_message))
+
+static bool autoboot __read_mostly;
+
+/**
+ * struct zynqmp_r5_mem - zynqmp rpu memory data
+ * @pnode_id: TCM power domain ids
+ * @res: memory resource
+ * @node: list node
+ */
+struct zynqmp_r5_mem {
+   u32 pnode_id[MAX_MEM_PNODES];
+   struct resource res;
+   struct list_head node;
+};
+
+/**
+ * struct zynqmp_r5_pdata - zynqmp rpu remote processor private data
+ * @dev: device of RPU instance
+ * @rproc: rproc handle
+ * @pnode_id: RPU CPU power domain id
+ * @mems: memory resources
+ * @is_r5_mode_set: indicate if r5 operation mode is set
+ * @tx_mc: tx mailbox client
+ * @rx_mc: rx mailbox client
+ * @tx_chan: tx mailbox channel
+ * @rx_chan: rx mailbox channel
+ * @mbox_work: mbox_work for the RPU remoteproc
+ * @tx_mc_skbs: socket buffers for tx mailbox client
+ * @rx_mc_buf: rx mailbox client buffer to save the rx message
+ */
+struct zynqmp_r5_pdata {
+   struct device dev;
+   s

Re: [PATCH v5 5/5] remoteproc: Add initial zynqmp R5 remoteproc driver

2020-06-08 Thread Mathieu Poirier
On Wed, Jun 03, 2020 at 07:49:43AM -0700, Ben Levinsky wrote:
> R5 is included in Xilinx Zynq UltraScale MPSoC so by adding this
> remotproc driver, we can boot the R5 sub-system in different
> configurations.
> 
> Acked-by: Stefano Stabellini 
> Acked-by: Ben Levinsky 
> Reviewed-by: Radhey Shyam Pandey 
> Signed-off-by: Ben Levinsky 
> Signed-off-by: Wendy Liang 
> Signed-off-by: Michal Simek 
> Signed-off-by: Ed Mooring 
> Signed-off-by: Jason Wu 
> Tested-by: Ben Levinsky 
> ---
> v2:
> - remove domain struct as per review from Mathieu
> v3:
> - add xilinx-related platform mgmt fn's instead of wrapping around
>   function pointer in xilinx eemi ops struct
> v4:
> - add default values for enums
> - fix formatting as per checkpatch.pl --strict. Note that 1 warning and 1 
> check
>   are still raised as each is due to fixing the warning results in that
> particular line going over 80 characters.
> v5:
> - parse_fw change from use of rproc_of_resm_mem_entry_init to 
> rproc_mem_entry_init and use of alloc/release
> - var's of type zynqmp_r5_pdata all have same local variable name
> - use dev_dbg instead of dev_info
> 
> ---
>  drivers/remoteproc/Kconfig|  10 +
>  drivers/remoteproc/Makefile   |   1 +
>  drivers/remoteproc/zynqmp_r5_remoteproc.c | 898 
> ++
>  3 files changed, 909 insertions(+)
>  create mode 100644 drivers/remoteproc/zynqmp_r5_remoteproc.c
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index fbaed07..735bd7f 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -240,6 +240,16 @@ config STM32_RPROC
>  
> This can be either built-in or a loadable module.
>  
> +config ZYNQMP_R5_REMOTEPROC
> + tristate "ZynqMP_R5 remoteproc support"
> + depends on ARM64 && PM && ARCH_ZYNQMP
> + select RPMSG_VIRTIO
> + select MAILBOX
> + select ZYNQMP_IPI_MBOX
> + help
> +   Say y here to support ZynqMP R5 remote processors via the remote
> +   processor framework.
> +
>  endif # REMOTEPROC
>  
>  endmenu
> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> index 0effd38..806ac3f 100644
> --- a/drivers/remoteproc/Makefile
> +++ b/drivers/remoteproc/Makefile
> @@ -27,5 +27,6 @@ obj-$(CONFIG_QCOM_WCNSS_PIL)+= 
> qcom_wcnss_pil.o
>  qcom_wcnss_pil-y += qcom_wcnss.o
>  qcom_wcnss_pil-y += qcom_wcnss_iris.o
>  obj-$(CONFIG_ST_REMOTEPROC)  += st_remoteproc.o
> +obj-$(CONFIG_ZYNQMP_R5_REMOTEPROC)   += zynqmp_r5_remoteproc.o
>  obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o
>  obj-$(CONFIG_STM32_RPROC)+= stm32_rproc.o
> diff --git a/drivers/remoteproc/zynqmp_r5_remoteproc.c 
> b/drivers/remoteproc/zynqmp_r5_remoteproc.c
> new file mode 100644
> index 000..0e4f3ad
> --- /dev/null
> +++ b/drivers/remoteproc/zynqmp_r5_remoteproc.c
> @@ -0,0 +1,898 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Zynq R5 Remote Processor driver
> + *
> + * Copyright (C) 2019, 2020 Xilinx Inc. Ben Levinsky 
> 
> + * Copyright (C) 2015 - 2018 Xilinx Inc.
> + * Copyright (C) 2015 Jason Wu 
> + *
> + * Based on origin OMAP and Zynq Remote Processor driver
> + *
> + * Copyright (C) 2012 Michal Simek 
> + * Copyright (C) 2012 PetaLogix
> + * Copyright (C) 2011 Texas Instruments, Inc.
> + * Copyright (C) 2011 Google, Inc.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "remoteproc_internal.h"
> +
> +#define MAX_RPROCS   2 /* Support up to 2 RPU */
> +#define MAX_MEM_PNODES   4 /* Max power nodes for one RPU memory 
> instance */
> +
> +#define DEFAULT_FIRMWARE_NAME"rproc-rpu-fw"
> +
> +/* PM proc states */
> +#define PM_PROC_STATE_ACTIVE 1U
> +
> +/* IPI buffer MAX length */
> +#define IPI_BUF_LEN_MAX  32U
> +/* RX mailbox client buffer max length */
> +#define RX_MBOX_CLIENT_BUF_MAX   (IPI_BUF_LEN_MAX + \
> +  sizeof(struct zynqmp_ipi_message))
> +
> +static bool autoboot __read_mostly;
> +
> +/**
> + * struct zynqmp_r5_mem - zynqmp rpu memory data
> + * @pnode_id: TCM power domain ids
> + * @res: memory resource
> + * @node: list node
> + */
> +struct zynqmp_r5_mem {
> + u32 pnode_id[MAX_MEM_PNODES];
> + struct resource res;
> + struct list_head node;
> +};
> +
> +/**
> + * struct zynqmp_r5_pdata - zynqmp rpu remote processor private data
> + * @dev: device of RPU instance
> + * @rproc: rproc handle
> + * @pnode_id: RPU CPU power domain id
> + * @mems: memory resources
> + * @is_r5_mode_set: indicate if r5 operation mode is set
> + * @tx_mc: tx mailbox client
> + * @rx_mc: rx mailbox client
> + * @tx_chan: tx mailbox channel
> + * @rx_