From patchwork Wed Jan 22 08:19:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 313163 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id CDE542C00A7 for ; Wed, 22 Jan 2014 19:20:07 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 78CD04B50F; Wed, 22 Jan 2014 09:20:06 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 39M-a3hu-f9r; Wed, 22 Jan 2014 09:20:06 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 323D04B4D3; Wed, 22 Jan 2014 09:19:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5CA1C4B4D3 for ; Wed, 22 Jan 2014 09:19:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A3onk1e+7YQI for ; Wed, 22 Jan 2014 09:19:40 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by theia.denx.de (Postfix) with ESMTPS id 4BA954B4D2 for ; Wed, 22 Jan 2014 09:19:32 +0100 (CET) Received: by mail-ee0-f42.google.com with SMTP id e49so4672373eek.1 for ; Wed, 22 Jan 2014 00:19:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :content-type; bh=XJ3w8Mjg/3Sqdf/vpDJYtXJ9u3CbSfdw+9+K0+zx9m8=; b=lcMCy6Sah+btpf6F0URTemIvp8kde0fmXXDTXa8AWnglhFCWYVNLHmAIZoVcbbsbRw gBYDfkxyiSSW3IBA9PCt042/Bm271tHCW5PxH0ZY0CUHhffdrro/nrp4xI2xPnbcirDE pTTXFR8M4vpylTbG7GQ6KzcjNf0gVwBy6zF757zmRY+sQDvbaeoaHpSoVj5RB2Nz7eZt qRXzJijMLlUrw96NRx29w8fxtHIC7UnNsHMXobgD+ph+HJiFBOKZScKLNrFdPh24XSh5 Vh7mocOx59xxNOa1UE5SfX1vHKX0yvQZsffeT27YV1E9zdDjnp1DLduF8YvG6QbOJoBJ 53Hg== X-Gm-Message-State: ALoCoQny3nws4waVTsPc4OrLotS+/gq4VVwBj5ipi2ruCMoEqRTyzBQ0NaaqZW0Li+T7KeX1tahq X-Received: by 10.14.69.200 with SMTP id n48mr192903eed.54.1390378772107; Wed, 22 Jan 2014 00:19:32 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id z42sm16407606eel.3.2014.01.22.00.19.30 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 22 Jan 2014 00:19:31 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de Date: Wed, 22 Jan 2014 09:19:29 +0100 Message-Id: X-Mailer: git-send-email 1.8.2.3 Cc: Novasys Ingenierie Subject: [U-Boot] [PATCH] fpga: zynq: Correct fpga load when buf is not aligned X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Novasys Ingenierie When ARCH_DMA_MINALIGN is greater than header size of the bit file, and buf is not aligned, new_buf address became greater then buf_start address and the load_word loop corrupts bit file data. A work around is to decrease new_buf of ARCH_DMA_MINALIGN, it might corrupt data before buf but permits to load correctly. Signed-off-by: Stany MARCEL Signed-off-by: Michal Simek --- drivers/fpga/zynqpl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 1.8.2.3 diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c index 1effbad..15900c9 100644 --- a/drivers/fpga/zynqpl.c +++ b/drivers/fpga/zynqpl.c @@ -187,6 +187,16 @@ int zynq_load(Xilinx_desc *desc, const void *buf, size_t bsize) if ((u32)buf != ALIGN((u32)buf, ARCH_DMA_MINALIGN)) { u32 *new_buf = (u32 *)ALIGN((u32)buf, ARCH_DMA_MINALIGN); + /* + * This might be dangerous but permits to flash if + * ARCH_DMA_MINALIGN is greater than header size + */ + if (new_buf > buf_start) { + debug("%s: Aligned buffer is after buffer start\n", + __func__); + new_buf -= ARCH_DMA_MINALIGN; + } + printf("%s: Align buffer at %x to %x(swap %d)\n", __func__, (u32)buf_start, (u32)new_buf, swap);