|
6 | 6 |
|
7 | 7 | #include <hypervisor.h>
|
8 | 8 |
|
9 |
| -#define ACTIVE_FLAG 0x1 /* any non zero should be okay */ |
10 |
| - |
11 |
| -/* SOFTIRQ_DEV_ASSIGN list for all CPUs */ |
12 |
| -static struct list_head softirq_dev_entry_list; |
13 |
| -/* passthrough device link */ |
14 |
| -static struct list_head ptdev_list; |
15 |
| -static spinlock_t ptdev_lock; |
16 |
| - |
17 |
| -/* invalid_entry for error return */ |
18 |
| -static struct ptdev_remapping_info invalid_entry = { |
19 |
| - .type = PTDEV_INTR_INV, |
20 |
| -}; |
21 |
| - |
22 |
| -/* |
23 |
| - * entry could both be in ptdev_list and softirq_dev_entry_list. |
24 |
| - * When release entry, we need make sure entry deleted from both |
25 |
| - * lists. We have to require two locks and the lock sequence is: |
26 |
| - * ptdev_lock |
27 |
| - * softirq_dev_lock |
28 |
| - */ |
29 |
| -static spinlock_t softirq_dev_lock; |
30 |
| - |
31 | 9 | static inline uint32_t
|
32 | 10 | entry_id_from_msix(uint16_t bdf, int8_t index)
|
33 | 11 | {
|
@@ -166,105 +144,6 @@ lookup_entry_by_vintx(struct vm *vm, uint8_t vpin,
|
166 | 144 | return entry;
|
167 | 145 | }
|
168 | 146 |
|
169 |
| -static void ptdev_enqueue_softirq(struct ptdev_remapping_info *entry) |
170 |
| -{ |
171 |
| - spinlock_rflags; |
172 |
| - /* enqueue request in order, SOFTIRQ_DEV_ASSIGN will pickup */ |
173 |
| - spinlock_irqsave_obtain(&softirq_dev_lock); |
174 |
| - |
175 |
| - /* avoid adding recursively */ |
176 |
| - list_del(&entry->softirq_node); |
177 |
| - /* TODO: assert if entry already in list */ |
178 |
| - list_add_tail(&entry->softirq_node, |
179 |
| - &softirq_dev_entry_list); |
180 |
| - spinlock_irqrestore_release(&softirq_dev_lock); |
181 |
| - raise_softirq(SOFTIRQ_DEV_ASSIGN); |
182 |
| -} |
183 |
| - |
184 |
| -static struct ptdev_remapping_info* |
185 |
| -ptdev_dequeue_softirq(void) |
186 |
| -{ |
187 |
| - struct ptdev_remapping_info *entry = NULL; |
188 |
| - |
189 |
| - spinlock_rflags; |
190 |
| - spinlock_irqsave_obtain(&softirq_dev_lock); |
191 |
| - |
192 |
| - if (!list_empty(&softirq_dev_entry_list)) { |
193 |
| - entry = get_first_item(&softirq_dev_entry_list, |
194 |
| - struct ptdev_remapping_info, softirq_node); |
195 |
| - list_del_init(&entry->softirq_node); |
196 |
| - } |
197 |
| - |
198 |
| - spinlock_irqrestore_release(&softirq_dev_lock); |
199 |
| - return entry; |
200 |
| -} |
201 |
| - |
202 |
| -/* require ptdev_lock protect */ |
203 |
| -static struct ptdev_remapping_info * |
204 |
| -alloc_entry(struct vm *vm, enum ptdev_intr_type type) |
205 |
| -{ |
206 |
| - struct ptdev_remapping_info *entry; |
207 |
| - |
208 |
| - /* allocate */ |
209 |
| - entry = calloc(1, sizeof(*entry)); |
210 |
| - ASSERT(entry, "alloc memory failed"); |
211 |
| - entry->type = type; |
212 |
| - entry->vm = vm; |
213 |
| - |
214 |
| - INIT_LIST_HEAD(&entry->softirq_node); |
215 |
| - INIT_LIST_HEAD(&entry->entry_node); |
216 |
| - |
217 |
| - atomic_clear_int(&entry->active, ACTIVE_FLAG); |
218 |
| - list_add(&entry->entry_node, &ptdev_list); |
219 |
| - |
220 |
| - return entry; |
221 |
| -} |
222 |
| - |
223 |
| -/* require ptdev_lock protect */ |
224 |
| -static void |
225 |
| -release_entry(struct ptdev_remapping_info *entry) |
226 |
| -{ |
227 |
| - spinlock_rflags; |
228 |
| - |
229 |
| - /* remove entry from ptdev_list */ |
230 |
| - list_del_init(&entry->entry_node); |
231 |
| - |
232 |
| - /* |
233 |
| - * remove entry from softirq list.the ptdev_lock |
234 |
| - * is required before calling release_entry. |
235 |
| - */ |
236 |
| - spinlock_irqsave_obtain(&softirq_dev_lock); |
237 |
| - list_del_init(&entry->softirq_node); |
238 |
| - spinlock_irqrestore_release(&softirq_dev_lock); |
239 |
| - |
240 |
| - free(entry); |
241 |
| -} |
242 |
| - |
243 |
| -/* require ptdev_lock protect */ |
244 |
| -static void |
245 |
| -release_all_entries(struct vm *vm) |
246 |
| -{ |
247 |
| - struct ptdev_remapping_info *entry; |
248 |
| - struct list_head *pos, *tmp; |
249 |
| - |
250 |
| - list_for_each_safe(pos, tmp, &ptdev_list) { |
251 |
| - entry = list_entry(pos, struct ptdev_remapping_info, |
252 |
| - entry_node); |
253 |
| - if (entry->vm == vm) |
254 |
| - release_entry(entry); |
255 |
| - } |
256 |
| -} |
257 |
| - |
258 |
| -/* interrupt context */ |
259 |
| -static int ptdev_interrupt_handler(__unused int irq, void *data) |
260 |
| -{ |
261 |
| - struct ptdev_remapping_info *entry = |
262 |
| - (struct ptdev_remapping_info *) data; |
263 |
| - |
264 |
| - ptdev_enqueue_softirq(entry); |
265 |
| - return 0; |
266 |
| -} |
267 |
| - |
268 | 147 | static void
|
269 | 148 | ptdev_update_irq_handler(struct vm *vm, struct ptdev_remapping_info *entry)
|
270 | 149 | {
|
@@ -306,40 +185,6 @@ ptdev_update_irq_handler(struct vm *vm, struct ptdev_remapping_info *entry)
|
306 | 185 | }
|
307 | 186 | }
|
308 | 187 |
|
309 |
| -/* active intr with irq registering */ |
310 |
| -static struct ptdev_remapping_info * |
311 |
| -ptdev_activate_entry(struct ptdev_remapping_info *entry, uint32_t phys_irq, |
312 |
| - bool lowpri) |
313 |
| -{ |
314 |
| - struct dev_handler_node *node; |
315 |
| - |
316 |
| - /* register and allocate host vector/irq */ |
317 |
| - node = normal_register_handler(phys_irq, ptdev_interrupt_handler, |
318 |
| - (void *)entry, true, lowpri, "dev assign"); |
319 |
| - |
320 |
| - ASSERT(node != NULL, "dev register failed"); |
321 |
| - entry->node = node; |
322 |
| - |
323 |
| - atomic_set_int(&entry->active, ACTIVE_FLAG); |
324 |
| - return entry; |
325 |
| -} |
326 |
| - |
327 |
| -static void |
328 |
| -ptdev_deactivate_entry(struct ptdev_remapping_info *entry) |
329 |
| -{ |
330 |
| - spinlock_rflags; |
331 |
| - |
332 |
| - atomic_clear_int(&entry->active, ACTIVE_FLAG); |
333 |
| - |
334 |
| - unregister_handler_common(entry->node); |
335 |
| - entry->node = NULL; |
336 |
| - |
337 |
| - /* remove from softirq list if added */ |
338 |
| - spinlock_irqsave_obtain(&softirq_dev_lock); |
339 |
| - list_del_init(&entry->softirq_node); |
340 |
| - spinlock_irqrestore_release(&softirq_dev_lock); |
341 |
| -} |
342 |
| - |
343 | 188 | static bool ptdev_hv_owned_intx(struct vm *vm, struct ptdev_intx_info *info)
|
344 | 189 | {
|
345 | 190 | /* vm0 pin 4 (uart) is owned by hypervisor under debug version */
|
@@ -1068,25 +913,6 @@ void ptdev_remove_msix_remapping(struct vm *vm, uint16_t virt_bdf,
|
1068 | 913 | remove_msix_remapping(vm, virt_bdf, i);
|
1069 | 914 | }
|
1070 | 915 |
|
1071 |
| -void ptdev_init(void) |
1072 |
| -{ |
1073 |
| - if (get_cpu_id() > 0) |
1074 |
| - return; |
1075 |
| - |
1076 |
| - INIT_LIST_HEAD(&ptdev_list); |
1077 |
| - spinlock_init(&ptdev_lock); |
1078 |
| - INIT_LIST_HEAD(&softirq_dev_entry_list); |
1079 |
| - spinlock_init(&softirq_dev_lock); |
1080 |
| -} |
1081 |
| - |
1082 |
| -void ptdev_release_all_entries(struct vm *vm) |
1083 |
| -{ |
1084 |
| - /* VM already down */ |
1085 |
| - spinlock_obtain(&ptdev_lock); |
1086 |
| - release_all_entries(vm); |
1087 |
| - spinlock_release(&ptdev_lock); |
1088 |
| -} |
1089 |
| - |
1090 | 916 | static void get_entry_info(struct ptdev_remapping_info *entry, char *type,
|
1091 | 917 | uint32_t *irq, uint32_t *vector, uint64_t *dest, bool *lvl_tm,
|
1092 | 918 | int *pin, int *vpin, int *bdf, int *vbdf)
|
|
0 commit comments