/* * sun4v watchdog timer * (c) Copyright 2016 Oracle Corporation * * Implement a simple watchdog driver using the built-in sun4v hypervisor * watchdog support. If time expires, the hypervisor stops or bounces * the guest domain. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include #include #include #include #include #include #include #define WDT_TIMEOUT 60 #define WDT_MAX_TIMEOUT 31536000 #define WDT_MIN_TIMEOUT 1 #define WDT_DEFAULT_RESOLUTION_MS 1000 /* 1 second */ static unsigned int timeout; module_param(timeout, uint, 0); MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=" __MODULE_STRING(WDT_TIMEOUT) ")"); static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, S_IRUGO); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); static int sun4v_wdt_stop(struct watchdog_device *wdd) { sun4v_mach_set_watchdog(0, NULL); return 0; } static int sun4v_wdt_ping(struct watchdog_device *wdd) { int hverr; /* * HV watchdog timer will round up the timeout * passed in to the nearest multiple of the * watchdog resolution in milliseconds. */ hverr = sun4v_mach_set_watchdog(wdd->timeout * 1000, NULL); if (hverr == HV_EINVAL) return -EINVAL; return 0; } static int sun4v_wdt_set_timeout(struct watchdog_device *wdd, unsigned int timeout) { wdd->timeout = timeout; return 0; } static const struct watchdog_info sun4v_wdt_ident = { .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, .identity = "sun4v hypervisor watchdog", .firmware_version = 0, }; static struct watchdog_ops sun4v_wdt_ops = { .owner = THIS_MODULE, .start = sun4v_wdt_ping, .stop = sun4v_wdt_stop, .ping = sun4v_wdt_ping, .set_timeout = sun4v_wdt_set_timeout, }; static struct watchdog_device wdd = { .info = &sun4v_wdt_ident, .ops = &sun4v_wdt_ops, .min_timeout = WDT_MIN_TIMEOUT, .max_timeout = WDT_MAX_TIMEOUT, .timeout = WDT_TIMEOUT, }; static int __init sun4v_wdt_init(void) { struct mdesc_handle *handle; u64 node; const u64 *value; int err = 0; unsigned long major = 1, minor = 1; /* * There are 2 properties that can be set from the control * domain for the watchdog. * watchdog-resolution * watchdog-max-timeout * * We can expect a handle to be returned otherwise something * serious is wrong. Correct to return -ENODEV here. */ handle = mdesc_grab(); if (!handle) return -ENODEV; node = mdesc_node_by_name(handle, MDESC_NODE_NULL, "platform"); err = -ENODEV; if (node == MDESC_NODE_NULL) goto out_release; /* * This is a safe way to validate if we are on the right * platform. */ if (sun4v_hvapi_register(HV_GRP_CORE, major, &minor)) goto out_hv_unreg; /* Allow value of watchdog-resolution up to 1s (default) */ value = mdesc_get_property(handle, node, "watchdog-resolution", NULL); err = -EINVAL; if (value) { if (*value == 0 || *value > WDT_DEFAULT_RESOLUTION_MS) goto out_hv_unreg; } value = mdesc_get_property(handle, node, "watchdog-max-timeout", NULL); if (value) { /* * If the property value (in ms) is smaller than * min_timeout, return -EINVAL. */ if (*value < wdd.min_timeout * 1000) goto out_hv_unreg; /* * If the property value is smaller than * default max_timeout then set watchdog max_timeout to * the value of the property in seconds. */ if (*value < wdd.max_timeout * 1000) wdd.max_timeout = *value / 1000; } watchdog_init_timeout(&wdd, timeout, NULL); watchdog_set_nowayout(&wdd, nowayout); err = watchdog_register_device(&wdd); if (err) goto out_hv_unreg; pr_info("initialized (timeout=%ds, nowayout=%d)\n", wdd.timeout, nowayout); mdesc_release(handle); return 0; out_hv_unreg: sun4v_hvapi_unregister(HV_GRP_CORE); out_release: mdesc_release(handle); return err; } static void __exit sun4v_wdt_exit(void) { sun4v_hvapi_unregister(HV_GRP_CORE); watchdog_unregister_device(&wdd); } module_init(sun4v_wdt_init); module_exit(sun4v_wdt_exit); MODULE_AUTHOR("Wim Coekaerts "); MODULE_DESCRIPTION("sun4v watchdog driver"); MODULE_LICENSE("GPL"); pe='submit' value='reload'/>
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-27 12:29:30 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-27 12:29:30 -0800
commitdd3b9f25c867cb2507a45e436d6ede8eb08e7b05 (patch)
tree1ec6c08cd75610083d117a2c8d5eb0829e65f33e /net/iucv
parent69978aa0f21f43529e11f924504dadb6ce2f229a (diff)
parentb4cfe3971f6eab542dd7ecc398bfa1aeec889934 (diff)
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma
Pull rdma fixes from Doug Ledford: "Second round of -rc fixes for 4.10. This -rc cycle has been slow for the rdma subsystem. I had already sent you the first batch before the Holiday break. After that, we kept only getting a few here or there. Up until this week, when I got a drop of 13 to one driver (qedr). So, here's the -rc patches I have. I currently have none held in reserve, so unless something new comes in, this is it until the next merge window opens. Summary: - series of iw_cxgb4 fixes to make it work with the drain cq API - one or two patches each to: srp, iser, cxgb3, vmw_pvrdma, umem, rxe, and ipoib - one big series (13 patches) for the new qedr driver" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma: (27 commits) RDMA/cma: Fix unknown symbol when CONFIG_IPV6 is not enabled IB/rxe: Prevent from completer to operate on non valid QP IB/rxe: Fix rxe dev insertion to rxe_dev_list IB/umem: Release pid in error and ODP flow RDMA/qedr: Dispatch port active event from qedr_add RDMA/qedr: Fix and simplify memory leak in PD alloc RDMA/qedr: Fix RDMA CM loopback RDMA/qedr: Fix formatting RDMA/qedr: Mark three functions as static RDMA/qedr: Don't reset QP when queues aren't flushed RDMA/qedr: Don't spam dmesg if QP is in error state RDMA/qedr: Remove CQ spinlock from CM completion handlers RDMA/qedr: Return max inline data in QP query result RDMA/qedr: Return success when not changing QP state RDMA/qedr: Add uapi header qedr-abi.h RDMA/qedr: Fix MTU returned from QP query RDMA/core: Add the function ib_mtu_int_to_enum IB/vmw_pvrdma: Fix incorrect cleanup on pvrdma_pci_probe error path IB/vmw_pvrdma: Don't leak info from alloc_ucontext IB/cxgb3: fix misspelling in header guard ...
Diffstat (limited to 'net/iucv')