[U-Boot] [PATCH] fpga: zynqpl: Fixed bug in alignment routine

Michal Simek monstr at monstr.eu
Tue Mar 18 13:17:05 CET 2014


On 03/18/2014 11:20 AM, Eli Billauer wrote:
> On 18/03/14 08:11, S Durga Prasad Paladugu wrote:
>> This looks like not correct because if you look at the code above this, it always ensuring that the new aligned buffer start is in front of the actual buffer
> 
> Maybe it should, but it doesn't. In the boot log it says:
> 
> zynq_load: Align buffer at 10006f to 100080(swap 1)
> 

I have checked this and there is bug in code.

I have tested it by:
+       int i;
+
+       for (i = 0; i < 100; i++) {
+               printf("%x: align %x\n", i, ALIGN((u32)i, ARCH_DMA_MINALIGN));
+       }


Does this work for you? If yes, I will send this as regular patch.

diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c
index 3572bc9..49eef0f 100644
--- a/drivers/fpga/zynqpl.c
+++ b/drivers/fpga/zynqpl.c
@@ -289,10 +289,11 @@ static int zynq_dma_xfer_init(u32 partialbit)
 static u32 *zynq_align_dma_buffer(u32 *buf, u32 len, u32 swap)
 {
        u32 *new_buf;
-       u32 i;
+       u32 i, align;

-       if ((u32)buf != ALIGN((u32)buf, ARCH_DMA_MINALIGN)) {
-               new_buf = (u32 *)ALIGN((u32)buf, ARCH_DMA_MINALIGN);
+       align = ALIGN((u32)(buf - ARCH_DMA_MINALIGN + 1), ARCH_DMA_MINALIGN);
+       if ((u32)buf != align) {
+               new_buf = (u32 *)align;

                /*
                 * This might be dangerous but permits to flash if

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140318/d420533a/attachment.pgp>


More information about the U-Boot mailing list