Commit 30332eee authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Herbert Xu

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: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 9e00df71
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/pm_runtime.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/security.h> #include <linux/security.h>
...@@ -1060,7 +1061,14 @@ static int debugfs_show_regset32(struct seq_file *s, void *data) ...@@ -1060,7 +1061,14 @@ static int debugfs_show_regset32(struct seq_file *s, void *data)
{ {
struct debugfs_regset32 *regset = s->private; struct debugfs_regset32 *regset = s->private;
if (regset->dev)
pm_runtime_get_sync(regset->dev);
debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, ""); debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, "");
if (regset->dev)
pm_runtime_put(regset->dev);
return 0; return 0;
} }
......
...@@ -35,6 +35,7 @@ struct debugfs_regset32 { ...@@ -35,6 +35,7 @@ struct debugfs_regset32 {
const struct debugfs_reg32 *regs; const struct debugfs_reg32 *regs;
int nregs; int nregs;
void __iomem *base; void __iomem *base;
struct device *dev; /* Optional device for Runtime PM */
}; };
extern struct dentry *arch_debugfs_dir; extern struct dentry *arch_debugfs_dir;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment