maltalinux-cvs-patches
[Top] [All Lists]

CVS Update@linux-mips.org: malta

To: maltalinux-cvs-patches@linux-mips.org
Subject: CVS Update@linux-mips.org: malta
From: beth@linux-mips.org
Date: Mon, 08 Aug 2005 14:24:18 +0100
Reply-to: linux-mips@linux-mips.org
Sender: maltalinux-cvs-patches-bounce@linux-mips.org
CVSROOT:        /home/cvs
Module name:    malta
Changes by:     beth@ftp.linux-mips.org 05/08/08 14:24:15

Modified files:
        linux/arch/mips/kernel: Tag: MaltaRef_2_6 kspd.c rtlx.c vpe.c 
        linux/include/asm-mips: Tag: MaltaRef_2_6 mipsmtregs.h 

Log message:
        * arch/mips/kernel/kspd.c
        * arch/mips/kernel/rtlx.c
        * arch/mips/kernel/vpe.c: Fix reliabilty issues starting VPE1.
        
        * include/asm-mips/mipsmtregs.h: Additional c0 register macros.

diff -urN malta/linux/arch/mips/kernel/kspd.c 
malta/linux/arch/mips/kernel/kspd.c
--- malta/linux/arch/mips/kernel/Attic/kspd.c   2005/07/27 13:37:54     
1.1.1000.1
+++ malta/linux/arch/mips/kernel/Attic/kspd.c   2005/08/08 13:24:14     
1.1.1000.2
@@ -192,6 +192,8 @@
                                n->kspd_sp_exit(SP_VPE);
                        }
                        sp_stopping = 1;
+
+                       printk(KERN_DEBUG "KSPD got exit syscall from SP\n");
                        break;
 
                default:
diff -urN malta/linux/arch/mips/kernel/rtlx.c 
malta/linux/arch/mips/kernel/rtlx.c
--- malta/linux/arch/mips/kernel/rtlx.c 2005/07/27 13:37:54     1.1.1000.1
+++ malta/linux/arch/mips/kernel/rtlx.c 2005/08/08 13:24:14     1.1.1000.2
@@ -61,6 +61,7 @@
 
 extern void *vpe_get_shared(int index);
 static int rtlx_init(struct rtlx_info *rtlxi);
