public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] Cache alignment warnings on Tegra (ARM)
Date: Tue, 18 Sep 2012 16:54:19 +0200	[thread overview]
Message-ID: <20120918145419.GA28525@avionic-0098.mockup.avionic-design.de> (raw)
In-Reply-To: <CAPnjgZ1Fn8HfP9+gwZRR-4S5vcpWQCo1LiYGBj-eV602BJA-Kw@mail.gmail.com>

On Mon, Sep 17, 2012 at 02:39:01PM -0700, Simon Glass wrote:
> Hi Thierry,
> 
> On Sat, Sep 15, 2012 at 11:49 PM, Thierry Reding
> <thierry.reding@avionic-design.de> wrote:
> > On Sat, Sep 15, 2012 at 07:45:30PM -0700, Simon Glass wrote:
> >> Hi,
> >>
> >> On Sat, Sep 15, 2012 at 1:41 PM, Thierry Reding
> >> <thierry.reding@avionic-design.de> wrote:
> >> > On Sat, Sep 15, 2012 at 10:11:54PM +0200, Marek Vasut wrote:
> >> >> Dear Thierry Reding,
> >> >>
> >> >> > On Fri, Sep 14, 2012 at 08:53:32AM -0700, Simon Glass wrote:
> >> >> > > Hi,
> >> >> > >
> >> >> > > On Wed, Sep 12, 2012 at 4:42 PM, Marek Vasut <marex@denx.de> wrote:
> >> >> > > > Dear Stephen Warren,
> >> >> > > >
> >> >> > > >> On 09/12/2012 04:38 PM, Marek Vasut wrote:
> >> >> > > >> > Dear Stephen Warren,
> >> >> > > >> >
> >> >> > > >> >> On 09/12/2012 10:19 AM, Tom Warren wrote:
> >> >> > > >> >>> Folks,
> >> >> > > >> >>>
> >> >> > > >> >>> Stephen Warren has posted an internal bug regarding the cache
> >> >> > > >> >>> alignment 'warnings' seen on Tegra20 boards when accessing MMC.
> >> >> > > >> >>> Here's the gist:
> >> >> > > >> >>>
> >> >> > > >> >>> Executing "mmc dev 0" still yields cache warnings:
> >> >> > > >> >>>
> >> >> > > >> >>> Tegra20 (Harmony) # mmc dev 0
> >> >> > > >> >>> ERROR: v7_dcache_inval_range- stop address is not aligned-
> >> >> > > >> >>> 0x3fb69908 mmc0 is current device
> >> >> > > >> >>
> >> >> > > >> >> ...
> >> >> > > >> >>
> >> >> > > >> >>> There have been patches in the past (IIRC) that have tried to
> >> >> > > >> >>> ensure all callers (FS, MMC driver, USB driver, etc.) force their
> >> >> > > >> >>> buffers to the appropriate alignment, but I don't know that we
> >> >> > > >> >>> can ever correct every instance, now or in the future.
> >> >> > > >> >>>
> >> >> > > >> >>> Can we start a discussion about what we can do about this warning?
> >> >> > > >> >>> Adding an appropriate #ifdef
> >> >> > > >> >>> (CONFIG_SYS_NO_CACHE_ALIGNMENT_WARNINGS, etc.) where Stephen put
> >> >> > > >> >>> his #if 0's would be one approach, or changing the printf() to a
> >> >> > > >> >>> debug(), perhaps. As far as I can tell, these alignment 'errors'
> >> >> > > >> >>> don't seem to produce bad data in the transfer.
> >> >> > > >> >>
> >> >> > > >> >> I don't think simply turning off the warning is the correct
> >> >> > > >> >> approach; I believe they represent real problems that can in fact
> >> >> > > >> >> cause data corruption. I don't believe we have any choice other
> >> >> > > >> >> than to fully solve the root-cause.
> >> >> > >
> >> >> > > Yes I agree, and I think it is pretty close - certainly much better
> >> >> > > than it used to be. The good thing about them being annoying is that
> >> >> > > they will likely get fixed :-)
> >> >> >
> >> >> > I think I traced this to the copying of CSD a while back. The problem is
> >> >> > that the transferred buffer is 8 bytes, so there's no way to make it
> >> >> > aligned properly. Unfortunately the entailing discussion did not yield a
> >> >> > solution at the time.
> >> >>
> >> >> And how exactly does the MMC bounce buffer not help here?
> >> >
> >> > The problem solved by the bounce buffer is that it is properly cache-
> >> > line aligned. However the issue here is not that the buffer is not
> >> > properly aligned but rather that the transfer is too small.
> >> >
> >> > When the MMC core transfers the SCR, it requests 8 bytes. The buffer
> >> > used to store these 8 bytes is properly allocated. However, those 8
> >> > bytes eventually end up as the size of the range that is to be
> >> > invalidated. This is the reason for the warning. Address x of the buffer
> >> > is cache-line aligned, but x + 8 is never properly aligned and therefore
> >> > the code complains.
> >>
> >> Would it be too dreadful to define a minimum MMC transfer size, and
> >> set that to the cache line size?
> >
> > I did try setting the data size to the cache line size back then, but
> > that resulted in an error. After that I gave up. I think what we really
> > need to do is separate the invalidation size from the transfer size in
> > order to properly handle these situations. Or alternatively pass an
> > additional buffer size so the code knows how much needs to be
> > invalidated. AFAICT this is the only location where this actually
> > happens. All other transfers are typically block sized so they'll be a
> > multiple of the cache line anyway.
> 
> I suppose the requirement is that the buffer size is large enough, and
> is aligned. Even if fewer bytes are transferred than the size of the
> buffer, that still solves the problem. As you say, if we had a way of
> saying 'here is a 64-byte buffer but only 16 bytes need to be
> transferred' then we would be good. If this is really just an MMC
> problem then perhaps the fix can be localised there.

