diff options
-rw-r--r-- | virt/kvm/coalesced_mmio.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c index c4c7ec2f9d30..754906800999 100644 --- a/virt/kvm/coalesced_mmio.c +++ b/virt/kvm/coalesced_mmio.c | |||
@@ -24,7 +24,8 @@ static int coalesced_mmio_in_range(struct kvm_io_device *this, | |||
24 | { | 24 | { |
25 | struct kvm_coalesced_mmio_dev *dev = to_mmio(this); | 25 | struct kvm_coalesced_mmio_dev *dev = to_mmio(this); |
26 | struct kvm_coalesced_mmio_zone *zone; | 26 | struct kvm_coalesced_mmio_zone *zone; |
27 | int next; | 27 | struct kvm_coalesced_mmio_ring *ring; |
28 | unsigned avail; | ||
28 | int i; | 29 | int i; |
29 | 30 | ||
30 | if (!is_write) | 31 | if (!is_write) |
@@ -40,10 +41,9 @@ static int coalesced_mmio_in_range(struct kvm_io_device *this, | |||
40 | * check if we don't meet the first used entry | 41 | * check if we don't meet the first used entry |
41 | * there is always one unused entry in the buffer | 42 | * there is always one unused entry in the buffer |
42 | */ | 43 | */ |
43 | 44 | ring = dev->kvm->coalesced_mmio_ring; | |
44 | next = (dev->kvm->coalesced_mmio_ring->last + 1) % | 45 | avail = (ring->first - ring->last - 1) % KVM_COALESCED_MMIO_MAX; |
45 | KVM_COALESCED_MMIO_MAX; | 46 | if (avail < 1) { |
46 | if (next == dev->kvm->coalesced_mmio_ring->first) { | ||
47 | /* full */ | 47 | /* full */ |
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |