|
24 | 24 |
|
25 | 25 | #define UNDERVOLTAGE_BIT BIT(0)
|
26 | 26 |
|
| 27 | + |
| 28 | +/* |
| 29 | + * This section defines some rate limited logging that prevent |
| 30 | + * repeated messages at much lower Hz than the default kernel settings. |
| 31 | + * It's usually 5s, this is 5 minutes. |
| 32 | + * Burst 3 means you may get three messages 'quickly', before |
| 33 | + * the ratelimiting kicks in. |
| 34 | + */ |
| 35 | +#define LOCAL_RATELIMIT_INTERVAL (5 * 60 * HZ) |
| 36 | +#define LOCAL_RATELIMIT_BURST 3 |
| 37 | + |
| 38 | +#ifdef CONFIG_PRINTK |
| 39 | +#define printk_ratelimited_local(fmt, ...) \ |
| 40 | +({ \ |
| 41 | + static DEFINE_RATELIMIT_STATE(_rs, \ |
| 42 | + LOCAL_RATELIMIT_INTERVAL, \ |
| 43 | + LOCAL_RATELIMIT_BURST); \ |
| 44 | + \ |
| 45 | + if (__ratelimit(&_rs)) \ |
| 46 | + printk(fmt, ##__VA_ARGS__); \ |
| 47 | +}) |
| 48 | +#else |
| 49 | +#define printk_ratelimited_local(fmt, ...) \ |
| 50 | + no_printk(fmt, ##__VA_ARGS__) |
| 51 | +#endif |
| 52 | + |
| 53 | +#define pr_crit_ratelimited_local(fmt, ...) \ |
| 54 | + printk_ratelimited_local(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
| 55 | +#define pr_info_ratelimited_local(fmt, ...) \ |
| 56 | + printk_ratelimited_local(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
| 57 | + |
| 58 | + |
27 | 59 | struct rpi_firmware {
|
28 | 60 | struct mbox_client cl;
|
29 | 61 | struct mbox_chan *chan; /* The property channel. */
|
@@ -216,9 +248,13 @@ static int rpi_firmware_get_throttled(struct rpi_firmware *fw, u32 *value)
|
216 | 248 |
|
217 | 249 | if (new_uv != old_uv) {
|
218 | 250 | if (new_uv)
|
219 |
| - pr_crit("Under-voltage detected! (0x%08x)\n", *value); |
| 251 | + pr_crit_ratelimited_local( |
| 252 | + "Under-voltage detected! (0x%08x)\n", |
| 253 | + *value); |
220 | 254 | else
|
221 |
| - pr_info("Voltage normalised (0x%08x)\n", *value); |
| 255 | + pr_info_ratelimited_local( |
| 256 | + "Voltage normalised (0x%08x)\n", |
| 257 | + *value); |
222 | 258 | }
|
223 | 259 |
|
224 | 260 | sysfs_notify(&fw->cl.dev->kobj, NULL, "get_throttled");
|
|
0 commit comments