Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1524499 > unrolled thread

[PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic

Started byPaolo Bonzini <pbonzini@redhat.com>
First post2016-11-17 18:10 +0100
Last post2016-11-19 20:40 +0100
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic Paolo Bonzini <pbonzini@redhat.com> - 2016-11-17 18:10 +0100
    Re: [PATCH] kvm: x86: merge kvm_arch_set_irq and  kvm_arch_set_irq_inatomic David Hildenbrand <david@redhat.com> - 2016-11-18 19:30 +0100
      Re: [PATCH] kvm: x86: merge kvm_arch_set_irq and  kvm_arch_set_irq_inatomic David Hildenbrand <david@redhat.com> - 2016-11-18 20:30 +0100
      Re: [PATCH] kvm: x86: merge kvm_arch_set_irq and  kvm_arch_set_irq_inatomic Paolo Bonzini <pbonzini@redhat.com> - 2016-11-18 20:30 +0100
    Re: [PATCH] kvm: x86: merge kvm_arch_set_irq and  kvm_arch_set_irq_inatomic Radim Krčmář <rkrcmar@redhat.com> - 2016-11-19 20:40 +0100

#1524499 — [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic

FromPaolo Bonzini <pbonzini@redhat.com>
Date2016-11-17 18:10 +0100
Subject[PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic
Message-ID<sEymf-3v8-101@gated-at.bofh.it>
kvm_arch_set_irq is unused since commit b97e6de9c96.  Merge
its functionality with kvm_arch_set_irq_inatomic.

Reported-by: Jiang Biao <jiang.biao2@zte.com.cn>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/irq_comm.c | 58 +++++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 31 deletions(-)

diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 25810b144b58..4da03030d5a7 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -156,6 +156,16 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
 }
 
 
+static int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e,
+		    struct kvm *kvm, int irq_source_id, int level,
+		    bool line_status)
+{
+	if (!level)
+		return -1;
+
+	return kvm_hv_synic_set_irq(kvm, e->hv_sint.vcpu, e->hv_sint.sint);
+}
+
 int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
 			      struct kvm *kvm, int irq_source_id, int level,
 			      bool line_status)
@@ -163,18 +173,26 @@ int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
 	struct kvm_lapic_irq irq;
 	int r;
 
-	if (unlikely(e->type != KVM_IRQ_ROUTING_MSI))
-		return -EWOULDBLOCK;
+	switch (e->type) {
+	case KVM_IRQ_ROUTING_HV_SINT:
+		return kvm_hv_set_sint(e, kvm, irq_source_id, level,
+				       line_status);
 
-	if (kvm_msi_route_invalid(kvm, e))
-		return -EINVAL;
+	case KVM_IRQ_ROUTING_MSI:
+		if (kvm_msi_route_invalid(kvm, e))
+			return -EINVAL;
 
-	kvm_set_msi_irq(kvm, e, &irq);
+		kvm_set_msi_irq(kvm, e, &irq);
 
-	if (kvm_irq_delivery_to_apic_fast(kvm, NULL, &irq, &r, NULL))
-		return r;
-	else
-		return -EWOULDBLOCK;
+		if (kvm_irq_delivery_to_apic_fast(kvm, NULL, &irq, &r, NULL))
+			return r;
+		break;
+
+	default:
+		break;
+	}
+
+	return -EWOULDBLOCK;
 }
 
 int kvm_request_irq_source_id(struct kvm *kvm)
@@ -254,16 +272,6 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
 	srcu_read_unlock(&kvm->irq_srcu, idx);
 }
 
-static int kvm_hv_set_sint(struct kvm_kernel_irq_routing_entry *e,
-		    struct kvm *kvm, int irq_source_id, int level,
-		    bool line_status)
-{
-	if (!level)
-		return -1;
-
-	return kvm_hv_synic_set_irq(kvm, e->hv_sint.vcpu, e->hv_sint.sint);
-}
-
 int kvm_set_routing_entry(struct kvm *kvm,
 			  struct kvm_kernel_irq_routing_entry *e,
 			  const struct kvm_irq_routing_entry *ue)
@@ -423,18 +431,6 @@ void kvm_scan_ioapic_routes(struct kvm_vcpu *vcpu,
 	srcu_read_unlock(&kvm->irq_srcu, idx);
 }
 
