--- zzzz-none-000/linux-3.10.107/arch/mips/kernel/genex.S 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/arch/mips/kernel/genex.S 2021-11-10 11:53:54.000000000 +0000 @@ -7,6 +7,7 @@ * Copyright (C) 1999, 2000 Silicon Graphics, Inc. * Copyright (C) 2002, 2007 Maciej W. Rozycki * Copyright (C) 2001, 2012 MIPS Technologies, Inc. All rights reserved. + * Copyright (C) 2013 AVM GmbH */ #include @@ -16,10 +17,13 @@ #include #include #include -#include +#include #include #include #include +#if CONFIG_ATH_DDR_RELEASE_TIMER +#include +#endif #ifdef CONFIG_MIPS_MT_SMTC #define PANIC_PIC(msg) \ @@ -54,6 +58,23 @@ #ifdef CONFIG_64BIT dsll k1, k1, 1 #endif +#ifdef CONFIG_AVM_ENHANCED +#if defined(CONFIG_MIPS_MT_SMTC) ||defined(CONFIG_MIPS_MT_SMP) +#define FIRST_YIELD_TC 2 + /*--------------------------------------------------------------------------------*\ + * AVM(mbahr): special exception handling for yield-context + \*--------------------------------------------------------------------------------*/ + mfc0 k0, CP0_TCBIND + sra k0, k0, TCBIND_CURTC_SHIFT + andi k0, k0, 0xff + slti k0, k0, FIRST_YIELD_TC + bnez k0, 1f + nop + j yield_exception_handler + nop +1: +#endif +#endif PTR_L k0, exception_handlers(k1) jr k0 .set pop @@ -67,7 +88,7 @@ */ NESTED(except_vec3_r4000, 0, sp) .set push - .set mips3 + .set mips32r2 .set noat mfc0 k1, CP0_CAUSE li k0, 31<<2 @@ -139,7 +160,6 @@ nop nop #endif - .set mips3 wait /* end of rollback region (the region size must be power of two) */ 1: @@ -196,6 +216,64 @@ 1: .set pop #endif + +#if CONFIG_ATH_DDR_RELEASE_TIMER + /* Check whether the MISC interrupt is enabled and present */ + mfc0 k0, CP0_STATUS, 0 + mfc0 k1, CP0_CAUSE, 0 + and k0, k0, k1 + andi k0, k0, CAUSEF_IP6 + beqz k0, 2f + + /* Check whether the interrupt is Timer interrupt in the MISC space */ + li k0, RST_GENERAL_BASE + lw k1, RST_MISC_INTERRUPT_STATUS_OFFSET(k0) + lw k0, RST_MISC_INTERRUPT_MASK_OFFSET(k0) + and k0, k0, k1 + andi k0, k0, RST_MISC_INTERRUPT_STATUS_TIMER2_INT_MASK + beqz k0, 2f + + /* Clear the interrupt */ + li k0, RST_GENERAL_BASE + lw k1, RST_MISC_INTERRUPT_STATUS_OFFSET(k0) + ori k1, k1, RST_MISC_INTERRUPT_STATUS_TIMER2_INT_MASK + xori k1, k1, RST_MISC_INTERRUPT_STATUS_TIMER2_INT_MASK + sw k1, RST_MISC_INTERRUPT_STATUS_OFFSET(k0) + + /* Save GPRS a0, a1 for using them in this routine */ + li k0, KSEG1ADDR(ATH_SRAM_BASE) + sw a0, 0x0(k0) + sw a1, 0x4(k0) + + /* Reset the DDR Performance counters - Client is CPU */ + li k0, DDR_CONFIG_BASE + li k1, 0x7 + sw k1, DDRMON_CTL_OFFSET(k0) + sw $0, DDRMON_CTL_OFFSET(k0) + + /* Delay between reading the Performance counters while polling */ + lw k1, DDRMON_GNT_OFFSET(k0) +4: + ori a0, k1, 0x0 + li a1, 0x20 +12: + addiu a1, a1, -1 + bnez a1, 12b + + /* Read and compare whether the CPU didnt get any grant */ + lw k1, DDRMON_GNT_OFFSET(k0) + bne a0, k1, 4b + + /* Put the values back to a0 and a1 and continue */ + li k0, KSEG1ADDR(ATH_SRAM_BASE) + lw a0, 0x0(k0) + lw a1, 0x4(k0) + +5: + eret + +2: +#endif SAVE_ALL CLI TRACE_IRQS_OFF @@ -222,7 +300,11 @@ * to fit into space reserved for the exception handler. */ NESTED(except_vec4, 0, sp) -1: j 1b /* Dummy, will be replaced */ +FEXPORT(except_vec4_lui) + lui k0, 0 /* Patched */ +FEXPORT(except_vec4_ori) + ori k0, 0 /* Patched */ + jr k0 END(except_vec4) /* @@ -340,7 +422,7 @@ ejtag_return: MFC0 k0, CP0_DESAVE - .set mips32 + .set mips32r2 deret .set pop END(ejtag_debug_handler) @@ -370,15 +452,98 @@ END(except_vec_nmi) __FINIT +#ifdef CONFIG_AVM_ENHANCED +#if defined(CONFIG_MIPS_MT_SMTC) ||defined(CONFIG_MIPS_MT_SMP) +/*--------------------------------------------------------------------------------*\ + * AVM(mbahr): special exception handling for yield-context +\*--------------------------------------------------------------------------------*/ +NESTED(yield_exception_handler, PT_SIZE, sp) + .set push + .set noat + .set mips32r2 + bgtz sp, 2f /* < check for valid: YIELD-SP < KSEG0 -> pt_regs == NULL */ + lui k0,0x9000 /* < check for valid: YIELD-SP >= KSEG1 -> pt_regs == NULL */ + sltu k0, sp,k0 + beqz k0, 2f + move k0, sp + move k1,sp + .set noreorder + PTR_SUBU k1, PT_SIZE + move sp, k1 + LONG_S k0, PT_R29(sp) + LONG_S $3, PT_R3(sp) + LONG_S $0, PT_R0(sp) + mfc0 v1, CP0_STATUS + LONG_S $2, PT_R2(sp) + LONG_S v1, PT_STATUS(sp) + mfc0 v1, CP0_TCSTATUS + LONG_S $4, PT_R4(sp) + LONG_S v1, PT_TCSTATUS(sp) + mfc0 v1, CP0_CAUSE + LONG_S $5, PT_R5(sp) + LONG_S v1, PT_CAUSE(sp) + LONG_S $6, PT_R6(sp) + MFC0 v1, CP0_EPC + LONG_S $7, PT_R7(sp) + LONG_S v1, PT_EPC(sp) + LONG_S $25, PT_R25(sp) + LONG_S $28, PT_R28(sp) + MFC0 v1, CP0_BADVADDR + LONG_S $31, PT_R31(sp) + PTR_S v1, PT_BVADDR(sp) + SAVE_AT + SAVE_TEMP + SAVE_STATIC + + jal do_yield + move a0, k1 /* pt_reg */ + move k0, v0 /* new stackpointer */ + LONG_L v1, PT_R4(sp) + LONG_L v0, PT_R3(sp) + PTR_ADDU sp, PT_SIZE + beqz k0, 1f + nop + move sp, k0 +1: + eret + nop +2: + jal do_yield + move a0, zero + eret + nop + .set pop + END(yield_exception_handler) +#endif +#endif NESTED(nmi_handler, PT_SIZE, sp) .set push .set noat + /* Clear ERL - restore segment mapping */ + mfc0 k0, CP0_STATUS + ori k0, k0, ST0_EXL + lui k1, 0xffff & ~(ST0_BEV>>16) + ori k1, k1, 0xffff & ~(ST0_ERL) + and k0, k0, k1 + mtc0 k0, CP0_STATUS + ehb SAVE_ALL move a0, sp +#ifdef CONFIG_AVM_ENHANCED + LONG_S sp, TI_REGS($28) /* important! set current_thread_info()->regs, so get_irq_regs() works also in nmi */ +#endif/*--- #ifdef CONFIG_AVM_ENHANCED ---*/ jal nmi_exception_handler RESTORE_ALL - .set mips3 + /* Set ERL and clear EXL|NMI */ + mfc0 k0, CP0_STATUS + ori k0, k0, ST0_ERL + lui k1, 0xffff & ~(ST0_NMI>>16) + ori k1, k1, 0xffff & ~(ST0_EXL) + and k0, k0, k1 + mtc0 k0, CP0_STATUS + ehb + .set mips32r2 eret .set pop END(nmi_handler) @@ -398,8 +563,6 @@ .macro __build_clear_fpe .set push - /* gas fails to assemble cfc1 for some archs (octeon).*/ \ - .set mips1 cfc1 a1, fcr31 li a2, ~(0x3f << 12) and a2, a1 @@ -449,6 +612,9 @@ .set at __BUILD_\verbose \exception move a0, sp +#ifdef CONFIG_AVM_ENHANCED + LONG_S sp, TI_REGS($28) /* important! set current_thread_info()->regs, so get_irq_regs() works also in exception */ +#endif/*--- #ifdef CONFIG_AVM_ENHANCED ---*/ PTR_LA ra, ret_from_exception j do_\handler END(handle_\exception) @@ -468,6 +634,7 @@ BUILD_HANDLER ov ov sti silent /* #12 */ BUILD_HANDLER tr tr sti silent /* #13 */ BUILD_HANDLER fpe fpe fpe silent /* #15 */ + BUILD_HANDLER ftlb ftlb none silent /* #16 */ BUILD_HANDLER mdmx mdmx sti silent /* #22 */ #ifdef CONFIG_HARDWARE_WATCHPOINTS /*