History

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.

Geert Uytterhoeven committed 6 years ago

Commit 30332ee1 parent 9e00df72 files · +9 −0Browse files

Unified · Split

2 files
  1. fs/debugfs/file.c +8 −0
  2. include/linux/debugfs.h +1 −0
fs/debugfs/file.c+8−0
@@ -18,6 +18,7 @@ · 17 unmodified lines
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) · 1036 unmodified lines
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+1−0
@@ -35,6 +35,7 @@ struct debugfs_regset32 { · 34 unmodified lines
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;