From: Steve Sistare Date: Tue, 13 Feb 2024 14:25:58 +0000 (-0800) Subject: vdpa: skip suspend/resume ops if not DRIVER_OK X-Git-Tag: v6.9-rc1~59^2~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4e8b5aed7cd18bb8377b6dd461e336688c5d503;p=thirdparty%2Fkernel%2Flinux.git vdpa: skip suspend/resume ops if not DRIVER_OK 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 " Signed-off-by: Steve Sistare Message-Id: <1707834358-165470-1-git-send-email-steven.sistare@oracle.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: Eugenio Pérez --- diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index bc4a51e4638b4..aef92a7c57f3f 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -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;