Commit 16d19894 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

edmac-memcpy: use cache handling similar to FIO;

updated selftest and bench modules for the new restriction

--HG--
branch : cache-fixes
parent f2386746915b
......@@ -90,9 +90,11 @@ static void mem_test_bmp_fill(int arg0, int arg1, int arg2, int arg3)
static void mem_test_edmac_copy_rectangle(int arg0, int arg1, int arg2, int arg3)
{
uint8_t* real = bmp_vram_real();
uint8_t* idle = bmp_vram_idle();
edmac_copy_rectangle_adv(BMP_VRAM_START(idle), BMP_VRAM_START(real), 960, 0, 0, 960, 0, 0, 720, 480);
uint8_t* real = BMP_VRAM_START(bmp_vram_real());
uint8_t* idle = BMP_VRAM_START(bmp_vram_idle());
/* careful - do not mix cacheable and uncacheable pointers unless you know what you are doing */
edmac_copy_rectangle_adv(UNCACHEABLE(idle), UNCACHEABLE(real), 960, 0, 0, 960, 0, 0, 720, 480);
}
static uint64_t FAST DUMP_ASM mem_test_read64(uint64_t* buf, uint32_t n)
......@@ -146,8 +148,8 @@ static void mem_benchmark_task()
void* buf1 = 0;
void* buf2 = 0;
buf1 = tmp_malloc(bufsize);
buf2 = tmp_malloc(bufsize);
buf1 = fio_malloc(bufsize);
buf2 = fio_malloc(bufsize);
if (!buf1 || !buf2)
{
bmp_printf(FONT_LARGE, 0, 0, "malloc error :(");
......@@ -177,7 +179,7 @@ static void mem_benchmark_task()
if (HAS_EDMAC_MEMCPY)
{
mem_benchmark_run("edmac_memcpy ", &y, bufsize, (mem_bench_fun)edmac_memcpy, (intptr_t)buf1, (intptr_t)buf2, bufsize, 0);
mem_benchmark_run("edmac_memcpy ", &y, bufsize, (mem_bench_fun)edmac_memcpy, (intptr_t)UNCACHEABLE(buf1), (intptr_t)UNCACHEABLE(buf2), bufsize, 0);
mem_benchmark_run("edmac_copy_rectangle", &y, 720*480, (mem_bench_fun)mem_test_edmac_copy_rectangle, 0, 0, 0, 0);
}
......@@ -199,6 +201,6 @@ static void mem_benchmark_task()
canon_gui_enable_front_buffer(0);
cleanup:
if (buf1) tmp_free(buf1);
if (buf2) tmp_free(buf2);
if (buf1) free(buf1);
if (buf2) free(buf2);
}
......@@ -156,15 +156,26 @@ static void stub_test_cache_bmp()
clrscr();
bmp_draw_scaled_ex(bmp, os.x0, os.y0, os.x_ex, os.y_ex, bvram_mirror);
if (k == 1)
{
/* make sure the data is written to physical memory */
clean_d_cache();
}
/* copy the image to idle buffer using EDMAC */
uint8_t * src = bmp_vram_real();
uint8_t * dst = bmp_vram_idle();
ASSERT(src == CACHEABLE(src));
ASSERT(dst == CACHEABLE(dst));
if (k == 0)
{
/* trick the copying routine so it doesn't handle caching issues.
* these pointers are actually cacheable (for speed reasons);
* flagging them as uncacheable has no effect on DMA behavior.
* this test should fail. */
src = UNCACHEABLE(src);
}
/* mark destination as uncacheable (the EDMAC routine expects it this way) */
/* this is generally incorrect; you should use fio_malloc instead. */
dst = UNCACHEABLE(dst);
edmac_copy_rectangle_adv_start(dst, src, 960, 0, 0, 960, 0, 0, 720, 480);
/* wait for EDMAC transfer to finish */
......
......@@ -111,6 +111,16 @@ void* edmac_copy_rectangle_cbr_start(void* dst, void* src, int src_width, int sr
if (dst_width % 8)
return 0;
/* make sure we are writing to uncacheable memory */
ASSERT(dst == UNCACHEABLE(dst));
/* clean the cache before reading from regular (cacheable) memory */
/* see FIO_WriteFile for more info */
if (src == CACHEABLE(src))
{
clean_d_cache();
}
take_semaphore(edmac_memcpy_sem, 0);
/* see wiki, register map, EDMAC what the flags mean. they are for setting up copy block size */
......
......@@ -47,7 +47,7 @@ const char * format_memory_size(uint64_t size); /* e.g. 2.0GB, 32MB, 2.4kB... */
#define tmp_malloc(len) __mem_malloc(len, MEM_TEMPORARY, __FILE__, __LINE__)
#define tmp_free free
/* allocate temporary memory for reading files */
/* allocate temporary memory for reading files or for DMA operations */
/* (very large buffers will prefer SRM, smaller ones will use shoot_malloc / alloc_dma_memory) */
#define fio_malloc(len) __mem_malloc(len, (len > 20*1024*1024 ? MEM_SRM : MEM_TEMPORARY) | MEM_DMA, __FILE__, __LINE__)
#define fio_free free
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment