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>
This commit is contained in:
Jan Kiszka 2012-03-14 11:02:11 +01:00 committed by Avi Kivity
parent 02626b6af5
commit cf9eeac463
2 changed files with 8 additions and 8 deletions

View File

@ -556,7 +556,7 @@ struct kvm_assigned_dev_kernel {
struct pci_dev *dev; struct pci_dev *dev;
struct kvm *kvm; struct kvm *kvm;
spinlock_t intx_lock; spinlock_t intx_lock;
struct mutex intx_mask_lock; spinlock_t intx_mask_lock;
char irq_name[32]; char irq_name[32];
struct pci_saved_state *pci_saved_state; struct pci_saved_state *pci_saved_state;
}; };

View File

@ -77,11 +77,11 @@ kvm_assigned_dev_raise_guest_irq(struct kvm_assigned_dev_kernel *assigned_dev,
{ {
if (unlikely(assigned_dev->irq_requested_type & if (unlikely(assigned_dev->irq_requested_type &
KVM_DEV_IRQ_GUEST_INTX)) { KVM_DEV_IRQ_GUEST_INTX)) {
mutex_lock(&assigned_dev->intx_mask_lock); spin_lock(&assigned_dev->intx_mask_lock);
if (!(assigned_dev->flags & KVM_DEV_ASSIGN_MASK_INTX)) if (!(assigned_dev->flags & KVM_DEV_ASSIGN_MASK_INTX))
kvm_set_irq(assigned_dev->kvm, kvm_set_irq(assigned_dev->kvm,
assigned_dev->irq_source_id, vector, 1); assigned_dev->irq_source_id, vector, 1);
mutex_unlock(&assigned_dev->intx_mask_lock); spin_unlock(&assigned_dev->intx_mask_lock);
} else } else
kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id, kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id,
vector, 1); vector, 1);
@ -141,7 +141,7 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
kvm_set_irq(dev->kvm, dev->irq_source_id, dev->guest_irq, 0); kvm_set_irq(dev->kvm, dev->irq_source_id, dev->guest_irq, 0);
mutex_lock(&dev->intx_mask_lock); spin_lock(&dev->intx_mask_lock);
if (!(dev->flags & KVM_DEV_ASSIGN_MASK_INTX)) { if (!(dev->flags & KVM_DEV_ASSIGN_MASK_INTX)) {
bool reassert = false; bool reassert = false;
@ -165,7 +165,7 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
dev->guest_irq, 1); dev->guest_irq, 1);
} }
mutex_unlock(&dev->intx_mask_lock); spin_unlock(&dev->intx_mask_lock);
} }
static void deassign_guest_irq(struct kvm *kvm, static void deassign_guest_irq(struct kvm *kvm,
@ -707,7 +707,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
match->flags = assigned_dev->flags; match->flags = assigned_dev->flags;
match->dev = dev; match->dev = dev;
spin_lock_init(&match->intx_lock); spin_lock_init(&match->intx_lock);
mutex_init(&match->intx_mask_lock); spin_lock_init(&match->intx_mask_lock);
match->irq_source_id = -1; match->irq_source_id = -1;
match->kvm = kvm; match->kvm = kvm;
match->ack_notifier.irq_acked = kvm_assigned_dev_ack_irq; 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,
goto out; goto out;
} }
mutex_lock(&match->intx_mask_lock); spin_lock(&match->intx_mask_lock);
match->flags &= ~KVM_DEV_ASSIGN_MASK_INTX; match->flags &= ~KVM_DEV_ASSIGN_MASK_INTX;
match->flags |= assigned_dev->flags & KVM_DEV_ASSIGN_MASK_INTX; 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,
} }
} }
mutex_unlock(&match->intx_mask_lock); spin_unlock(&match->intx_mask_lock);
out: out:
mutex_unlock(&kvm->lock); mutex_unlock(&kvm->lock);