mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] firmware: zynqmp: fix loading for PMU FWv1.1
@ 2023-06-23 11:42 Steffen Trumtrar
  2023-06-23 14:14 ` Michael Tretter
  2023-06-26  9:59 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Steffen Trumtrar @ 2023-06-23 11:42 UTC (permalink / raw)
  To: barebox; +Cc: mtr, str

FPGA programming on ZynqMP is done by the PMU. The SoC just hands a
file to the PMU and lets it load this file to the FPGA.

The bitstream that is sent to the FPGA consists of two headers, the
optional struct bs_header and a binary-header. See comment in driver:

 (...)
 * Bitstream can be provided with an optinal header (`struct bs_header`).
 * The true bitstream starts with the binary-header composed of 21 words:
 (...)

The PMUFW v1.0 had a feature for taking the bitstream only, skipping
the header, or including the binary-header and only skipping the
optional header. This is controlled via the BIT_ONLY_BIN flag. When
the flag is set, the complete header should be skipped.

The current implementation sets the flag *and* sends the binary-header
to the PMU:

	header_length = get_header_length(mgr->buf, mgr->size);
	(...)
	body = (u32 *)&mgr->buf[header_length];

get_header_length searches for the first DUMMY_WORD, i.e. the beginning
of the binary header. Then we set body to this offset, skipping the
optional header.

The flag is always set to ZYNQMP_FPGA_BIT_ONLY_BIN, which is then obviously
incorrect. It seems like the PMUFW v1.0 was capable of still handling this
although the flag was set.

The newer PMUFW v1.1 doesn't support this and expects the flag to be
unset and getting handed binary-header+bitstream. This is the same as
the linux kernel handles bitstream loading on the ZynqMP. There the flag
is also always unset.

As this wasn't correct in the first place (although it most likely still
worked depending on PMUFW and its configuration), we won't break anything
when we just set the flag to zero as the PMUFW v1.1 expects it.

TLDR: set fpga_load flags to zero to fix firmwareloading with newer
PMUFW versions.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/firmware/zynqmp-fpga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/zynqmp-fpga.c b/drivers/firmware/zynqmp-fpga.c
index 9c160e9098..1a9a5c1b2c 100644
--- a/drivers/firmware/zynqmp-fpga.c
+++ b/drivers/firmware/zynqmp-fpga.c
@@ -206,7 +206,7 @@ static int fpgamgr_program_finish(struct firmware_handler *fh)
 	enum xilinx_byte_order byte_order;
 	dma_addr_t addr;
 	int status = 0;
-	u8 flags = ZYNQMP_FPGA_BIT_ONLY_BIN;
+	u8 flags = 0;
 
 	if (!mgr->buf) {
 		status = -ENOBUFS;
-- 
2.41.0




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: zynqmp: fix loading for PMU FWv1.1
  2023-06-23 11:42 [PATCH] firmware: zynqmp: fix loading for PMU FWv1.1 Steffen Trumtrar
@ 2023-06-23 14:14 ` Michael Tretter
  2023-06-26  9:59 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Tretter @ 2023-06-23 14:14 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox, str

On Fri, 23 Jun 2023 13:42:56 +0200, Steffen Trumtrar wrote:
> FPGA programming on ZynqMP is done by the PMU. The SoC just hands a
> file to the PMU and lets it load this file to the FPGA.
> 
> The bitstream that is sent to the FPGA consists of two headers, the
> optional struct bs_header and a binary-header. See comment in driver:
> 
>  (...)
>  * Bitstream can be provided with an optinal header (`struct bs_header`).
>  * The true bitstream starts with the binary-header composed of 21 words:
>  (...)
> 
> The PMUFW v1.0 had a feature for taking the bitstream only, skipping
> the header, or including the binary-header and only skipping the
> optional header. This is controlled via the BIT_ONLY_BIN flag. When
> the flag is set, the complete header should be skipped.
> 
> The current implementation sets the flag *and* sends the binary-header
> to the PMU:
> 
> 	header_length = get_header_length(mgr->buf, mgr->size);
> 	(...)
> 	body = (u32 *)&mgr->buf[header_length];
> 
> get_header_length searches for the first DUMMY_WORD, i.e. the beginning
> of the binary header. Then we set body to this offset, skipping the
> optional header.
> 
> The flag is always set to ZYNQMP_FPGA_BIT_ONLY_BIN, which is then obviously
> incorrect. It seems like the PMUFW v1.0 was capable of still handling this
> although the flag was set.
> 
> The newer PMUFW v1.1 doesn't support this and expects the flag to be
> unset and getting handed binary-header+bitstream. This is the same as
> the linux kernel handles bitstream loading on the ZynqMP. There the flag
> is also always unset.
> 
> As this wasn't correct in the first place (although it most likely still
> worked depending on PMUFW and its configuration), we won't break anything
> when we just set the flag to zero as the PMUFW v1.1 expects it.
> 
> TLDR: set fpga_load flags to zero to fix firmwareloading with newer
> PMUFW versions.
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>

Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>

