diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hvc_iucv.c | 6 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 71 | ||||
-rw-r--r-- | drivers/char/mem.c | 195 | ||||
-rw-r--r-- | drivers/char/mmtimer.c | 2 | ||||
-rw-r--r-- | drivers/char/n_tty.c | 17 | ||||
-rw-r--r-- | drivers/char/tty_audit.c | 1 |
6 files changed, 190 insertions, 102 deletions
diff --git a/drivers/char/hvc_iucv.c b/drivers/char/hvc_iucv.c index 21681a81cc35..37b0542a4eeb 100644 --- a/drivers/char/hvc_iucv.c +++ b/drivers/char/hvc_iucv.c @@ -139,6 +139,8 @@ struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) * * This function allocates a new struct iucv_tty_buffer element and, optionally, * allocates an internal data buffer with the specified size @size. + * The internal data buffer is always allocated with GFP_DMA which is + * required for receiving and sending data with IUCV. * Note: The total message size arises from the internal buffer size and the * members of the iucv_tty_msg structure. * The function returns NULL if memory allocation has failed. @@ -154,7 +156,7 @@ static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags) if (size > 0) { bufp->msg.length = MSG_SIZE(size); - bufp->mbuf = kmalloc(bufp->msg.length, flags); + bufp->mbuf = kmalloc(bufp->msg.length, flags | GFP_DMA); if (!bufp->mbuf) { mempool_free(bufp, hvc_iucv_mempool); return NULL; @@ -237,7 +239,7 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv, if (!rb->mbuf) { /* message not yet received ... */ /* allocate mem to store msg data; if no memory is available * then leave the buffer on the list and re-try later */ - rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC); + rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC | GFP_DMA); if (!rb->mbuf) return -ENOMEM; diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 176f1751237f..4462b113ba3f 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -295,6 +295,9 @@ struct smi_info { static int force_kipmid[SI_MAX_PARMS]; static int num_force_kipmid; +static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; +static int num_max_busy_us; + static int unload_when_empty = 1; static int try_smi_init(struct smi_info *smi); @@ -925,23 +928,77 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion) } } +/* + * Use -1 in the nsec value of the busy waiting timespec to tell that + * we are spinning in kipmid looking for something and not delaying + * between checks + */ +static inline void ipmi_si_set_not_busy(struct timespec *ts) +{ + ts->tv_nsec = -1; +} +static inline int ipmi_si_is_busy(struct timespec *ts) +{ + return ts->tv_nsec != -1; +} + +static int ipmi_thread_busy_wait(enum si_sm_result smi_result, + const struct smi_info *smi_info, + struct timespec *busy_until) +{ + unsigned int max_busy_us = 0; + + if (smi_info->intf_num < num_max_busy_us) + max_busy_us = kipmid_max_busy_us[smi_info->intf_num]; + if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY) + ipmi_si_set_not_busy(busy_until); + else if (!ipmi_si_is_busy(busy_until)) { + getnstimeofday(busy_until); + timespec_add_ns(busy_until, max_busy_us*NSEC_PER_USEC); + } else { + struct timespec now; + getnstimeofday(&now); + if (unlikely(timespec_compare(&now, busy_until) > 0)) { + ipmi_si_set_not_busy(busy_until); + return 0; + } + } + return 1; +} + + +/* + * A busy-waiting loop for speeding up IPMI operation. + * + * Lousy hardware makes this hard. This is only enabled for systems + * that are not BT and do not have interrupts. It starts spinning + * when an operation is complete or until max_busy tells it to stop + * (if that is enabled). See the paragraph on kimid_max_busy_us in + * Documentation/IPMI.txt for details. + */ static int ipmi_thread(void *data) { struct smi_info *smi_info = data; unsigned long flags; enum si_sm_result smi_result; + struct timespec busy_until; + ipmi_si_set_not_busy(&busy_until); set_user_nice(current, 19); while (!kthread_should_stop()) { + int busy_wait; + spin_lock_irqsave(&(smi_info->si_lock), flags); smi_result = smi_event_handler(smi_info, 0); spin_unlock_irqrestore(&(smi_info->si_lock), flags); + busy_wait = ipmi_thread_busy_wait(smi_result, smi_info, + &busy_until); if (smi_result == SI_SM_CALL_WITHOUT_DELAY) ; /* do nothing */ - else if (smi_result == SI_SM_CALL_WITH_DELAY) + else if (smi_result == SI_SM_CALL_WITH_DELAY && busy_wait) schedule(); else - schedule_timeout_interruptible(1); + schedule_timeout_interruptible(0); } return 0; } @@ -1144,7 +1201,7 @@ static int regsizes[SI_MAX_PARMS]; static unsigned int num_regsizes; static int regshifts[SI_MAX_PARMS]; static unsigned int num_regshifts; -static int slave_addrs[SI_MAX_PARMS]; +static int slave_addrs[SI_MAX_PARMS]; /* Leaving 0 chooses the default value */ static unsigned int num_slave_addrs; #define IPMI_IO_ADDR_SPACE 0 @@ -1212,6 +1269,11 @@ module_param(unload_when_empty, int, 0); MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are" " specified or found, default is 1. Setting to 0" " is useful for hot add of devices using hotmod."); +module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644); +MODULE_PARM_DESC(kipmid_max_busy_us, + "Max time (in microseconds) to busy-wait for IPMI data before" + " sleeping. 0 (default) means to wait forever. Set to 100-500" + " if kipmid is using up a lot of CPU time."); static void std_irq_cleanup(struct smi_info *info) @@ -1607,7 +1669,7 @@ static int hotmod_handler(const char *val, struct kernel_param *kp) regsize = 1; regshift = 0; irq = 0; - ipmb = 0x20; + ipmb = 0; /* Choose the default if not specified */ next = strchr(curr, ':'); if (next) { @@ -1799,6 +1861,7 @@ static __devinit void hardcode_find_bmc(void) info->irq = irqs[i]; if (info->irq) info->irq_setup = std_irq_setup; + info->slave_addr = slave_addrs[i]; try_smi_init(info); } diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 48788db4e280..1f3215ac085b 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -3,7 +3,7 @@ * * Copyright (C) 1991, 1992 Linus Torvalds * - * Added devfs support. + * Added devfs support. * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu> * Shared /dev/zero mmapping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com> */ @@ -44,36 +44,6 @@ static inline unsigned long size_inside_page(unsigned long start, return min(sz, size); } -/* - * Architectures vary in how they handle caching for addresses - * outside of main memory. - * - */ -static inline int uncached_access(struct file *file, unsigned long addr) -{ -#if defined(CONFIG_IA64) - /* - * On ia64, we ignore O_DSYNC because we cannot tolerate memory attribute aliases. - */ - return !(efi_mem_attributes(addr) & EFI_MEMORY_WB); -#elif defined(CONFIG_MIPS) - { - extern int __uncached_access(struct file *file, - unsigned long addr); - - return __uncached_access(file, addr); - } -#else - /* - * Accessing memory above the top the kernel knows about or through a file pointer - * that was marked O_DSYNC will be done non-cached. - */ - if (file->f_flags & O_DSYNC) - return 1; - return addr >= __pa(high_memory); -#endif -} - #ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE static inline int valid_phys_addr_range(unsigned long addr, size_t count) { @@ -115,15 +85,15 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size) } #endif -void __attribute__((weak)) unxlate_dev_mem_ptr(unsigned long phys, void *addr) +void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr) { } /* - * This funcion reads the *physical* memory. The f_pos points directly to the - * memory location. + * This funcion reads the *physical* memory. The f_pos points directly to the + * memory location. */ -static ssize_t read_mem(struct file * file, char __user * buf, +static ssize_t read_mem(struct file *file, char __user *buf, size_t count, loff_t *ppos) { unsigned long p = *ppos; @@ -140,10 +110,10 @@ static ssize_t read_mem(struct file * file, char __user * buf, if (sz > 0) { if (clear_user(buf, sz)) return -EFAULT; - buf += sz; - p += sz; - count -= sz; - read += sz; + buf += sz; + p += sz; + count -= sz; + read += sz; } } #endif @@ -157,9 +127,9 @@ static ssize_t read_mem(struct file * file, char __user * buf, return -EPERM; /* - * On ia64 if a page has been mapped somewhere as - * uncached, then it must also be accessed uncached - * by the kernel or data corruption may occur + * On ia64 if a page has been mapped somewhere as uncached, then + * it must also be accessed uncached by the kernel or data + * corruption may occur. */ ptr = xlate_dev_mem_ptr(p); if (!ptr) @@ -180,7 +150,7 @@ static ssize_t read_mem(struct file * file, char __user * buf, return read; } -static ssize_t write_mem(struct file * file, const char __user * buf, +static ssize_t write_mem(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { unsigned long p = *ppos; @@ -212,9 +182,9 @@ static ssize_t write_mem(struct file * file, const char __user * buf, return -EPERM; /* - * On ia64 if a page has been mapped somewhere as - * uncached, then it must also be accessed uncached - * by the kernel or data corruption may occur + * On ia64 if a page has been mapped somewhere as uncached, then + * it must also be accessed uncached by the kernel or data + * corruption may occur. */ ptr = xlate_dev_mem_ptr(p); if (!ptr) { @@ -242,13 +212,46 @@ static ssize_t write_mem(struct file * file, const char __user * buf, return written; } -int __attribute__((weak)) phys_mem_access_prot_allowed(struct file *file, +int __weak phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, unsigned long size, pgprot_t *vma_prot) { return 1; } #ifndef __HAVE_PHYS_MEM_ACCESS_PROT + +/* + * Architectures vary in how they handle caching for addresses + * outside of main memory. + * + */ +static int uncached_access(struct file *file, unsigned long addr) +{ +#if defined(CONFIG_IA64) + /* + * On ia64, we ignore O_DSYNC because we cannot tolerate memory + * attribute aliases. + */ + return !(efi_mem_attributes(addr) & EFI_MEMORY_WB); +#elif defined(CONFIG_MIPS) + { + extern int __uncached_access(struct file *file, + unsigned long addr); + + return __uncached_access(file, addr); + } +#else + /* + * Accessing memory above the top the kernel knows about or through a + * file pointer + * that was marked O_DSYNC will be done non-cached. + */ + if (file->f_flags & O_DSYNC) + return 1; + return addr >= __pa(high_memory); +#endif +} + static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size, pgprot_t vma_prot) { @@ -294,7 +297,7 @@ static const struct vm_operations_struct mmap_mem_ops = { #endif }; -static int mmap_mem(struct file * file, struct vm_area_struct * vma) +static int mmap_mem(struct file *file, struct vm_area_struct *vma) { size_t size = vma->vm_end - vma->vm_start; @@ -329,7 +332,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma) } #ifdef CONFIG_DEVKMEM -static int mmap_kmem(struct file * file, struct vm_area_struct * vma) +static int mmap_kmem(struct file *file, struct vm_area_struct *vma) { unsigned long pfn; @@ -337,9 +340,9 @@ static int mmap_kmem(struct file * file, struct vm_area_struct * vma) pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; /* - * RED-PEN: on some architectures there is more mapped memory - * than available in mem_map which pfn_valid checks - * for. Perhaps should add a new macro here. + * RED-PEN: on some architectures there is more mapped memory than + * available in mem_map which pfn_valid checks for. Perhaps should add a + * new macro here. * * RED-PEN: vmalloc is not supported right now. */ @@ -389,7 +392,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf, /* * This function reads the *virtual* memory as seen by the kernel. */ -static ssize_t read_kmem(struct file *file, char __user *buf, +static ssize_t read_kmem(struct file *file, char __user *buf, size_t count, loff_t *ppos) { unsigned long p = *ppos; @@ -400,8 +403,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf, read = 0; if (p < (unsigned long) high_memory) { low_count = count; - if (count > (unsigned long) high_memory - p) - low_count = (unsigned long) high_memory - p; + if (count > (unsigned long)high_memory - p) + low_count = (unsigned long)high_memory - p; #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED /* we don't have page 0 mapped on sparc and m68k.. */ @@ -465,9 +468,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf, } -static inline ssize_t -do_write_kmem(unsigned long p, const char __user *buf, - size_t count, loff_t *ppos) +static ssize_t do_write_kmem(unsigned long p, const char __user *buf, + size_t count, loff_t *ppos) { ssize_t written, sz; unsigned long copied; @@ -491,9 +493,9 @@ do_write_kmem(unsigned long p, const char __user *buf, sz = size_inside_page(p, count); /* - * On ia64 if a page has been mapped somewhere as - * uncached, then it must also be accessed uncached - * by the kernel or data corruption may occur + * On ia64 if a page has been mapped somewhere as uncached, then + * it must also be accessed uncached by the kernel or data + * corruption may occur. */ ptr = xlate_dev_kmem_ptr((char *)p); @@ -514,11 +516,10 @@ do_write_kmem(unsigned long p, const char __user *buf, return written; } - /* * This function writes to the *virtual* memory as seen by the kernel. */ -static ssize_t write_kmem(struct file * file, const char __user * buf, +static ssize_t write_kmem(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { unsigned long p = *ppos; @@ -570,17 +571,17 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, #endif #ifdef CONFIG_DEVPORT -static ssize_t read_port(struct file * file, char __user * buf, +static ssize_t read_port(struct file *file, char __user *buf, size_t count, loff_t *ppos) { unsigned long i = *ppos; char __user *tmp = buf; if (!access_ok(VERIFY_WRITE, buf, count)) - return -EFAULT; + return -EFAULT; while (count-- > 0 && i < 65536) { - if (__put_user(inb(i),tmp) < 0) - return -EFAULT; + if (__put_user(inb(i), tmp) < 0) + return -EFAULT; i++; tmp++; } @@ -588,22 +589,22 @@ static ssize_t read_port(struct file * file, char __user * buf, return tmp-buf; } -static ssize_t write_port(struct file * file, const char __user * buf, +static ssize_t write_port(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { unsigned long i = *ppos; const char __user * tmp = buf; - if (!access_ok(VERIFY_READ,buf,count)) + if (!access_ok(VERIFY_READ, buf, count)) return -EFAULT; while (count-- > 0 && i < 65536) { char c; if (__get_user(c, tmp)) { if (tmp > buf) break; - return -EFAULT; + return -EFAULT; } - outb(c,i); + outb(c, i); i++; tmp++; } @@ -612,13 +613,13 @@ static ssize_t write_port(struct file * file, const char __user * buf, } #endif -static ssize_t read_null(struct file * file, char __user * buf, +static ssize_t read_null(struct file *file, char __user *buf, size_t count, loff_t *ppos) { return 0; } -static ssize_t write_null(struct file * file, const char __user * buf, +static ssize_t write_null(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { return count; @@ -630,13 +631,13 @@ static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf, return sd->len; } -static ssize_t splice_write_null(struct pipe_inode_info *pipe,struct file *out, +static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags) { return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null); } -static ssize_t read_zero(struct file * file, char __user * buf, +static ssize_t read_zero(struct file *file, char __user *buf, size_t count, loff_t *ppos) { size_t written; @@ -667,7 +668,7 @@ static ssize_t read_zero(struct file * file, char __user * buf, return written ? written : -EFAULT; } -static int mmap_zero(struct file * file, struct vm_area_struct * vma) +static int mmap_zero(struct file *file, struct vm_area_struct *vma) { #ifndef CONFIG_MMU return -ENOSYS; @@ -677,7 +678,7 @@ static int mmap_zero(struct file * file, struct vm_area_struct * vma) return 0; } -static ssize_t write_full(struct file * file, const char __user * buf, +static ssize_t write_full(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { return -ENOSPC; @@ -688,8 +689,7 @@ static ssize_t write_full(struct file * file, const char __user * buf, * can fopen() both devices with "a" now. This was previously impossible. * -- SRB. */ - -static loff_t null_lseek(struct file * file, loff_t offset, int orig) +static loff_t null_lseek(struct file *file, loff_t offset, int orig) { return file->f_pos = 0; } @@ -702,24 +702,31 @@ static loff_t null_lseek(struct file * file, loff_t offset, int orig) * also note that seeking relative to the "end of file" isn't supported: * it has no meaning, so it returns -EINVAL. */ -static loff_t memory_lseek(struct file * file, loff_t offset, int orig) +static loff_t memory_lseek(struct file *file, loff_t offset, int orig) { loff_t ret; mutex_lock(&file->f_path.dentry->d_inode->i_mutex); switch (orig) { - case 0: - file->f_pos = offset; - ret = file->f_pos; - force_successful_syscall_return(); + case SEEK_CUR: + offset += file->f_pos; + if ((unsigned long long)offset < + (unsigned long long)file->f_pos) { + ret = -EOVERFLOW; break; - case 1: - file->f_pos += offset; - ret = file->f_pos; - force_successful_syscall_return(); + } + case SEEK_SET: + /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */ + if ((unsigned long long)offset >= ~0xFFFULL) { + ret = -EOVERFLOW; break; - default: - ret = -EINVAL; + } + file->f_pos = offset; + ret = file->f_pos; + force_successful_syscall_return(); + break; + default: + ret = -EINVAL; } mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); return ret; @@ -803,7 +810,7 @@ static const struct file_operations oldmem_fops = { }; #endif -static ssize_t kmsg_write(struct file * file, const char __user * buf, +static ssize_t kmsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { char *tmp; @@ -825,7 +832,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf, } static const struct file_operations kmsg_fops = { - .write = kmsg_write, + .write = kmsg_write, }; static const struct memdev { @@ -876,7 +883,7 @@ static int memory_open(struct inode *inode, struct file *filp) } static const struct file_operations memory_fops = { - .open = memory_open, + .open = memory_open, }; static char *mem_devnode(struct device *dev, mode_t *mode) @@ -897,7 +904,7 @@ static int __init chr_dev_init(void) if (err) return err; - if (register_chrdev(MEM_MAJOR,"mem",&memory_fops)) + if (register_chrdev(MEM_MAJOR, "mem", &memory_fops)) printk("unable to get major %d for memory devs\n", MEM_MAJOR); mem_class = class_create(THIS_MODULE, "mem"); diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 918711aa56f3..04fd0d843b3b 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c @@ -546,7 +546,7 @@ static void mmtimer_tasklet(unsigned long data) { int nodeid = data; struct mmtimer_node *mn = &timers[nodeid]; - struct mmtimer *x = rb_entry(mn->next, struct mmtimer, list); + struct mmtimer *x; struct k_itimer *t; unsigned long flags; diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 2e50f4dfc79c..bdae8327143c 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -48,6 +48,7 @@ #include <linux/audit.h> #include <linux/file.h> #include <linux/uaccess.h> +#include <linux/module.h> #include <asm/system.h> @@ -2091,3 +2092,19 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = { .receive_buf = n_tty_receive_buf, .write_wakeup = n_tty_write_wakeup }; + +/** + * n_tty_inherit_ops - inherit N_TTY methods + * @ops: struct tty_ldisc_ops where to save N_TTY methods + * + * Used by a generic struct tty_ldisc_ops to easily inherit N_TTY + * methods. + */ + +void n_tty_inherit_ops(struct tty_ldisc_ops *ops) +{ + *ops = tty_ldisc_N_TTY; + ops->owner = NULL; + ops->refcount = ops->flags = 0; +} +EXPORT_SYMBOL_GPL(n_tty_inherit_ops); diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c index ac16fbec72d0..283a15bc84e3 100644 --- a/drivers/char/tty_audit.c +++ b/drivers/char/tty_audit.c @@ -148,7 +148,6 @@ void tty_audit_fork(struct signal_struct *sig) spin_lock_irq(¤t->sighand->siglock); sig->audit_tty = current->signal->audit_tty; spin_unlock_irq(¤t->sighand->siglock); - sig->tty_audit_buf = NULL; } /** |