From 969d3be339d9884bb09dff5e07e67c88cd346853 Mon Sep 17 00:00:00 2001
From: Thomas Chou <thomas@wytron.com.tw>
Date: Mon, 7 Jan 2008 08:45:12 +0800
Subject: [PATCH] nios2: flush cache in ptrace poke text

The nios2 arch has seperated icache and dcache. We have to flush cache
to change text memory.

It is not necessary to flush usr and regs, as they will be accessed by
data master of nios2 exclusively. Only changes in text/code should be
flushed, as the code will be passed from data master to memory, and then
to instruction master.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 linux-2.6.x/arch/nios2nommu/kernel/ptrace.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/linux-2.6.x/arch/nios2nommu/kernel/ptrace.c b/linux-2.6.x/arch/nios2nommu/kernel/ptrace.c
index df7d2a5..6982f9a 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/ptrace.c
+++ b/linux-2.6.x/arch/nios2nommu/kernel/ptrace.c
@@ -24,6 +24,7 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 #include <asm/processor.h>
+#include <asm/cacheflush.h>
 
 #define DEBUG
 
@@ -163,6 +164,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 			PRINTK_DEBUG("%s POKETEXT: addr=0x%08x, data=0x%08x\n", __FUNCTION__, (u32)addr, (u32)data);
 			ret = 0;
 			copied = access_process_vm(child, addr, &data, sizeof(data), 1);
+			if (request == PTRACE_POKETEXT)
+				cache_push(addr, sizeof(data));
 			PRINTK_DEBUG("%s POKETEXT: copied size = %d\n", __FUNCTION__, copied);
 			if (copied == sizeof(data))
 				break;
-- 
1.5.3.3

