media: atomisp: Allow system suspend to continue with open /dev/video# nodes
authorHans de Goede <hdegoede@redhat.com>
Fri, 12 May 2023 15:24:32 +0000 (16:24 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 9 Jun 2023 13:50:06 +0000 (14:50 +0100)
Just having a /dev/video# node open is not a reason to block system
suspend. At least when userspace is not streaming.

In that case the worst case scenario is that streams have been created,
but we can just destroy those before powering off the ISP and
recreate the streams on resume.

Fixing suspend when streaming is left as a FIXME item for later.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_subdev.h
drivers/staging/media/atomisp/pci/atomisp_v4l2.c

index 49177386d57fc7e09717b7f65f08bd85342d7d83..dc6970b486333ef00795bd7971ebe73defe2e6b5 100644 (file)
@@ -301,6 +301,7 @@ struct atomisp_sub_device {
         */
        bool streaming;
        bool stream_prepared; /* whether css stream is created */
+       bool recreate_streams_on_resume;
 
        unsigned int latest_preview_exp_id; /* CSS ZSL/SDV raw buffer id */
 
index c68e9062743d09f1be4d7da671ca2d7837b41d5b..a76b60f8b41182868f89950262ddce0baf657db9 100644 (file)
@@ -664,13 +664,7 @@ static int atomisp_suspend(struct device *dev)
                                     dev_get_drvdata(dev);
        unsigned long flags;
 
-       /*
-        * FIXME: Suspend is not supported by sensors. Abort if any video
-        * node was opened.
-        */
-       if (atomisp_dev_users(isp))
-               return -EBUSY;
-
+       /* FIXME: Suspend is not supported by sensors. Abort if streaming. */
        spin_lock_irqsave(&isp->lock, flags);
        if (isp->asd.streaming) {
                spin_unlock_irqrestore(&isp->lock, flags);
@@ -681,12 +675,25 @@ static int atomisp_suspend(struct device *dev)
 
        pm_runtime_resume(dev);
 
+       isp->asd.recreate_streams_on_resume = isp->asd.stream_prepared;
+       atomisp_destroy_pipes_stream(&isp->asd);
+
        return atomisp_power_off(dev);
 }
 
 static int atomisp_resume(struct device *dev)
 {
-       return atomisp_power_on(dev);
+       struct atomisp_device *isp = dev_get_drvdata(dev);
+       int ret;
+
+       ret = atomisp_power_on(dev);
+       if (ret)
+               return ret;
+
+       if (isp->asd.recreate_streams_on_resume)
+               ret = atomisp_create_pipes_stream(&isp->asd);
+
+       return ret;
 }
 
 int atomisp_csi_lane_config(struct atomisp_device *isp)