/* * txx9wdt: A Hardware Watchdog Driver for TXx9 SoCs * * Copyright (C) 2007 Atsushi Nemoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include #include #include #include #include #include #include #include #include #define WD_TIMER_CCD 7 /* 1/256 */ #define WD_TIMER_CLK (clk_get_rate(txx9_imclk) / (2 << WD_TIMER_CCD)) #define WD_MAX_TIMEOUT ((0xffffffff >> (32 - TXX9_TIMER_BITS)) / WD_TIMER_CLK) #define TIMER_MARGIN 60 /* Default is 60 seconds */ static unsigned int timeout = TIMER_MARGIN; /* in seconds */ module_param(timeout, uint, 0); MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. " "(0wtmr); spin_unlock(&txx9_lock); return 0; } static int txx9wdt_start(struct watchdog_device *wdt_dev) { spin_lock(&txx9_lock); __raw_writel(WD_TIMER_CLK * wdt_dev->timeout, &txx9wdt_reg->cpra); __raw_writel(WD_TIMER_CCD, &txx9wdt_reg->ccdr); __raw_writel(0, &txx9wdt_reg->tisr); /* clear pending interrupt */ __raw_writel(TXx9_TMTCR_TCE | TXx9_TMTCR_CCDE | TXx9_TMTCR_TMODE_WDOG, &txx9wdt_reg->tcr); __raw_writel(TXx9_TMWTMR_TWIE | TXx9_TMWTMR_TWC, &txx9wdt_reg->wtmr); spin_unlock(&txx9_lock); return 0; } static int txx9wdt_stop(struct watchdog_device *wdt_dev) { spin_lock(&txx9_lock); __raw_writel(TXx9_TMWTMR_WDIS, &txx9wdt_reg->wtmr); __raw_writel(__raw_readl(&txx9wdt_reg->tcr) & ~TXx9_TMTCR_TCE, &txx9wdt_reg->tcr); spin_unlock(&txx9_lock); return 0; } static int txx9wdt_set_timeout(struct watchdog_device *wdt_dev, unsigned int new_timeout) { wdt_dev->timeout = new_timeout; txx9wdt_stop(wdt_dev); txx9wdt_start(wdt_dev); return 0; } static const struct watchdog_info txx9wdt_info = { .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, .identity = "Hardware Watchdog for TXx9", }; static const struct watchdog_ops txx9wdt_ops = { .owner = THIS_MODULE, .start = txx9wdt_start, .stop = txx9wdt_stop, .ping = txx9wdt_ping, .set_timeout = txx9wdt_set_timeout, }; static struct watchdog_device txx9wdt = { .info = &txx9wdt_info, .ops = &txx9wdt_ops, }; static int __init txx9wdt_probe(struct platform_device *dev) { struct resource *res; int ret; txx9_imclk = clk_get(NULL, "imbus_clk"); if (IS_ERR(txx9_imclk)) { ret = PTR_ERR(txx9_imclk); txx9_imclk = NULL; goto exit; } ret = clk_prepare_enable(txx9_imclk); if (ret) { clk_put(txx9_imclk); txx9_imclk = NULL; goto exit; } res = platform_get_resource(dev, IORESOURCE_MEM, 0); txx9wdt_reg = devm_ioremap_resource(&dev->dev, res); if (IS_ERR(txx9wdt_reg)) { ret = PTR_ERR(txx9wdt_reg); goto exit; } if (timeout < 1 || timeout > WD_MAX_TIMEOUT) timeout = TIMER_MARGIN; txx9wdt.timeout = timeout; txx9wdt.min_timeout = 1; txx9wdt.max_timeout = WD_MAX_TIMEOUT; txx9wdt.parent = &dev->dev; watchdog_set_nowayout(&txx9wdt, nowayout); ret = watchdog_register_device(&txx9wdt); if (ret) goto exit; pr_info("Hardware Watchdog Timer: timeout=%d sec (max %ld) (nowayout= %d)\n", timeout, WD_MAX_TIMEOUT, nowayout); return 0; exit: if (txx9_imclk) { clk_disable_unprepare(txx9_imclk); clk_put(txx9_imclk); } return ret; } static int __exit txx9wdt_remove(struct platform_device *dev) { watchdog_unregister_device(&txx9wdt); clk_disable_unprepare(txx9_imclk); clk_put(txx9_imclk); return 0; } static void txx9wdt_shutdown(struct platform_device *dev) { txx9wdt_stop(&txx9wdt); } static struct platform_driver txx9wdt_driver = { .remove = __exit_p(txx9wdt_remove), .shutdown = txx9wdt_shutdown, .driver = { .name = "txx9wdt", }, }; module_platform_driver_probe(txx9wdt_driver, txx9wdt_probe); MODULE_DESCRIPTION("TXx9 Watchdog Driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:txx9wdt"); change='this.form.submit();'>
authorThomas Gleixner <tglx@linutronix.de>2017-01-31 23:58:38 +0100
committerIngo Molnar <mingo@kernel.org>2017-02-01 08:37:27 +0100
commitdd86e373e09fb16b83e8adf5c48c421a4ca76468 (patch)
tree55703c2ea8584e303e342090614e0aab3509ab21 /tools/arch/s390/include/asm/barrier.h
parent0b3589be9b98994ce3d5aeca52445d1f5627c4ba (diff)
perf/x86/intel/rapl: Make package handling more robust
The package management code in RAPL relies on package mapping being available before a CPU is started. This changed with: 9d85eb9119f4 ("x86/smpboot: Make logical package management more robust") because the ACPI/BIOS information turned out to be unreliable, but that left RAPL in broken state. This was not noticed because on a regular boot all CPUs are online before RAPL is initialized. A possible fix would be to reintroduce the mess which allocates a package data structure in CPU prepare and when it turns out to already exist in starting throw it away later in the CPU online callback. But that's a horrible hack and not required at all because RAPL becomes functional for perf only in the CPU online callback. That's correct because user space is not yet informed about the CPU being onlined, so nothing caan rely on RAPL being available on that particular CPU. Move the allocation to the CPU online callback and simplify the hotplug handling. At this point the package mapping is established and correct. This also adds a missing check for available package data in the event_init() function. Reported-by: Yasuaki Ishimatsu <yasu.isimatu@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sebastian Siewior <bigeasy@linutronix.de> Cc: Stephane Eranian <eranian@google.com> Cc: Vince Weaver <vincent.weaver@maine.edu> Fixes: 9d85eb9119f4 ("x86/smpboot: Make logical package management more robust") Link: http://lkml.kernel.org/r/20170131230141.212593966@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/arch/s390/include/asm/barrier.h')