cache-smp.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SMP caching definitions
  2. *
  3. * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. /*
  12. * Operation requests for smp_cache_call().
  13. *
  14. * One of smp_icache_ops and one of smp_dcache_ops can be OR'd together.
  15. */
  16. enum smp_icache_ops {
  17. SMP_ICACHE_NOP = 0x0000,
  18. SMP_ICACHE_INV = 0x0001,
  19. SMP_ICACHE_INV_RANGE = 0x0002,
  20. };
  21. #define SMP_ICACHE_OP_MASK 0x0003
  22. enum smp_dcache_ops {
  23. SMP_DCACHE_NOP = 0x0000,
  24. SMP_DCACHE_INV = 0x0004,
  25. SMP_DCACHE_INV_RANGE = 0x0008,
  26. SMP_DCACHE_FLUSH = 0x000c,
  27. SMP_DCACHE_FLUSH_RANGE = 0x0010,
  28. SMP_DCACHE_FLUSH_INV = 0x0014,
  29. SMP_DCACHE_FLUSH_INV_RANGE = 0x0018,
  30. };
  31. #define SMP_DCACHE_OP_MASK 0x001c
  32. #define SMP_IDCACHE_INV_FLUSH (SMP_ICACHE_INV | SMP_DCACHE_FLUSH)
  33. #define SMP_IDCACHE_INV_FLUSH_RANGE (SMP_ICACHE_INV_RANGE | SMP_DCACHE_FLUSH_RANGE)
  34. /*
  35. * cache-smp.c
  36. */
  37. #ifdef CONFIG_SMP
  38. extern spinlock_t smp_cache_lock;
  39. extern void smp_cache_call(unsigned long opr_mask,
  40. unsigned long addr, unsigned long end);
  41. static inline unsigned long smp_lock_cache(void)
  42. __acquires(&smp_cache_lock)
  43. {
  44. unsigned long flags;
  45. spin_lock_irqsave(&smp_cache_lock, flags);
  46. return flags;
  47. }
  48. static inline void smp_unlock_cache(unsigned long flags)
  49. __releases(&smp_cache_lock)
  50. {
  51. spin_unlock_irqrestore(&smp_cache_lock, flags);
  52. }
  53. #else
  54. static inline unsigned long smp_lock_cache(void) { return 0; }
  55. static inline void smp_unlock_cache(unsigned long flags) {}
  56. static inline void smp_cache_call(unsigned long opr_mask,
  57. unsigned long addr, unsigned long end)
  58. {
  59. }
  60. #endif /* CONFIG_SMP */