cacheflush.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  4. *
  5. * vineetg: May 2011: for Non-aliasing VIPT D-cache following can be NOPs
  6. * -flush_cache_dup_mm (fork)
  7. * -likewise for flush_cache_mm (exit/execve)
  8. * -likewise for flush_cache_{range,page} (munmap, exit, COW-break)
  9. *
  10. * vineetg: April 2008
  11. * -Added a critical CacheLine flush to copy_to_user_page( ) which
  12. * was causing gdbserver to not setup breakpoints consistently
  13. */
  14. #ifndef _ASM_CACHEFLUSH_H
  15. #define _ASM_CACHEFLUSH_H
  16. #include <linux/mm.h>
  17. #include <asm/shmparam.h>
  18. void flush_cache_all(void);
  19. void flush_icache_range(unsigned long kstart, unsigned long kend);
  20. void __sync_icache_dcache(phys_addr_t paddr, unsigned long vaddr, int len);
  21. void __inv_icache_pages(phys_addr_t paddr, unsigned long vaddr, unsigned nr);
  22. void __flush_dcache_pages(phys_addr_t paddr, unsigned long vaddr, unsigned nr);
  23. #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
  24. void flush_dcache_page(struct page *page);
  25. void flush_dcache_folio(struct folio *folio);
  26. #define flush_dcache_folio flush_dcache_folio
  27. void dma_cache_wback_inv(phys_addr_t start, unsigned long sz);
  28. void dma_cache_inv(phys_addr_t start, unsigned long sz);
  29. void dma_cache_wback(phys_addr_t start, unsigned long sz);
  30. #define flush_dcache_mmap_lock(mapping) do { } while (0)
  31. #define flush_dcache_mmap_unlock(mapping) do { } while (0)
  32. /* TBD: optimize this */
  33. #define flush_cache_vmap(start, end) flush_cache_all()
  34. #define flush_cache_vmap_early(start, end) do { } while (0)
  35. #define flush_cache_vunmap(start, end) flush_cache_all()
  36. #define flush_cache_dup_mm(mm) /* called on fork (VIVT only) */
  37. #define flush_cache_mm(mm) /* called on munmap/exit */
  38. #define flush_cache_range(mm, u_vstart, u_vend)
  39. #define flush_cache_page(vma, u_vaddr, pfn) /* PF handling/COW-break */
  40. /*
  41. * A new pagecache page has PG_arch_1 clear - thus dcache dirty by default
  42. * This works around some PIO based drivers which don't call flush_dcache_page
  43. * to record that they dirtied the dcache
  44. */
  45. #define PG_dc_clean PG_arch_1
  46. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  47. do { \
  48. memcpy(dst, src, len); \
  49. if (vma->vm_flags & VM_EXEC) \
  50. __sync_icache_dcache((unsigned long)(dst), vaddr, len); \
  51. } while (0)
  52. #define copy_from_user_page(vma, page, vaddr, dst, src, len) \
  53. memcpy(dst, src, len); \
  54. #endif