Commit d5c2dcc3 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Avi Kivity

KVM: switch coalesced mmio changes to slots_lock

switch coalesced mmio slots_lock.  slots_lock is already taken for read
everywhere, so we only need to take it for write when changing zones.
This is in preparation to removing in_range and kvm->lock around it.

[avi: fix build]
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 69fa2d78
...@@ -115,16 +115,16 @@ int kvm_vm_ioctl_register_coalesced_mmio(struct kvm *kvm, ...@@ -115,16 +115,16 @@ int kvm_vm_ioctl_register_coalesced_mmio(struct kvm *kvm,
if (dev == NULL) if (dev == NULL)
return -EINVAL; return -EINVAL;
mutex_lock(&kvm->lock); down_write(&kvm->slots_lock);
if (dev->nb_zones >= KVM_COALESCED_MMIO_ZONE_MAX) { if (dev->nb_zones >= KVM_COALESCED_MMIO_ZONE_MAX) {
mutex_unlock(&kvm->lock); up_write(&kvm->slots_lock);
return -ENOBUFS; return -ENOBUFS;
} }
dev->zone[dev->nb_zones] = *zone; dev->zone[dev->nb_zones] = *zone;
dev->nb_zones++; dev->nb_zones++;
mutex_unlock(&kvm->lock); up_write(&kvm->slots_lock);
return 0; return 0;
} }
...@@ -138,7 +138,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm, ...@@ -138,7 +138,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
if (dev == NULL) if (dev == NULL)
return -EINVAL; return -EINVAL;
mutex_lock(&kvm->lock); down_write(&kvm->slots_lock);
i = dev->nb_zones; i = dev->nb_zones;
while(i) { while(i) {
...@@ -156,7 +156,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm, ...@@ -156,7 +156,7 @@ int kvm_vm_ioctl_unregister_coalesced_mmio(struct kvm *kvm,
i--; i--;
} }
mutex_unlock(&kvm->lock); up_write(&kvm->slots_lock);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment