Skip to content

Commit 30332ee

Browse files
geertuherbertx
authored andcommitted
debugfs: regset32: Add Runtime PM support
Hardware registers of devices under control of power management cannot be accessed at all times. If such a device is suspended, register accesses may lead to undefined behavior, like reading bogus values, or causing exceptions or system lock-ups. Extend struct debugfs_regset32 with an optional field to let device drivers specify the device the registers in the set belong to. This allows debugfs_show_regset32() to make sure the device is resumed while its registers are being read. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 9e00df7 commit 30332ee

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

fs/debugfs/file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/slab.h>
1919
#include <linux/atomic.h>
2020
#include <linux/device.h>
21+
#include <linux/pm_runtime.h>
2122
#include <linux/poll.h>
2223
#include <linux/security.h>
2324

@@ -1060,7 +1061,14 @@ static int debugfs_show_regset32(struct seq_file *s, void *data)
10601061
{
10611062
struct debugfs_regset32 *regset = s->private;
10621063

1064+
if (regset->dev)
1065+
pm_runtime_get_sync(regset->dev);
1066+
10631067
debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, "");
1068+
1069+
if (regset->dev)
1070+
pm_runtime_put(regset->dev);
1071+
10641072
return 0;
10651073
}
10661074

include/linux/debugfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct debugfs_regset32 {
3535
const struct debugfs_reg32 *regs;
3636
int nregs;
3737
void __iomem *base;
38+
struct device *dev; /* Optional device for Runtime PM */
3839
};
3940

4041
extern struct dentry *arch_debugfs_dir;

0 commit comments

Comments
 (0)