powerpc/64s/powernv: Ratelimit harmless HMI error printing
authorNicholas Piggin <npiggin@gmail.com>
Sat, 28 Nov 2020 07:07:25 +0000 (17:07 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 3 Dec 2020 14:01:23 +0000 (01:01 +1100)
Harmless HMI errors can be triggered by guests in some cases, and don't
contain much useful information anyway. Ratelimit these to avoid
flooding the console/logs.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Use dedicated ratelimit state, not printk_ratelimit()]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201128070728.825934-6-npiggin@gmail.com
arch/powerpc/platforms/powernv/opal-hmi.c

index 3e1f064..f0c1830 100644 (file)
@@ -213,6 +213,8 @@ static void print_hmi_event_info(struct OpalHMIEvent *hmi_evt)
                "A hypervisor resource error occurred",
                "CAPP recovery process is in progress",
        };
+       static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
+                                     DEFAULT_RATELIMIT_BURST);
 
        /* Print things out */
        if (hmi_evt->version < OpalHMIEvt_V1) {
@@ -240,19 +242,22 @@ static void print_hmi_event_info(struct OpalHMIEvent *hmi_evt)
                break;
        }
 
-       printk("%s%s Hypervisor Maintenance interrupt [%s]\n",
-               level, sevstr,
-               hmi_evt->disposition == OpalHMI_DISPOSITION_RECOVERED ?
-               "Recovered" : "Not recovered");
-       error_info = hmi_evt->type < ARRAY_SIZE(hmi_error_types) ?
-                       hmi_error_types[hmi_evt->type]
-                       : "Unknown";
-       printk("%s Error detail: %s\n", level, error_info);
-       printk("%s      HMER: %016llx\n", level, be64_to_cpu(hmi_evt->hmer));
-       if ((hmi_evt->type == OpalHMI_ERROR_TFAC) ||
-               (hmi_evt->type == OpalHMI_ERROR_TFMR_PARITY))
-               printk("%s      TFMR: %016llx\n", level,
+       if (hmi_evt->severity != OpalHMI_SEV_NO_ERROR || __ratelimit(&rs)) {
+               printk("%s%s Hypervisor Maintenance interrupt [%s]\n",
+                       level, sevstr,
+                       hmi_evt->disposition == OpalHMI_DISPOSITION_RECOVERED ?
+                       "Recovered" : "Not recovered");
+               error_info = hmi_evt->type < ARRAY_SIZE(hmi_error_types) ?
+                               hmi_error_types[hmi_evt->type]
+                               : "Unknown";
+               printk("%s Error detail: %s\n", level, error_info);
+               printk("%s      HMER: %016llx\n", level,
+                                       be64_to_cpu(hmi_evt->hmer));
+               if ((hmi_evt->type == OpalHMI_ERROR_TFAC) ||
+                       (hmi_evt->type == OpalHMI_ERROR_TFMR_PARITY))
+                       printk("%s      TFMR: %016llx\n", level,
                                                be64_to_cpu(hmi_evt->tfmr));
+       }
 
        if (hmi_evt->version < OpalHMIEvt_V2)
                return;