mb.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* mb.S: Out of line memory barriers.
  2. *
  3. * Copyright (C) 2005 David S. Miller (davem@davemloft.net)
  4. */
  5. /* These are here in an effort to more fully work around
  6. * Spitfire Errata #51. Essentially, if a memory barrier
  7. * occurs soon after a mispredicted branch, the chip can stop
  8. * executing instructions until a trap occurs. Therefore, if
  9. * interrupts are disabled, the chip can hang forever.
  10. *
  11. * It used to be believed that the memory barrier had to be
  12. * right in the delay slot, but a case has been traced
  13. * recently wherein the memory barrier was one instruction
  14. * after the branch delay slot and the chip still hung. The
  15. * offending sequence was the following in sym_wakeup_done()
  16. * of the sym53c8xx_2 driver:
  17. *
  18. * call sym_ccb_from_dsa, 0
  19. * movge %icc, 0, %l0
  20. * brz,pn %o0, .LL1303
  21. * mov %o0, %l2
  22. * membar #LoadLoad
  23. *
  24. * The branch has to be mispredicted for the bug to occur.
  25. * Therefore, we put the memory barrier explicitly into a
  26. * "branch always, predicted taken" delay slot to avoid the
  27. * problem case.
  28. */
  29. .text
  30. 99: retl
  31. nop
  32. .globl mb
  33. mb: ba,pt %xcc, 99b
  34. membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad
  35. .size mb, .-mb
  36. .globl rmb
  37. rmb: ba,pt %xcc, 99b
  38. membar #LoadLoad
  39. .size rmb, .-rmb
  40. .globl wmb
  41. wmb: ba,pt %xcc, 99b
  42. membar #StoreStore
  43. .size wmb, .-wmb
  44. .globl membar_storeload
  45. membar_storeload:
  46. ba,pt %xcc, 99b
  47. membar #StoreLoad
  48. .size membar_storeload, .-membar_storeload
  49. .globl membar_storeload_storestore
  50. membar_storeload_storestore:
  51. ba,pt %xcc, 99b
  52. membar #StoreLoad | #StoreStore
  53. .size membar_storeload_storestore, .-membar_storeload_storestore
  54. .globl membar_storeload_loadload
  55. membar_storeload_loadload:
  56. ba,pt %xcc, 99b
  57. membar #StoreLoad | #LoadLoad
  58. .size membar_storeload_loadload, .-membar_storeload_loadload
  59. .globl membar_storestore_loadstore
  60. membar_storestore_loadstore:
  61. ba,pt %xcc, 99b
  62. membar #StoreStore | #LoadStore
  63. .size membar_storestore_loadstore, .-membar_storestore_loadstore