All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerlando Falauto <gerlando.falauto@keymile.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] cmd_sf: Fix problem with "sf update" and unaligned length
Date: Mon, 12 Jan 2015 08:51:35 +0100	[thread overview]
Message-ID: <54B37D07.5060400@keymile.com> (raw)
In-Reply-To: <1420810762-10712-1-git-send-email-sr@denx.de>

Hi Stefan,

thanks for the patch.
Please compare it with my v1 revision of the patch:
http://patchwork.ozlabs.org/patch/150468/
Back then, Simon suggested to use two separate SPI flash operations to 
avoid the memcpy() operation. I guess noone would have guessed about 
QSPI devices at the time.

Anyway, your patch looks even better than my v1 then, so:

Acked-by: Gerlando Falauto <gerlando.falauto@keymile.com>

Thank you,
Gerlando

On 01/09/2015 02:39 PM, Stefan Roese wrote:
> On SoCFPGA, using "sf update" with an non-4byte aligned length leads
> to a hangup (and reboot via watchdog). This is because of the unaligned
> access in the cadence QSPI driver which is hard to prevent since the
> data is written into a 4-byte wide FIFO. This patch fixes this problem
> by changing the behavior of the last sector write (not sector aligned).
>
> The new code is even simpler and copies the source data into the temp
> buffer and now uses the temp buffer to write the complete sector. So
> only one SPI sector write is used now instead of 2 in the old version.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Gerlando Falauto <gerlando.falauto@keymile.com>
> Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
> Cc: Holger Brunck <holger.brunck@keymile.com>
> Cc: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
> ---
>   common/cmd_sf.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index 5c788e9..dd82290 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -163,6 +163,8 @@ static int do_spi_flash_probe(int argc, char * const argv[])
>   static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
>   		size_t len, const char *buf, char *cmp_buf, size_t *skipped)
>   {
> +	char *ptr = (char *)buf;
> +
>   	debug("offset=%#x, sector_size=%#x, len=%#zx\n",
>   	      offset, flash->sector_size, len);
>   	/* Read the entire sector so to allow for rewriting */
> @@ -178,16 +180,14 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
>   	/* Erase the entire sector */
>   	if (spi_flash_erase(flash, offset, flash->sector_size))
>   		return "erase";
> -	/* Write the initial part of the block from the source */
> -	if (spi_flash_write(flash, offset, len, buf))
> -		return "write";
> -	/* If it's a partial sector, rewrite the existing part */
> +	/* If it's a partial sector, copy the data into the temp-buffer */
>   	if (len != flash->sector_size) {
> -		/* Rewrite the original data to the end of the sector */
> -		if (spi_flash_write(flash, offset + len,
> -				    flash->sector_size - len, &cmp_buf[len]))
> -			return "write";
> +		memcpy(cmp_buf, buf, len);
> +		ptr = cmp_buf;
>   	}
> +	/* Write one complete sector */
> +	if (spi_flash_write(flash, offset, flash->sector_size, ptr))
> +		return "write";
>
>   	return NULL;
>   }
>

  parent reply	other threads:[~2015-01-12  7:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 13:39 [U-Boot] [PATCH] cmd_sf: Fix problem with "sf update" and unaligned length Stefan Roese
2015-01-12  7:17 ` Wolfgang Denk
2015-01-12  7:27   ` Stefan Roese
2015-01-12  8:07     ` Gerlando Falauto
2015-01-12 21:12       ` Wolfgang Denk
2015-01-12 21:10     ` Wolfgang Denk
2015-01-13  6:05       ` Stefan Roese
2015-04-22 11:11         ` Jagan Teki
2015-04-22 11:15           ` Stefan Roese
2015-04-22 11:26             ` Jagan Teki
2015-01-12  7:51 ` Gerlando Falauto [this message]
2015-01-12  7:56   ` Stefan Roese
2015-01-12  8:12     ` Gerlando Falauto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54B37D07.5060400@keymile.com \
    --to=gerlando.falauto@keymile.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.