On Mon, Aug 28, 2017 at 03:53:05PM +0200, Ralf Baechle wrote: > Patch is looking perfect at a glance but without support for an R5900 > system that is the PS2 it kinda pointless so I'd like to wait and > review and apply everything at once. Thanks for your quick feedback! Everything else is here: https://github.com/frno7/linux/tree/ps2-v4.12-squashed This is GPL work by Sony, Jürgen Urban, Rick Gaiser, and others. About 40000 lines of code with drivers etc. and unpostable in current form. I've updated it from 2.6.35 to 4.12 and it's running with workarounds and a few reverts. I believe the patch can be improved in several areas. Some notes: - The R5900 has 128 bit registers. In the patch this is implemented by replacing __u64 pt_regs::regs[32] with r5900_reg_t { __u64 lo, hi; }, and consequently replacing all 300+ register reads and writes with macros such as MIPS_READ_REG, MIPS_WRITE_REG, etc. Perhaps a less intrusive way is to store the most significant 64 bits separately and only use the least 64 bits in the rest of the kernel, without modification? - MFC0/MTC0 and a few other instructions need additional SYNC. The patch uses ifdefs but perhaps macros are better? (See p. C-28 in TX79 Core Architecture manual by Toshiba, for example.) - A new SYNC.P instruction is added to arch/mips/mm/uasm-mips.c. - According to the same manual, the "first two instructions in an exception handler are executed as NOP when a bus error occurs (FLX05)" with the corrective measure to "place NOP in the first two instruction locations in all exception handlers" (p. 1-11). - The memcpy/strlen/etc. family of functions need short loop NOP padding to avoid hardware bugs. Perhaps it's less fragile to rely on the compiler and use C implementations instead of assembly for R5900? - A few other places apparently also need NOP padding. - I'm unusure about arch/mips/kernel/scall32-n32.S. - LL, SC, LLD and SCD etc. are not implemented in R5900 and are emulated. - FPU needs special save/restore. - arch/mips/include/asm/r4kcache.h is modified with special cache macros. - arch/mips/mm/tlbex.c is updated with scratch pad memory map. - The USB driver in the patch broke on 6f65126c7 "USB: OHCI: add SG support" and 6894258ed "dma-mapping: consolidate dma_{alloc,free}_{attrs,coherent}". - The patch also broke on a6335fa1 "MIPS: bootmem: Don't use memory holes for page bitmap", as well as 084a7cf7 "MIPS: IRQ Stack: Unwind IRQ stack onto task stack". - One should look at the 2.6.35 patch series to make sense of some of the changes in this updated patch. These parts need to be reworked, of course. That's a start and some design choices need to be made to continue. What are your thoughts? Fredrik