vdpa: skip suspend/resume ops if not DRIVER_OK
authorSteve Sistare <steven.sistare@oracle.com>
Tue, 13 Feb 2024 14:25:58 +0000 (06:25 -0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 19 Mar 2024 06:45:49 +0000 (02:45 -0400)
If a vdpa device is not in state DRIVER_OK, then there is no driver state
to preserve, so no need to call the suspend and resume driver ops.

Suggested-by: Eugenio Perez Martin <eperezma@redhat.com>"
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Message-Id: <1707834358-165470-1-git-send-email-steven.sistare@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
drivers/vhost/vdpa.c

index bc4a51e4638b46c79345f2be89dc7639b81ee28a..aef92a7c57f3fd58a2bf40a49d7bf9011ae08ba1 100644 (file)
@@ -595,6 +595,9 @@ static long vhost_vdpa_suspend(struct vhost_vdpa *v)
        const struct vdpa_config_ops *ops = vdpa->config;
        int ret;
 
+       if (!(ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK))
+               return 0;
+
        if (!ops->suspend)
                return -EOPNOTSUPP;
 
@@ -615,6 +618,9 @@ static long vhost_vdpa_resume(struct vhost_vdpa *v)
        const struct vdpa_config_ops *ops = vdpa->config;
        int ret;
 
+       if (!(ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK))
+               return 0;
+
        if (!ops->resume)
                return -EOPNOTSUPP;