* [PATCH 1/1] regmap: debugfs: runtime resume a device when reading registers
@ 2024-01-10 9:53 Alexander Stein
2024-01-10 12:23 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Stein @ 2024-01-10 9:53 UTC (permalink / raw)
To: Mark Brown, Greg Kroah-Hartman, Rafael J . Wysocki
Cc: Alexander Stein, linux-kernel
If the registers shall be read from device, runtime resume it in order
to enable a possiblly attached power domain before accessing the device.
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
drivers/base/regmap/regmap-debugfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index fb84cda92a753..063ede23173af 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -12,6 +12,7 @@
#include <linux/uaccess.h>
#include <linux/device.h>
#include <linux/list.h>
+#include <linux/pm_runtime.h>
#include "internal.h"
@@ -233,6 +234,10 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
if (!buf)
return -ENOMEM;
+ ret = pm_runtime_resume_and_get(map->dev);
+ if (ret)
+ goto out_free;
+
regmap_calc_tot_len(map, buf, count);
/* Work out which register we're starting at */
@@ -277,6 +282,8 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
*ppos += buf_pos;
out:
+ pm_runtime_put(map->dev);
+out_free:
kfree(buf);
return ret;
}
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] regmap: debugfs: runtime resume a device when reading registers
2024-01-10 9:53 [PATCH 1/1] regmap: debugfs: runtime resume a device when reading registers Alexander Stein
@ 2024-01-10 12:23 ` Mark Brown
2024-01-10 12:46 ` Alexander Stein
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2024-01-10 12:23 UTC (permalink / raw)
To: Alexander Stein; +Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
On Wed, Jan 10, 2024 at 10:53:58AM +0100, Alexander Stein wrote:
> If the registers shall be read from device, runtime resume it in order
> to enable a possiblly attached power domain before accessing the device.
The idea is that the debugfs interface isn't supposed to be disruptive
to the thing being debugged. It would be better to detect if there will
be problems and report the status as busy.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] regmap: debugfs: runtime resume a device when reading registers
2024-01-10 12:23 ` Mark Brown
@ 2024-01-10 12:46 ` Alexander Stein
2024-01-10 13:04 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Stein @ 2024-01-10 12:46 UTC (permalink / raw)
To: Mark Brown; +Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-kernel
Am Mittwoch, 10. Januar 2024, 13:23:17 CET schrieb Mark Brown:
> On Wed, Jan 10, 2024 at 10:53:58AM +0100, Alexander Stein wrote:
> > If the registers shall be read from device, runtime resume it in order
> > to enable a possiblly attached power domain before accessing the device.
>
> The idea is that the debugfs interface isn't supposed to be disruptive
> to the thing being debugged. It would be better to detect if there will
> be problems and report the status as busy.
In my case the device is actually unused, runtime suspended, thus disabled
power domain. That's totally different to busy. In this case dumping the
registers is non-disruptive, unless you account enabling/disabling the power
domain as well. Any attached clock is already enabled/disabled, but power
domains are not.
Best regards,
Alexander
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] regmap: debugfs: runtime resume a device when reading registers
2024-01-10 12:46 ` Alexander Stein
@ 2024-01-10 13:04 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2024-01-10 13:04 UTC (permalink / raw)
To: Alexander Stein; +Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 837 bytes --]
On Wed, Jan 10, 2024 at 01:46:31PM +0100, Alexander Stein wrote:
> Am Mittwoch, 10. Januar 2024, 13:23:17 CET schrieb Mark Brown:
> > The idea is that the debugfs interface isn't supposed to be disruptive
> > to the thing being debugged. It would be better to detect if there will
> > be problems and report the status as busy.
> In my case the device is actually unused, runtime suspended, thus disabled
> power domain. That's totally different to busy. In this case dumping the
> registers is non-disruptive, unless you account enabling/disabling the power
> domain as well. Any attached clock is already enabled/disabled, but power
> domains are not.
At a regmap level we map that onto -EBUSY for devices with a cache
(using a cache for your specific device ought to DTRT, it's not a
general solution though).
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-10 13:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 9:53 [PATCH 1/1] regmap: debugfs: runtime resume a device when reading registers Alexander Stein
2024-01-10 12:23 ` Mark Brown
2024-01-10 12:46 ` Alexander Stein
2024-01-10 13:04 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®