> ---
>  drivers/firmware/zynqmp-fpga.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/zynqmp-fpga.c b/drivers/firmware/zynqmp-fpga.c
> index 9c160e9098..1a9a5c1b2c 100644
> --- a/drivers/firmware/zynqmp-fpga.c
> +++ b/drivers/firmware/zynqmp-fpga.c
> @@ -206,7 +206,7 @@ static int fpgamgr_program_finish(struct firmware_handler *fh)
>  	enum xilinx_byte_order byte_order;
>  	dma_addr_t addr;
>  	int status = 0;
> -	u8 flags = ZYNQMP_FPGA_BIT_ONLY_BIN;
> +	u8 flags = 0;
>  
>  	if (!mgr->buf) {
>  		status = -ENOBUFS;
> -- 
> 2.41.0
> 
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: zynqmp: fix loading for PMU FWv1.1
  2023-06-23 11:42 [PATCH] firmware: zynqmp: fix loading for PMU FWv1.1 Steffen Trumtrar
  2023-06-23 14:14 ` Michael Tretter
@ 2023-06-26  9:59 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-06-26  9:59 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox, mtr, str

On Fri, Jun 23, 2023 at 01:42:56PM +0200, Steffen Trumtrar wrote:
> FPGA programming on ZynqMP is done by the PMU. The SoC just hands a
> file to the PMU and lets it load this file to the FPGA.
> 
> The bitstream that is sent to the FPGA consists of two headers, the
> optional struct bs_header and a binary-header. See comment in driver:
> 
>  (...)
>  * Bitstream can be provided with an optinal header (`struct bs_header`).
>  * The true bitstream starts with the binary-header composed of 21 words:
>  (...)
> 
> The PMUFW v1.0 had a feature for taking the bitstream only, skipping
> the header, or including the binary-header and only skipping the
> optional header. This is controlled via the BIT_ONLY_BIN flag. When
> the flag is set, the complete header should be skipped.
> 
> The current implementation sets the flag *and* sends the binary-header
> to the PMU:
> 
> 	header_length = get_header_length(mgr->buf, mgr->size);
> 	(...)
> 	body = (u32 *)&mgr->buf[header_length];
> 
> get_header_length searches for the first DUMMY_WORD, i.e. the beginning
> of the binary header. Then we set body to this offset, skipping the
> optional header.
> 
> The flag is always set to ZYNQMP_FPGA_BIT_ONLY_BIN, which is then obviously
> incorrect. It seems like the PMUFW v1.0 was capable of still handling this
> although the flag was set.
> 
> The newer PMUFW v1.1 doesn't support this and expects the flag to be
> unset and getting handed binary-header+bitstream. This is the same as
> the linux kernel handles bitstream loading on the ZynqMP. There the flag
> is also always unset.
> 
> As this wasn't correct in the first place (although it most likely still
> worked depending on PMUFW and its configuration), we won't break anything
> when we just set the flag to zero as the PMUFW v1.1 expects it.
> 
> TLDR: set fpga_load flags to zero to fix firmwareloading with newer
> PMUFW versions.
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  drivers/firmware/zynqmp-fpga.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/firmware/zynqmp-fpga.c b/drivers/firmware/zynqmp-fpga.c
> index 9c160e9098..1a9a5c1b2c 100644
> --- a/drivers/firmware/zynqmp-fpga.c
> +++ b/drivers/firmware/zynqmp-fpga.c
> @@ -206,7 +206,7 @@ static int fpgamgr_program_finish(struct firmware_handler *fh)
>  	enum xilinx_byte_order byte_order;
>  	dma_addr_t addr;
>  	int status = 0;
> -	u8 flags = ZYNQMP_FPGA_BIT_ONLY_BIN;
> +	u8 flags = 0;
>  
>  	if (!mgr->buf) {
>  		status = -ENOBUFS;
> -- 
> 2.41.0
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-26 10:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23 11:42 [PATCH] firmware: zynqmp: fix loading for PMU FWv1.1 Steffen Trumtrar
2023-06-23 14:14 ` Michael Tretter
2023-06-26  9:59 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox