aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2012-03-14 06:02:11 -0400
committerAvi Kivity <avi@redhat.com>2012-03-20 06:41:24 -0400
commitcf9eeac46350b8b43730b7dc5e999757bed089a4 (patch)
treea71645c281a36c080f58bf660a95c176070e4f83 /virt/kvm
parent02626b6af5d2bc62db3bb85fc2891b2725535d44 (diff)
KVM: Convert intx_mask_lock to spin lock
As kvm_notify_acked_irq calls kvm_assigned_dev_ack_irq under rcu_read_lock, we cannot use a mutex in the latter function. Switch to a spin lock to address this. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/assigned-dev.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
index 08e05715df72..01f572c10c71 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -77,11 +77,11 @@ kvm_assigned_dev_raise_guest_irq(struct kvm_assigned_dev_kernel *assigned_dev,
77{ 77{
78 if (unlikely(assigned_dev->irq_requested_type & 78 if (unlikely(assigned_dev->irq_requested_type &
79 KVM_DEV_IRQ_GUEST_INTX)) { 79 KVM_DEV_IRQ_GUEST_INTX)) {
80 mutex_lock(&assigned_dev->intx_mask_lock); 80 spin_lock(&assigned_dev->intx_mask_lock);
81 if (!(assigned_dev->flags & KVM_DEV_ASSIGN_MASK_INTX)) 81 if (!(assigned_dev->flags & KVM_DEV_ASSIGN_MASK_INTX))
82 kvm_set_irq(assigned_dev->kvm, 82 kvm_set_irq(assigned_dev->kvm,
83 assigned_dev->irq_source_id, vector, 1); 83 assigned_dev->irq_source_id, vector, 1);
84 mutex_unlock(&assigned_dev->intx_mask_lock); 84 spin_unlock(&assigned_dev->intx_mask_lock);
85 } else 85 } else
86 kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id, 86 kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id,
87 vector, 1); 87 vector, 1);
@@ -141,7 +141,7 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
141 141
142 kvm_set_irq(dev->kvm, dev->irq_source_id, dev->guest_irq, 0); 142 kvm_set_irq(dev->kvm, dev->irq_source_id, dev->guest_irq, 0);
143 143
144 mutex_lock(&dev->intx_mask_lock); 144 spin_lock(&dev->intx_mask_lock);
145 145
146 if (!(dev->flags & KVM_DEV_ASSIGN_MASK_INTX)) { 146 if (!(dev->flags & KVM_DEV_ASSIGN_MASK_INTX)) {
147 bool reassert = false; 147 bool reassert = false;
@@ -165,7 +165,7 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
165 dev->guest_irq, 1); 165 dev->guest_irq, 1);
166 } 166 }
167 167
168 mutex_unlock(&dev->intx_mask_lock); 168 spin_unlock(&dev->intx_mask_lock);
169} 169}
170 170
171static void deassign_guest_irq(struct kvm *kvm, 171static void deassign_guest_irq(struct kvm *kvm,
@@ -707,7 +707,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
707 match->flags = assigned_dev->flags; 707 match->flags = assigned_dev->flags;
708 match->dev = dev; 708 match->dev = dev;
709 spin_lock_init(&match->intx_lock); 709 spin_lock_init(&match->intx_lock);
710 mutex_init(&match->intx_mask_lock); 710 spin_lock_init(&match->intx_mask_lock);
711 match->irq_source_id = -1; 711 match->irq_source_id = -1;
712 match->kvm = kvm; 712 match->kvm = kvm;
713 match->ack_notifier.irq_acked = kvm_assigned_dev_ack_irq; 713 match->ack_notifier.irq_acked = kvm_assigned_dev_ack_irq;
@@ -868,7 +868,7 @@ static int kvm_vm_ioctl_set_pci_irq_mask(struct kvm *kvm,
868 goto out; 868 goto out;
869 } 869 }
870 870
871 mutex_lock(&match->intx_mask_lock); 871 spin_lock(&match->intx_mask_lock);
872 872
873 match->flags &= ~KVM_DEV_ASSIGN_MASK_INTX; 873 match->flags &= ~KVM_DEV_ASSIGN_MASK_INTX;
874 match->flags |= assigned_dev->flags & KVM_DEV_ASSIGN_MASK_INTX; 874 match->flags |= assigned_dev->flags & KVM_DEV_ASSIGN_MASK_INTX;
@@ -895,7 +895,7 @@ static int kvm_vm_ioctl_set_pci_irq_mask(struct kvm *kvm,
895 } 895 }
896 } 896 }
897 897
898 mutex_unlock(&match->intx_mask_lock); 898 spin_unlock(&match->intx_mask_lock);
899 899
900out: 900out:
901 mutex_unlock(&kvm->lock); 901 mutex_unlock(&kvm->lock);