flush.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Cache flushing routines.
  4. *
  5. * Copyright (C) 1999-2001, 2005 Hewlett-Packard Co
  6. * David Mosberger-Tang <[email protected]>
  7. *
  8. * 05/28/05 Zoltan Menyhart Dynamic stride size
  9. */
  10. #include <asm/asmmacro.h>
  11. #include <asm/export.h>
  12. /*
  13. * flush_icache_range(start,end)
  14. *
  15. * Make i-cache(s) coherent with d-caches.
  16. *
  17. * Must deal with range from start to end-1 but nothing else (need to
  18. * be careful not to touch addresses that may be unmapped).
  19. *
  20. * Note: "in0" and "in1" are preserved for debugging purposes.
  21. */
  22. .section .kprobes.text,"ax"
  23. GLOBAL_ENTRY(flush_icache_range)
  24. .prologue
  25. alloc r2=ar.pfs,2,0,0,0
  26. movl r3=ia64_i_cache_stride_shift
  27. mov r21=1
  28. ;;
  29. ld8 r20=[r3] // r20: stride shift
  30. sub r22=in1,r0,1 // last byte address
  31. ;;
  32. shr.u r23=in0,r20 // start / (stride size)
  33. shr.u r22=r22,r20 // (last byte address) / (stride size)
  34. shl r21=r21,r20 // r21: stride size of the i-cache(s)
  35. ;;
  36. sub r8=r22,r23 // number of strides - 1
  37. shl r24=r23,r20 // r24: addresses for "fc.i" =
  38. // "start" rounded down to stride boundary
  39. .save ar.lc,r3
  40. mov r3=ar.lc // save ar.lc
  41. ;;
  42. .body
  43. mov ar.lc=r8
  44. ;;
  45. /*
  46. * 32 byte aligned loop, even number of (actually 2) bundles
  47. */
  48. .Loop: fc.i r24 // issuable on M0 only
  49. add r24=r21,r24 // we flush "stride size" bytes per iteration
  50. nop.i 0
  51. br.cloop.sptk.few .Loop
  52. ;;
  53. sync.i
  54. ;;
  55. srlz.i
  56. ;;
  57. mov ar.lc=r3 // restore ar.lc
  58. br.ret.sptk.many rp
  59. END(flush_icache_range)
  60. EXPORT_SYMBOL_GPL(flush_icache_range)
  61. /*
  62. * clflush_cache_range(start,size)
  63. *
  64. * Flush cache lines from start to start+size-1.
  65. *
  66. * Must deal with range from start to start+size-1 but nothing else
  67. * (need to be careful not to touch addresses that may be
  68. * unmapped).
  69. *
  70. * Note: "in0" and "in1" are preserved for debugging purposes.
  71. */
  72. .section .kprobes.text,"ax"
  73. GLOBAL_ENTRY(clflush_cache_range)
  74. .prologue
  75. alloc r2=ar.pfs,2,0,0,0
  76. movl r3=ia64_cache_stride_shift
  77. mov r21=1
  78. add r22=in1,in0
  79. ;;
  80. ld8 r20=[r3] // r20: stride shift
  81. sub r22=r22,r0,1 // last byte address
  82. ;;
  83. shr.u r23=in0,r20 // start / (stride size)
  84. shr.u r22=r22,r20 // (last byte address) / (stride size)
  85. shl r21=r21,r20 // r21: stride size of the i-cache(s)
  86. ;;
  87. sub r8=r22,r23 // number of strides - 1
  88. shl r24=r23,r20 // r24: addresses for "fc" =
  89. // "start" rounded down to stride
  90. // boundary
  91. .save ar.lc,r3
  92. mov r3=ar.lc // save ar.lc
  93. ;;
  94. .body
  95. mov ar.lc=r8
  96. ;;
  97. /*
  98. * 32 byte aligned loop, even number of (actually 2) bundles
  99. */
  100. .Loop_fc:
  101. fc r24 // issuable on M0 only
  102. add r24=r21,r24 // we flush "stride size" bytes per iteration
  103. nop.i 0
  104. br.cloop.sptk.few .Loop_fc
  105. ;;
  106. sync.i
  107. ;;
  108. srlz.i
  109. ;;
  110. mov ar.lc=r3 // restore ar.lc
  111. br.ret.sptk.many rp
  112. END(clflush_cache_range)