42
42
static struct list_head softirq_dev_entry_list ;
43
43
/* passthrough device link */
44
44
static struct list_head ptdev_list ;
45
+ static spinlock_t ptdev_lock ;
45
46
46
47
/*
47
48
* entry could both be in ptdev_list and softirq_dev_entry_list.
48
49
* When release entry, we need make sure entry deleted from both
49
50
* lists. We have to require two locks and the lock sequence is:
50
- * vm-> ptdev_lock
51
+ * ptdev_lock
51
52
* softirq_dev_lock
52
53
*/
53
54
static spinlock_t softirq_dev_lock ;
@@ -115,9 +116,9 @@ get_remapping_entry(struct vm *vm, uint32_t id)
115
116
{
116
117
struct ptdev_remapping_info * entry ;
117
118
118
- spinlock_obtain (& vm -> ptdev_lock );
119
+ spinlock_obtain (& ptdev_lock );
119
120
entry = _get_remapping_entry (vm , id );
120
- spinlock_release (& vm -> ptdev_lock );
121
+ spinlock_release (& ptdev_lock );
121
122
return entry ;
122
123
}
123
124
@@ -297,7 +298,7 @@ static void check_deactive_pic_intx(struct vm *vm, uint8_t phys_pin)
297
298
if (phys_pin >= NR_LEGACY_IRQ )
298
299
return ;
299
300
300
- spinlock_obtain (& vm -> ptdev_lock );
301
+ spinlock_obtain (& ptdev_lock );
301
302
list_for_each (pos , & ptdev_list ) {
302
303
entry = list_entry (pos , struct ptdev_remapping_info ,
303
304
entry_node );
@@ -315,7 +316,7 @@ static void check_deactive_pic_intx(struct vm *vm, uint8_t phys_pin)
315
316
entry -> vm -> attr .id , entry -> intx .virt_pin );
316
317
}
317
318
}
318
- spinlock_release (& vm -> ptdev_lock );
319
+ spinlock_release (& ptdev_lock );
319
320
}
320
321
321
322
static bool ptdev_native_owned_intx (struct vm * vm , struct ptdev_intx_info * info )
@@ -430,7 +431,7 @@ add_msix_remapping(struct vm *vm, uint16_t virt_bdf, uint16_t phys_bdf,
430
431
{
431
432
struct ptdev_remapping_info * entry ;
432
433
433
- spinlock_obtain (& vm -> ptdev_lock );
434
+ spinlock_obtain (& ptdev_lock );
434
435
entry = _get_remapping_entry (vm ,
435
436
entry_id_from_msix (virt_bdf , msix_entry_index ));
436
437
if (!entry ) {
@@ -439,7 +440,7 @@ add_msix_remapping(struct vm *vm, uint16_t virt_bdf, uint16_t phys_bdf,
439
440
entry -> phys_bdf = phys_bdf ;
440
441
entry -> msi .msix_entry_index = msix_entry_index ;
441
442
}
442
- spinlock_release (& vm -> ptdev_lock );
443
+ spinlock_release (& ptdev_lock );
443
444
444
445
dev_dbg (ACRN_DBG_IRQ ,
445
446
"VM%d MSIX add vector mapping vbdf%x:pbdf%x idx=%d" ,
@@ -453,7 +454,7 @@ remove_msix_remapping(struct vm *vm, uint16_t virt_bdf, int msix_entry_index)
453
454
{
454
455
struct ptdev_remapping_info * entry ;
455
456
456
- spinlock_obtain (& vm -> ptdev_lock );
457
+ spinlock_obtain (& ptdev_lock );
457
458
entry = _get_remapping_entry (vm ,
458
459
entry_id_from_msix (virt_bdf , msix_entry_index ));
459
460
if (!entry )
@@ -471,7 +472,7 @@ remove_msix_remapping(struct vm *vm, uint16_t virt_bdf, int msix_entry_index)
471
472
release_entry (entry );
472
473
473
474
END :
474
- spinlock_release (& vm -> ptdev_lock );
475
+ spinlock_release (& ptdev_lock );
475
476
476
477
}
477
478
@@ -483,7 +484,7 @@ add_intx_remapping(struct vm *vm, uint8_t virt_pin, uint8_t phys_pin, bool pic_p
483
484
enum ptdev_vpin_source vpin_src =
484
485
pic_pin ? PTDEV_VPIN_PIC : PTDEV_VPIN_IOAPIC ;
485
486
486
- spinlock_obtain (& vm -> ptdev_lock );
487
+ spinlock_obtain (& ptdev_lock );
487
488
entry = _get_remapping_entry (vm ,
488
489
entry_id_from_intx (virt_pin , vpin_src ));
489
490
if (!entry ) {
@@ -494,7 +495,7 @@ add_intx_remapping(struct vm *vm, uint8_t virt_pin, uint8_t phys_pin, bool pic_p
494
495
/* update existing */
495
496
entry -> intx .virt_pin = virt_pin ;
496
497
entry -> intx .phys_pin = phys_pin ;
497
- spinlock_release (& vm -> ptdev_lock );
498
+ spinlock_release (& ptdev_lock );
498
499
499
500
dev_dbg (ACRN_DBG_IRQ ,
500
501
"VM%d INTX add pin mapping vpin%d:ppin%d" ,
@@ -511,7 +512,7 @@ void remove_intx_remapping(struct vm *vm, uint8_t virt_pin, bool pic_pin)
511
512
enum ptdev_vpin_source vpin_src =
512
513
pic_pin ? PTDEV_VPIN_PIC : PTDEV_VPIN_IOAPIC ;
513
514
514
- spinlock_obtain (& vm -> ptdev_lock );
515
+ spinlock_obtain (& ptdev_lock );
515
516
entry = _get_remapping_entry (vm ,
516
517
entry_id_from_intx (virt_pin , vpin_src ));
517
518
if (!entry )
@@ -537,7 +538,7 @@ void remove_intx_remapping(struct vm *vm, uint8_t virt_pin, bool pic_pin)
537
538
release_entry (entry );
538
539
539
540
END :
540
- spinlock_release (& vm -> ptdev_lock );
541
+ spinlock_release (& ptdev_lock );
541
542
}
542
543
543
544
static void ptdev_intr_handle_irq (struct vm * vm ,
@@ -860,21 +861,17 @@ void ptdev_init(void)
860
861
return ;
861
862
862
863
INIT_LIST_HEAD (& ptdev_list );
864
+ spinlock_init (& ptdev_lock );
863
865
INIT_LIST_HEAD (& softirq_dev_entry_list );
864
866
spinlock_init (& softirq_dev_lock );
865
867
}
866
868
867
- void ptdev_vm_init (struct vm * vm )
868
- {
869
- spinlock_init (& vm -> ptdev_lock );
870
- }
871
-
872
869
void ptdev_vm_deinit (struct vm * vm )
873
870
{
874
871
/* VM already down */
875
- spinlock_obtain (& vm -> ptdev_lock );
872
+ spinlock_obtain (& ptdev_lock );
876
873
release_all_entry (vm );
877
- spinlock_release (& vm -> ptdev_lock );
874
+ spinlock_release (& ptdev_lock );
878
875
}
879
876
880
877
void ptdev_add_intx_remapping (struct vm * vm ,
@@ -979,33 +976,29 @@ int get_ptdev_info(char *str, int str_max)
979
976
uint64_t dest ;
980
977
bool lvl_tm ;
981
978
int pin , vpin , bdf , vbdf ;
982
- struct list_head * pos , * vm_pos ;
983
- struct vm * vm ;
979
+ struct list_head * pos ;
984
980
985
981
len = snprintf (str , size ,
986
982
"\r\nVM\tTYPE\tIRQ\tVEC\tDEST\tTM\tPIN\tVPIN\tBDF\tVBDF" );
987
983
size -= len ;
988
984
str += len ;
989
985
990
- spinlock_obtain (& vm_list_lock );
991
- list_for_each (vm_pos , & vm_list ) {
992
- vm = list_entry (vm_pos , struct vm , list );
993
- spinlock_obtain (& vm -> ptdev_lock );
994
- list_for_each (pos , & ptdev_list ) {
995
- entry = list_entry (pos , struct ptdev_remapping_info ,
996
- entry_node );
997
- if (entry_is_active (entry )) {
998
- get_entry_info (entry , type , & irq , & vector ,
986
+ spinlock_obtain (& ptdev_lock );
987
+ list_for_each (pos , & ptdev_list ) {
988
+ entry = list_entry (pos , struct ptdev_remapping_info ,
989
+ entry_node );
990
+ if (entry_is_active (entry )) {
991
+ get_entry_info (entry , type , & irq , & vector ,
999
992
& dest , & lvl_tm , & pin , & vpin ,
1000
993
& bdf , & vbdf );
1001
- len = snprintf (str , size ,
994
+ len = snprintf (str , size ,
1002
995
"\r\n%d\t%s\t%d\t0x%X\t0x%X" ,
1003
996
entry -> vm -> attr .id , type ,
1004
997
irq , vector , dest );
1005
- size -= len ;
1006
- str += len ;
998
+ size -= len ;
999
+ str += len ;
1007
1000
1008
- len = snprintf (str , size ,
1001
+ len = snprintf (str , size ,
1009
1002
"\t%s\t%d\t%d\t%x:%x.%x\t%x:%x.%x" ,
1010
1003
entry_is_active (entry ) ?
1011
1004
(lvl_tm ? "level" : "edge" ) : "none" ,
@@ -1014,13 +1007,11 @@ int get_ptdev_info(char *str, int str_max)
1014
1007
(bdf & 0xf8 ) >> 3 , bdf & 0x7 ,
1015
1008
(vbdf & 0xff00 ) >> 8 ,
1016
1009
(vbdf & 0xf8 ) >> 3 , vbdf & 0x7 );
1017
- size -= len ;
1018
- str += len ;
1019
- }
1010
+ size -= len ;
1011
+ str += len ;
1020
1012
}
1021
- spinlock_release (& vm -> ptdev_lock );
1022
1013
}
1023
- spinlock_release (& vm_list_lock );
1014
+ spinlock_release (& ptdev_lock );
1024
1015
1025
1016
snprintf (str , size , "\r\n" );
1026
1017
return 0 ;
0 commit comments