Merge branch 'topic-0620/samsung-audio-3.4' into chromeos-exynos-3.4
[cascardo/linux.git] / drivers / gpu / vithar / kbase / src / common / mali_kbase_cache_policy.c
1 /*
2  * This confidential and proprietary software may be used only as
3  * authorised by a licensing agreement from ARM Limited
4  * (C) COPYRIGHT 2012 ARM Limited
5  * ALL RIGHTS RESERVED
6  * The entire notice above must be reproduced on all authorised
7  * copies and copies may only be made to the extent permitted
8  * by a licensing agreement from ARM Limited.
9  */
10
11 /**
12  * @file mali_kbase_cache_policy.h
13  * Cache Policy API.
14  */
15
16 #include "mali_kbase_cache_policy.h"
17
18 /*
19  * The output flags should be a combination of the following values:
20  * KBASE_REG_CPU_CACHED: CPU cache should be enabled
21  * KBASE_REG_GPU_CACHED: GPU cache should be enabled
22  *
23  * The input flags may contain a combination of hints:
24  * BASE_MEM_HINT_CPU_RD: region heavily read CPU side
25  * BASE_MEM_HINT_CPU_WR: region heavily written CPU side
26  * BASE_MEM_HINT_GPU_RD: region heavily read GPU side
27  * BASE_MEM_HINT_GPU_WR: region heavily written GPU side
28  */
29 u32 kbase_cache_enabled(u32 flags, u32 nr_pages)
30 {
31         u32 cache_flags = 0;
32
33         CSTD_UNUSED(nr_pages);
34
35         /* The CPU cache should be enabled for regions heavily read and written
36          * from the CPU side
37          */
38 #if !MALI_UNCACHED
39         if ((flags & BASE_MEM_HINT_CPU_RD) && (flags & BASE_MEM_HINT_CPU_WR))
40         {
41                 cache_flags |= KBASE_REG_CPU_CACHED;
42         }
43 #endif
44
45         /* The GPU cache should be enabled for regions heavily read and written
46          * from the GPU side
47          */
48         if ((flags & BASE_MEM_HINT_GPU_RD) && (flags & BASE_MEM_HINT_GPU_WR))
49         {
50                 cache_flags |= KBASE_REG_GPU_CACHED;
51         }
52
53         return cache_flags;
54 }