summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Tretter <m.tretter@pengutronix.de>2022-02-02 11:10:54 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-02-03 11:16:02 +0100
commitbfa76583c12407d9ef8cf59e02b95297ec19f845 (patch)
tree69f7ba78a687fb82fb3576081a991d57fd76a725 /drivers
parent2f1df20b3798151889b4cce1513d8f691a0e72ca (diff)
downloadbarebox-bfa76583c12407d9ef8cf59e02b95297ec19f845.tar.gz
barebox-bfa76583c12407d9ef8cf59e02b95297ec19f845.tar.xz
firmware: zynqmp-fpga: fix use of uninitialized addr
The bitstream loading API of the firmware is a bit clunky, as the driver needs to either pass the size of the bitstream or a pointer to the size of the bitstream. Commit 2f29ee311f1d ("firmware: zynqmp-fpga: do not use DMA coherent memory for bitstream") broke the loading by address, as the pointer to the bitstream size was set using the uninitialized DMA address. Fix it by determining the argument that is passed to the firmware after the bitstream has been mapped and always write the size of the bitstream at the end of the passed buffer. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Link: https://lore.barebox.org/20220202101054.3924339-1-m.tretter@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firmware/zynqmp-fpga.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/firmware/zynqmp-fpga.c b/drivers/firmware/zynqmp-fpga.c
index a76600d4c9..63d7398fd4 100644
--- a/drivers/firmware/zynqmp-fpga.c
+++ b/drivers/firmware/zynqmp-fpga.c
@@ -252,13 +252,7 @@ static int fpgamgr_program_finish(struct firmware_handler *fh)
body_length / sizeof(u32));
else
memcpy((u32 *)buf_aligned, body, body_length);
-
- if (mgr->features & ZYNQMP_PM_FEATURE_SIZE_NOT_NEEDED) {
- buf_size = body_length;
- } else {
- buf_aligned[body_length / sizeof(*buf_aligned)] = body_length;
- buf_size = addr + body_length;
- }
+ buf_aligned[body_length / sizeof(*buf_aligned)] = body_length;
addr = dma_map_single(&mgr->dev, buf_aligned,
body_length + sizeof(buf_size), DMA_TO_DEVICE);
@@ -267,6 +261,11 @@ static int fpgamgr_program_finish(struct firmware_handler *fh)
goto err_free_dma;
}
+ if (mgr->features & ZYNQMP_PM_FEATURE_SIZE_NOT_NEEDED)
+ buf_size = body_length;
+ else
+ buf_size = addr + body_length;
+
status = mgr->eemi_ops->fpga_load((u64)addr, buf_size, flags);
dma_unmap_single(&mgr->dev, addr, body_length + sizeof(buf_size),
DMA_TO_DEVICE);