Skip to content

Commit

Permalink
soundwire: bus_type: add DPM_FLAG_SMART_SUSPEND support
Browse files Browse the repository at this point in the history
Where the SoundWire manager is pm_runtime suspended with the
clock-stop mode enabled, we currently do nothing on Intel platforms
before entering system suspend.

This is problematic since the hardware does not seem to fully reset
during system resume, we have e.g. been tracking issues related to
this clock stop mode for the last 6 months.

The power management framework already defines a
DPM_FLAG_SMART_SUSPEND flag. This patch exposes a bus .suspend
callback that will handle a pm_runtime_resume when this flag is not
set.

FIXME: need to find a way to set this flag or not depending on parent
capabilities.

BugLink: thesofproject#2606
Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
  • Loading branch information
plbossart committed Jun 23, 2021
1 parent b1c762a commit d6eea48
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions drivers/soundwire/bus_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
#include "bus.h"
Expand Down Expand Up @@ -71,9 +72,31 @@ int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env)
return 0;
}

static int __maybe_unused sdw_slave_suspend(struct device *dev)
{
int (*callback)(struct device *) = NULL;
int ret = 0;

if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND))
pm_runtime_resume(dev);

if (dev->driver && dev->driver->pm)
callback = dev->driver->pm->suspend;

if (callback)
ret = callback(dev);

return ret;
}

static const struct dev_pm_ops sdw_bus_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(sdw_slave_suspend, NULL)
};

struct bus_type sdw_bus_type = {
.name = "soundwire",
.match = sdw_bus_match,
.pm = &sdw_bus_pm_ops
};
EXPORT_SYMBOL_GPL(sdw_bus_type);

Expand Down

0 comments on commit d6eea48

Please sign in to comment.