KVM: s390: Gracefully handle busy conditions on ccw_device_start
authorChristian Borntraeger <borntraeger@de.ibm.com>
Mon, 7 Jan 2013 14:51:52 +0000 (15:51 +0100)
committerMarcelo Tosatti <mtosatti@redhat.com>
Wed, 9 Jan 2013 20:40:19 +0000 (18:40 -0200)
In rare cases a virtio command might try to issue a ccw before a former
ccw was answered with a tsch. This will cause CC=2 (busy). Lets just
retry in that case.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
drivers/s390/kvm/virtio_ccw.c

index 70419a75d0e099ac03b1ef34f837803fcc5f4395..2edd94af131c232f5101f49331e0faf3534726e7 100644 (file)
@@ -132,11 +132,14 @@ static int ccw_io_helper(struct virtio_ccw_device *vcdev,
        unsigned long flags;
        int flag = intparm & VIRTIO_CCW_INTPARM_MASK;
 
-       spin_lock_irqsave(get_ccwdev_lock(vcdev->cdev), flags);
-       ret = ccw_device_start(vcdev->cdev, ccw, intparm, 0, 0);
-       if (!ret)
-               vcdev->curr_io |= flag;
-       spin_unlock_irqrestore(get_ccwdev_lock(vcdev->cdev), flags);
+       do {
+               spin_lock_irqsave(get_ccwdev_lock(vcdev->cdev), flags);
+               ret = ccw_device_start(vcdev->cdev, ccw, intparm, 0, 0);
+               if (!ret)
+                       vcdev->curr_io |= flag;
+               spin_unlock_irqrestore(get_ccwdev_lock(vcdev->cdev), flags);
+               cpu_relax();
+       } while (ret == -EBUSY);
        wait_event(vcdev->wait_q, doing_io(vcdev, flag) == 0);
        return ret ? ret : vcdev->err;
 }