From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <vkoul@kernel.org>
Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com,
pierre-louis.bossart@linux.intel.com,
linux-kernel@vger.kernel.org, sanyog.r.kale@intel.com,
yung-chuan.liao@linux.intel.com
Subject: [PATCH v4 3/4] soundwire: debugfs: Switch to sdw_read_no_pm
Date: Fri, 25 Nov 2022 14:20:27 +0000 [thread overview]
Message-ID: <20221125142028.1118618-4-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20221125142028.1118618-1-ckeepax@opensource.cirrus.com>
It is rather inefficient to be constantly playing with the runtime
PM reference for each individual register, switch to holding a PM
runtime reference across the whole register output.
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
No change since v3.
drivers/soundwire/debugfs.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/soundwire/debugfs.c b/drivers/soundwire/debugfs.c
index 49900cd207bc7..dea782e0edc4b 100644
--- a/drivers/soundwire/debugfs.c
+++ b/drivers/soundwire/debugfs.c
@@ -4,6 +4,7 @@
#include <linux/device.h>
#include <linux/debugfs.h>
#include <linux/mod_devicetable.h>
+#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_registers.h>
@@ -35,7 +36,7 @@ static ssize_t sdw_sprintf(struct sdw_slave *slave,
{
int value;
- value = sdw_read(slave, reg);
+ value = sdw_read_no_pm(slave, reg);
if (value < 0)
return scnprintf(buf + pos, RD_BUF - pos, "%3x\tXX\n", reg);
@@ -55,6 +56,12 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
if (!buf)
return -ENOMEM;
+ ret = pm_runtime_resume_and_get(&slave->dev);
+ if (ret < 0 && ret != -EACCES) {
+ kfree(buf);
+ return ret;
+ }
+
ret = scnprintf(buf, RD_BUF, "Register Value\n");
/* DP0 non-banked registers */
@@ -112,6 +119,10 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
}
seq_printf(s_file, "%s", buf);
+
+ pm_runtime_mark_last_busy(&slave->dev);
+ pm_runtime_put(&slave->dev);
+
kfree(buf);
return 0;
--
2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <vkoul@kernel.org>
Cc: <yung-chuan.liao@linux.intel.com>,
<pierre-louis.bossart@linux.intel.com>, <sanyog.r.kale@intel.com>,
<alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
<patches@opensource.cirrus.com>
Subject: [PATCH v4 3/4] soundwire: debugfs: Switch to sdw_read_no_pm
Date: Fri, 25 Nov 2022 14:20:27 +0000 [thread overview]
Message-ID: <20221125142028.1118618-4-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20221125142028.1118618-1-ckeepax@opensource.cirrus.com>
It is rather inefficient to be constantly playing with the runtime
PM reference for each individual register, switch to holding a PM
runtime reference across the whole register output.
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
No change since v3.
drivers/soundwire/debugfs.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/soundwire/debugfs.c b/drivers/soundwire/debugfs.c
index 49900cd207bc7..dea782e0edc4b 100644
--- a/drivers/soundwire/debugfs.c
+++ b/drivers/soundwire/debugfs.c
@@ -4,6 +4,7 @@
#include <linux/device.h>
#include <linux/debugfs.h>
#include <linux/mod_devicetable.h>
+#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_registers.h>
@@ -35,7 +36,7 @@ static ssize_t sdw_sprintf(struct sdw_slave *slave,
{
int value;
- value = sdw_read(slave, reg);
+ value = sdw_read_no_pm(slave, reg);
if (value < 0)
return scnprintf(buf + pos, RD_BUF - pos, "%3x\tXX\n", reg);
@@ -55,6 +56,12 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
if (!buf)
return -ENOMEM;
+ ret = pm_runtime_resume_and_get(&slave->dev);
+ if (ret < 0 && ret != -EACCES) {
+ kfree(buf);
+ return ret;
+ }
+
ret = scnprintf(buf, RD_BUF, "Register Value\n");
/* DP0 non-banked registers */
@@ -112,6 +119,10 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
}
seq_printf(s_file, "%s", buf);
+
+ pm_runtime_mark_last_busy(&slave->dev);
+ pm_runtime_put(&slave->dev);
+
kfree(buf);
return 0;
--
2.30.2
next prev parent reply other threads:[~2022-11-25 14:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 14:20 [PATCH v4 0/4] Minor SoundWire clean ups Charles Keepax
2022-11-25 14:20 ` Charles Keepax
2022-11-25 14:20 ` [PATCH v4 1/4] soundwire: bus: export sdw_nwrite_no_pm and sdw_nread_no_pm functions Charles Keepax
2022-11-25 14:20 ` Charles Keepax
2022-11-25 14:20 ` [PATCH v4 2/4] soundwire: Provide build stubs for common functions Charles Keepax
2022-11-25 14:20 ` Charles Keepax
2022-11-25 14:20 ` Charles Keepax [this message]
2022-11-25 14:20 ` [PATCH v4 3/4] soundwire: debugfs: Switch to sdw_read_no_pm Charles Keepax
2022-11-25 14:20 ` [PATCH v4 4/4] soundwire: stream: Move remaining register accesses over to no_pm Charles Keepax
2022-11-25 14:20 ` Charles Keepax
2023-01-09 16:16 ` [PATCH v4 0/4] Minor SoundWire clean ups Vinod Koul
2023-01-09 16:16 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221125142028.1118618-4-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.