From 7b2dfe4497013f4d3dd4ab9615c2bd4855369224 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 27 Jun 2011 15:12:58 -0700 Subject: [PATCH 1/3] map off-die shared memory in the kernel address space - plus example code --- arch/x86/scc/RCCE_admin.c | 5 +++-- arch/x86/scc/icc.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/x86/scc/RCCE_admin.c b/arch/x86/scc/RCCE_admin.c index 2ad87e18..dc7db27d 100644 --- a/arch/x86/scc/RCCE_admin.c +++ b/arch/x86/scc/RCCE_admin.c @@ -26,6 +26,7 @@ // #include +#include #ifdef CONFIG_ROCKCREEK @@ -335,13 +336,13 @@ int RCCE_init( RCCE_malloc_init(RCCE_comm_buffer[RCCE_IAM],RCCE_BUFF_SIZE); #ifdef SHMADD - RCCE_shmalloc_init(RC_SHM_BUFFER_START()+RCCE_SHM_BUFFER_offset ,RCCE_SHM_SIZE_MAX); + RCCE_shmalloc_init(map_region(NULL, RC_SHM_BUFFER_START()+RCCE_SHM_BUFFER_offset, RCCE_SHM_SIZE_MAX/PAGE_SIZE, MAP_KERNEL_SPACE|MAP_NO_CACHE), RCCE_SHM_SIZE_MAX); #ifdef SHMDBG kprintf("\n%d:%s:%d: RCCE_SHM_BUFFER_offset, RCCE_SHM_SIZE_MAX: %x %x\n", RCCE_IAM, __FILE__,__LINE__,RCCE_SHM_BUFFER_offset ,RCCE_SHM_SIZE_MAX); #endif #else - RCCE_shmalloc_init(RC_SHM_BUFFER_START(),RCCE_SHM_SIZE_MAX); + RCCE_shmalloc_init(map_region(NULL, RC_SHM_BUFFER_START(), RCCE_SHM_SIZE_MAX/PAGE_SIZE, MAP_KERNEL_SPACE|MAP_NO_CACHE), RCCE_SHM_SIZE_MAX); #endif // initialize the (global) flag bookkeeping data structure diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index 730add0b..4e77fb79 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -142,6 +142,17 @@ int icc_init(void) kprintf("failed! (0x%x)\n", msg); #endif +#if 0 + char* str = RCCE_shmalloc(128); + if (my_ue == 1) { + memset(str, 0x00, 128); + strcpy(str, "Hello RCCE_shmalloc\n"); + } + RCCE_barrier(&RCCE_COMM_WORLD); + kprintf("RCCE_shmalloc test: %s\n", str); + RCCE_shfree(str); +#endif + // reset INTR/LINT0 flag z = Z_PID(RC_COREID[my_ue]); tmp=ReadConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1)); From 01a7530d6354267da878f97a7041ebf1bdc1f839 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 28 Jun 2011 10:58:32 -0700 Subject: [PATCH 2/3] use the FPGA registers to determine the number slots, which are used as private memory --- include/metalsvm/config.h.example | 5 ---- mm/memory.c | 49 ++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/include/metalsvm/config.h.example b/include/metalsvm/config.h.example index f5b35948..34a2717a 100644 --- a/include/metalsvm/config.h.example +++ b/include/metalsvm/config.h.example @@ -63,11 +63,6 @@ extern "C" { #define SHMADD #define SHMDBG //#define SHMADD_CACHEABLE -/* default values for 16 GB system */ -#define PRIVATE_MEM1_START 0x00000000 -#define PRIVATE_MEM1_END 0x13FFFFFF -#define PRIVATE_MEM2_START 0xFF000000 -#define PRIVATE_MEM2_END 0xFFFFFFFF #define SCC_BOOTINFO 0x80000 #define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b)) diff --git a/mm/memory.c b/mm/memory.c index ad29aedd..efa3d5c6 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -30,6 +30,9 @@ #include #endif #ifdef CONFIG_ROCKCREEK +#include +#include +#include #include #endif @@ -93,6 +96,7 @@ int mmu_init(void) size_t kernel_size; unsigned int i; size_t addr; + int ret; // at first, set default value of the bitmap memset(bitmap, 0xFF, sizeof(uint8_t)*BITMAP_SIZE); @@ -148,15 +152,8 @@ int mmu_init(void) } } #elif defined(CONFIG_ROCKCREEK) - for(addr=PRIVATE_MEM1_START; addr> PAGE_SHIFT); - if (addr > addr + PAGE_SIZE) - break; - atomic_int32_inc(&total_pages); - atomic_int32_inc(&total_available_pages); - } - - for(addr=PRIVATE_MEM2_START; addr> PAGE_SHIFT); if (addr > addr + PAGE_SIZE) break; @@ -200,7 +197,39 @@ int mmu_init(void) if ((size_t) &kernel_end & (PAGE_SIZE-1)) alloc_start++; - return paging_init(); + ret = paging_init(); + +#ifdef CONFIG_ROCKCREEK + /* + * Now, we are able to read the FPGA register and to + * determin the number of slots. + */ + uint32_t slots = *((volatile uint32_t*) (FPGA_BASE + 0x8244)); + if (slots == 0) + slots = 21; + + kprintf("MetalSVM use %d slots for private memory\n", slots); + + // define all the private slots as free + for(addr=0x1000000; addr<(slots-1)*0x1000000; addr+=PAGE_SIZE) { + page_clear_mark(addr >> PAGE_SHIFT); + if (addr > addr + PAGE_SIZE) + break; + atomic_int32_inc(&total_pages); + atomic_int32_inc(&total_available_pages); + } + + // Note: The last slot belongs always to the private memory. + for(addr=0xFF000000; addr<0xFFFFFFFF; addr+=PAGE_SIZE) { + page_clear_mark(addr >> PAGE_SHIFT); + if (addr > addr + PAGE_SIZE) + break; + atomic_int32_inc(&total_pages); + atomic_int32_inc(&total_available_pages); + } +#endif + + return ret; } /* From af2345d15cb36a2b11a6e7c294c90e0b7096e42c Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 28 Jun 2011 13:45:12 -0700 Subject: [PATCH 3/3] remove typos and cosmetic changes --- mm/memory.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index efa3d5c6..11f6fdce 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -152,8 +152,8 @@ int mmu_init(void) } } #elif defined(CONFIG_ROCKCREEK) - /* of course, the first slot belongs to the private memory */ - for(addr=0x00; addr<0x1000000; addr+=PAGE_SIZE) { + /* of course, the first twenty slots belong to the private memory */ + for(addr=0x00; addr<20*0x1000000; addr+=PAGE_SIZE) { page_clear_mark(addr >> PAGE_SHIFT); if (addr > addr + PAGE_SIZE) break; @@ -161,6 +161,15 @@ int mmu_init(void) atomic_int32_inc(&total_available_pages); } + // Note: The last slot belongs always to the private memory. + for(addr=0xFF000000; addr<0xFFFFFFFF; addr+=PAGE_SIZE) { + page_clear_mark(addr >> PAGE_SHIFT); + if (addr > addr + PAGE_SIZE) + break; + atomic_int32_inc(&total_pages); + atomic_int32_inc(&total_available_pages); + } + /* * Mark the bootinfo as used. */ @@ -201,8 +210,8 @@ int mmu_init(void) #ifdef CONFIG_ROCKCREEK /* - * Now, we are able to read the FPGA register and to - * determin the number of slots. + * Now, we are able to read the FPGA registers and to + * determine the number of slots for private memory. */ uint32_t slots = *((volatile uint32_t*) (FPGA_BASE + 0x8244)); if (slots == 0) @@ -210,17 +219,8 @@ int mmu_init(void) kprintf("MetalSVM use %d slots for private memory\n", slots); - // define all the private slots as free - for(addr=0x1000000; addr<(slots-1)*0x1000000; addr+=PAGE_SIZE) { - page_clear_mark(addr >> PAGE_SHIFT); - if (addr > addr + PAGE_SIZE) - break; - atomic_int32_inc(&total_pages); - atomic_int32_inc(&total_available_pages); - } - - // Note: The last slot belongs always to the private memory. - for(addr=0xFF000000; addr<0xFFFFFFFF; addr+=PAGE_SIZE) { + // define the residual private slots as free + for(addr=20*0x1000000; addr<(slots-1)*0x1000000; addr+=PAGE_SIZE) { page_clear_mark(addr >> PAGE_SHIFT); if (addr > addr + PAGE_SIZE) break;