/* * Intel 21285 watchdog driver * Copyright (c) Phil Blundell , 1998 * * based on * * SoftDog 0.05: A Software Watchdog Device * * (c) Copyright 1996 Alan Cox , * All Rights Reserved. * * 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 #include #include #include #include #include #include #include #include #include /* * Define this to stop the watchdog actually rebooting the machine. */ #undef ONLY_TESTING static unsigned int soft_margin = 60; /* in seconds */ static unsigned int reload; static unsigned long timer_alive; #ifdef ONLY_TESTING /* * If the timer expires.. */ static void watchdog_fire(int irq, void *dev_id) { pr_crit("Would Reboot\n"); *CSR_TIMER4_CNTL = 0; *CSR_TIMER4_CLR = 0; } #endif /* * Refresh the timer. */ static void watchdog_ping(void) { *CSR_TIMER4_LOAD = reload; } /* * Allow only one person to hold it open */ static int watchdog_open(struct inode *inode, struct file *file) { int ret; if (*CSR_SA110_CNTL & (1 << 13)) return -EBUSY; if (test_and_set_bit(1, &timer_alive)) return -EBUSY; reload = soft_margin * (mem_fclk_21285 / 256); *CSR_TIMER4_CLR = 0; watchdog_ping(); *CSR_TIMER4_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV256; #ifdef ONLY_TESTING ret = request_irq(IRQ_TIMER4, watchdog_fire, 0, "watchdog", NULL); if (ret) { *CSR_TIMER4_CNTL = 0; clear_bit(1, &timer_alive); } #else /* * Setting this bit is irreversible; once enabled, there is * no way to disable the watchdog. */ *CSR_SA110_CNTL |= 1 << 13; ret = 0; #endif nonseekable_open(inode, file); return ret; } /* * Shut off the timer. * Note: if we really have enabled the watchdog, there * is no way to turn off. */ static int watchdog_release(struct inode *inode, struct file *file) { #ifdef ONLY_TESTING free_irq(IRQ_TIMER4, NULL); clear_bit(1, &timer_alive); #endif return 0; } static ssize_t watchdog_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { /* * Refresh the timer. */ if (len) watchdog_ping(); return len; } static const struct watchdog_info ident = { .options = WDIOF_SETTIMEOUT, .identity = "Footbridge Watchdog", }; static long watchdog_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int __user *int_arg = (int __user *)arg; int new_margin, ret = -ENOTTY; switch (cmd) { case WDIOC_GETSUPPORT: ret = 0; if (copy_to_user((void __user *)arg, &ident, sizeof(ident))) ret = -EFAULT; break; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: ret = put_user(0, int_arg); break; case WDIOC_KEEPALIVE: watchdog_ping(); ret = 0; break; case WDIOC_SETTIMEOUT: ret = get_user(new_margin, int_arg); if (ret) break; /* Arbitrary, can't find the card's limits */ if (new_margin < 0 || new_margin > 60) { ret = -EINVAL; break; } soft_margin = new_margin; reload = soft_margin * (mem_fclk_21285 / 256); watchdog_ping(); /* Fall */ case WDIOC_GETTIMEOUT: ret = put_user(soft_margin, int_arg); break; } return ret; } static const struct file_operations watchdog_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = watchdog_write, .unlocked_ioctl = watchdog_ioctl, .open = watchdog_open, .release = watchdog_release, }; static struct miscdevice watchdog_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &watchdog_fops, }; static int __init footbridge_watchdog_init(void) { int retval; if (machine_is_netwinder()) return -ENODEV; retval = misc_register(&watchdog_miscdev); if (retval < 0) return retval; pr_info("Footbridge Watchdog Timer: 0.01, timer margin: %d sec\n", soft_margin); if (machine_is_cats()) pr_warn("Warning: Watchdog reset may not work on this machine\n"); return 0; } static void __exit footbridge_watchdog_exit(void) { misc_deregister(&watchdog_miscdev); } MODULE_AUTHOR("Phil Blundell "); MODULE_DESCRIPTION("Footbridge watchdog driver"); MODULE_LICENSE("GPL"); module_param(soft_margin, int, 0); MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds"); module_init(footbridge_watchdog_init); module_exit(footbridge_watchdog_exit); e7cfeb0cc9ef03d885182ce8b'>ae4a3e028bb8b59e7cfeb0cc9ef03d885182ce8b (patch) tree139fc7e29f97d6bb6c4dca2a97be2dc3f824bd51 /fs/nfs/nfs2xdr.c parent49def1853334396f948dcb4cedb9347abb318df5 (diff)
dmaengine: cppi41: Fix runtime PM timeouts with USB mass storage
Commit fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support") added runtime PM support for cppi41, but had corner case issues. Some of the issues were fixed with commit 098de42ad670 ("dmaengine: cppi41: Fix unpaired pm runtime when only a USB hub is connected"). That fix however caused a new regression where we can get error -115 messages with USB on BeagleBone when connecting a USB mass storage device to a hub. This is because when connecting a USB mass storage device to a hub, the initial DMA transfers can take over 200ms to complete and cppi41 autosuspend delay times out. To fix the issue, we want to implement refcounting for chan_busy array that contains the active dma transfers. Increasing the autosuspend delay won't help as that the delay could be potentially seconds, and it's best to let the USB subsystem to deal with the timeouts on errors. The earlier attempt for runtime PM was buggy as the pm_runtime_get/put() calls could get unpaired easily as they did not follow the state of the chan_busy array as described in commit 098de42ad670 ("dmaengine: cppi41: Fix unpaired pm runtime when only a USB hub is connected". Let's fix the issue by adding pm_runtime_get() to where a new transfer is added to the chan_busy array, and calls to pm_runtime_put() where chan_busy array entry is cleared. This prevents any autosuspend timeouts from happening while dma transfers are active. Fixes: 098de42ad670 ("dmaengine: cppi41: Fix unpaired pm runtime when only a USB hub is connected") Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support") Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Bin Liu <b-liu@ti.com> Cc: Grygorii Strashko <grygorii.strashko@ti.com> Cc: Kevin Hilman <khilman@baylibre.com> Cc: Patrick Titiano <ptitiano@baylibre.com> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'fs/nfs/nfs2xdr.c')