提交 af94e7c3 编写于 作者: S Stefan Wahren 提交者: Zheng Zengkai

hwmon: raspberrypi: Prevent voltage low warnings from filling log

raspberrypi inclusion
category: feature
bugzilla: 50432

--------------------------------

Although the correct fix for low voltage warnings is to
improve the power supply, the current implementation
of the detection can fill the log if the warning
happens freqently. This replaces the logging with
slightly custom ratelimited logging.
Signed-off-by: NJames Hughes <james.hughes@raspberrypi.org>
Signed-off-by: NStefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 59f6f74f
......@@ -15,6 +15,36 @@
#include <linux/workqueue.h>
#include <soc/bcm2835/raspberrypi-firmware.h>
/*
* 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__)
#define UNDERVOLTAGE_STICKY_BIT BIT(16)
struct rpi_hwmon_data {
......@@ -47,10 +77,13 @@ static void rpi_firmware_get_throttled(struct rpi_hwmon_data *data)
if (new_uv == old_uv)
return;
if (new_uv)
dev_crit(data->hwmon_dev, "Undervoltage detected!\n");
else
dev_info(data->hwmon_dev, "Voltage normalised\n");
if (new_uv) {
pr_crit_ratelimited_local("Under-voltage detected! (0x%08x)\n",
value);
} else {
pr_info_ratelimited_local("Voltage normalised (0x%08x)\n",
value);
}
sysfs_notify(&data->hwmon_dev->kobj, NULL, "in0_lcrit_alarm");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册