mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] mei: vsc: Don't stop/restart mei device during system suspend/resume
@ 2024-05-27 12:38 Wentong Wu
  2024-05-27 20:23 ` Winkler, Tomas
  0 siblings, 1 reply; 3+ messages in thread
From: Wentong Wu @ 2024-05-27 12:38 UTC (permalink / raw)
  To: sakari.ailus, tomas.winkler, gregkh
  Cc: linux-kernel, Wentong Wu, stable, Hao Yao, Jason Chen

The dynamically created mei client device (mei csi) is used as one V4L2
sub device of the whole video pipeline, and the V4L2 connection graph is
built by software node. The mei_stop() and mei_restart() will delete the
old mei csi client device and create a new mei client device, which will
cause the software node information saved in old mei csi device lost and
the whole video pipeline will be broken.

Removing mei_stop()/mei_restart() during system suspend/resume can fix
the issue above and won't impact hardware actual power saving logic.

Fixes: f6085a96c973 ("mei: vsc: Unregister interrupt handler for system suspend")
Cc: stable@vger.kernel.org # for 6.8+
Reported-by: Hao Yao <hao.yao@intel.com>
Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Jason Chen <jason.z.chen@intel.com>
Tested-by: Sakari Ailus <sakari.ailus@linux.intel.com>

---
Changes since v2:
 - add change log which is not covered by v2, and no code change

Changes since v1:
 - correct Fixes commit id in commit message, and no code change

---
 drivers/misc/mei/platform-vsc.c | 39 +++++++++++++--------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/drivers/misc/mei/platform-vsc.c b/drivers/misc/mei/platform-vsc.c
index b543e6b9f3cf..1ec65d87488a 100644
--- a/drivers/misc/mei/platform-vsc.c
+++ b/drivers/misc/mei/platform-vsc.c
@@ -399,41 +399,32 @@ static void mei_vsc_remove(struct platform_device *pdev)
 
 static int mei_vsc_suspend(struct device *dev)
 {
-	struct mei_device *mei_dev = dev_get_drvdata(dev);
-	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);
+	struct mei_device *mei_dev;
+	int ret = 0;
 
-	mei_stop(mei_dev);
+	mei_dev = dev_get_drvdata(dev);
+	if (!mei_dev)
+		return -ENODEV;
 
-	mei_disable_interrupts(mei_dev);
+	mutex_lock(&mei_dev->device_lock);
 
-	vsc_tp_free_irq(hw->tp);
+	if (!mei_write_is_idle(mei_dev))
+		ret = -EAGAIN;
 
-	return 0;
+	mutex_unlock(&mei_dev->device_lock);
+
+	return ret;
 }
 
 static int mei_vsc_resume(struct device *dev)
 {
-	struct mei_device *mei_dev = dev_get_drvdata(dev);
-	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);
-	int ret;
-
-	ret = vsc_tp_request_irq(hw->tp);
-	if (ret)
-		return ret;
-
-	ret = mei_restart(mei_dev);
-	if (ret)
-		goto err_free;
+	struct mei_device *mei_dev;
 
-	/* start timer if stopped in suspend */
-	schedule_delayed_work(&mei_dev->timer_work, HZ);
+	mei_dev = dev_get_drvdata(dev);
+	if (!mei_dev)
+		return -ENODEV;
 
 	return 0;
-
-err_free:
-	vsc_tp_free_irq(hw->tp);
-
-	return ret;
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(mei_vsc_pm_ops, mei_vsc_suspend, mei_vsc_resume);
-- 
2.34.1


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

* RE: [PATCH v3] mei: vsc: Don't stop/restart mei device during system suspend/resume
  2024-05-27 12:38 [PATCH v3] mei: vsc: Don't stop/restart mei device during system suspend/resume Wentong Wu
@ 2024-05-27 20:23 ` Winkler, Tomas
  2024-05-28  0:57   ` Wu, Wentong
  0 siblings, 1 reply; 3+ messages in thread
From: Winkler, Tomas @ 2024-05-27 20:23 UTC (permalink / raw)
  To: Wu, Wentong, sakari.ailus, gregkh
  Cc: linux-kernel, stable, Yao, Hao, Chen, Jason Z



> -----Original Message-----
> From: Wu, Wentong <wentong.wu@intel.com>
> Sent: Monday, May 27, 2024 3:39 PM
> To: sakari.ailus@linux.intel.com; Winkler, Tomas
> <tomas.winkler@intel.com>; gregkh@linuxfoundation.org
> Cc: linux-kernel@vger.kernel.org; Wu, Wentong <wentong.wu@intel.com>;
> stable@vger.kernel.org; Yao, Hao <hao.yao@intel.com>; Chen, Jason Z
> <jason.z.chen@intel.com>
> Subject: [PATCH v3] mei: vsc: Don't stop/restart mei device during system
> suspend/resume
> 
> The dynamically created mei client device (mei csi) is used as one V4L2 sub
> device of the whole video pipeline, and the V4L2 connection graph is built by
> software node. The mei_stop() and mei_restart() will delete the old mei csi
> client device and create a new mei client device, which will cause the
> software node information saved in old mei csi device lost and the whole
> video pipeline will be broken.
> 
> Removing mei_stop()/mei_restart() during system suspend/resume can fix
> the issue above and won't impact hardware actual power saving logic.
> 
> Fixes: f6085a96c973 ("mei: vsc: Unregister interrupt handler for system
> suspend")
> Cc: stable@vger.kernel.org # for 6.8+
> Reported-by: Hao Yao <hao.yao@intel.com>
> Signed-off-by: Wentong Wu <wentong.wu@intel.com>
> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Tested-by: Jason Chen <jason.z.chen@intel.com>
> Tested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
> 
> ---
> Changes since v2:
>  - add change log which is not covered by v2, and no code change
> 
> Changes since v1:
>  - correct Fixes commit id in commit message, and no code change
> 
> ---
vX descriptions should go here 


>  drivers/misc/mei/platform-vsc.c | 39 +++++++++++++--------------------
>  1 file changed, 15 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/misc/mei/platform-vsc.c b/drivers/misc/mei/platform-
> vsc.c index b543e6b9f3cf..1ec65d87488a 100644
> --- a/drivers/misc/mei/platform-vsc.c
> +++ b/drivers/misc/mei/platform-vsc.c
> @@ -399,41 +399,32 @@ static void mei_vsc_remove(struct platform_device
> *pdev)
> 
>  static int mei_vsc_suspend(struct device *dev)  {
> -	struct mei_device *mei_dev = dev_get_drvdata(dev);
> -	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);
> +	struct mei_device *mei_dev;
> +	int ret = 0;
> 
> -	mei_stop(mei_dev);
> +	mei_dev = dev_get_drvdata(dev);
> +	if (!mei_dev)
> +		return -ENODEV;
> 
> -	mei_disable_interrupts(mei_dev);
> +	mutex_lock(&mei_dev->device_lock);
> 
> -	vsc_tp_free_irq(hw->tp);
> +	if (!mei_write_is_idle(mei_dev))
> +		ret = -EAGAIN;
> 
> -	return 0;
> +	mutex_unlock(&mei_dev->device_lock);
> +
> +	return ret;
>  }
> 
>  static int mei_vsc_resume(struct device *dev)  {
> -	struct mei_device *mei_dev = dev_get_drvdata(dev);
> -	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);
> -	int ret;
> -
> -	ret = vsc_tp_request_irq(hw->tp);
> -	if (ret)
> -		return ret;
> -
> -	ret = mei_restart(mei_dev);
> -	if (ret)
> -		goto err_free;
> +	struct mei_device *mei_dev;
> 
> -	/* start timer if stopped in suspend */
> -	schedule_delayed_work(&mei_dev->timer_work, HZ);
> +	mei_dev = dev_get_drvdata(dev);
> +	if (!mei_dev)
> +		return -ENODEV;
> 
>  	return 0;
> -
> -err_free:
> -	vsc_tp_free_irq(hw->tp);
> -
> -	return ret;
>  }
> 
>  static DEFINE_SIMPLE_DEV_PM_OPS(mei_vsc_pm_ops, mei_vsc_suspend,
> mei_vsc_resume);
> --
> 2.34.1


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

* RE: [PATCH v3] mei: vsc: Don't stop/restart mei device during system suspend/resume
  2024-05-27 20:23 ` Winkler, Tomas
