Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent voltage low warnings from filling log #2520

Merged
merged 1 commit into from
Apr 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions drivers/firmware/raspberrypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,38 @@

#define UNDERVOLTAGE_BIT BIT(0)


/*
* This section defines some rate limited logging that prevent
* repeated messages at much lower Hz than the default kernel settings.
* It's usually 5s, this is 5 minutes.
* Burst 3 means you may get three messages 'quickly', before
* the ratelimiting kicks in.
*/
#define LOCAL_RATELIMIT_INTERVAL (5 * 60 * HZ)
#define LOCAL_RATELIMIT_BURST 3

#ifdef CONFIG_PRINTK
#define printk_ratelimited_local(fmt, ...) \
({ \
static DEFINE_RATELIMIT_STATE(_rs, \
LOCAL_RATELIMIT_INTERVAL, \
LOCAL_RATELIMIT_BURST); \
\
if (__ratelimit(&_rs)) \
printk(fmt, ##__VA_ARGS__); \
})
#else
#define printk_ratelimited_local(fmt, ...) \
no_printk(fmt, ##__VA_ARGS__)
#endif

#define pr_crit_ratelimited_local(fmt, ...) \
printk_ratelimited_local(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info_ratelimited_local(fmt, ...) \
printk_ratelimited_local(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)


struct rpi_firmware {
struct mbox_client cl;
struct mbox_chan *chan; /* The property channel. */
Expand Down Expand Up @@ -216,9 +248,13 @@ static int rpi_firmware_get_throttled(struct rpi_firmware *fw, u32 *value)

if (new_uv != old_uv) {
if (new_uv)
pr_crit("Under-voltage detected! (0x%08x)\n", *value);
pr_crit_ratelimited_local(
"Under-voltage detected! (0x%08x)\n",
*value);
else
pr_info("Voltage normalised (0x%08x)\n", *value);
pr_info_ratelimited_local(
"Voltage normalised (0x%08x)\n",
*value);
}

sysfs_notify(&fw->cl.dev->kobj, NULL, "get_throttled");
Expand Down