public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] fix for mpc8xxx cache handling
@ 2007-11-06 10:29 Pieter-Jan Busschaert
  0 siblings, 0 replies; only message in thread
From: Pieter-Jan Busschaert @ 2007-11-06 10:29 UTC (permalink / raw)
  To: ecos-discuss

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-06 10:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-06 10:29 [ECOS] fix for mpc8xxx cache handling Pieter-Jan Busschaert

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).