mali_kbase_cache_policy.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. *
  3. * (C) COPYRIGHT 2012-2016 ARM Limited. All rights reserved.
  4. *
  5. * This program is free software and is provided to you under the terms of the
  6. * GNU General Public License version 2 as published by the Free Software
  7. * Foundation, and any use by you of this program is subject to the terms
  8. * of such GNU licence.
  9. *
  10. * A copy of the licence is included with the program, and can also be obtained
  11. * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  12. * Boston, MA 02110-1301, USA.
  13. *
  14. */
  15. /*
  16. * Cache Policy API.
  17. */
  18. #include "mali_kbase_cache_policy.h"
  19. /*
  20. * The output flags should be a combination of the following values:
  21. * KBASE_REG_CPU_CACHED: CPU cache should be enabled.
  22. */
  23. u32 kbase_cache_enabled(u32 flags, u32 nr_pages)
  24. {
  25. u32 cache_flags = 0;
  26. CSTD_UNUSED(nr_pages);
  27. if (flags & BASE_MEM_CACHED_CPU)
  28. cache_flags |= KBASE_REG_CPU_CACHED;
  29. return cache_flags;
  30. }
  31. void kbase_sync_single_for_device(struct kbase_device *kbdev, dma_addr_t handle,
  32. size_t size, enum dma_data_direction dir)
  33. {
  34. /* Check if kernel is using coherency with GPU */
  35. #ifdef CONFIG_MALI_COH_KERN
  36. if (kbdev->system_coherency == COHERENCY_ACE)
  37. return;
  38. #endif
  39. dma_sync_single_for_device(kbdev->dev, handle, size, dir);
  40. }
  41. void kbase_sync_single_for_cpu(struct kbase_device *kbdev, dma_addr_t handle,
  42. size_t size, enum dma_data_direction dir)
  43. {
  44. /* Check if kernel is using coherency with GPU */
  45. #ifdef CONFIG_MALI_COH_KERN
  46. if (kbdev->system_coherency == COHERENCY_ACE)
  47. return;
  48. #endif
  49. dma_sync_single_for_cpu(kbdev->dev, handle, size, dir);
  50. }