cxl-base.h 1017 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2014 IBM Corp.
  4. */
  5. #ifndef _MISC_CXL_BASE_H
  6. #define _MISC_CXL_BASE_H
  7. #ifdef CONFIG_CXL_BASE
  8. #define CXL_IRQ_RANGES 4
  9. struct cxl_irq_ranges {
  10. irq_hw_number_t offset[CXL_IRQ_RANGES];
  11. irq_hw_number_t range[CXL_IRQ_RANGES];
  12. };
  13. extern atomic_t cxl_use_count;
  14. static inline bool cxl_ctx_in_use(void)
  15. {
  16. return (atomic_read(&cxl_use_count) != 0);
  17. }
  18. static inline void cxl_ctx_get(void)
  19. {
  20. atomic_inc(&cxl_use_count);
  21. }
  22. static inline void cxl_ctx_put(void)
  23. {
  24. atomic_dec(&cxl_use_count);
  25. }
  26. struct cxl_afu *cxl_afu_get(struct cxl_afu *afu);
  27. void cxl_afu_put(struct cxl_afu *afu);
  28. void cxl_slbia(struct mm_struct *mm);
  29. #else /* CONFIG_CXL_BASE */
  30. static inline bool cxl_ctx_in_use(void) { return false; }
  31. static inline struct cxl_afu *cxl_afu_get(struct cxl_afu *afu) { return NULL; }
  32. static inline void cxl_afu_put(struct cxl_afu *afu) {}
  33. static inline void cxl_slbia(struct mm_struct *mm) {}
  34. #endif /* CONFIG_CXL_BASE */
  35. #endif