linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] bus: mhi: host: pci_generic: Flush recovery worker during freeze
@ 2022-04-08 15:00 Manivannan Sadhasivam
  2022-04-08 18:30 ` Bhaumik Vasav Bhatt
  2022-04-11  6:09 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2022-04-08 15:00 UTC (permalink / raw)
  To: mhi
  Cc: quic_hemantk, quic_bbhatt, linux-arm-msm, linux-kernel,
	loic.poulain, Manivannan Sadhasivam, stable

It is possible that the recovery work might be running while the freeze
gets executed (during hibernation etc.,). Currently, we don't powerdown
the stack if it is not up but if the recovery work completes after freeze,
then the device will be up afterwards. This will not be a sane situation.

So let's flush the recovery worker before trying to powerdown the device.

Cc: stable@vger.kernel.org
Fixes: 5f0c2ee1fe8d ("bus: mhi: pci-generic: Fix hibernation")
Reported-by: Bhaumik Vasav Bhatt <quic_bbhatt@quicinc.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---

Changes in v2:

* Switched to flush_work() as the workqueue used is global one.

 drivers/bus/mhi/host/pci_generic.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
index ef85dbfb3216..541ced27d941 100644
--- a/drivers/bus/mhi/host/pci_generic.c
+++ b/drivers/bus/mhi/host/pci_generic.c
@@ -1060,6 +1060,7 @@ static int __maybe_unused mhi_pci_freeze(struct device *dev)
 	 * the intermediate restore kernel reinitializes MHI device with new
 	 * context.
 	 */
+	flush_work(&mhi_pdev->recovery_work);
 	if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
 		mhi_power_down(mhi_cntrl, true);
 		mhi_unprepare_after_power_down(mhi_cntrl);
-- 
2.25.1


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

* Re: [PATCH v2] bus: mhi: host: pci_generic: Flush recovery worker during freeze
  2022-04-08 15:00 [PATCH v2] bus: mhi: host: pci_generic: Flush recovery worker during freeze Manivannan Sadhasivam
@ 2022-04-08 18:30 ` Bhaumik Vasav Bhatt
  2022-04-11  6:09 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Bhaumik Vasav Bhatt @ 2022-04-08 18:30 UTC (permalink / raw)
  To: Manivannan Sadhasivam, mhi
  Cc: quic_hemantk, linux-arm-msm, linux-kernel, loic.poulain, stable


On 4/8/2022 8:00 AM, Manivannan Sadhasivam wrote:
> It is possible that the recovery work might be running while the freeze
> gets executed (during hibernation etc.,). Currently, we don't powerdown
> the stack if it is not up but if the recovery work completes after freeze,
> then the device will be up afterwards. This will not be a sane situation.
>
> So let's flush the recovery worker before trying to powerdown the device.
>
> Cc: stable@vger.kernel.org
> Fixes: 5f0c2ee1fe8d ("bus: mhi: pci-generic: Fix hibernation")
> Reported-by: Bhaumik Vasav Bhatt <quic_bbhatt@quicinc.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
Reviewed-by: Bhaumik Vasav Bhatt <quic_bbhatt@quicinc.com>
> Changes in v2:
>
> * Switched to flush_work() as the workqueue used is global one.
>
>   drivers/bus/mhi/host/pci_generic.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
> index ef85dbfb3216..541ced27d941 100644
> --- a/drivers/bus/mhi/host/pci_generic.c
> +++ b/drivers/bus/mhi/host/pci_generic.c
> @@ -1060,6 +1060,7 @@ static int __maybe_unused mhi_pci_freeze(struct device *dev)
>   	 * the intermediate restore kernel reinitializes MHI device with new
>   	 * context.
>   	 */
> +	flush_work(&mhi_pdev->recovery_work);
>   	if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
>   		mhi_power_down(mhi_cntrl, true);
>   		mhi_unprepare_after_power_down(mhi_cntrl);

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

* Re: [PATCH v2] bus: mhi: host: pci_generic: Flush recovery worker during freeze
  2022-04-08 15:00 [PATCH v2] bus: mhi: host: pci_generic: Flush recovery worker during freeze Manivannan Sadhasivam
  2022-04-08 18:30 ` Bhaumik Vasav Bhatt
@ 2022-04-11  6:09 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2022-04-11  6:09 UTC (permalink / raw)
  To: mhi
  Cc: quic_hemantk, quic_bbhatt, linux-arm-msm, linux-kernel,
	loic.poulain, stable

On Fri, Apr 08, 2022 at 08:30:39PM +0530, Manivannan Sadhasivam wrote:
> It is possible that the recovery work might be running while the freeze
> gets executed (during hibernation etc.,). Currently, we don't powerdown
> the stack if it is not up but if the recovery work completes after freeze,
> then the device will be up afterwards. This will not be a sane situation.
> 
> So let's flush the recovery worker before trying to powerdown the device.
> 
> Cc: stable@vger.kernel.org
> Fixes: 5f0c2ee1fe8d ("bus: mhi: pci-generic: Fix hibernation")
> Reported-by: Bhaumik Vasav Bhatt <quic_bbhatt@quicinc.com>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Applied to mhi-next!

Thanks,
Mani

> ---
> 
> Changes in v2:
> 
> * Switched to flush_work() as the workqueue used is global one.
> 
>  drivers/bus/mhi/host/pci_generic.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
> index ef85dbfb3216..541ced27d941 100644
> --- a/drivers/bus/mhi/host/pci_generic.c
> +++ b/drivers/bus/mhi/host/pci_generic.c
> @@ -1060,6 +1060,7 @@ static int __maybe_unused mhi_pci_freeze(struct device *dev)
>  	 * the intermediate restore kernel reinitializes MHI device with new
>  	 * context.
>  	 */
> +	flush_work(&mhi_pdev->recovery_work);
>  	if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
>  		mhi_power_down(mhi_cntrl, true);
>  		mhi_unprepare_after_power_down(mhi_cntrl);
> -- 
> 2.25.1
> 

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

end of thread, other threads:[~2022-04-11  6:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 15:00 [PATCH v2] bus: mhi: host: pci_generic: Flush recovery worker during freeze Manivannan Sadhasivam
2022-04-08 18:30 ` Bhaumik Vasav Bhatt
2022-04-11  6:09 ` Manivannan Sadhasivam

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).