xref: /openbmc/linux/include/misc/cxl-base.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*2874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2ec249dd8SMichael Neuling /*
3ec249dd8SMichael Neuling  * Copyright 2014 IBM Corp.
4ec249dd8SMichael Neuling  */
5ec249dd8SMichael Neuling 
6ec249dd8SMichael Neuling #ifndef _MISC_CXL_BASE_H
7ec249dd8SMichael Neuling #define _MISC_CXL_BASE_H
8ec249dd8SMichael Neuling 
9ec249dd8SMichael Neuling #ifdef CONFIG_CXL_BASE
10ec249dd8SMichael Neuling 
11ec249dd8SMichael Neuling #define CXL_IRQ_RANGES 4
12ec249dd8SMichael Neuling 
13ec249dd8SMichael Neuling struct cxl_irq_ranges {
14ec249dd8SMichael Neuling 	irq_hw_number_t offset[CXL_IRQ_RANGES];
15ec249dd8SMichael Neuling 	irq_hw_number_t range[CXL_IRQ_RANGES];
16ec249dd8SMichael Neuling };
17ec249dd8SMichael Neuling 
18ec249dd8SMichael Neuling extern atomic_t cxl_use_count;
19ec249dd8SMichael Neuling 
cxl_ctx_in_use(void)20ec249dd8SMichael Neuling static inline bool cxl_ctx_in_use(void)
21ec249dd8SMichael Neuling {
22ec249dd8SMichael Neuling        return (atomic_read(&cxl_use_count) != 0);
23ec249dd8SMichael Neuling }
24ec249dd8SMichael Neuling 
cxl_ctx_get(void)25ec249dd8SMichael Neuling static inline void cxl_ctx_get(void)
26ec249dd8SMichael Neuling {
27ec249dd8SMichael Neuling        atomic_inc(&cxl_use_count);
28ec249dd8SMichael Neuling }
29ec249dd8SMichael Neuling 
cxl_ctx_put(void)30ec249dd8SMichael Neuling static inline void cxl_ctx_put(void)
31ec249dd8SMichael Neuling {
32ec249dd8SMichael Neuling        atomic_dec(&cxl_use_count);
33ec249dd8SMichael Neuling }
34ec249dd8SMichael Neuling 
3562ccf2d2SIan Munsie struct cxl_afu *cxl_afu_get(struct cxl_afu *afu);
3662ccf2d2SIan Munsie void cxl_afu_put(struct cxl_afu *afu);
37ec249dd8SMichael Neuling void cxl_slbia(struct mm_struct *mm);
38ec249dd8SMichael Neuling 
39ec249dd8SMichael Neuling #else /* CONFIG_CXL_BASE */
40ec249dd8SMichael Neuling 
cxl_ctx_in_use(void)41ec249dd8SMichael Neuling static inline bool cxl_ctx_in_use(void) { return false; }
cxl_afu_get(struct cxl_afu * afu)4262ccf2d2SIan Munsie static inline struct cxl_afu *cxl_afu_get(struct cxl_afu *afu) { return NULL; }
cxl_afu_put(struct cxl_afu * afu)4362ccf2d2SIan Munsie static inline void cxl_afu_put(struct cxl_afu *afu) {}
cxl_slbia(struct mm_struct * mm)44ec249dd8SMichael Neuling static inline void cxl_slbia(struct mm_struct *mm) {}
45ec249dd8SMichael Neuling 
46ec249dd8SMichael Neuling #endif /* CONFIG_CXL_BASE */
47ec249dd8SMichael Neuling 
48ec249dd8SMichael Neuling #endif
49