-int kvm_arch_set_irq(struct kvm_kernel_irq_routing_entry *irq, struct kvm *kvm,
-		     int irq_source_id, int level, bool line_status)
-{
-	switch (irq->type) {
-	case KVM_IRQ_ROUTING_HV_SINT:
-		return kvm_hv_set_sint(irq, kvm, irq_source_id, level,
-				       line_status);
-	default:
-		return -EWOULDBLOCK;
-	}
-}
-
 void kvm_arch_irq_routing_update(struct kvm *kvm)
 {
 	kvm_hv_irq_routing_update(kvm);
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1525617 — Re: [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic

FromDavid Hildenbrand <david@redhat.com>
Date2016-11-18 19:30 +0100
SubjectRe: [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic
Message-ID<sEW5b-2jW-19@gated-at.bofh.it>
In reply to#1524499
Am 17.11.2016 um 15:55 schrieb Paolo Bonzini:
> kvm_arch_set_irq is unused since commit b97e6de9c96.  Merge
> its functionality with kvm_arch_set_irq_inatomic.
>
> Reported-by: Jiang Biao <jiang.biao2@zte.com.cn>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---

As you said, it is unused. Therefore the functionality is superfluous. 
Why merge it?

We can still introduce this later if we ever need it. Or do you have a 
concrete user in mind?

The patch in general looks good to me. Just wondering if we can't simply 
rip out that single function.

-- 

David

[toc] | [prev] | [next] | [standalone]


#1525670 — Re: [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic

FromDavid Hildenbrand <david@redhat.com>
Date2016-11-18 20:30 +0100
SubjectRe: [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic
Message-ID<sEX1f-2SU-1@gated-at.bofh.it>
In reply to#1525617
Am 18.11.2016 um 20:20 schrieb Paolo Bonzini:
>
>
> On 18/11/2016 19:20, David Hildenbrand wrote:
>> Am 17.11.2016 um 15:55 schrieb Paolo Bonzini:
>>> kvm_arch_set_irq is unused since commit b97e6de9c96.  Merge
>>> its functionality with kvm_arch_set_irq_inatomic.
>>>
>>> Reported-by: Jiang Biao <jiang.biao2@zte.com.cn>
>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>> ---
>>
>> As you said, it is unused. Therefore the functionality is superfluous.
>> Why merge it?
>
> Because we can handle Hyper-V synthetic interrupts atomically, and that
> was the intended usage of kvm_arch_set_irq's code (see commit
> c9a5eccac1ab, "kvm/eventfd: add arch-specific set_irq", 2015-10-16).
>
> What happened was that the API changed between commit c9a5eccac1ab and
> the merge of the Hyper-V synthetic interrupt patches, and the latter was
> not adjusted.
>

Alright, got it. Thanks for the explanation. So

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

David

[toc] | [prev] | [next] | [standalone]


#1525674 — Re: [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic

FromPaolo Bonzini <pbonzini@redhat.com>
Date2016-11-18 20:30 +0100
SubjectRe: [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic
Message-ID<sEX1f-2SU-3@gated-at.bofh.it>
In reply to#1525617

On 18/11/2016 19:20, David Hildenbrand wrote:
> Am 17.11.2016 um 15:55 schrieb Paolo Bonzini:
>> kvm_arch_set_irq is unused since commit b97e6de9c96.  Merge
>> its functionality with kvm_arch_set_irq_inatomic.
>>
>> Reported-by: Jiang Biao <jiang.biao2@zte.com.cn>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
> 
> As you said, it is unused. Therefore the functionality is superfluous.
> Why merge it?

Because we can handle Hyper-V synthetic interrupts atomically, and that
was the intended usage of kvm_arch_set_irq's code (see commit
c9a5eccac1ab, "kvm/eventfd: add arch-specific set_irq", 2015-10-16).

What happened was that the API changed between commit c9a5eccac1ab and
the merge of the Hyper-V synthetic interrupt patches, and the latter was
not adjusted.

Paolo

> We can still introduce this later if we ever need it. Or do you have a
> concrete user in mind?
> 
> The patch in general looks good to me. Just wondering if we can't simply
> rip out that single function.
> 

[toc] | [prev] | [next] | [standalone]


#1526126 — Re: [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic

FromRadim Krčmář <rkrcmar@redhat.com>
Date2016-11-19 20:40 +0100
SubjectRe: [PATCH] kvm: x86: merge kvm_arch_set_irq and kvm_arch_set_irq_inatomic
Message-ID<sFjEt-Ip-9@gated-at.bofh.it>
In reply to#1524499
2016-11-17 15:55+0100, Paolo Bonzini:
> kvm_arch_set_irq is unused since commit b97e6de9c96.  Merge
> its functionality with kvm_arch_set_irq_inatomic.
> 
> Reported-by: Jiang Biao <jiang.biao2@zte.com.cn>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---

Applied to kvm/master, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web