Skip to content

Commit 2edd9cb

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
kvm: detect assigned device via irqbypass manager
vDPA devices has dedicated backed hardware like passthrough-ed devices. Then it is possible to setup irq offloading to vCPU for vDPA devices. Thus this patch tries to manipulated assigned device counters by kvm_arch_start/end_assignment() in irqbypass manager, so that assigned devices could be detected in update_pi_irte() We will increase/decrease the assigned device counter in kvm/x86. Both vDPA and VFIO would go through this code path. Only X86 uses these counters and kvm_arch_start/end_assignment(), so this code path only affect x86 for now. Signed-off-by: Zhu Lingshan <[email protected]> Suggested-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 265a0ad commit 2edd9cb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

arch/x86/kvm/x86.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10630,11 +10630,17 @@ int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
1063010630
{
1063110631
struct kvm_kernel_irqfd *irqfd =
1063210632
container_of(cons, struct kvm_kernel_irqfd, consumer);
10633+
int ret;
1063310634

1063410635
irqfd->producer = prod;
10636+
kvm_arch_start_assignment(irqfd->kvm);
10637+
ret = kvm_x86_ops.update_pi_irte(irqfd->kvm,
10638+
prod->irq, irqfd->gsi, 1);
10639+
10640+
if (ret)
10641+
kvm_arch_end_assignment(irqfd->kvm);
1063510642

10636-
return kvm_x86_ops.update_pi_irte(irqfd->kvm,
10637-
prod->irq, irqfd->gsi, 1);
10643+
return ret;
1063810644
}
1063910645

1064010646
void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
@@ -10657,6 +10663,8 @@ void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
1065710663
if (ret)
1065810664
printk(KERN_INFO "irq bypass consumer (token %p) unregistration"
1065910665
" fails: %d\n", irqfd->consumer.token, ret);
10666+
10667+
kvm_arch_end_assignment(irqfd->kvm);
1066010668
}
1066110669

1066210670
int kvm_arch_update_irqfd_routing(struct kvm *kvm, unsigned int host_irq,

0 commit comments

Comments
 (0)