mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 06:31:52 +00:00
kvm: Conditionally register IRQ bypass consumer
If we don't support a mechanism for bypassing IRQs, don't register as a consumer. This eliminates meaningless dev_info()s when the connect fails between producer and consumer, such as on AMD systems where kvm_x86_ops->update_pi_irte is not implemented Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
b52f3ed022
commit
14717e2031
@ -8358,19 +8358,21 @@ bool kvm_arch_has_noncoherent_dma(struct kvm *kvm)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(kvm_arch_has_noncoherent_dma);
|
EXPORT_SYMBOL_GPL(kvm_arch_has_noncoherent_dma);
|
||||||
|
|
||||||
|
bool kvm_arch_has_irq_bypass(void)
|
||||||
|
{
|
||||||
|
return kvm_x86_ops->update_pi_irte != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
|
int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
|
||||||
struct irq_bypass_producer *prod)
|
struct irq_bypass_producer *prod)
|
||||||
{
|
{
|
||||||
struct kvm_kernel_irqfd *irqfd =
|
struct kvm_kernel_irqfd *irqfd =
|
||||||
container_of(cons, struct kvm_kernel_irqfd, consumer);
|
container_of(cons, struct kvm_kernel_irqfd, consumer);
|
||||||
|
|
||||||
if (kvm_x86_ops->update_pi_irte) {
|
|
||||||
irqfd->producer = prod;
|
irqfd->producer = prod;
|
||||||
|
|
||||||
return kvm_x86_ops->update_pi_irte(irqfd->kvm,
|
return kvm_x86_ops->update_pi_irte(irqfd->kvm,
|
||||||
prod->irq, irqfd->gsi, 1);
|
prod->irq, irqfd->gsi, 1);
|
||||||
}
|
|
||||||
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
|
void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
|
||||||
@ -8380,11 +8382,6 @@ void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
|
|||||||
struct kvm_kernel_irqfd *irqfd =
|
struct kvm_kernel_irqfd *irqfd =
|
||||||
container_of(cons, struct kvm_kernel_irqfd, consumer);
|
container_of(cons, struct kvm_kernel_irqfd, consumer);
|
||||||
|
|
||||||
if (!kvm_x86_ops->update_pi_irte) {
|
|
||||||
WARN_ON(irqfd->producer != NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WARN_ON(irqfd->producer != prod);
|
WARN_ON(irqfd->producer != prod);
|
||||||
irqfd->producer = NULL;
|
irqfd->producer = NULL;
|
||||||
|
|
||||||
|
@ -1185,6 +1185,7 @@ static inline void kvm_vcpu_set_dy_eligible(struct kvm_vcpu *vcpu, bool val)
|
|||||||
#endif /* CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT */
|
#endif /* CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT */
|
||||||
|
|
||||||
#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
|
#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
|
||||||
|
bool kvm_arch_has_irq_bypass(void);
|
||||||
int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *,
|
int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *,
|
||||||
struct irq_bypass_producer *);
|
struct irq_bypass_producer *);
|
||||||
void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *,
|
void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *,
|
||||||
|
@ -408,6 +408,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
|
|||||||
*/
|
*/
|
||||||
fdput(f);
|
fdput(f);
|
||||||
#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
|
#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
|
||||||
|
if (kvm_arch_has_irq_bypass()) {
|
||||||
irqfd->consumer.token = (void *)irqfd->eventfd;
|
irqfd->consumer.token = (void *)irqfd->eventfd;
|
||||||
irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
|
irqfd->consumer.add_producer = kvm_arch_irq_bypass_add_producer;
|
||||||
irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
|
irqfd->consumer.del_producer = kvm_arch_irq_bypass_del_producer;
|
||||||
@ -417,6 +418,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
|
|||||||
if (ret)
|
if (ret)
|
||||||
pr_info("irq bypass consumer (token %p) registration fails: %d\n",
|
pr_info("irq bypass consumer (token %p) registration fails: %d\n",
|
||||||
irqfd->consumer.token, ret);
|
irqfd->consumer.token, ret);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user