OpenQNX :: The QNX Community Portal

Sep 07, 2008 - 07:28 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 46 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Mike Gorchak
Post subject: How to invalidate CPU cache ?  PostPosted: Sep 06, 2007 - 07:15 AM
Guest





Hello, All!

I have the following situation, hope somebody will help me:

PCI hardware have LUT data in system memory for the DMA scatter/gather,
which is disabled by default. When LUT's entries contains of all zeroes
adapter will ignore data in it, when LUT table's entries are not all zero
adapter will start to cache data of physical addresses, which are just
entries in the LUT. So if LUT will be enabled with LUT data in system memory
which are not cleared, adapter will begin DMA transfers using wrong and/or
bad physical addresses.

My code looks like this (it's for x86 platform only !):

memset(ctx->pcie_lut, 0x00,ctx->pcie_lut_size);
__asm__ __volatile__ ("wbinvd": : :"memory");
EnableLUT(ctx);

I'm using wbinvd CPU command to be sure, that memset clearing will be done
and all LUT data already cleared before I engage LUT engine. Otherwise
without using wbinvd it is exist probability when LUT engine will be enabled
before all CPU caches are flushed with delayed writeback writes.

But driver segfaults when executing wbinvd CPU command with GP #0, even when
all IOs are permitted by using ThreadCtl(_NTO_TCTL_IO, ...

Is it possible somehow to flush all delayed writes in the CPU caches in QNX
6.3 SP3 for x86 ?

Thanks in advance !

With best regards, Mike Gorchak. E-mail: mike@malva.ua
 
   
Reply with quote Back to top
Mike Gorchak
Post subject: Re: How to invalidate CPU cache ?  PostPosted: Sep 19, 2007 - 02:27 PM
Guest





Hello, Mike!

MG> Is it possible somehow to flush all delayed writes in the CPU caches in
MG> QNX 6.3 SP3 for x86 ?

As far as I can interpret the silence, the way only to hook INT 0 timer
interrupt, do the wbinvd instruction in the interrupt handler and then
immediately free the timer interrupt hook. Something tell's me this will
work, but it is wrong way to do such things ... :-/

With best regards, Mike Gorchak. E-mail: mike@malva.ua
 
   
Reply with quote Back to top
David Gibbs
Post subject: Re: How to invalidate CPU cache ?  PostPosted: Oct 09, 2007 - 08:58 PM
Guest





Mike Gorchak <mike@malva.ua> wrote:
Quote:
Hello, All!


Quote:
I'm using wbinvd CPU command to be sure, that memset clearing will be done
and all LUT data already cleared before I engage LUT engine. Otherwise
without using wbinvd it is exist probability when LUT engine will be enabled
before all CPU caches are flushed with delayed writeback writes.

But driver segfaults when executing wbinvd CPU command with GP #0, even when
all IOs are permitted by using ThreadCtl(_NTO_TCTL_IO, ...

wbinvd may be a ring 0 operation, TCTL_IO allows ring 1. Only the kernel
operates at ring 0.

Quote:
Is it possible somehow to flush all delayed writes in the CPU caches in QNX
6.3 SP3 for x86 ?

Have you looked at the cache contral API? I don't know if it allows flushing
of all cache -- but it does allow it for configured/controlled areas.

Look at cache_fini(), CACHE_FLUSH().

-David
--
David Gibbs
QNX Training Services
dagibbs@qnx.com
 
   
Reply with quote Back to top
Mike Gorchak
Post subject: Re: How to invalidate CPU cache ?  PostPosted: Oct 10, 2007 - 10:42 AM
Guest





Hello, David!

Quote:
I'm using wbinvd CPU command to be sure, that memset clearing will be
done and all LUT data already cleared before I engage LUT engine.
Otherwise without using wbinvd it is exist probability when LUT engine
will be enabled before all CPU caches are flushed with delayed writeback
writes.
But driver segfaults when executing wbinvd CPU command with GP #0, even
when all IOs are permitted by using ThreadCtl(_NTO_TCTL_IO, ...
DG> wbinvd may be a ring 0 operation, TCTL_IO allows ring 1. Only the

DG> kernel operates at ring 0.

Yep, it is.

Quote:
Is it possible somehow to flush all delayed writes in the CPU caches in
QNX 6.3 SP3 for x86 ?
DG> Have you looked at the cache contral API?


I have missed it, since cache control API appeared in QNX 6.3.0 SP2 first
time.

DG> I don't know if it allows flushing of all cache -- but it does allow it
DG> for configured/controlled areas.
DG> Look at cache_fini(), CACHE_FLUSH().

Thank you for guidance ! Region range cache flush will be enough in my case.
Thanks one more!

P.S. It would be cool to have MTRR API and library also released some good
day :)

With best regards, Mike Gorchak. E-mail: mike@malva.ua
 
   
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.