+DECLARE_MUTEX(wq_mutex);
 
 static void rtlx_dispatch(struct pt_regs *regs)
 {
@@ -130,6 +131,7 @@
        /* wake up any sleeping rtlx_open's */
        for (i = 0; i < RTLX_CHANNELS; i++)
                wake_up_interruptible(&channel_wqs[i].lx_queue);
+
 }
 static void stopping(int vpe)
 {
@@ -158,6 +160,7 @@
                                set_current_state(TASK_INTERRUPTIBLE);
                                while ((p = vpe_get_shared(RTLX_TARG_VPE)) == 
NULL) {
                                        schedule();
+                                       set_current_state(TASK_INTERRUPTIBLE);
                                }
 
                                set_current_state(TASK_RUNNING);
@@ -171,13 +174,26 @@
                        if (can_sleep) {
                                DECLARE_WAITQUEUE(wait, current);
                        
-
                                /* go to sleep */
                                add_wait_queue(&channel_wqs[index].lx_queue, 
&wait);
                                
                                set_current_state(TASK_INTERRUPTIBLE);
                                while (*p == NULL) {
                                        schedule();
+
+                                       /* reset task state to interruptable 
otherwise
+                                          we'll whizz round here like a very 
fast loopy 
+                                          thing. schedule() appears to return 
with state
+                                          set to TASK_RUNNING. 
+
+                                          If the loaded SP program, for 
whatever reason, 
+                                          doesn't set up the shared structure 
*p will never
+                                          become true. So whoever connected to 
either /dev/rt?
+                                          or if it was kspd, will then take up 
rather a lot of 
+                                          processor cycles.
+                                       */
+
+                                       set_current_state(TASK_INTERRUPTIBLE);
                                }
                                
                                set_current_state(TASK_RUNNING);
diff -urN malta/linux/arch/mips/kernel/vpe.c malta/linux/arch/mips/kernel/vpe.c
--- malta/linux/arch/mips/kernel/vpe.c  2005/07/27 13:37:54     1.1.1000.1
+++ malta/linux/arch/mips/kernel/vpe.c  2005/08/08 13:24:14     1.1.1000.2
@@ -267,20 +267,17 @@
        printk("config3 0x%lx MT %ld\n", val,
               (val & CONFIG3_MT) >> CONFIG3_MT_SHIFT);
 
-       val = read_c0_mvpconf0();
-       printk("mvpconf0 0x%lx, PVPE %ld PTC %ld M %ld\n", val,
-              (val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT,
-              val & MVPCONF0_PTC, (val & MVPCONF0_M) >> MVPCONF0_M_SHIFT);
-
        val = read_c0_mvpcontrol();
        printk("MVPControl 0x%lx, STLB %ld VPC %ld EVP %ld\n", val,
               (val & MVPCONTROL_STLB) >> MVPCONTROL_STLB_SHIFT,
               (val & MVPCONTROL_VPC) >> MVPCONTROL_VPC_SHIFT,
               (val & MVPCONTROL_EVP));
 
-       val = read_c0_vpeconf0();
-       printk("VPEConf0 0x%lx MVP %ld\n", val,
-              (val & VPECONF0_MVP) >> VPECONF0_MVP_SHIFT);
+       val = read_c0_mvpconf0();
+       printk("mvpconf0 0x%lx, PVPE %ld PTC %ld M %ld\n", val,
+              (val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT,
+              val & MVPCONF0_PTC, (val & MVPCONF0_M) >> MVPCONF0_M_SHIFT);
+
 }
 
 /* Find some VPE program space  */
@@ -695,10 +692,26 @@
 
 static void dump_tc(struct tc *t)
 {
-       printk(KERN_WARNING "VPE: TC index %d TCStatus 0x%lx halt 0x%lx\n",
-              t->index, read_tc_c0_tcstatus(), read_tc_c0_tchalt());
+       unsigned long val;
+
+       settc(t->index);
+
+       printk(KERN_WARNING "\nVPE: TC index %d targtc %ld TCStatus 0x%lx halt 
0x%lx\n",
+              t->index, read_c0_vpecontrol() & VPECONTROL_TARGTC, 
+              read_tc_c0_tcstatus(), read_tc_c0_tchalt());
+
        printk(KERN_WARNING "VPE: tcrestart 0x%lx\n", read_tc_c0_tcrestart());
        printk(KERN_WARNING "VPE: tcbind 0x%lx\n", read_tc_c0_tcbind());
+
+       val = read_c0_vpeconf0();
+       printk("VPEConf0 0x%lx MVP %ld\n", val,
+              (val & VPECONF0_MVP) >> VPECONF0_MVP_SHIFT);
+
+       printk(KERN_WARNING "VPE: c0 status 0x%lx\n", read_vpe_c0_status());
+       printk(KERN_WARNING "VPE: c0 cause 0x%lx\n", read_vpe_c0_cause());
+
+       printk(KERN_WARNING "VPE: c0 badvaddr 0x%lx\n", read_vpe_c0_badvaddr());
+       printk(KERN_WARNING "VPE: c0 epc 0x%lx\n", read_vpe_c0_epc());
 }
 
 static void dump_tclist(void)
@@ -713,7 +726,7 @@
 /* We are prepared so configure and start the VPE... */
 int vpe_run(vpe_t * v)
 {
-       unsigned long val;
+       unsigned long val, dmt_flag;
        struct tc *t;
        struct vpe_notifications *n;
 
@@ -745,8 +758,6 @@
 
        settc(t->index);
 
-       val = read_vpe_c0_vpeconf0();
-
        /* should check it is halted, and not activated */
        if ((read_tc_c0_tcstatus() & TCSTATUS_A) || !(read_tc_c0_tchalt() & 
TCHALT_H)) {
                printk(KERN_WARNING "VPE: TC %d is already doing something!\n",
@@ -756,13 +767,16 @@
                return -ENOEXEC;
        }
 
+       /* disable multi-threaded execution whilst we activate, clear the halt 
bit
+          and bound the tc to the other VPE... */
+       dmt_flag = dmt();
 
        /* Write the address we want it to start running from in the TCPC 
register. */
        write_tc_c0_tcrestart((unsigned long)v->__start);
 
-       /* write the sivc_info address to tccontext */
        write_tc_c0_tccontext((unsigned long)0);
 
+
        /* mark the TC as activated, not interrupt exempt and not dynamically 
           allocatable */
        val = read_tc_c0_tcstatus();
@@ -782,18 +796,23 @@
           registers to set up, and so an EJTAG probe can trigger on it */
        write_tc_c0_tcbind((read_tc_c0_tcbind() & ~TCBIND_CURVPE) | v->minor);
 
+
        /* Set up the XTC bit in vpeconf0 to point at our tc */
-       write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | (t->index << 
VPECONF0_XTC_SHIFT));
+       write_vpe_c0_vpeconf0( (read_vpe_c0_vpeconf0() & ~(VPECONF0_XTC))
+                              | (t->index << VPECONF0_XTC_SHIFT));
        
        /* enable this VPE */
        write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | VPECONF0_VPA);   
 
+       /* clear out any leftovers from a previous program */
+       write_vpe_c0_status(0); 
+       write_vpe_c0_cause(0);
+
        /* take system out of configuration state */
        write_c0_mvpcontrol(read_c0_mvpcontrol() & ~MVPCONTROL_VPC);
 
-
-       dump_tc(t);
-       
+       /* now safe to re-enable multi-threading */
+       emt(dmt_flag);
 
        /* set it running */
        evpe(EVPE_ENABLE);
@@ -801,7 +820,6 @@
        list_for_each_entry(n, &v->notify, list) {
                n->start(v->minor);
        }
-
        return 0;
 }
 
@@ -937,8 +955,7 @@
                        continue;
 
                if (sechdrs[i].sh_type == SHT_REL)
-                       err =
-                               apply_relocations(sechdrs, strtab, symindex, i, 
&mod);
+                       err = apply_relocations(sechdrs, strtab, symindex, i, 
&mod);
                else if (sechdrs[i].sh_type == SHT_RELA)
                        err = apply_relocate_add(sechdrs, strtab, symindex, i,
                                                 &mod);
@@ -971,6 +988,8 @@
 {
        struct tc *t;
 
+       settc(v->minor);
+
        printk(KERN_DEBUG "VPEControl 0x%lx\n", read_vpe_c0_vpecontrol());
        printk(KERN_DEBUG "VPEConf0 0x%lx\n", read_vpe_c0_vpeconf0());
 
@@ -996,12 +1015,6 @@
        
        write_tc_c0_tchalt(TCHALT_H);
 
-       /* clear out any left overs from a previous program */
-       write_vpe_c0_cause(0);
-
-       /* clear interrupts enabled IE, ERL, EXL, and KSU from c0 status */
-       write_vpe_c0_status(read_vpe_c0_status() & ~(ST0_ERL | ST0_KSU | ST0_IE 
| ST0_EXL));
-
        /* bind it to anything other than VPE1 */
        write_tc_c0_tcbind(read_tc_c0_tcbind() & ~TCBIND_CURVPE); // | 
TCBIND_CURVPE
 
@@ -1043,6 +1056,9 @@
 
        if (v->state != VPE_STATE_UNUSED) {
                dvpe();
+
+               printk("vpe_open tc in use dumping regs\n");
+               dump_tc(get_tc(minor));
                
                list_for_each_entry(not, &v->notify, list) {
                        not->stop(minor);
diff -urN malta/linux/include/asm-mips/mipsmtregs.h 
malta/linux/include/asm-mips/mipsmtregs.h
--- malta/linux/include/asm-mips/mipsmtregs.h   2005/07/28 17:22:13     
1.2.1000.2
+++ malta/linux/include/asm-mips/mipsmtregs.h   2005/08/08 13:24:14     
1.2.1000.3
@@ -338,6 +338,10 @@
 #define read_vpe_c0_ebase()            mftc0($15,1)
 #define write_vpe_c0_ebase(val)                mttc0($15, 1, val)
 #define write_vpe_c0_compare(val)      mttc0($11, 0, val)
+#define read_vpe_c0_badvaddr()         mftc0($8,0)
+#define read_vpe_c0_epc()              mftc0($14,0)
+#define write_vpe_c0_epc(val)          mttc0($14,0, val)
+
 
 
 /* TC */

<Prev in Thread] Current Thread [Next in Thread>