vfio/platform: Fix reset_required behaviour
Subsystems (3)
Mostafa Saleh
reviewerPATCH 1/1 vfio/platform: Fix reset_required behaviour
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.
--- drivers/vfio/platform/vfio_platform_common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +5 -2
@@ -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);
Signature · 1 line
2.40.0.rc0.216.gc4246ad0f0-goog
Quoted 35 lines · On Fri, 3 Mar 2023 12:11:52 +0000 Mostafa Saleh <[email protected]> wrote:
vfio_platform_devicehas a flagreset_requiredthat can be set frommodule_paramor vfio driver which indicates that reset is not a requirement and it bypasses related checks.This was introduced and implemented in
vfio_platform_probe_commonin "b5add544d67vfio, platform: make reset driver a requirement by default"However,
vfio_platform_probe_commonwas removed in "ac1237912fbvfio/amba: Use the new device life cycle helpers"And new implementation added in
vfio_platform_init_commonin "5f6c7e0831avfio/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_deviceandvfio_platform_close_device.Signed-off-by Mostafa Saleh <[email protected]>--- drivers/vfio/platform/vfio_platform_common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/vfio/platform/vfio_platform_common.c +1
-1@@ -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) {
drivers/vfio/platform/vfio_platform_common.c int vfio_platform_init_common(struct vfio_platform_device *vdev) · line 662
Quoted 10 lines
drivers/vfio/platform/vfio_platform_common.c +4
-1dev_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:
Thanks,
Alex
Mostafa Saleh
reviewerQuoted 51 lines · Alex Williamson
Quoted 35 lines · On Fri, 3 Mar 2023 12:11:52 +0000 Mostafa Saleh <[email protected]> wrote:
vfio_platform_devicehas a flagreset_requiredthat can be set frommodule_paramor vfio driver which indicates that reset is not a requirement and it bypasses related checks.This was introduced and implemented in
vfio_platform_probe_commonin "b5add544d67vfio, platform: make reset driver a requirement by default"However,
vfio_platform_probe_commonwas removed in "ac1237912fbvfio/amba: Use the new device life cycle helpers"And new implementation added in
vfio_platform_init_commonin "5f6c7e0831avfio/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_deviceandvfio_platform_close_device.Signed-off-by Mostafa Saleh <[email protected]>--- drivers/vfio/platform/vfio_platform_common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/vfio/platform/vfio_platform_common.c +1
-1@@ -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) {drivers/vfio/platform/vfio_platform_common.c int vfio_platform_init_common(struct vfio_platform_device *vdev) · line 662
Quoted 10 lines
drivers/vfio/platform/vfio_platform_common.c +4
-1dev_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:
Oh, sorry, missed that!
Thanks,
Mostafa