diff options
Diffstat (limited to 'drivers/misc/cxl/base.c')
-rw-r--r-- | drivers/misc/cxl/base.c | 104 |
1 files changed, 99 insertions, 5 deletions
diff --git a/drivers/misc/cxl/base.c b/drivers/misc/cxl/base.c index 9b90ec6c07cd..cd54ce6f6230 100644 --- a/drivers/misc/cxl/base.c +++ b/drivers/misc/cxl/base.c | |||
@@ -54,6 +54,19 @@ static inline void cxl_calls_put(struct cxl_calls *calls) { } | |||
54 | 54 | ||
55 | #endif /* CONFIG_CXL_MODULE */ | 55 | #endif /* CONFIG_CXL_MODULE */ |
56 | 56 | ||
57 | /* AFU refcount management */ | ||
58 | struct cxl_afu *cxl_afu_get(struct cxl_afu *afu) | ||
59 | { | ||
60 | return (get_device(&afu->dev) == NULL) ? NULL : afu; | ||
61 | } | ||
62 | EXPORT_SYMBOL_GPL(cxl_afu_get); | ||
63 | |||
64 | void cxl_afu_put(struct cxl_afu *afu) | ||
65 | { | ||
66 | put_device(&afu->dev); | ||
67 | } | ||
68 | EXPORT_SYMBOL_GPL(cxl_afu_put); | ||
69 | |||
57 | void cxl_slbia(struct mm_struct *mm) | 70 | void cxl_slbia(struct mm_struct *mm) |
58 | { | 71 | { |
59 | struct cxl_calls *calls; | 72 | struct cxl_calls *calls; |
@@ -93,9 +106,92 @@ int cxl_update_properties(struct device_node *dn, | |||
93 | } | 106 | } |
94 | EXPORT_SYMBOL_GPL(cxl_update_properties); | 107 | EXPORT_SYMBOL_GPL(cxl_update_properties); |
95 | 108 | ||
109 | /* | ||
110 | * API calls into the driver that may be called from the PHB code and must be | ||
111 | * built in. | ||
112 | */ | ||
113 | bool cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu) | ||
114 | { | ||
115 | bool ret; | ||
116 | struct cxl_calls *calls; | ||
117 | |||
118 | calls = cxl_calls_get(); | ||
119 | if (!calls) | ||
120 | return false; | ||
121 | |||
122 | ret = calls->cxl_pci_associate_default_context(dev, afu); | ||
123 | |||
124 | cxl_calls_put(calls); | ||
125 | |||
126 | return ret; | ||
127 | } | ||
128 | EXPORT_SYMBOL_GPL(cxl_pci_associate_default_context); | ||
129 | |||
130 | void cxl_pci_disable_device(struct pci_dev *dev) | ||
131 | { | ||
132 | struct cxl_calls *calls; | ||
133 | |||
134 | calls = cxl_calls_get(); | ||
135 | if (!calls) | ||
136 | return; | ||
137 | |||
138 | calls->cxl_pci_disable_device(dev); | ||
139 | |||
140 | cxl_calls_put(calls); | ||
141 | } | ||
142 | EXPORT_SYMBOL_GPL(cxl_pci_disable_device); | ||
143 | |||
144 | int cxl_next_msi_hwirq(struct pci_dev *pdev, struct cxl_context **ctx, int *afu_irq) | ||
145 | { | ||
146 | int ret; | ||
147 | struct cxl_calls *calls; | ||
148 | |||
149 | calls = cxl_calls_get(); | ||
150 | if (!calls) | ||
151 | return -EBUSY; | ||
152 | |||
153 | ret = calls->cxl_next_msi_hwirq(pdev, ctx, afu_irq); | ||
154 | |||
155 | cxl_calls_put(calls); | ||
156 | |||
157 | return ret; | ||
158 | } | ||
159 | EXPORT_SYMBOL_GPL(cxl_next_msi_hwirq); | ||
160 | |||
161 | int cxl_cx4_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) | ||
162 | { | ||
163 | int ret; | ||
164 | struct cxl_calls *calls; | ||
165 | |||
166 | calls = cxl_calls_get(); | ||
167 | if (!calls) | ||
168 | return false; | ||
169 | |||
170 | ret = calls->cxl_cx4_setup_msi_irqs(pdev, nvec, type); | ||
171 | |||
172 | cxl_calls_put(calls); | ||
173 | |||
174 | return ret; | ||
175 | } | ||
176 | EXPORT_SYMBOL_GPL(cxl_cx4_setup_msi_irqs); | ||
177 | |||
178 | void cxl_cx4_teardown_msi_irqs(struct pci_dev *pdev) | ||
179 | { | ||
180 | struct cxl_calls *calls; | ||
181 | |||
182 | calls = cxl_calls_get(); | ||
183 | if (!calls) | ||
184 | return; | ||
185 | |||
186 | calls->cxl_cx4_teardown_msi_irqs(pdev); | ||
187 | |||
188 | cxl_calls_put(calls); | ||
189 | } | ||
190 | EXPORT_SYMBOL_GPL(cxl_cx4_teardown_msi_irqs); | ||
191 | |||
96 | static int __init cxl_base_init(void) | 192 | static int __init cxl_base_init(void) |
97 | { | 193 | { |
98 | struct device_node *np = NULL; | 194 | struct device_node *np; |
99 | struct platform_device *dev; | 195 | struct platform_device *dev; |
100 | int count = 0; | 196 | int count = 0; |
101 | 197 | ||
@@ -105,8 +201,7 @@ static int __init cxl_base_init(void) | |||
105 | if (cpu_has_feature(CPU_FTR_HVMODE)) | 201 | if (cpu_has_feature(CPU_FTR_HVMODE)) |
106 | return 0; | 202 | return 0; |
107 | 203 | ||
108 | while ((np = of_find_compatible_node(np, NULL, | 204 | for_each_compatible_node(np, NULL, "ibm,coherent-platform-facility") { |
109 | "ibm,coherent-platform-facility"))) { | ||
110 | dev = of_platform_device_create(np, NULL, NULL); | 205 | dev = of_platform_device_create(np, NULL, NULL); |
111 | if (dev) | 206 | if (dev) |
112 | count++; | 207 | count++; |
@@ -114,5 +209,4 @@ static int __init cxl_base_init(void) | |||
114 | pr_devel("Found %d cxl device(s)\n", count); | 209 | pr_devel("Found %d cxl device(s)\n", count); |
115 | return 0; | 210 | return 0; |
116 | } | 211 | } |
117 | 212 | device_initcall(cxl_base_init); | |
118 | module_init(cxl_base_init); | ||