From 211d0a6a1c70a5c4045b060d7ec12a1f7016ae3f Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 9 Nov 2018 10:21:10 +0800 Subject: [PATCH] ASoC: SOF: debug: change runtime PM get/put to correct usuage When doing debugFS entry read, we should make sure it won't enter suspend during the reading, and the reading won't interact the runtime PM(e.g. if the idle timeout is expired when should enter runtime suspend ASSP) neither. Here change to use get_noresume() to make sure not resuming ADSP for debugFS reading, and put_sync_autosuspend() to ensure we can enter runtime suspend after reading finished if needed. Signed-off-by: Keyon Jie --- sound/soc/sof/debug.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c index f1a95902279fb5..fa25be01a09657 100644 --- a/sound/soc/sof/debug.c +++ b/sound/soc/sof/debug.c @@ -36,7 +36,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, { struct snd_sof_dfsentry_io *dfse = file->private_data; struct snd_sof_dev *sdev = dfse->sdev; - int size, err; + int size; u32 *buf; loff_t pos = *ppos; size_t ret; @@ -58,20 +58,18 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, return -ENOMEM; /* copy from DSP MMIO */ - err = pm_runtime_get_sync(sdev->dev); - if (err < 0) { - dev_err(sdev->dev, "error: debugFS failed to resume %d\n", - err); - kfree(buf); - return err; - } + pm_runtime_get_noresume(sdev->dev); memcpy_fromio(buf, dfse->buf + pos, size); - ret = pm_runtime_put(sdev->dev); + /* + * TODO: revisit to check if we need mark_last_busy, or if we + * should change to use xxx_put_sync[_suspend](). + */ + ret = pm_runtime_put_sync_autosuspend(sdev->dev); if (ret < 0) - dev_err(sdev->dev, "error: debugFS failed to idle %zd\n", - ret); + dev_warn(sdev->dev, "warn: debugFS failed to autosuspend %zd\n", + ret); /* copy to userspace */ ret = copy_to_user(buffer, buf, count);