At least on Tegra that is the only warning that I've seen. I guess a new
member could be added to the struct mmc_data. Alternatively maybe an
extra flag would be better, something like MMC_DATA_CACHE_ALIGNED. It
could be passed anywhere where it is known that the buffer is properly
sized but not a full cache line is transferred.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120918/62636666/attachment.pgp>

  reply	other threads:[~2012-09-18 14:54 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12 16:19 [U-Boot] Cache alignment warnings on Tegra (ARM) Tom Warren
2012-09-12 16:49 ` Stephen Warren
2012-09-12 22:38   ` Marek Vasut
2012-09-12 23:10     ` Stephen Warren
2012-09-12 23:42       ` Marek Vasut
2012-09-14 15:53         ` Simon Glass
2012-09-15 20:01           ` Thierry Reding
2012-09-15 20:11             ` Marek Vasut
2012-09-15 20:41               ` Thierry Reding
2012-09-15 20:56                 ` Marek Vasut
2012-09-16  2:45                 ` Simon Glass
2012-09-16  6:49                   ` Thierry Reding
2012-09-17 21:39                     ` Simon Glass
2012-09-18 14:54                       ` Thierry Reding [this message]
2012-09-18 18:24                         ` Simon Glass
2012-09-18 18:37                           ` Marek Vasut
2012-09-18 19:00                             ` Thierry Reding
2012-09-18 19:21                               ` Marek Vasut
2012-09-18 19:29                                 ` Thierry Reding
2012-09-18 19:36                                   ` Marek Vasut
2012-09-18 20:04                                     ` Thierry Reding
2012-09-18 20:28                                       ` Simon Glass
2012-09-18 21:21                                         ` Marek Vasut
2012-09-18 22:42                                           ` Simon Glass
2012-09-18 22:44                                             ` Marek Vasut
2012-09-19  5:45                                               ` Thierry Reding
2012-09-18 21:20                                       ` Marek Vasut
2012-09-19  5:46                                         ` Thierry Reding
2012-09-15 20:19             ` Thierry Reding

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=20120918145419.GA28525@avionic-0098.mockup.avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox