Re: [PATCH v4 3/3] PM: i2c-designware-platdrv: Suspend/resume at the late/early stages

Wolfram Sang
2017-10-05T11:00:55Z

[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]

On Mon, Sep 25, 2017 at 01:30:51AM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> As reported by Rajat Jain, there are problems when ACPI operation
> region handlers or similar, called at the ->resume_early() time, for
> I2C client devices try to access an I2C controller that has already
> been suspended at that point. To avoid that, move the suspend/resume
> of i2c-designware-platdrv to the late/early stages, respectively.
>
> While at it, avoid resuming the device from runtime suspend in the
> driver's ->suspend callback which isn't particularly nice. [A better
> approach would be to make the driver track the PM state of the device
> so that it doesn't need to resume it in ->suspend, so implement it.]
>
> First, drop dw_i2c_plat_suspend() added by commit a23318feeff6 (i2c:
> designware: Fix system suspend) and rename dw_i2c_plat_runtime_suspend()
> back to dw_i2c_plat_suspend().
>
> Second, point the driver's ->late_suspend and ->early_resume
> callbacks, rather than its ->suspend and ->resume callbacks,
> to dw_i2c_plat_suspend() and dw_i2c_plat_resume(), respectively,
> so that they are not executed in parallel with each other, for
> example if runtime resume of the device takes place during system
> suspend.
>
> Finally, add "suspended" and "skip_resume" flags to struct dw_i2c_dev
> and make dw_i2c_plat_suspend() and dw_i2c_plat_resume() use them to
> avoid suspending or resuming the device twice in a row and to avoid
> resuming a previously runtime-suspended device during system resume.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Tested-by: Johannes Stezenbach <js@sig21.net>
> Tested-by: Rajat Jain <rajatja@google.com>

Applied to for-next, thanks!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]