From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: Vladimir Zapolskiy To: Wim Van Sebroeck , Guenter Roeck , Wolfram Sang CC: Subject: [PATCH v5 00/10] watchdog: add watchdog pretimeout framework Date: Wed, 31 Aug 2016 14:52:40 +0300 Message-ID: <1472644370-16982-1-git-send-email-vladimir_zapolskiy@mentor.com> MIME-Version: 1.0 Content-Type: text/plain List-ID: The change adds a simple watchdog pretimeout framework infrastructure, its purpose is to allow users to select a desired handling of watchdog pretimeout events, which may be generated by a watchdog driver. The idea of adding this kind of a framework appeared after reviewing several attempts to add hardcoded pretimeout event handling to some watchdog driver and after a discussion with Guenter, see https://lkml.org/lkml/2015/11/4/346 Watchdogs with WDIOF_PRETIMEOUT capability now may have three device attributes in sysfs: read only pretimeout value attribute, read/write pretimeout_governor attribute, read only pretimeout_available_governors attribute. To throw a pretimeout event for further processing a watchdog driver should call exported watchdog_notify_pretimeout(wdd) interface. In addition to the framework two simple watchdog pretimeout governors are added for review: panic and noop. Changes from v4 to v5: * fixed in source tree compilation issue, thanks to Wolfram * replaced strncmp() with more suitable sysfs_streq() to compare strings passed over sysfs (Wolfram) * added Wolfram's implementation of pretimeout to softdog driver * added watchdog pretimeout support to iMX2+ driver * minor whitespace issue fixes reported by checkpatch Changes from v3 to v4 : * took Wolfram's more advanced flavour of "watchdog: add set_pretimeout interface" change, which is based on originally written by Robin Gong code (Wolfram) * documented new watchdog_notify_pretimeout() function for developers of watchdog device drivers (Guenter) * reordered logical operations in wdt_is_visible() for better clarity (Guenter) * if watchdog pretimeout governor is not registered return empty string on reading "pretimeout_governor" device attribute, however with the default governor built-in this should never happen on practice (Guenter) * removed a number of sanity checks from functions which are assumed to be exported, callers are expected to write correct code, also this fixes one bug in watchdog_register_governor() noticed by Guenter (Guenter) * reworded some commit messages (Guenter) * moved registration of watchdog pretimeout event by from watchdog_core.c to watchdog_dev.c (Wolfram) * from the series removed support of potentially sleeping governors (Wolfram) * removed "panic panic" duplication in a user's message (Wolfram) * report watchdog name in a message given by noop governor (Wolfram) * exploiting the fact that there is only one default governor selected at build time allows to remove .is_default from "struct governor_priv" and find_default_governor() helper function, this is a change against complete version v2 * by unloading some assigned non-default governor a watchdog device falls back to default governor, this allows to avoid complicated module locking scheme by module owners, this is a change against completeversion v2 * to avoid spreading of watchdog device "struct device" operations while adding device attributes by watchdog_pretimeout_governor_[gs]et() and watchdog_pretimeout_available_governors_get() functions called from watchdog_dev.c, this is a change against complete version v2 * split the main change into 3 to hopefully enlighten review process: 1) default governor support only, 2) selectable by a user governor in runtime, 3) added pretimeout_available_governors attribute * fixed a list element deregistration bug Changes from v2 to v3: * from watchdog_pretimeout.c removed all features mentioned above * rebased panic and noop governors on top of the simplified watchdog pretimeout framework * added 2 rebased and cleaned up changes done by Robin Gong to the series, Robin's changes allow to test the series, if some individual watchdog driver adds WDIOF_PRETIMEOUT support and calls watchdog_notify_pretimeout(), for example Robin implemented the feature for imx2+ watchdog driver * added pretimeout value display over sysfs for WDIOF_PRETIMEOUT capable watchdog devices * moved sysfs device attributes to watchdog_dev.c, this required to add exported watchdog_pretimeout_governor_name() interface * if pretimeout framework is not selected, then pretimeout event ends up in kernel panic -- this behaviour as a default one was asked by Guenter * due to removal of support to sleeing governors removed userspace notification pretimeout governor from the series * minor clean-ups and adjustments Changes from v1 to v2, thanks to Guenter for review and discussion: * removed re-ping pretimeout governor, the functionality is supposed to be covered by the pending infrastructure enhancements, * removed watchdog driver specific pretimeout governor, at the moment it is not expected to add driver specific handlers, * reordered governors, panic comes in the first place, * removed framework private bits from struct watchdog_governor, * centralized compile-time selection of a default governor in watchdog_pretimeout.h, * added can_sleep option, now only sleeping governors (e.g. userspace) will be executed in a special workqueue, * changed fallback logic, if a governor in use is removed, now this situation is not possible, because in use governors have non-zero module refcount, * slightly improved description of the governors in Kconfig. Vladimir Zapolskiy (7): watchdog: add watchdog pretimeout governor framework watchdog: pretimeout: add panic pretimeout governor watchdog: pretimeout: add noop pretimeout governor watchdog: pretimeout: add option to select a pretimeout governor in runtime watchdog: pretimeout: add pretimeout_available_governors attribute watchdog: imx2_wdt: use preferred BIT macro instead of open coded values watchdog: imx2_wdt: add pretimeout function support Wolfram Sang (3): watchdog: add pretimeout support to the core fs: compat_ioctl: add pretimeout functions for watchdogs watchdog: softdog: implement pretimeout support Documentation/watchdog/watchdog-kernel-api.txt | 32 ++++ drivers/watchdog/Kconfig | 49 ++++++ drivers/watchdog/Makefile | 8 +- drivers/watchdog/imx2_wdt.c | 60 ++++++- drivers/watchdog/pretimeout_noop.c | 47 ++++++ drivers/watchdog/pretimeout_panic.c | 47 ++++++ drivers/watchdog/softdog.c | 22 ++- drivers/watchdog/watchdog_dev.c | 101 +++++++++++- drivers/watchdog/watchdog_pretimeout.c | 220 +++++++++++++++++++++++++ drivers/watchdog/watchdog_pretimeout.h | 60 +++++++ fs/compat_ioctl.c | 2 + include/linux/watchdog.h | 24 +++ 12 files changed, 662 insertions(+), 10 deletions(-) create mode 100644 drivers/watchdog/pretimeout_noop.c create mode 100644 drivers/watchdog/pretimeout_panic.c create mode 100644 drivers/watchdog/watchdog_pretimeout.c create mode 100644 drivers/watchdog/watchdog_pretimeout.h -- 2.8.1