]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: imx355: Enable runtime PM before registering async sub-device
authorBingbu Cao <bingbu.cao@intel.com>
Wed, 22 Nov 2023 09:46:06 +0000 (17:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Feb 2024 07:54:24 +0000 (08:54 +0100)
commit efa5fe19c0a9199f49e36e1f5242ed5c88da617d upstream.

As the sensor device maybe accessible right after its async sub-device is
registered, such as ipu-bridge will try to power up sensor by sensor's
client device's runtime PM from the async notifier callback, if runtime PM
is not enabled, it will fail.

So runtime PM should be ready before its async sub-device is registered
and accessible by others.

Fixes: df0b5c4a7ddd ("media: add imx355 camera sensor driver")
Cc: stable@vger.kernel.org
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/i2c/imx355.c

index cb51c81786bd3ce647b3227db65e4dd1a381de22..f49fc5663d221430b4ee995346e26d38eab96ca0 100644 (file)
@@ -1784,10 +1784,6 @@ static int imx355_probe(struct i2c_client *client)
                goto error_handler_free;
        }
 
-       ret = v4l2_async_register_subdev_sensor(&imx355->sd);
-       if (ret < 0)
-               goto error_media_entity;
-
        /*
         * Device is already turned on by i2c-core with ACPI domain PM.
         * Enable runtime PM and turn off the device.
@@ -1796,9 +1792,15 @@ static int imx355_probe(struct i2c_client *client)
        pm_runtime_enable(&client->dev);
        pm_runtime_idle(&client->dev);
 
+       ret = v4l2_async_register_subdev_sensor(&imx355->sd);
+       if (ret < 0)
+               goto error_media_entity_runtime_pm;
+
        return 0;
 
-error_media_entity:
+error_media_entity_runtime_pm:
+       pm_runtime_disable(&client->dev);
+       pm_runtime_set_suspended(&client->dev);
        media_entity_cleanup(&imx355->sd.entity);
 
 error_handler_free: