cxl-base.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2014 IBM Corp.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #ifndef _MISC_CXL_BASE_H
  10. #define _MISC_CXL_BASE_H
  11. #ifdef CONFIG_CXL_BASE
  12. #define CXL_IRQ_RANGES 4
  13. struct cxl_irq_ranges {
  14. irq_hw_number_t offset[CXL_IRQ_RANGES];
  15. irq_hw_number_t range[CXL_IRQ_RANGES];
  16. };
  17. extern atomic_t cxl_use_count;
  18. static inline bool cxl_ctx_in_use(void)
  19. {
  20. return (atomic_read(&cxl_use_count) != 0);
  21. }
  22. static inline void cxl_ctx_get(void)
  23. {
  24. atomic_inc(&cxl_use_count);
  25. }
  26. static inline void cxl_ctx_put(void)
  27. {
  28. atomic_dec(&cxl_use_count);
  29. }
  30. struct cxl_afu *cxl_afu_get(struct cxl_afu *afu);
  31. void cxl_afu_put(struct cxl_afu *afu);
  32. void cxl_slbia(struct mm_struct *mm);
  33. #else /* CONFIG_CXL_BASE */
  34. static inline bool cxl_ctx_in_use(void) { return false; }
  35. static inline struct cxl_afu *cxl_afu_get(struct cxl_afu *afu) { return NULL; }
  36. static inline void cxl_afu_put(struct cxl_afu *afu) {}
  37. static inline void cxl_slbia(struct mm_struct *mm) {}
  38. #endif /* CONFIG_CXL_BASE */
  39. #endif