1 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
2 /*
3 *
4 * (C) COPYRIGHT 2012-2018, 2020-2021 ARM Limited. All rights reserved.
5 *
6 * This program is free software and is provided to you under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation, and any use by you of this program is subject to the terms
9 * of such GNU license.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you can access it online at
18 * http://www.gnu.org/licenses/gpl-2.0.html.
19 *
20 */
21
22 /*
23 * Cache Policy API.
24 */
25
26 #include "mali_kbase_cache_policy.h"
27
28 /*
29 * The output flags should be a combination of the following values:
30 * KBASE_REG_CPU_CACHED: CPU cache should be enabled
31 * KBASE_REG_GPU_CACHED: GPU cache should be enabled
32 *
33 * NOTE: Some components within the GPU might only be able to access memory
34 * that is KBASE_REG_GPU_CACHED. Refer to the specific GPU implementation for
35 * more details.
36 */
kbase_cache_enabled(u32 flags,u32 nr_pages)37 u32 kbase_cache_enabled(u32 flags, u32 nr_pages)
38 {
39 u32 cache_flags = 0;
40
41 CSTD_UNUSED(nr_pages);
42
43 if (!(flags & BASE_MEM_UNCACHED_GPU))
44 cache_flags |= KBASE_REG_GPU_CACHED;
45
46 if (flags & BASE_MEM_CACHED_CPU)
47 cache_flags |= KBASE_REG_CPU_CACHED;
48
49 return cache_flags;
50 }
51
52
kbase_sync_single_for_device(struct kbase_device * kbdev,dma_addr_t handle,size_t size,enum dma_data_direction dir)53 void kbase_sync_single_for_device(struct kbase_device *kbdev, dma_addr_t handle,
54 size_t size, enum dma_data_direction dir)
55 {
56 dma_sync_single_for_device(kbdev->dev, handle, size, dir);
57 }
58 KBASE_EXPORT_TEST_API(kbase_sync_single_for_device);
59
kbase_sync_single_for_cpu(struct kbase_device * kbdev,dma_addr_t handle,size_t size,enum dma_data_direction dir)60 void kbase_sync_single_for_cpu(struct kbase_device *kbdev, dma_addr_t handle,
61 size_t size, enum dma_data_direction dir)
62 {
63 dma_sync_single_for_cpu(kbdev->dev, handle, size, dir);
64 }
65 KBASE_EXPORT_TEST_API(kbase_sync_single_for_cpu);
66