Re: [PATCH] net: wwan: t7xx: Ensure init is completed before system sleep

From: Piotr Raczynski
Date: Tue May 16 2023 - 06:42:57 EST


On Tue, May 16, 2023 at 04:03:27PM +0800, Kai-Heng Feng wrote:
> When the system attempts to sleep while mtk_t7xx is not ready, the driver
> cannot put the device to sleep:
> [ 12.472918] mtk_t7xx 0000:57:00.0: [PM] Exiting suspend, modem in invalid state
> [ 12.472936] mtk_t7xx 0000:57:00.0: PM: pci_pm_suspend(): t7xx_pci_pm_suspend+0x0/0x20 [mtk_t7xx] returns -14
> [ 12.473678] mtk_t7xx 0000:57:00.0: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1b0 returns -14
> [ 12.473711] mtk_t7xx 0000:57:00.0: PM: failed to suspend async: error -14
> [ 12.764776] PM: Some devices failed to suspend, or early wake event detected
>
> Mediatek confirmed the device can take a rather long time to complete
> its initialization, so wait for up to 20 seconds until init is done.
>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@xxxxxxxxxxxxx>

Does it fix any issue? Anyway target tree would help here I guess.

[...]

> +static int t7xx_pci_pm_prepare(struct device *dev)
> +{
> + struct pci_dev *pdev = to_pci_dev(dev);
> + struct t7xx_pci_dev *t7xx_dev;
> +
> + t7xx_dev = pci_get_drvdata(pdev);
> + if (!wait_for_completion_timeout(&t7xx_dev->init_done, 20 * HZ))

#define T7XX_INIT_TIMEOUT or something similar wouldn't do any harm here.

> + dev_warn(dev, "Not ready for system sleep.\n");
> +
> + return 0;

So in case of a timeout you still return 0, is that OK?

[...]
Thanks, Piotr.