From 93d652bbfca28ff825d7d472e2a10fdda3189d3d Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Wed, 21 Dec 2016 16:12:03 +0800 Subject: [PATCH] Utilities: Add ACPI_DO_ONCE macros This patch implements ACPI_DO_ONCE macros to avoid log floodings. There could be OSPM gaps causing some ACPICA functionalities continously reporting errors, filling up users' filesystem. Reported by Aaron Franke, Fixed by Lv Zheng. Link: https://bugzilla.kernel.org/show_bug.cgi?id=188331 Reported-by: Aaron Franke Signed-off-by: Lv Zheng --- source/include/acmacros.h | 5 +++++ source/include/acoutput.h | 7 +++++++ source/include/acpixf.h | 8 ++++++++ source/include/platform/acgcc.h | 15 +++++++++++++++ source/include/platform/aclinux.h | 4 ++++ 5 files changed, 39 insertions(+) diff --git a/source/include/acmacros.h b/source/include/acmacros.h index 1255be5c5..90dcc7714 100644 --- a/source/include/acmacros.h +++ b/source/include/acmacros.h @@ -531,8 +531,13 @@ * the plist contains a set of parens to allow variable-length lists. * These macros are used for both the debug and non-debug versions of the code. */ +#if defined (ACPI_USE_DO_ONCE_MACRO) && defined (ACPI_DO_ONCE) +#define ACPI_ERROR_NAMESPACE(s, e) ACPI_DO_ONCE(AcpiUtNamespaceError (AE_INFO, s, e)); +#define ACPI_ERROR_METHOD(s, n, p, e) ACPI_DO_ONCE(AcpiUtMethodError (AE_INFO, s, n, p, e)); +#else #define ACPI_ERROR_NAMESPACE(s, e) AcpiUtNamespaceError (AE_INFO, s, e); #define ACPI_ERROR_METHOD(s, n, p, e) AcpiUtMethodError (AE_INFO, s, n, p, e); +#endif #define ACPI_WARN_PREDEFINED(plist) AcpiUtPredefinedWarning plist #define ACPI_INFO_PREDEFINED(plist) AcpiUtPredefinedInfo plist #define ACPI_BIOS_ERROR_PREDEFINED(plist) AcpiUtPredefinedBiosError plist diff --git a/source/include/acoutput.h b/source/include/acoutput.h index 717a2c31c..39e09365c 100644 --- a/source/include/acoutput.h +++ b/source/include/acoutput.h @@ -302,10 +302,17 @@ * the plist contains a set of parens to allow variable-length lists. * These macros are used for both the debug and non-debug versions of the code. */ +#if defined (ACPI_USE_DO_ONCE_MACRO) && defined (ACPI_DO_ONCE) +#define ACPI_INFO(plist) ACPI_DO_ONCE(AcpiInfo plist) +#define ACPI_WARNING(plist) ACPI_DO_ONCE(AcpiWarning plist) +#define ACPI_EXCEPTION(plist) ACPI_DO_ONCE(AcpiException plist) +#define ACPI_ERROR(plist) ACPI_DO_ONCE(AcpiError plist) +#else #define ACPI_INFO(plist) AcpiInfo plist #define ACPI_WARNING(plist) AcpiWarning plist #define ACPI_EXCEPTION(plist) AcpiException plist #define ACPI_ERROR(plist) AcpiError plist +#endif #define ACPI_BIOS_WARNING(plist) AcpiBiosWarning plist #define ACPI_BIOS_ERROR(plist) AcpiBiosError plist #define ACPI_DEBUG_OBJECT(obj,l,i) AcpiExDoDebugObject(obj,l,i) diff --git a/source/include/acpixf.h b/source/include/acpixf.h index c491ae159..40c201318 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -247,6 +247,14 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_VerifyTableChecksum, TRUE); */ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_EnableAmlDebugObject, FALSE); +/* + * Optionally enable ACPI_DO_ONCE to avoid log flodding. Default is TRUE + * so that when ACPI_USE_DO_ONCE_MACRO is enabled, log flooding can be + * avoided by default. And this option is provided so that OSPMs can + * disable it during runtime. + */ +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_EnableDoOnceMacro, TRUE); + /* * Optionally copy the entire DSDT to local memory (instead of simply * mapping it.) There are some BIOSs that corrupt or replace the original diff --git a/source/include/platform/acgcc.h b/source/include/platform/acgcc.h index 097539ca8..5ec3ffd32 100644 --- a/source/include/platform/acgcc.h +++ b/source/include/platform/acgcc.h @@ -146,4 +146,19 @@ #define COMPILER_VA_MACRO 1 +/* GCC supports _ONCE macros */ + +#define ACPI_DO_ONCE(plist) \ +({ \ + static BOOLEAN __AcpiErrorOnce__ = FALSE; \ + if (!__AcpiErrorOnce__) \ + { \ + if (AcpiGbl_EnableDoOnceMacro) \ + { \ + __AcpiErrorOnce__ = TRUE; \ + } \ + plist; \ + } \ +}) + #endif /* __ACGCC_H__ */ diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h index 27803ad31..665756fba 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -146,6 +146,10 @@ #define ACPI_DEBUGGER #endif +#ifdef CONFIG_ACPI_MESSAGE_ONCE +#define ACPI_USE_DO_ONCE_MACRO 1 +#endif + #include #include #include