All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Håvard Skinnemoen" <hskinnemoen@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Fixed cfi flash read uchar bug.
Date: Sat, 13 Jan 2007 18:53:04 +0100	[thread overview]
Message-ID: <1defaf580701130953s55dd6597uc59eda90506c7c21@mail.gmail.com> (raw)
In-Reply-To: <45A8863C.1040303@orkun.us>

On 1/13/07, Tolunay Orkun <listmember@orkun.us> wrote:
> Perhaps, more important issue would be if these areas were cached. In
> that case, every time we change the flash from read mode to special
> query modes, we should probably invalidate the cache. In PowerPC 405
> platform our flash is uncached so this is not necessary. I do not know
> if any platform caches its flash areas.

AVR32 does cache its flash area by default, but it can be worked
around by specifying an uncached virtual mapping (i.e. the physical
address ORed with 0xa0000000, similar to MIPS and SH) as the flash
address instead of the physical address.

However, doing cached flash accesses would probably improve the
performance of things like fsload, so how about using something like
the following interface when uncached access is needed?

void *flash_map(unsigned long paddr, size_t len);
void flash_unmap(void *vaddr, size_t len);

On platforms where the flash is always uncached, flash_map would
simply return paddr cast as a void *, and flash_unmap would do
nothing. Other platforms may invalidate the range and return a virtual
address which will bypass the cache (or simply disable the dcache and
return the physical address.)

> > Actually I might have been wrong in my assessment here, when I stated
> > that memcpy() performs a character-wise copy, too.  The  simple  code
> > from  lib_generic/string.c  is  used  only  if  __HAVE_ARCH_MEMCPY is
> > undefined,   and   especially   on   PPC   we   define    this    (in
> > include/asm-ppc/string.h).  So  we  might  use  an optimized versions
> > where it *does* make a difference.
>
> Memcopy might be OK for flash tables but I am not sure if we use the
> same function to access status registers. I would rather access flash
> using bus wide accesses instead of byte by byte. Maybe it is safe but I
> do not know how it behaves in various platforms and bus interface units
> of various processors. I would take the safe route.

I agree. Please don't make any assumptions about how memcpy() accesses
memory -- it might do all kinds of crazy stuff in the name of
optimization, including prefetching. And it may introduce _really_
subtle bugs where adding a field to a struct may cause things to break
because it causes its size to cross some implementation threshold (for
example on avr32 we might switch to 32-byte load/store-multiple
instructions if the size is >= 32 bytes and the start address is
properly aligned. Also, I believe gcc uses some threshold to determine
whether to emit __builtin_memcpy in-line or emit a call to the
out-of-line memcpy implementation, which may cause entirely different
things to happen from the flash chip's point of view.)

Best regards,
Haavard

  reply	other threads:[~2007-01-13 17:53 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-22  7:27 [U-Boot-Users] [PATCH] Fixed cfi flash read uchar bug wei.zhang at freescale.com
2006-12-22 10:00 ` Wolfgang Denk
2006-12-22 11:02   ` Zhang Wei
2006-12-22 14:11     ` Wolfgang Denk
2006-12-22 16:34       ` [U-Boot-Users] 答复: " Zhang Wei-r63237
2006-12-22 17:17         ` Wolfgang Denk
2006-12-25  7:03           ` Zhang Wei
2006-12-25 23:24             ` Wolfgang Denk
2006-12-26  6:04               ` Zhang Wei
2007-01-04  2:07                 ` Zhang Wei-r63237
2007-01-04  8:17                   ` Wolfgang Denk
2007-01-04  8:36               ` Zhang Wei-r63237
2007-01-04  9:23                 ` Wolfgang Denk
2007-01-04 11:19                   ` Stefan Roese
2007-01-05 13:27                   ` Stefan Roese
2007-01-07 10:12                     ` Tolunay Orkun
2007-01-07 10:40                       ` Wolfgang Denk
2007-01-13  7:11                         ` Tolunay Orkun
2007-01-13 17:53                           ` Håvard Skinnemoen [this message]
2007-01-16  6:52                             ` Stefan Roese
2007-01-25  4:38                           ` Zhang Wei-r63237
2007-01-25 16:10                             ` Timur Tabi
2007-01-25 20:33                               ` Wolfgang Denk
2007-01-26  2:13                                 ` Zhang Wei-r63237
2007-01-29 11:29                                   ` Tolunay Orkun
2007-01-30  3:36                                     ` Wang Haiying-r54964
2007-01-31  9:01                                       ` Tolunay Orkun
2007-01-31 19:25                                         ` Haiying Wang
2007-02-01  5:26                                           ` Tolunay Orkun
2007-02-01 22:06                                             ` Haiying Wang
2007-02-01 22:52                                               ` Chris Fester
2007-02-09 17:47                                             ` [U-Boot-Users] [PATCH0/2] Re-do the patch for adding DO_SYNC in flash_write_cmd Haiying Wang
2007-02-09 19:42                                               ` Wolfgang Denk
2007-02-09 19:48                                                 ` Haiying Wang
2007-02-10  1:04                                                   ` Wolfgang Denk
2007-02-10  7:23                                                     ` Tolunay Orkun
2007-02-10  7:40                                                       ` Stefan Roese
2007-02-10  7:57                                                         ` Tolunay Orkun
2007-02-10  8:07                                                           ` Stefan Roese
2007-02-10 21:55                                                             ` Wolfgang Denk
2007-02-10 21:54                                                         ` Wolfgang Denk
2007-02-11  2:34                                                         ` Timur Tabi
2007-02-11 10:23                                                           ` Wolfgang Denk
2007-02-09 19:59                                                 ` Haavard Skinnemoen
2007-02-10  1:02                                                   ` Wolfgang Denk
2007-02-09 17:47                                             ` [U-Boot-Users] [PATCH 1/2] Add DO_SYNC at the end of flash_write_cmd Haiying Wang
2007-02-09 19:45                                               ` Wolfgang Denk
2007-02-09 17:47                                             ` [U-Boot-Users] [PATCH 2/2] Define DO_SYNC in each CPU's header file Haiying Wang
2007-02-09 19:46                                               ` Wolfgang Denk
2007-02-10  7:17                                                 ` Tolunay Orkun
2007-01-08  2:41                     ` [U-Boot-Users] [PATCH] Fixed cfi flash read uchar bug Zhang Wei-r63237
2006-12-22 17:07       ` Chris Fester
2006-12-22 17:24         ` Wolfgang Denk
2006-12-22 17:42           ` Chris Fester
2006-12-22 21:33             ` Wolfgang Denk

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=1defaf580701130953s55dd6597uc59eda90506c7c21@mail.gmail.com \
    --to=hskinnemoen@gmail.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.