[PATCH V2] vdpa: skip suspend/resume ops if not DRIVER_OK

Steve Sistare posted 1 patch 1 year, 11 months ago
drivers/vhost/vdpa.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH V2] vdpa: skip suspend/resume ops if not DRIVER_OK
Posted by Steve Sistare 1 year, 11 months ago
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>
---
 drivers/vhost/vdpa.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index bc4a51e4638b..aef92a7c57f3 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;
 
-- 
2.39.3
Re: [PATCH V2] vdpa: skip suspend/resume ops if not DRIVER_OK
Posted by Eugenio Perez Martin 1 year, 11 months ago
On Tue, Feb 13, 2024 at 3:26 PM Steve Sistare <steven.sistare@oracle.com> wrote:
>
> 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>

Reviewed-by: Eugenio Pérez <eperezma@redhat.com>

Please include a changelog from previous versions for the next series.

Thanks!

> ---
>  drivers/vhost/vdpa.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index bc4a51e4638b..aef92a7c57f3 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;
>
> --
> 2.39.3
>
Re: [PATCH V2] vdpa: skip suspend/resume ops if not DRIVER_OK
Posted by Steven Sistare 1 year, 11 months ago
On 2/13/2024 9:58 AM, Eugenio Perez Martin wrote:
> On Tue, Feb 13, 2024 at 3:26 PM Steve Sistare <steven.sistare@oracle.com> wrote:
>>
>> 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>
> 
> Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
> 
> Please include a changelog from previous versions for the next series.
> 
> Thanks!

Will do, thanks - steve

>> ---
>>  drivers/vhost/vdpa.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
>> index bc4a51e4638b..aef92a7c57f3 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;
>>
>> --
>> 2.39.3
>>
>