Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions drivers/soundwire/intel_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/pm_runtime.h>
#include <linux/soundwire/sdw_intel.h>
#include "cadence_master.h"
#include "bus.h"
#include "intel.h"
#include "intel_auxdevice.h"

Expand Down Expand Up @@ -363,6 +364,47 @@ void sdw_intel_exit(struct sdw_intel_ctx *ctx)
}
EXPORT_SYMBOL_NS(sdw_intel_exit, SOUNDWIRE_INTEL_INIT);

static int intel_disable_runtime_pm_child_device(struct device *dev, void *data)
{
struct sdw_slave *slave = dev_to_sdw_dev(dev);
unsigned long time;

if (!slave->probed) {
dev_dbg(dev, "skipping device, no probed driver\n");
return 0;
}
if (!slave->dev_num_sticky) {
dev_dbg(dev, "skipping device, never detected on bus\n");
return 0;
}

pm_runtime_disable(dev);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is conceptually broken.

pm_runtime_disable() only means that the device can no longer enter pm_runtime suspend. It doesn't do what is suggested in the commit message "wait for peripherals to being initialized"

In addition, if something else tries to do a pm_runtime_get_sync() or pm_runtime_resume(), an error code -EACCESS will be thrown.

We should only use pm_runtime_disable() in the .remove functions or AFTER resuming the devices fully.

time = wait_for_completion_timeout(&slave->initialization_complete,
msecs_to_jiffies(5000));

if (!time) {
dev_err(&slave->dev, "Initialization not complete, timed out\n");
return -ETIMEDOUT;
}
return 0;
}

void sdw_intel_pre_exit(struct sdw_intel_ctx *ctx)
{
struct sdw_intel_link_res *link;

list_for_each_entry(link, &ctx->link_list, list) {
struct sdw_bus *bus = &link->cdns->bus;
int ret;

ret = device_for_each_child(bus->dev, NULL, intel_disable_runtime_pm_child_device);
if (ret < 0)
dev_err(bus->dev, "%s: intel_disable_runtime_pm_child_device failed: %d\n",
__func__, ret);
}
}
EXPORT_SYMBOL_NS(sdw_intel_pre_exit, SOUNDWIRE_INTEL_INIT);

void sdw_intel_process_wakeen_event(struct sdw_intel_ctx *ctx)
{
struct sdw_intel_link_dev *ldev;
Expand Down
1 change: 1 addition & 0 deletions include/linux/soundwire/sdw_intel.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ sdw_intel_probe(struct sdw_intel_res *res);
int sdw_intel_startup(struct sdw_intel_ctx *ctx);

void sdw_intel_exit(struct sdw_intel_ctx *ctx);
void sdw_intel_pre_exit(struct sdw_intel_ctx *ctx);

irqreturn_t sdw_intel_thread(int irq, void *dev_id);

Expand Down
3 changes: 3 additions & 0 deletions sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ static int hda_sdw_exit(struct snd_sof_dev *sdev)

hdev = sdev->pdata->hw_pdata;

if (hdev->sdw)
sdw_intel_pre_exit(hdev->sdw);

hda_sdw_int_enable(sdev, false);

if (hdev->sdw)
Expand Down