All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	rkrcmar@redhat.com, Peter Xu <peterx@redhat.com>,
	david@redhat.com
Subject: [PATCH v3 06/24] KVM: x86: get rid of pic_irqchip()
Date: Fri,  7 Apr 2017 10:50:23 +0200	[thread overview]
Message-ID: <20170407085041.5257-7-david@redhat.com> (raw)
In-Reply-To: <20170407085041.5257-1-david@redhat.com>

It seemed like a nice idea to encapsulate access to kvm->arch.vpic. But
as the usage is already mixed, internal locks are taken outside of i8259.c
and grepping for "vpic" only is much easier, let's just get rid of
pic_irqchip().

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/x86/kvm/i8259.c    |  4 ++--
 arch/x86/kvm/irq.c      |  2 +-
 arch/x86/kvm/irq.h      |  5 -----
 arch/x86/kvm/irq_comm.c |  4 ++--
 arch/x86/kvm/x86.c      | 24 +++++++++++-------------
 5 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 047b17a..af97c5a 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -239,7 +239,7 @@ static inline void pic_intack(struct kvm_kpic_state *s, int irq)
 int kvm_pic_read_irq(struct kvm *kvm)
 {
 	int irq, irq2, intno;
-	struct kvm_pic *s = pic_irqchip(kvm);
+	struct kvm_pic *s = kvm->arch.vpic;
 
 	s->output = 0;
 
@@ -576,7 +576,7 @@ static int picdev_eclr_read(struct kvm_vcpu *vcpu, struct kvm_io_device *dev,
  */
 static void pic_irq_request(struct kvm *kvm, int level)
 {
-	struct kvm_pic *s = pic_irqchip(kvm);
+	struct kvm_pic *s = kvm->arch.vpic;
 
 	if (!s->output)
 		s->wakeup_needed = true;
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index 60d91c9..5c24811 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -60,7 +60,7 @@ static int kvm_cpu_has_extint(struct kvm_vcpu *v)
 		if (irqchip_split(v->kvm))
 			return pending_userspace_extint(v);
 		else
-			return pic_irqchip(v->kvm)->output;
+			return v->kvm->arch.vpic->output;
 	} else
 		return 0;
 }
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 26d8dd4..8fec66d 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -78,11 +78,6 @@ void kvm_pic_destroy(struct kvm *kvm);
 int kvm_pic_read_irq(struct kvm *kvm);
 void kvm_pic_update_irq(struct kvm_pic *s);
 
-static inline struct kvm_pic *pic_irqchip(struct kvm *kvm)
-{
-	return kvm->arch.vpic;
-}
-
 static inline int pic_in_kernel(struct kvm *kvm)
 {
 	int mode = kvm->arch.irqchip_mode;
diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 2e5eec8..d82fc14 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -42,7 +42,7 @@ static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e,
 			   struct kvm *kvm, int irq_source_id, int level,
 			   bool line_status)
 {
-	struct kvm_pic *pic = pic_irqchip(kvm);
+	struct kvm_pic *pic = kvm->arch.vpic;
 	return kvm_pic_set_irq(pic, e->irqchip.pin, irq_source_id, level);
 }
 
@@ -236,7 +236,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id)
 		goto unlock;
 
 	kvm_ioapic_clear_all(kvm->arch.vioapic, irq_source_id);
