kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/platform: Fix reset_required behaviour
@ 2023-03-03 12:11 Mostafa Saleh
  2023-03-03 13:34 ` Alex Williamson
  0 siblings, 1 reply; 3+ messages in thread
From: Mostafa Saleh @ 2023-03-03 12:11 UTC (permalink / raw)
  To: eric.auger, alex.williamson; +Cc: cohuck, kvm, linux-kernel, smostafa

vfio_platform_device has a flag reset_required that can be set from
module_param or vfio driver which indicates that reset is not a
requirement and it bypasses related checks.

This was introduced and implemented in vfio_platform_probe_common in
"b5add544d67 vfio, platform: make reset driver a requirement by default"

However, vfio_platform_probe_common was removed in
"ac1237912fb vfio/amba: Use the new device life cycle helpers"

And new implementation added in vfio_platform_init_common in
"5f6c7e0831a vfio/platform: Use the new device life cycle helpers"

which causes an error even if vfio-platform.reset_required=0, as it
only guards printing and not the return as before.

This patch fixes this by returning 0 if there is no reset function
for the device and reset_required=0. This is also consistent with
checks in vfio_platform_open_device and vfio_platform_close_device.

Signed-off-by: Mostafa Saleh <smostafa@google.com>
---
 drivers/vfio/platform/vfio_platform_common.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
index 1a0a238ffa35..7325ff463cf0 100644
--- a/drivers/vfio/platform/vfio_platform_common.c
+++ b/drivers/vfio/platform/vfio_platform_common.c
@@ -650,10 +650,13 @@ int vfio_platform_init_common(struct vfio_platform_device *vdev)
 	mutex_init(&vdev->igate);
 
 	ret = vfio_platform_get_reset(vdev);
-	if (ret && vdev->reset_required)
+	if (ret && vdev->reset_required) {
 		dev_err(dev, "No reset function found for device %s\n",
 			vdev->name);
-	return ret;
+		return ret;
+	}
+
+	return 0;
 }
 EXPORT_SYMBOL_GPL(vfio_platform_init_common);
 
-- 
2.40.0.rc0.216.gc4246ad0f0-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vfio/platform: Fix reset_required behaviour
  2023-03-03 12:11 [PATCH] vfio/platform: Fix reset_required behaviour Mostafa Saleh
@ 2023-03-03 13:34 ` Alex Williamson
  2023-03-03 13:41   ` Mostafa Saleh
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Williamson @ 2023-03-03 13:34 UTC (permalink / raw)
  To: Mostafa Saleh; +Cc: eric.auger, cohuck, kvm, linux-kernel

On Fri,  3 Mar 2023 12:11:52 +0000
Mostafa Saleh <smostafa@google.com> wrote:

> vfio_platform_device has a flag reset_required that can be set from
> module_param or vfio driver which indicates that reset is not a
> requirement and it bypasses related checks.
> 
> This was introduced and implemented in vfio_platform_probe_common in
> "b5add544d67 vfio, platform: make reset driver a requirement by default"
> 
> However, vfio_platform_probe_common was removed in
> "ac1237912fb vfio/amba: Use the new device life cycle helpers"
> 
> And new implementation added in vfio_platform_init_common in
> "5f6c7e0831a vfio/platform: Use the new device life cycle helpers"
> 
> which causes an error even if vfio-platform.reset_required=0, as it
> only guards printing and not the return as before.
> 
> This patch fixes this by returning 0 if there is no reset function
> for the device and reset_required=0. This is also consistent with
> checks in vfio_platform_open_device and vfio_platform_close_device.
> 
> Signed-off-by: Mostafa Saleh <smostafa@google.com>
> ---
>  drivers/vfio/platform/vfio_platform_common.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
> index 1a0a238ffa35..7325ff463cf0 100644
> --- a/drivers/vfio/platform/vfio_platform_common.c
> +++ b/drivers/vfio/platform/vfio_platform_common.c
> @@ -650,10 +650,13 @@ int vfio_platform_init_common(struct vfio_platform_device *vdev)
>  	mutex_init(&vdev->igate);
>  
>  	ret = vfio_platform_get_reset(vdev);
> -	if (ret && vdev->reset_required)
> +	if (ret && vdev->reset_required) {
>  		dev_err(dev, "No reset function found for device %s\n",
>  			vdev->name);
> -	return ret;
> +		return ret;
> +	}
> +
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(vfio_platform_init_common);
>  

An identical patch has already accepted and merged for v6.3:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=168a9c91fe0a1180959b6394f4566de7080244b6

Thanks,
Alex


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vfio/platform: Fix reset_required behaviour
  2023-03-03 13:34 ` Alex Williamson
@ 2023-03-03 13:41   ` Mostafa Saleh
  0 siblings, 0 replies; 3+ messages in thread
From: Mostafa Saleh @ 2023-03-03 13:41 UTC (permalink / raw)
  To: Alex Williamson; +Cc: eric.auger, cohuck, kvm, linux-kernel

On Fri, Mar 03, 2023 at 06:34:51AM -0700, Alex Williamson wrote:
> On Fri,  3 Mar 2023 12:11:52 +0000
> Mostafa Saleh <smostafa@google.com> wrote:
> 
> > vfio_platform_device has a flag reset_required that can be set from
> > module_param or vfio driver which indicates that reset is not a
> > requirement and it bypasses related checks.
> > 
> > This was introduced and implemented in vfio_platform_probe_common in
> > "b5add544d67 vfio, platform: make reset driver a requirement by default"
> > 
> > However, vfio_platform_probe_common was removed in
> > "ac1237912fb vfio/amba: Use the new device life cycle helpers"
> > 
> > And new implementation added in vfio_platform_init_common in
> > "5f6c7e0831a vfio/platform: Use the new device life cycle helpers"
> > 
> > which causes an error even if vfio-platform.reset_required=0, as it
> > only guards printing and not the return as before.
> > 
> > This patch fixes this by returning 0 if there is no reset function
> > for the device and reset_required=0. This is also consistent with
> > checks in vfio_platform_open_device and vfio_platform_close_device.
> > 
> > Signed-off-by: Mostafa Saleh <smostafa@google.com>
> > ---
> >  drivers/vfio/platform/vfio_platform_common.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
> > index 1a0a238ffa35..7325ff463cf0 100644
> > --- a/drivers/vfio/platform/vfio_platform_common.c
> > +++ b/drivers/vfio/platform/vfio_platform_common.c
> > @@ -650,10 +650,13 @@ int vfio_platform_init_common(struct vfio_platform_device *vdev)
> >  	mutex_init(&vdev->igate);
> >  
> >  	ret = vfio_platform_get_reset(vdev);
> > -	if (ret && vdev->reset_required)
> > +	if (ret && vdev->reset_required) {
> >  		dev_err(dev, "No reset function found for device %s\n",
> >  			vdev->name);
> > -	return ret;
> > +		return ret;
> > +	}
> > +
> > +	return 0;
> >  }
> >  EXPORT_SYMBOL_GPL(vfio_platform_init_common);
> >  
> 
> An identical patch has already accepted and merged for v6.3:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=168a9c91fe0a1180959b6394f4566de7080244b6

Oh, sorry, missed that!

Thanks,
Mostafa


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-03 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-03 12:11 [PATCH] vfio/platform: Fix reset_required behaviour Mostafa Saleh
2023-03-03 13:34 ` Alex Williamson
2023-03-03 13:41   ` Mostafa Saleh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).