public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Pieter-Jan Busschaert" <pieterjan.busschaert@gmail.com>
To: ecos-discuss@ecos.sourceware.org
Subject: [ECOS] fix for mpc8xxx cache handling
Date: Tue, 06 Nov 2007 10:29:00 -0000	[thread overview]
Message-ID: <950a36fb0711060229lee6c6fi7d75eeb6c73e6088@mail.gmail.com> (raw)

Hello,


We have discovered a problem in the HAL_DCACHE_FLUSH macro for the
mpc8xxx powerpc variant. The same issue is present in the similar
macros HAL_DCACHE_INVALIDATE and HAL_DCACHE_STORE.

Just for reference, here is the current HAL_DCACHE_FLUSH macro :

#define HAL_DCACHE_FLUSH( _base_ , _size_ )                     \
    CYG_MACRO_START                                             \
    cyg_uint32 __base = (cyg_uint32) (_base_);                  \
    cyg_int32 __size = (cyg_int32) (_size_);                    \
    while (__size > 0) {                                        \
        asm volatile ("dcbf 0,%0;sync;" : : "r" (__base));      \
        __base += HAL_DCACHE_LINE_SIZE;                         \
        __size -= HAL_DCACHE_LINE_SIZE;                         \
    }                                                           \
    CYG_MACRO_END


When you want to flush some buffer that spans 2 cache lines (but its
size is smaller than one cache line), only the first cache line will
be flushed. This macro will only work correctly if _base_ is aligned
to the start of a cache line.

It can be fixed by adding this line in front of the while loop :

__size += (__base % HAL_DCACHE_LINE_SIZE);


Before submitting a patch, I'd rather have input about this change :
=> Is the assembler function dcbf supposed to work on non-aligned
addresses (it seems to work here) ?
=> Is the HAL_DCACHE_FLUSH macro supposed to work on non-aligned addresses ?
=> Is this the good way to fix the issue or is there a better alternative ?


greetings,

--
Pieter-Jan Busschaert
Software Engineer
Barco Presentation & Simulation

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

                 reply	other threads:[~2007-11-06 10:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=950a36fb0711060229lee6c6fi7d75eeb6c73e6088@mail.gmail.com \
    --to=pieterjan.busschaert@gmail.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).