-	kvm_pic_clear_all(pic_irqchip(kvm), irq_source_id);
+	kvm_pic_clear_all(kvm->arch.vpic, irq_source_id);
 unlock:
 	mutex_unlock(&kvm->irq_lock);
 }
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8f776f0..a804e63 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3721,18 +3721,17 @@ static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm)
 
 static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 {
+	struct kvm_pic *pic = kvm->arch.vpic;
 	int r;
 
 	r = 0;
 	switch (chip->chip_id) {
 	case KVM_IRQCHIP_PIC_MASTER:
-		memcpy(&chip->chip.pic,
-			&pic_irqchip(kvm)->pics[0],
+		memcpy(&chip->chip.pic, &pic->pics[0],
 			sizeof(struct kvm_pic_state));
 		break;
 	case KVM_IRQCHIP_PIC_SLAVE:
-		memcpy(&chip->chip.pic,
-			&pic_irqchip(kvm)->pics[1],
+		memcpy(&chip->chip.pic, &pic->pics[1],
 			sizeof(struct kvm_pic_state));
 		break;
 	case KVM_IRQCHIP_IOAPIC:
@@ -3747,23 +3746,22 @@ static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 
 static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 {
+	struct kvm_pic *pic = kvm->arch.vpic;
 	int r;
 
 	r = 0;
 	switch (chip->chip_id) {
 	case KVM_IRQCHIP_PIC_MASTER:
-		spin_lock(&pic_irqchip(kvm)->lock);
-		memcpy(&pic_irqchip(kvm)->pics[0],
-			&chip->chip.pic,
+		spin_lock(&pic->lock);
+		memcpy(&pic->pics[0], &chip->chip.pic,
 			sizeof(struct kvm_pic_state));
-		spin_unlock(&pic_irqchip(kvm)->lock);
+		spin_unlock(&pic->lock);
 		break;
 	case KVM_IRQCHIP_PIC_SLAVE:
-		spin_lock(&pic_irqchip(kvm)->lock);
-		memcpy(&pic_irqchip(kvm)->pics[1],
-			&chip->chip.pic,
+		spin_lock(&pic->lock);
+		memcpy(&pic->pics[1], &chip->chip.pic,
 			sizeof(struct kvm_pic_state));
-		spin_unlock(&pic_irqchip(kvm)->lock);
+		spin_unlock(&pic->lock);
 		break;
 	case KVM_IRQCHIP_IOAPIC:
 		r = kvm_set_ioapic(kvm, &chip->chip.ioapic);
@@ -3772,7 +3770,7 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 		r = -EINVAL;
 		break;
 	}
-	kvm_pic_update_irq(pic_irqchip(kvm));
+	kvm_pic_update_irq(pic);
 	return r;
 }
 
-- 
2.9.3

  parent reply	other threads:[~2017-04-07  8:50 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07  8:50 [PATCH v3 00/24] pic/ioapic/irqchip cleanups + minor fixes David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 01/24] KVM: x86: race between KVM_SET_GSI_ROUTING and KVM_CREATE_IRQCHIP David Hildenbrand
2017-04-24 22:39   ` Steve Rutherford
2017-04-25 12:34     ` David Hildenbrand
2017-04-25 14:58       ` Radim Krčmář
2017-04-25 19:03     ` [PATCH] KVM: x86: don't hold kvm->lock in KVM_SET_GSI_ROUTING David Hildenbrand
2017-04-25 19:38       ` Steve Rutherford
2017-04-25 19:59       ` Radim Krčmář
2017-04-26  8:40         ` David Hildenbrand
2017-04-26 14:27           ` Radim Krčmář
2017-04-26 15:21             ` David Hildenbrand
2017-04-26 20:47               ` Radim Krčmář
2017-04-26 12:33       ` kbuild test robot
2017-04-26 14:24         ` Radim Krčmář
2017-04-07  8:50 ` [PATCH v3 02/24] KVM: x86: new irqchip mode KVM_IRQCHIP_INIT_IN_PROGRESS David Hildenbrand
2017-04-12 18:26   ` Radim Krčmář
2017-04-12 19:55     ` David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 03/24] KVM: x86: check against irqchip_mode in kvm_set_routing_entry() David Hildenbrand
2017-04-12 18:36   ` Radim Krčmář
2017-04-12 19:56     ` David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 04/24] KVM: x86: check against irqchip_mode in pic_in_kernel() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 05/24] KVM: x86: check against irqchip_mode in ioapic_in_kernel() David Hildenbrand
2017-04-07  8:50 ` David Hildenbrand [this message]
2017-04-07  8:50 ` [PATCH v3 07/24] KVM: x86: get rid of ioapic_irqchip() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 08/24] KVM: x86: use ioapic_in_kernel() to check for ioapic existence David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 09/24] KVM: x86: remove duplicate checks for ioapic David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 10/24] KVM: x86: convert kvm_(set|get)_ioapic() into void David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 11/24] KVM: x86: don't take kvm->irq_lock when creating IRQCHIP David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 12/24] KVM: x86: push usage of slots_lock down David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 13/24] KVM: x86: KVM_IRQCHIP_PIC_MASTER only has 8 pins David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 14/24] KVM: x86: remove all-vcpu request from kvm_ioapic_init() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 15/24] KVM: x86: directly call kvm_make_scan_ioapic_request() in ioapic.c David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 16/24] KVM: x86: rename kvm_vcpu_request_scan_ioapic() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 17/24] KVM: x86: drop goto label in kvm_set_routing_entry() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 18/24] KVM: x86: cleanup return handling in setup_routing_entry() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 19/24] KVM: x86: simplify pic_unlock() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 20/24] KVM: x86: make kvm_pic_reset() static David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 21/24] KVM: x86: drop picdev_in_range() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 22/24] KVM: x86: set data directly in picdev_read() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 23/24] KVM: x86: simplify pic_ioport_read() David Hildenbrand
2017-04-07  8:50 ` [PATCH v3 24/24] KVM: x86: use irqchip_kernel() to check for pic+ioapic David Hildenbrand
2017-04-12 18:58 ` [PATCH v3 00/24] pic/ioapic/irqchip cleanups + minor fixes Radim Krčmář
2017-04-12 19:59   ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170407085041.5257-7-david@redhat.com \
    --to=david@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.