All of lore.kernel.org
 help / color / mirror / Atom feed
* Invalidate Data Cache from User Space
@ 2009-11-09 18:10 Jonathan Haws
  2009-11-10  1:15 ` Josh Boyer
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Haws @ 2009-11-09 18:10 UTC (permalink / raw)
  To: linuxppc-dev

All,

I have a routine to invalidate the data cache from user space (since I do n=
ot believe there is a standard routine I can use outside of kernel space??)=
.

Here is the code:

	.text;
	.globl cacheInvalidate405;
cacheInvalidate405:

      /*
       *   r3 =3D Data cache
       *   r4 =3D address
       *   r5 =3D number of bytes
       */

        cmpwi   r5,0                /* make sure number of bytes is > 0 */
        beq     invalDone
        add     r6,r4,r5
        addi    r6,r6,31
        rlwinm  r6,r6,0,0,26        /* end addr to start of next cache line=
 */
        rlwinm  r7,r4,0,0,26        /* start address back to start of line =
 */
        sub     r6,r6,r7
        srawi   r6,r6,5             /* divide by 32 to get number of lines =
 */
        mtctr   r6
invalLoop:
        dcbi    r0,r4			/* THIS INSTRUCTION FAILS! */
        addi    r4,r4,32
        bdnz    invalLoop
        sync
invalDone:
        blr
.size	cacheInvalidate405, . - cacheInvalidate405

What is happening is the dcbi instruction will fail.  I get an Illegal Inst=
ruction message on the console and my program exits.

Is there a reason I cannot call dbci from a user space application, or is t=
here something wrong in my code?  Even better, is there a working and teste=
d function that I can call from user space to invalidate a portion of the d=
ata cache?

Thanks!

Jonathan

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Invalidate Data Cache from User Space
  2009-11-09 18:10 Invalidate Data Cache from User Space Jonathan Haws
@ 2009-11-10  1:15 ` Josh Boyer
  0 siblings, 0 replies; 2+ messages in thread
From: Josh Boyer @ 2009-11-10  1:15 UTC (permalink / raw)
  To: Jonathan Haws; +Cc: linuxppc-dev

On Mon, Nov 09, 2009 at 11:10:42AM -0700, Jonathan Haws wrote:
>All,
>What is happening is the dcbi instruction will fail.  I get an Illegal Instruction message on the console and my program exits.
>
>Is there a reason I cannot call dbci from a user space application, or is there something wrong in my code?  Even better, is there a working and tested function that I can call from user space to invalidate a portion of the data cache?

dcbi is a priviledged instruction on 4xx.  You can only execute it from
supervisor mode (kernel).

josh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-11-10  1:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-09 18:10 Invalidate Data Cache from User Space Jonathan Haws
2009-11-10  1:15 ` Josh Boyer

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.