@ 2024-05-28  0:57   ` Wu, Wentong
  0 siblings, 0 replies; 3+ messages in thread
From: Wu, Wentong @ 2024-05-28  0:57 UTC (permalink / raw)
  To: Winkler, Tomas, sakari.ailus, gregkh
  Cc: linux-kernel, stable, Yao, Hao, Chen, Jason Z

> From: Winkler, Tomas <tomas.winkler@intel.com>
> > From: Wu, Wentong <wentong.wu@intel.com>
> >
> > The dynamically created mei client device (mei csi) is used as one
> > V4L2 sub device of the whole video pipeline, and the V4L2 connection
> > graph is built by software node. The mei_stop() and mei_restart() will
> > delete the old mei csi client device and create a new mei client
> > device, which will cause the software node information saved in old
> > mei csi device lost and the whole video pipeline will be broken.
> >
> > Removing mei_stop()/mei_restart() during system suspend/resume can fix
> > the issue above and won't impact hardware actual power saving logic.
> >
> > Fixes: f6085a96c973 ("mei: vsc: Unregister interrupt handler for
> > system
> > suspend")
> > Cc: stable@vger.kernel.org # for 6.8+
> > Reported-by: Hao Yao <hao.yao@intel.com>
> > Signed-off-by: Wentong Wu <wentong.wu@intel.com>
> > Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Tested-by: Jason Chen <jason.z.chen@intel.com>
> > Tested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Acked-by: Tomas Winkler <tomas.winkler@intel.com>

Thanks
> >
> > ---
> > Changes since v2:
> >  - add change log which is not covered by v2, and no code change
> >
> > Changes since v1:
> >  - correct Fixes commit id in commit message, and no code change
> >
> > ---
> vX descriptions should go here

Thanks, I will follow this going forward, thanks

BR,
Wentong
> 
> 
> >  drivers/misc/mei/platform-vsc.c | 39
> > +++++++++++++--------------------
> >  1 file changed, 15 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/misc/mei/platform-vsc.c
> > b/drivers/misc/mei/platform- vsc.c index b543e6b9f3cf..1ec65d87488a
> > 100644
> > --- a/drivers/misc/mei/platform-vsc.c
> > +++ b/drivers/misc/mei/platform-vsc.c
> > @@ -399,41 +399,32 @@ static void mei_vsc_remove(struct
> > platform_device
> > *pdev)
> >
> >  static int mei_vsc_suspend(struct device *dev)  {
> > -	struct mei_device *mei_dev = dev_get_drvdata(dev);
> > -	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);
> > +	struct mei_device *mei_dev;
> > +	int ret = 0;
> >
> > -	mei_stop(mei_dev);
> > +	mei_dev = dev_get_drvdata(dev);
> > +	if (!mei_dev)
> > +		return -ENODEV;
> >
> > -	mei_disable_interrupts(mei_dev);
> > +	mutex_lock(&mei_dev->device_lock);
> >
> > -	vsc_tp_free_irq(hw->tp);
> > +	if (!mei_write_is_idle(mei_dev))
> > +		ret = -EAGAIN;
> >
> > -	return 0;
> > +	mutex_unlock(&mei_dev->device_lock);
> > +
> > +	return ret;
> >  }
> >
> >  static int mei_vsc_resume(struct device *dev)  {
> > -	struct mei_device *mei_dev = dev_get_drvdata(dev);
> > -	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);
> > -	int ret;
> > -
> > -	ret = vsc_tp_request_irq(hw->tp);
> > -	if (ret)
> > -		return ret;
> > -
> > -	ret = mei_restart(mei_dev);
> > -	if (ret)
> > -		goto err_free;
> > +	struct mei_device *mei_dev;
> >
> > -	/* start timer if stopped in suspend */
> > -	schedule_delayed_work(&mei_dev->timer_work, HZ);
> > +	mei_dev = dev_get_drvdata(dev);
> > +	if (!mei_dev)
> > +		return -ENODEV;
> >
> >  	return 0;
> > -
> > -err_free:
> > -	vsc_tp_free_irq(hw->tp);
> > -
> > -	return ret;
> >  }
> >
> >  static DEFINE_SIMPLE_DEV_PM_OPS(mei_vsc_pm_ops, mei_vsc_suspend,
> > mei_vsc_resume);
> > --
> > 2.34.1


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

end of thread, other threads:[~2024-05-28  0:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-27 12:38 [PATCH v3] mei: vsc: Don't stop/restart mei device during system suspend/resume Wentong Wu
2024-05-27 20:23 ` Winkler, Tomas
2024-05-28  0:57   ` Wu, Wentong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®