aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/cgroups/memcg_test.txt24
-rw-r--r--Documentation/filesystems/proc.txt28
-rw-r--r--Documentation/lguest/Makefile2
-rw-r--r--arch/alpha/Kconfig1
-rw-r--r--arch/alpha/include/asm/bug.h17
-rw-r--r--arch/alpha/include/asm/dma-mapping.h2
-rw-r--r--arch/alpha/kernel/entry.S2
-rw-r--r--arch/alpha/kernel/osf_sys.c113
-rw-r--r--arch/alpha/kernel/pci-noop.c3
-rw-r--r--arch/alpha/kernel/signal.c18
-rw-r--r--arch/alpha/kernel/smp.c3
-rw-r--r--arch/alpha/kernel/systbls.S52
-rw-r--r--arch/x86/lguest/boot.c4
-rw-r--r--drivers/firewire/fw-card.c4
-rw-r--r--drivers/firewire/fw-device.c123
-rw-r--r--drivers/firewire/fw-device.h1
-rw-r--r--drivers/firewire/fw-ohci.c6
-rw-r--r--drivers/firewire/fw-sbp2.c89
-rw-r--r--drivers/firewire/fw-topology.c12
-rw-r--r--drivers/firewire/fw-transaction.h9
-rw-r--r--drivers/gpio/gpiolib.c1
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c2
-rw-r--r--drivers/hid/hid-core.c4
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-microsoft.c13
-rw-r--r--drivers/hid/usbhid/hiddev.c2
-rw-r--r--drivers/hwmon/applesmc.c30
-rw-r--r--drivers/ieee1394/ieee1394.h4
-rw-r--r--drivers/ieee1394/ieee1394_core.c16
-rw-r--r--drivers/ieee1394/ohci1394.h2
-rw-r--r--drivers/ieee1394/sbp2.c54
-rw-r--r--drivers/lguest/core.c2
-rw-r--r--drivers/lguest/lguest_user.c5
-rw-r--r--drivers/misc/hpilo.c2
-rw-r--r--drivers/misc/sgi-xp/xpc_channel.c3
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c34
-rw-r--r--drivers/misc/sgi-xp/xpc_uv.c2
-rw-r--r--drivers/mtd/ubi/Kconfig.debug10
-rw-r--r--drivers/mtd/ubi/build.c21
-rw-r--r--drivers/mtd/ubi/cdev.c184
-rw-r--r--drivers/mtd/ubi/gluebi.c11
-rw-r--r--drivers/mtd/ubi/scan.c8
-rw-r--r--drivers/mtd/ubi/ubi.h11
-rw-r--r--drivers/mtd/ubi/upd.c21
-rw-r--r--drivers/mtd/ubi/vmt.c17
-rw-r--r--drivers/platform/x86/hp-wmi.c6
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--fs/eventpoll.c22
-rw-r--r--include/linux/cgroup.h1
-rw-r--r--include/linux/kprobes.h47
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/linux/syscalls.h5
-rw-r--r--include/mtd/ubi-user.h132
-rw-r--r--kernel/cgroup.c28
-rw-r--r--mm/memcontrol.c25
-rw-r--r--mm/mmap.c26
-rw-r--r--mm/swapfile.c5
-rw-r--r--sound/pci/hda/patch_conexant.c14
-rw-r--r--sound/pci/hda/patch_realtek.c1
-rw-r--r--sound/pci/hda/patch_sigmatel.c2
-rw-r--r--sound/soc/codecs/wm8753.c9
-rw-r--r--sound/soc/omap/omap-mcbsp.c4
62 files changed, 847 insertions, 457 deletions
diff --git a/Documentation/cgroups/memcg_test.txt b/Documentation/cgroups/memcg_test.txt
index 19533f93b7a2..523a9c16c400 100644
--- a/Documentation/cgroups/memcg_test.txt
+++ b/Documentation/cgroups/memcg_test.txt
@@ -1,6 +1,6 @@
1Memory Resource Controller(Memcg) Implementation Memo. 1Memory Resource Controller(Memcg) Implementation Memo.
2Last Updated: 2008/12/15 2Last Updated: 2009/1/19
3Base Kernel Version: based on 2.6.28-rc8-mm. 3Base Kernel Version: based on 2.6.29-rc2.
4 4
5Because VM is getting complex (one of reasons is memcg...), memcg's behavior 5Because VM is getting complex (one of reasons is memcg...), memcg's behavior
6is complex. This is a document for memcg's internal behavior. 6is complex. This is a document for memcg's internal behavior.
@@ -340,3 +340,23 @@ Under below explanation, we assume CONFIG_MEM_RES_CTRL_SWAP=y.
340 # mount -t cgroup none /cgroup -t cpuset,memory,cpu,devices 340 # mount -t cgroup none /cgroup -t cpuset,memory,cpu,devices
341 341
342 and do task move, mkdir, rmdir etc...under this. 342 and do task move, mkdir, rmdir etc...under this.
343
344 9.7 swapoff.
345 Besides management of swap is one of complicated parts of memcg,
346 call path of swap-in at swapoff is not same as usual swap-in path..
347 It's worth to be tested explicitly.
348
349 For example, test like following is good.
350 (Shell-A)
351 # mount -t cgroup none /cgroup -t memory
352 # mkdir /cgroup/test
353 # echo 40M > /cgroup/test/memory.limit_in_bytes
354 # echo 0 > /cgroup/test/tasks
355 Run malloc(100M) program under this. You'll see 60M of swaps.
356 (Shell-B)
357 # move all tasks in /cgroup/test to /cgroup
358 # /sbin/swapoff -a
359 # rmdir /test/cgroup
360 # kill malloc task.
361
362 Of course, tmpfs v.s. swapoff test should be tested, too.
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index bbebc3a43ac0..a87be42f8211 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -2027,6 +2027,34 @@ increase the likelihood of this process being killed by the oom-killer. Valid
2027values are in the range -16 to +15, plus the special value -17, which disables 2027values are in the range -16 to +15, plus the special value -17, which disables
2028oom-killing altogether for this process. 2028oom-killing altogether for this process.
2029 2029
2030The process to be killed in an out-of-memory situation is selected among all others
2031based on its badness score. This value equals the original memory size of the process
2032and is then updated according to its CPU time (utime + stime) and the
2033run time (uptime - start time). The longer it runs the smaller is the score.
2034Badness score is divided by the square root of the CPU time and then by
2035the double square root of the run time.
2036
2037Swapped out tasks are killed first. Half of each child's memory size is added to
2038the parent's score if they do not share the same memory. Thus forking servers
2039are the prime candidates to be killed. Having only one 'hungry' child will make
2040parent less preferable than the child.
2041
2042/proc/<pid>/oom_score shows process' current badness score.
2043
2044The following heuristics are then applied:
2045 * if the task was reniced, its score doubles
2046 * superuser or direct hardware access tasks (CAP_SYS_ADMIN, CAP_SYS_RESOURCE
2047 or CAP_SYS_RAWIO) have their score divided by 4
2048 * if oom condition happened in one cpuset and checked task does not belong
2049 to it, its score is divided by 8
2050 * the resulting score is multiplied by two to the power of oom_adj, i.e.
2051 points <<= oom_adj when it is positive and
2052 points >>= -(oom_adj) otherwise
2053
2054The task with the highest badness score is then selected and its children
2055are killed, process itself will be killed in an OOM situation when it does
2056not have children or some of them disabled oom like described above.
2057
20302.13 /proc/<pid>/oom_score - Display current oom-killer score 20582.13 /proc/<pid>/oom_score - Display current oom-killer score
2031------------------------------------------------------------- 2059-------------------------------------------------------------
2032 2060
diff --git a/Documentation/lguest/Makefile b/Documentation/lguest/Makefile
index 725eef81cd48..1f4f9e888bd1 100644
--- a/Documentation/lguest/Makefile
+++ b/Documentation/lguest/Makefile
@@ -1,5 +1,5 @@
1# This creates the demonstration utility "lguest" which runs a Linux guest. 1# This creates the demonstration utility "lguest" which runs a Linux guest.
2CFLAGS:=-Wall -Wmissing-declarations -Wmissing-prototypes -O3 -I../../include -I../../arch/x86/include 2CFLAGS:=-Wall -Wmissing-declarations -Wmissing-prototypes -O3 -I../../include -I../../arch/x86/include -U_FORTIFY_SOURCE
3LDLIBS:=-lz 3LDLIBS:=-lz
4 4
5all: lguest 5all: lguest
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 6110197757a3..9fb8aae5c391 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -8,6 +8,7 @@ config ALPHA
8 select HAVE_AOUT 8 select HAVE_AOUT
9 select HAVE_IDE 9 select HAVE_IDE
10 select HAVE_OPROFILE 10 select HAVE_OPROFILE
11 select HAVE_SYSCALL_WRAPPERS
11 help 12 help
12 The Alpha is a 64-bit general-purpose processor designed and 13 The Alpha is a 64-bit general-purpose processor designed and
13 marketed by the Digital Equipment Corporation of blessed memory, 14 marketed by the Digital Equipment Corporation of blessed memory,
diff --git a/arch/alpha/include/asm/bug.h b/arch/alpha/include/asm/bug.h
index 695a5ee4b5d3..7b85b7c93709 100644
--- a/arch/alpha/include/asm/bug.h
+++ b/arch/alpha/include/asm/bug.h
@@ -8,17 +8,12 @@
8 8
9/* ??? Would be nice to use .gprel32 here, but we can't be sure that the 9/* ??? Would be nice to use .gprel32 here, but we can't be sure that the
10 function loaded the GP, so this could fail in modules. */ 10 function loaded the GP, so this could fail in modules. */
11static inline void ATTRIB_NORET __BUG(const char *file, int line) 11#define BUG() { \
12{ 12 __asm__ __volatile__( \
13 __asm__ __volatile__( 13 "call_pal %0 # bugchk\n\t" \
14 "call_pal %0 # bugchk\n\t" 14 ".long %1\n\t.8byte %2" \
15 ".long %1\n\t.8byte %2" 15 : : "i"(PAL_bugchk), "i"(__LINE__), "i"(__FILE__)); \
16 : : "i" (PAL_bugchk), "i"(line), "i"(file)); 16 for ( ; ; ); }
17 for ( ; ; )
18 ;
19}
20
21#define BUG() __BUG(__FILE__, __LINE__)
22 17
23#define HAVE_ARCH_BUG 18#define HAVE_ARCH_BUG
24#endif 19#endif
diff --git a/arch/alpha/include/asm/dma-mapping.h b/arch/alpha/include/asm/dma-mapping.h
index a5801ae02e4b..04eb5681448c 100644
--- a/arch/alpha/include/asm/dma-mapping.h
+++ b/arch/alpha/include/asm/dma-mapping.h
@@ -29,6 +29,8 @@
29 29
30#else /* no PCI - no IOMMU. */ 30#else /* no PCI - no IOMMU. */
31 31
32#include <asm/io.h> /* for virt_to_phys() */
33
32struct scatterlist; 34struct scatterlist;
33void *dma_alloc_coherent(struct device *dev, size_t size, 35void *dma_alloc_coherent(struct device *dev, size_t size,
34 dma_addr_t *dma_handle, gfp_t gfp); 36 dma_addr_t *dma_handle, gfp_t gfp);
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index aa2e50cf9857..e4a54b615894 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -933,7 +933,7 @@ sys_execve:
933osf_sigprocmask: 933osf_sigprocmask:
934 .prologue 0 934 .prologue 0
935 mov $sp, $18 935 mov $sp, $18
936 jmp $31, do_osf_sigprocmask 936 jmp $31, sys_osf_sigprocmask
937.end osf_sigprocmask 937.end osf_sigprocmask
938 938
939 .align 4 939 .align 4
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 18a3ea1aac51..ae41f097864b 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -54,8 +54,7 @@ extern int do_pipe(int *);
54 * identical to OSF as we don't return 0 on success, but doing otherwise 54 * identical to OSF as we don't return 0 on success, but doing otherwise
55 * would require changes to libc. Hopefully this is good enough. 55 * would require changes to libc. Hopefully this is good enough.
56 */ 56 */
57asmlinkage unsigned long 57SYSCALL_DEFINE1(osf_brk, unsigned long, brk)
58osf_brk(unsigned long brk)
59{ 58{
60 unsigned long retval = sys_brk(brk); 59 unsigned long retval = sys_brk(brk);
61 if (brk && brk != retval) 60 if (brk && brk != retval)
@@ -66,9 +65,9 @@ osf_brk(unsigned long brk)
66/* 65/*
67 * This is pure guess-work.. 66 * This is pure guess-work..
68 */ 67 */
69asmlinkage int 68SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
70osf_set_program_attributes(unsigned long text_start, unsigned long text_len, 69 unsigned long, text_len, unsigned long, bss_start,
71 unsigned long bss_start, unsigned long bss_len) 70 unsigned long, bss_len)
72{ 71{
73 struct mm_struct *mm; 72 struct mm_struct *mm;
74 73
@@ -146,9 +145,9 @@ Efault:
146 return -EFAULT; 145 return -EFAULT;
147} 146}
148 147
149asmlinkage int 148SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
150osf_getdirentries(unsigned int fd, struct osf_dirent __user *dirent, 149 struct osf_dirent __user *, dirent, unsigned int, count,
151 unsigned int count, long __user *basep) 150 long __user *, basep)
152{ 151{
153 int error; 152 int error;
154 struct file *file; 153 struct file *file;
@@ -177,9 +176,9 @@ osf_getdirentries(unsigned int fd, struct osf_dirent __user *dirent,
177 176
178#undef NAME_OFFSET 177#undef NAME_OFFSET
179 178
180asmlinkage unsigned long 179SYSCALL_DEFINE6(osf_mmap, unsigned long, addr, unsigned long, len,
181osf_mmap(unsigned long addr, unsigned long len, unsigned long prot, 180 unsigned long, prot, unsigned long, flags, unsigned long, fd,
182 unsigned long flags, unsigned long fd, unsigned long off) 181 unsigned long, off)
183{ 182{
184 struct file *file = NULL; 183 struct file *file = NULL;
185 unsigned long ret = -EBADF; 184 unsigned long ret = -EBADF;
@@ -254,8 +253,8 @@ do_osf_statfs(struct dentry * dentry, struct osf_statfs __user *buffer,
254 return error; 253 return error;
255} 254}
256 255
257asmlinkage int 256SYSCALL_DEFINE3(osf_statfs, char __user *, pathname,
258osf_statfs(char __user *pathname, struct osf_statfs __user *buffer, unsigned long bufsiz) 257 struct osf_statfs __user *, buffer, unsigned long, bufsiz)
259{ 258{
260 struct path path; 259 struct path path;
261 int retval; 260 int retval;
@@ -268,8 +267,8 @@ osf_statfs(char __user *pathname, struct osf_statfs __user *buffer, unsigned lon
268 return retval; 267 return retval;
269} 268}
270 269
271asmlinkage int 270SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd,
272osf_fstatfs(unsigned long fd, struct osf_statfs __user *buffer, unsigned long bufsiz) 271 struct osf_statfs __user *, buffer, unsigned long, bufsiz)
273{ 272{
274 struct file *file; 273 struct file *file;
275 int retval; 274 int retval;
@@ -368,8 +367,8 @@ osf_procfs_mount(char *dirname, struct procfs_args __user *args, int flags)
368 return do_mount("", dirname, "proc", flags, NULL); 367 return do_mount("", dirname, "proc", flags, NULL);
369} 368}
370 369
371asmlinkage int 370SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, char __user *, path,
372osf_mount(unsigned long typenr, char __user *path, int flag, void __user *data) 371 int, flag, void __user *, data)
373{ 372{
374 int retval = -EINVAL; 373 int retval = -EINVAL;
375 char *name; 374 char *name;
@@ -399,8 +398,7 @@ osf_mount(unsigned long typenr, char __user *path, int flag, void __user *data)
399 return retval; 398 return retval;
400} 399}
401 400
402asmlinkage int 401SYSCALL_DEFINE1(osf_utsname, char __user *, name)
403osf_utsname(char __user *name)
404{ 402{
405 int error; 403 int error;
406 404
@@ -423,14 +421,12 @@ osf_utsname(char __user *name)
423 return error; 421 return error;
424} 422}
425 423
426asmlinkage unsigned long 424SYSCALL_DEFINE0(getpagesize)
427sys_getpagesize(void)
428{ 425{
429 return PAGE_SIZE; 426 return PAGE_SIZE;
430} 427}
431 428
432asmlinkage unsigned long 429SYSCALL_DEFINE0(getdtablesize)
433sys_getdtablesize(void)
434{ 430{
435 return sysctl_nr_open; 431 return sysctl_nr_open;
436} 432}
@@ -438,8 +434,7 @@ sys_getdtablesize(void)
438/* 434/*
439 * For compatibility with OSF/1 only. Use utsname(2) instead. 435 * For compatibility with OSF/1 only. Use utsname(2) instead.
440 */ 436 */
441asmlinkage int 437SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)
442osf_getdomainname(char __user *name, int namelen)
443{ 438{
444 unsigned len; 439 unsigned len;
445 int i; 440 int i;
@@ -527,8 +522,8 @@ enum pl_code {
527 PL_DEL = 5, PL_FDEL = 6 522 PL_DEL = 5, PL_FDEL = 6
528}; 523};
529 524
530asmlinkage long 525SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
531osf_proplist_syscall(enum pl_code code, union pl_args __user *args) 526 union pl_args __user *, args)
532{ 527{
533 long error; 528 long error;
534 int __user *min_buf_size_ptr; 529 int __user *min_buf_size_ptr;
@@ -567,8 +562,8 @@ osf_proplist_syscall(enum pl_code code, union pl_args __user *args)
567 return error; 562 return error;
568} 563}
569 564
570asmlinkage int 565SYSCALL_DEFINE2(osf_sigstack, struct sigstack __user *, uss,
571osf_sigstack(struct sigstack __user *uss, struct sigstack __user *uoss) 566 struct sigstack __user *, uoss)
572{ 567{
573 unsigned long usp = rdusp(); 568 unsigned long usp = rdusp();
574 unsigned long oss_sp = current->sas_ss_sp + current->sas_ss_size; 569 unsigned long oss_sp = current->sas_ss_sp + current->sas_ss_size;
@@ -608,8 +603,7 @@ osf_sigstack(struct sigstack __user *uss, struct sigstack __user *uoss)
608 return error; 603 return error;
609} 604}
610 605
611asmlinkage long 606SYSCALL_DEFINE3(osf_sysinfo, int, command, char __user *, buf, long, count)
612osf_sysinfo(int command, char __user *buf, long count)
613{ 607{
614 char *sysinfo_table[] = { 608 char *sysinfo_table[] = {
615 utsname()->sysname, 609 utsname()->sysname,
@@ -647,9 +641,8 @@ osf_sysinfo(int command, char __user *buf, long count)
647 return err; 641 return err;
648} 642}
649 643
650asmlinkage unsigned long 644SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
651osf_getsysinfo(unsigned long op, void __user *buffer, unsigned long nbytes, 645 unsigned long, nbytes, int __user *, start, void __user *, arg)
652 int __user *start, void __user *arg)
653{ 646{
654 unsigned long w; 647 unsigned long w;
655 struct percpu_struct *cpu; 648 struct percpu_struct *cpu;
@@ -705,9 +698,8 @@ osf_getsysinfo(unsigned long op, void __user *buffer, unsigned long nbytes,
705 return -EOPNOTSUPP; 698 return -EOPNOTSUPP;
706} 699}
707 700
708asmlinkage unsigned long 701SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
709osf_setsysinfo(unsigned long op, void __user *buffer, unsigned long nbytes, 702 unsigned long, nbytes, int __user *, start, void __user *, arg)
710 int __user *start, void __user *arg)
711{ 703{
712 switch (op) { 704 switch (op) {
713 case SSI_IEEE_FP_CONTROL: { 705 case SSI_IEEE_FP_CONTROL: {
@@ -880,8 +872,8 @@ jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
880 value->tv_sec = jiffies / HZ; 872 value->tv_sec = jiffies / HZ;
881} 873}
882 874
883asmlinkage int 875SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
884osf_gettimeofday(struct timeval32 __user *tv, struct timezone __user *tz) 876 struct timezone __user *, tz)
885{ 877{
886 if (tv) { 878 if (tv) {
887 struct timeval ktv; 879 struct timeval ktv;
@@ -896,8 +888,8 @@ osf_gettimeofday(struct timeval32 __user *tv, struct timezone __user *tz)
896 return 0; 888 return 0;
897} 889}
898 890
899asmlinkage int 891SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
900osf_settimeofday(struct timeval32 __user *tv, struct timezone __user *tz) 892 struct timezone __user *, tz)
901{ 893{
902 struct timespec kts; 894 struct timespec kts;
903 struct timezone ktz; 895 struct timezone ktz;
@@ -916,8 +908,7 @@ osf_settimeofday(struct timeval32 __user *tv, struct timezone __user *tz)
916 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); 908 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
917} 909}
918 910
919asmlinkage int 911SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it)
920osf_getitimer(int which, struct itimerval32 __user *it)
921{ 912{
922 struct itimerval kit; 913 struct itimerval kit;
923 int error; 914 int error;
@@ -929,8 +920,8 @@ osf_getitimer(int which, struct itimerval32 __user *it)
929 return error; 920 return error;
930} 921}
931 922
932asmlinkage int 923SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in,
933osf_setitimer(int which, struct itimerval32 __user *in, struct itimerval32 __user *out) 924 struct itimerval32 __user *, out)
934{ 925{
935 struct itimerval kin, kout; 926 struct itimerval kin, kout;
936 int error; 927 int error;
@@ -952,8 +943,8 @@ osf_setitimer(int which, struct itimerval32 __user *in, struct itimerval32 __use
952 943
953} 944}
954 945
955asmlinkage int 946SYSCALL_DEFINE2(osf_utimes, char __user *, filename,
956osf_utimes(char __user *filename, struct timeval32 __user *tvs) 947 struct timeval32 __user *, tvs)
957{ 948{
958 struct timespec tv[2]; 949 struct timespec tv[2];
959 950
@@ -979,9 +970,8 @@ osf_utimes(char __user *filename, struct timeval32 __user *tvs)
979#define MAX_SELECT_SECONDS \ 970#define MAX_SELECT_SECONDS \
980 ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1) 971 ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1)
981 972
982asmlinkage int 973SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp,
983osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, 974 fd_set __user *, exp, struct timeval32 __user *, tvp)
984 struct timeval32 __user *tvp)
985{ 975{
986 struct timespec end_time, *to = NULL; 976 struct timespec end_time, *to = NULL;
987 if (tvp) { 977 if (tvp) {
@@ -1026,8 +1016,7 @@ struct rusage32 {
1026 long ru_nivcsw; /* involuntary " */ 1016 long ru_nivcsw; /* involuntary " */
1027}; 1017};
1028 1018
1029asmlinkage int 1019SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
1030osf_getrusage(int who, struct rusage32 __user *ru)
1031{ 1020{
1032 struct rusage32 r; 1021 struct rusage32 r;
1033 1022
@@ -1053,9 +1042,8 @@ osf_getrusage(int who, struct rusage32 __user *ru)
1053 return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0; 1042 return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
1054} 1043}
1055 1044
1056asmlinkage long 1045SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1057osf_wait4(pid_t pid, int __user *ustatus, int options, 1046 struct rusage32 __user *, ur)
1058 struct rusage32 __user *ur)
1059{ 1047{
1060 struct rusage r; 1048 struct rusage r;
1061 long ret, err; 1049 long ret, err;
@@ -1101,8 +1089,8 @@ osf_wait4(pid_t pid, int __user *ustatus, int options,
1101 * seems to be a timeval pointer, and I suspect the second 1089 * seems to be a timeval pointer, and I suspect the second
1102 * one is the time remaining.. Ho humm.. No documentation. 1090 * one is the time remaining.. Ho humm.. No documentation.
1103 */ 1091 */
1104asmlinkage int 1092SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep,
1105osf_usleep_thread(struct timeval32 __user *sleep, struct timeval32 __user *remain) 1093 struct timeval32 __user *, remain)
1106{ 1094{
1107 struct timeval tmp; 1095 struct timeval tmp;
1108 unsigned long ticks; 1096 unsigned long ticks;
@@ -1155,8 +1143,7 @@ struct timex32 {
1155 int :32; int :32; int :32; int :32; 1143 int :32; int :32; int :32; int :32;
1156}; 1144};
1157 1145
1158asmlinkage int 1146SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
1159sys_old_adjtimex(struct timex32 __user *txc_p)
1160{ 1147{
1161 struct timex txc; 1148 struct timex txc;
1162 int ret; 1149 int ret;
@@ -1267,8 +1254,8 @@ osf_fix_iov_len(const struct iovec __user *iov, unsigned long count)
1267 return 0; 1254 return 0;
1268} 1255}
1269 1256
1270asmlinkage ssize_t 1257SYSCALL_DEFINE3(osf_readv, unsigned long, fd,
1271osf_readv(unsigned long fd, const struct iovec __user * vector, unsigned long count) 1258 const struct iovec __user *, vector, unsigned long, count)
1272{ 1259{
1273 if (unlikely(personality(current->personality) == PER_OSF4)) 1260 if (unlikely(personality(current->personality) == PER_OSF4))
1274 if (osf_fix_iov_len(vector, count)) 1261 if (osf_fix_iov_len(vector, count))
@@ -1276,8 +1263,8 @@ osf_readv(unsigned long fd, const struct iovec __user * vector, unsigned long co
1276 return sys_readv(fd, vector, count); 1263 return sys_readv(fd, vector, count);
1277} 1264}
1278 1265
1279asmlinkage ssize_t 1266SYSCALL_DEFINE3(osf_writev, unsigned long, fd,
1280osf_writev(unsigned long fd, const struct iovec __user * vector, unsigned long count) 1267 const struct iovec __user *, vector, unsigned long, count)
1281{ 1268{
1282 if (unlikely(personality(current->personality) == PER_OSF4)) 1269 if (unlikely(personality(current->personality) == PER_OSF4))
1283 if (osf_fix_iov_len(vector, count)) 1270 if (osf_fix_iov_len(vector, count))
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index 8ac08311f5a5..c19a376520f4 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -109,7 +109,8 @@ sys_pciconfig_write(unsigned long bus, unsigned long dfn,
109/* Stubs for the routines in pci_iommu.c: */ 109/* Stubs for the routines in pci_iommu.c: */
110 110
111void * 111void *
112pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp) 112__pci_alloc_consistent(struct pci_dev *pdev, size_t size,
113 dma_addr_t *dma_addrp, gfp_t gfp)
113{ 114{
114 return NULL; 115 return NULL;
115} 116}
diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c
index 410af4f3140e..df65eaa84c4c 100644
--- a/arch/alpha/kernel/signal.c
+++ b/arch/alpha/kernel/signal.c
@@ -19,6 +19,7 @@
19#include <linux/tty.h> 19#include <linux/tty.h>
20#include <linux/binfmts.h> 20#include <linux/binfmts.h>
21#include <linux/bitops.h> 21#include <linux/bitops.h>
22#include <linux/syscalls.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/sigcontext.h> 25#include <asm/sigcontext.h>
@@ -51,8 +52,8 @@ static void do_signal(struct pt_regs *, struct switch_stack *,
51 * Note that we don't need to acquire the kernel lock for SMP 52 * Note that we don't need to acquire the kernel lock for SMP
52 * operation, as all of this is local to this thread. 53 * operation, as all of this is local to this thread.
53 */ 54 */
54asmlinkage unsigned long 55SYSCALL_DEFINE3(osf_sigprocmask, int, how, unsigned long, newmask,
55do_osf_sigprocmask(int how, unsigned long newmask, struct pt_regs *regs) 56 struct pt_regs *, regs)
56{ 57{
57 unsigned long oldmask = -EINVAL; 58 unsigned long oldmask = -EINVAL;
58 59
@@ -81,9 +82,9 @@ do_osf_sigprocmask(int how, unsigned long newmask, struct pt_regs *regs)
81 return oldmask; 82 return oldmask;
82} 83}
83 84
84asmlinkage int 85SYSCALL_DEFINE3(osf_sigaction, int, sig,
85osf_sigaction(int sig, const struct osf_sigaction __user *act, 86 const struct osf_sigaction __user *, act,
86 struct osf_sigaction __user *oact) 87 struct osf_sigaction __user *, oact)
87{ 88{
88 struct k_sigaction new_ka, old_ka; 89 struct k_sigaction new_ka, old_ka;
89 int ret; 90 int ret;
@@ -112,10 +113,9 @@ osf_sigaction(int sig, const struct osf_sigaction __user *act,
112 return ret; 113 return ret;
113} 114}
114 115
115asmlinkage long 116SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act,
116sys_rt_sigaction(int sig, const struct sigaction __user *act, 117 struct sigaction __user *, oact,
117 struct sigaction __user *oact, 118 size_t, sigsetsize, void __user *, restorer)
118 size_t sigsetsize, void __user *restorer)
119{ 119{
120 struct k_sigaction new_ka, old_ka; 120 struct k_sigaction new_ka, old_ka;
121 int ret; 121 int ret;
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index d953e510f68d..00f1dc3dfd5f 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -120,8 +120,9 @@ void __cpuinit
120smp_callin(void) 120smp_callin(void)
121{ 121{
122 int cpuid = hard_smp_processor_id(); 122 int cpuid = hard_smp_processor_id();
123 cpumask_t mask = cpu_online_map;
123 124
124 if (cpu_test_and_set(cpuid, cpu_online_map)) { 125 if (cpu_test_and_set(cpuid, mask)) {
125 printk("??, cpu 0x%x already present??\n", cpuid); 126 printk("??, cpu 0x%x already present??\n", cpuid);
126 BUG(); 127 BUG();
127 } 128 }
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index 9d9e3a98bb95..95c9aef1c106 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -17,7 +17,7 @@ sys_call_table:
17 .quad sys_write 17 .quad sys_write
18 .quad alpha_ni_syscall /* 5 */ 18 .quad alpha_ni_syscall /* 5 */
19 .quad sys_close 19 .quad sys_close
20 .quad osf_wait4 20 .quad sys_osf_wait4
21 .quad alpha_ni_syscall 21 .quad alpha_ni_syscall
22 .quad sys_link 22 .quad sys_link
23 .quad sys_unlink /* 10 */ 23 .quad sys_unlink /* 10 */
@@ -27,11 +27,11 @@ sys_call_table:
27 .quad sys_mknod 27 .quad sys_mknod
28 .quad sys_chmod /* 15 */ 28 .quad sys_chmod /* 15 */
29 .quad sys_chown 29 .quad sys_chown
30 .quad osf_brk 30 .quad sys_osf_brk
31 .quad alpha_ni_syscall 31 .quad alpha_ni_syscall
32 .quad sys_lseek 32 .quad sys_lseek
33 .quad sys_getxpid /* 20 */ 33 .quad sys_getxpid /* 20 */
34 .quad osf_mount 34 .quad sys_osf_mount
35 .quad sys_umount 35 .quad sys_umount
36 .quad sys_setuid 36 .quad sys_setuid
37 .quad sys_getxuid 37 .quad sys_getxuid
@@ -53,7 +53,7 @@ sys_call_table:
53 .quad alpha_ni_syscall /* 40 */ 53 .quad alpha_ni_syscall /* 40 */
54 .quad sys_dup 54 .quad sys_dup
55 .quad sys_alpha_pipe 55 .quad sys_alpha_pipe
56 .quad osf_set_program_attributes 56 .quad sys_osf_set_program_attributes
57 .quad alpha_ni_syscall 57 .quad alpha_ni_syscall
58 .quad sys_open /* 45 */ 58 .quad sys_open /* 45 */
59 .quad alpha_ni_syscall 59 .quad alpha_ni_syscall
@@ -81,7 +81,7 @@ sys_call_table:
81 .quad sys_newlstat 81 .quad sys_newlstat
82 .quad alpha_ni_syscall 82 .quad alpha_ni_syscall
83 .quad alpha_ni_syscall /* 70 */ 83 .quad alpha_ni_syscall /* 70 */
84 .quad osf_mmap 84 .quad sys_osf_mmap
85 .quad alpha_ni_syscall 85 .quad alpha_ni_syscall
86 .quad sys_munmap 86 .quad sys_munmap
87 .quad sys_mprotect 87 .quad sys_mprotect
@@ -94,17 +94,17 @@ sys_call_table:
94 .quad sys_setgroups /* 80 */ 94 .quad sys_setgroups /* 80 */
95 .quad alpha_ni_syscall 95 .quad alpha_ni_syscall
96 .quad sys_setpgid 96 .quad sys_setpgid
97 .quad osf_setitimer 97 .quad sys_osf_setitimer
98 .quad alpha_ni_syscall 98 .quad alpha_ni_syscall
99 .quad alpha_ni_syscall /* 85 */ 99 .quad alpha_ni_syscall /* 85 */
100 .quad osf_getitimer 100 .quad sys_osf_getitimer
101 .quad sys_gethostname 101 .quad sys_gethostname
102 .quad sys_sethostname 102 .quad sys_sethostname
103 .quad sys_getdtablesize 103 .quad sys_getdtablesize
104 .quad sys_dup2 /* 90 */ 104 .quad sys_dup2 /* 90 */
105 .quad sys_newfstat 105 .quad sys_newfstat
106 .quad sys_fcntl 106 .quad sys_fcntl
107 .quad osf_select 107 .quad sys_osf_select
108 .quad sys_poll 108 .quad sys_poll
109 .quad sys_fsync /* 95 */ 109 .quad sys_fsync /* 95 */
110 .quad sys_setpriority 110 .quad sys_setpriority
@@ -123,22 +123,22 @@ sys_call_table:
123 .quad alpha_ni_syscall 123 .quad alpha_ni_syscall
124 .quad alpha_ni_syscall /* 110 */ 124 .quad alpha_ni_syscall /* 110 */
125 .quad sys_sigsuspend 125 .quad sys_sigsuspend
126 .quad osf_sigstack 126 .quad sys_osf_sigstack
127 .quad sys_recvmsg 127 .quad sys_recvmsg
128 .quad sys_sendmsg 128 .quad sys_sendmsg
129 .quad alpha_ni_syscall /* 115 */ 129 .quad alpha_ni_syscall /* 115 */
130 .quad osf_gettimeofday 130 .quad sys_osf_gettimeofday
131 .quad osf_getrusage 131 .quad sys_osf_getrusage
132 .quad sys_getsockopt 132 .quad sys_getsockopt
133 .quad alpha_ni_syscall 133 .quad alpha_ni_syscall
134#ifdef CONFIG_OSF4_COMPAT 134#ifdef CONFIG_OSF4_COMPAT
135 .quad osf_readv /* 120 */ 135 .quad sys_osf_readv /* 120 */
136 .quad osf_writev 136 .quad sys_osf_writev
137#else 137#else
138 .quad sys_readv /* 120 */ 138 .quad sys_readv /* 120 */
139 .quad sys_writev 139 .quad sys_writev
140#endif 140#endif
141 .quad osf_settimeofday 141 .quad sys_osf_settimeofday
142 .quad sys_fchown 142 .quad sys_fchown
143 .quad sys_fchmod 143 .quad sys_fchmod
144 .quad sys_recvfrom /* 125 */ 144 .quad sys_recvfrom /* 125 */
@@ -154,7 +154,7 @@ sys_call_table:
154 .quad sys_socketpair /* 135 */ 154 .quad sys_socketpair /* 135 */
155 .quad sys_mkdir 155 .quad sys_mkdir
156 .quad sys_rmdir 156 .quad sys_rmdir
157 .quad osf_utimes 157 .quad sys_osf_utimes
158 .quad alpha_ni_syscall 158 .quad alpha_ni_syscall
159 .quad alpha_ni_syscall /* 140 */ 159 .quad alpha_ni_syscall /* 140 */
160 .quad sys_getpeername 160 .quad sys_getpeername
@@ -172,16 +172,16 @@ sys_call_table:
172 .quad alpha_ni_syscall 172 .quad alpha_ni_syscall
173 .quad alpha_ni_syscall 173 .quad alpha_ni_syscall
174 .quad alpha_ni_syscall /* 155 */ 174 .quad alpha_ni_syscall /* 155 */
175 .quad osf_sigaction 175 .quad sys_osf_sigaction
176 .quad alpha_ni_syscall 176 .quad alpha_ni_syscall
177 .quad alpha_ni_syscall 177 .quad alpha_ni_syscall
178 .quad osf_getdirentries 178 .quad sys_osf_getdirentries
179 .quad osf_statfs /* 160 */ 179 .quad sys_osf_statfs /* 160 */
180 .quad osf_fstatfs 180 .quad sys_osf_fstatfs
181 .quad alpha_ni_syscall 181 .quad alpha_ni_syscall
182 .quad alpha_ni_syscall 182 .quad alpha_ni_syscall
183 .quad alpha_ni_syscall 183 .quad alpha_ni_syscall
184 .quad osf_getdomainname /* 165 */ 184 .quad sys_osf_getdomainname /* 165 */
185 .quad sys_setdomainname 185 .quad sys_setdomainname
186 .quad alpha_ni_syscall 186 .quad alpha_ni_syscall
187 .quad alpha_ni_syscall 187 .quad alpha_ni_syscall
@@ -224,7 +224,7 @@ sys_call_table:
224 .quad sys_semctl 224 .quad sys_semctl
225 .quad sys_semget /* 205 */ 225 .quad sys_semget /* 205 */
226 .quad sys_semop 226 .quad sys_semop
227 .quad osf_utsname 227 .quad sys_osf_utsname
228 .quad sys_lchown 228 .quad sys_lchown
229 .quad sys_shmat 229 .quad sys_shmat
230 .quad sys_shmctl /* 210 */ 230 .quad sys_shmctl /* 210 */
@@ -258,23 +258,23 @@ sys_call_table:
258 .quad alpha_ni_syscall 258 .quad alpha_ni_syscall
259 .quad alpha_ni_syscall 259 .quad alpha_ni_syscall
260 .quad alpha_ni_syscall /* 240 */ 260 .quad alpha_ni_syscall /* 240 */
261 .quad osf_sysinfo 261 .quad sys_osf_sysinfo
262 .quad alpha_ni_syscall 262 .quad alpha_ni_syscall
263 .quad alpha_ni_syscall 263 .quad alpha_ni_syscall
264 .quad osf_proplist_syscall 264 .quad sys_osf_proplist_syscall
265 .quad alpha_ni_syscall /* 245 */ 265 .quad alpha_ni_syscall /* 245 */
266 .quad alpha_ni_syscall 266 .quad alpha_ni_syscall
267 .quad alpha_ni_syscall 267 .quad alpha_ni_syscall
268 .quad alpha_ni_syscall 268 .quad alpha_ni_syscall
269 .quad alpha_ni_syscall 269 .quad alpha_ni_syscall
270 .quad alpha_ni_syscall /* 250 */ 270 .quad alpha_ni_syscall /* 250 */
271 .quad osf_usleep_thread 271 .quad sys_osf_usleep_thread
272 .quad alpha_ni_syscall 272 .quad alpha_ni_syscall
273 .quad alpha_ni_syscall 273 .quad alpha_ni_syscall
274 .quad sys_sysfs 274 .quad sys_sysfs
275 .quad alpha_ni_syscall /* 255 */ 275 .quad alpha_ni_syscall /* 255 */
276 .quad osf_getsysinfo 276 .quad sys_osf_getsysinfo
277 .quad osf_setsysinfo 277 .quad sys_osf_setsysinfo
278 .quad alpha_ni_syscall 278 .quad alpha_ni_syscall
279 .quad alpha_ni_syscall 279 .quad alpha_ni_syscall
280 .quad alpha_ni_syscall /* 260 */ 280 .quad alpha_ni_syscall /* 260 */
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index a7ed208f81e3..92f1c6f3e19d 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -931,7 +931,7 @@ static void lguest_restart(char *reason)
931 * that we can fit comfortably. 931 * that we can fit comfortably.
932 * 932 *
933 * First we need assembly templates of each of the patchable Guest operations, 933 * First we need assembly templates of each of the patchable Guest operations,
934 * and these are in lguest_asm.S. */ 934 * and these are in i386_head.S. */
935 935
936/*G:060 We construct a table from the assembler templates: */ 936/*G:060 We construct a table from the assembler templates: */
937static const struct lguest_insns 937static const struct lguest_insns
@@ -1093,7 +1093,7 @@ __init void lguest_init(void)
1093 acpi_ht = 0; 1093 acpi_ht = 0;
1094#endif 1094#endif
1095 1095
1096 /* We set the perferred console to "hvc". This is the "hypervisor 1096 /* We set the preferred console to "hvc". This is the "hypervisor
1097 * virtual console" driver written by the PowerPC people, which we also 1097 * virtual console" driver written by the PowerPC people, which we also
1098 * adapted for lguest's use. */ 1098 * adapted for lguest's use. */
1099 add_preferred_console("hvc", 0, NULL); 1099 add_preferred_console("hvc", 0, NULL);
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 6bd91a15d5e6..7be2cf3514e7 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -232,7 +232,7 @@ fw_card_bm_work(struct work_struct *work)
232 root_id = root_node->node_id; 232 root_id = root_node->node_id;
233 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); 233 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10));
234 234
235 if (card->bm_generation + 1 == generation || 235 if (is_next_generation(generation, card->bm_generation) ||
236 (card->bm_generation != generation && grace)) { 236 (card->bm_generation != generation && grace)) {
237 /* 237 /*
238 * This first step is to figure out who is IRM and 238 * This first step is to figure out who is IRM and
@@ -512,7 +512,7 @@ fw_core_remove_card(struct fw_card *card)
512 fw_core_initiate_bus_reset(card, 1); 512 fw_core_initiate_bus_reset(card, 1);
513 513
514 mutex_lock(&card_mutex); 514 mutex_lock(&card_mutex);
515 list_del(&card->link); 515 list_del_init(&card->link);
516 mutex_unlock(&card_mutex); 516 mutex_unlock(&card_mutex);
517 517
518 /* Set up the dummy driver. */ 518 /* Set up the dummy driver. */
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 2af5a8d1e012..bf53acb45652 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -25,6 +25,7 @@
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/idr.h> 27#include <linux/idr.h>
28#include <linux/jiffies.h>
28#include <linux/string.h> 29#include <linux/string.h>
29#include <linux/rwsem.h> 30#include <linux/rwsem.h>
30#include <linux/semaphore.h> 31#include <linux/semaphore.h>
@@ -634,12 +635,39 @@ struct fw_device *fw_device_get_by_devt(dev_t devt)
634 return device; 635 return device;
635} 636}
636 637
638/*
639 * These defines control the retry behavior for reading the config
640 * rom. It shouldn't be necessary to tweak these; if the device
641 * doesn't respond to a config rom read within 10 seconds, it's not
642 * going to respond at all. As for the initial delay, a lot of
643 * devices will be able to respond within half a second after bus
644 * reset. On the other hand, it's not really worth being more
645 * aggressive than that, since it scales pretty well; if 10 devices
646 * are plugged in, they're all getting read within one second.
647 */
648
649#define MAX_RETRIES 10
650#define RETRY_DELAY (3 * HZ)
651#define INITIAL_DELAY (HZ / 2)
652#define SHUTDOWN_DELAY (2 * HZ)
653
637static void fw_device_shutdown(struct work_struct *work) 654static void fw_device_shutdown(struct work_struct *work)
638{ 655{
639 struct fw_device *device = 656 struct fw_device *device =
640 container_of(work, struct fw_device, work.work); 657 container_of(work, struct fw_device, work.work);
641 int minor = MINOR(device->device.devt); 658 int minor = MINOR(device->device.devt);
642 659
660 if (time_is_after_jiffies(device->card->reset_jiffies + SHUTDOWN_DELAY)
661 && !list_empty(&device->card->link)) {
662 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
663 return;
664 }
665
666 if (atomic_cmpxchg(&device->state,
667 FW_DEVICE_GONE,
668 FW_DEVICE_SHUTDOWN) != FW_DEVICE_GONE)
669 return;
670
643 fw_device_cdev_remove(device); 671 fw_device_cdev_remove(device);
644 device_for_each_child(&device->device, NULL, shutdown_unit); 672 device_for_each_child(&device->device, NULL, shutdown_unit);
645 device_unregister(&device->device); 673 device_unregister(&device->device);
@@ -647,6 +675,7 @@ static void fw_device_shutdown(struct work_struct *work)
647 down_write(&fw_device_rwsem); 675 down_write(&fw_device_rwsem);
648 idr_remove(&fw_device_idr, minor); 676 idr_remove(&fw_device_idr, minor);
649 up_write(&fw_device_rwsem); 677 up_write(&fw_device_rwsem);
678
650 fw_device_put(device); 679 fw_device_put(device);
651} 680}
652 681
@@ -654,25 +683,63 @@ static struct device_type fw_device_type = {
654 .release = fw_device_release, 683 .release = fw_device_release,
655}; 684};
656 685
686static void fw_device_update(struct work_struct *work);
687
657/* 688/*
658 * These defines control the retry behavior for reading the config 689 * If a device was pending for deletion because its node went away but its
659 * rom. It shouldn't be necessary to tweak these; if the device 690 * bus info block and root directory header matches that of a newly discovered
660 * doesn't respond to a config rom read within 10 seconds, it's not 691 * device, revive the existing fw_device.
661 * going to respond at all. As for the initial delay, a lot of 692 * The newly allocated fw_device becomes obsolete instead.
662 * devices will be able to respond within half a second after bus
663 * reset. On the other hand, it's not really worth being more
664 * aggressive than that, since it scales pretty well; if 10 devices
665 * are plugged in, they're all getting read within one second.
666 */ 693 */
694static int lookup_existing_device(struct device *dev, void *data)
695{
696 struct fw_device *old = fw_device(dev);
697 struct fw_device *new = data;
698 struct fw_card *card = new->card;
699 int match = 0;
700
701 down_read(&fw_device_rwsem); /* serialize config_rom access */
702 spin_lock_irq(&card->lock); /* serialize node access */
703
704 if (memcmp(old->config_rom, new->config_rom, 6 * 4) == 0 &&
705 atomic_cmpxchg(&old->state,
706 FW_DEVICE_GONE,
707 FW_DEVICE_RUNNING) == FW_DEVICE_GONE) {
708 struct fw_node *current_node = new->node;
709 struct fw_node *obsolete_node = old->node;
710
711 new->node = obsolete_node;
712 new->node->data = new;
713 old->node = current_node;
714 old->node->data = old;
715
716 old->max_speed = new->max_speed;
717 old->node_id = current_node->node_id;
718 smp_wmb(); /* update node_id before generation */
719 old->generation = card->generation;
720 old->config_rom_retries = 0;
721 fw_notify("rediscovered device %s\n", dev_name(dev));
667 722
668#define MAX_RETRIES 10 723 PREPARE_DELAYED_WORK(&old->work, fw_device_update);
669#define RETRY_DELAY (3 * HZ) 724 schedule_delayed_work(&old->work, 0);
670#define INITIAL_DELAY (HZ / 2) 725
726 if (current_node == card->root_node)
727 fw_schedule_bm_work(card, 0);
728
729 match = 1;
730 }
731
732 spin_unlock_irq(&card->lock);
733 up_read(&fw_device_rwsem);
734
735 return match;
736}
671 737
672static void fw_device_init(struct work_struct *work) 738static void fw_device_init(struct work_struct *work)
673{ 739{
674 struct fw_device *device = 740 struct fw_device *device =
675 container_of(work, struct fw_device, work.work); 741 container_of(work, struct fw_device, work.work);
742 struct device *revived_dev;
676 int minor, err; 743 int minor, err;
677 744
678 /* 745 /*
@@ -696,6 +763,15 @@ static void fw_device_init(struct work_struct *work)
696 return; 763 return;
697 } 764 }
698 765
766 revived_dev = device_find_child(device->card->device,
767 device, lookup_existing_device);
768 if (revived_dev) {
769 put_device(revived_dev);
770 fw_device_release(&device->device);
771
772 return;
773 }
774
699 device_initialize(&device->device); 775 device_initialize(&device->device);
700 776
701 fw_device_get(device); 777 fw_device_get(device);
@@ -734,9 +810,10 @@ static void fw_device_init(struct work_struct *work)
734 * fw_node_event(). 810 * fw_node_event().
735 */ 811 */
736 if (atomic_cmpxchg(&device->state, 812 if (atomic_cmpxchg(&device->state,
737 FW_DEVICE_INITIALIZING, 813 FW_DEVICE_INITIALIZING,
738 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) { 814 FW_DEVICE_RUNNING) == FW_DEVICE_GONE) {
739 fw_device_shutdown(work); 815 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
816 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
740 } else { 817 } else {
741 if (device->config_rom_retries) 818 if (device->config_rom_retries)
742 fw_notify("created device %s: GUID %08x%08x, S%d00, " 819 fw_notify("created device %s: GUID %08x%08x, S%d00, "
@@ -847,8 +924,8 @@ static void fw_device_refresh(struct work_struct *work)
847 924
848 case REREAD_BIB_UNCHANGED: 925 case REREAD_BIB_UNCHANGED:
849 if (atomic_cmpxchg(&device->state, 926 if (atomic_cmpxchg(&device->state,
850 FW_DEVICE_INITIALIZING, 927 FW_DEVICE_INITIALIZING,
851 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) 928 FW_DEVICE_RUNNING) == FW_DEVICE_GONE)
852 goto gone; 929 goto gone;
853 930
854 fw_device_update(work); 931 fw_device_update(work);
@@ -879,8 +956,8 @@ static void fw_device_refresh(struct work_struct *work)
879 create_units(device); 956 create_units(device);
880 957
881 if (atomic_cmpxchg(&device->state, 958 if (atomic_cmpxchg(&device->state,
882 FW_DEVICE_INITIALIZING, 959 FW_DEVICE_INITIALIZING,
883 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) 960 FW_DEVICE_RUNNING) == FW_DEVICE_GONE)
884 goto gone; 961 goto gone;
885 962
886 fw_notify("refreshed device %s\n", dev_name(&device->device)); 963 fw_notify("refreshed device %s\n", dev_name(&device->device));
@@ -890,8 +967,9 @@ static void fw_device_refresh(struct work_struct *work)
890 give_up: 967 give_up:
891 fw_notify("giving up on refresh of device %s\n", dev_name(&device->device)); 968 fw_notify("giving up on refresh of device %s\n", dev_name(&device->device));
892 gone: 969 gone:
893 atomic_set(&device->state, FW_DEVICE_SHUTDOWN); 970 atomic_set(&device->state, FW_DEVICE_GONE);
894 fw_device_shutdown(work); 971 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
972 schedule_delayed_work(&device->work, SHUTDOWN_DELAY);
895 out: 973 out:
896 if (node_id == card->root_node->node_id) 974 if (node_id == card->root_node->node_id)
897 fw_schedule_bm_work(card, 0); 975 fw_schedule_bm_work(card, 0);
@@ -995,9 +1073,10 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
995 */ 1073 */
996 device = node->data; 1074 device = node->data;
997 if (atomic_xchg(&device->state, 1075 if (atomic_xchg(&device->state,
998 FW_DEVICE_SHUTDOWN) == FW_DEVICE_RUNNING) { 1076 FW_DEVICE_GONE) == FW_DEVICE_RUNNING) {
999 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); 1077 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
1000 schedule_delayed_work(&device->work, 0); 1078 schedule_delayed_work(&device->work,
1079 list_empty(&card->link) ? 0 : SHUTDOWN_DELAY);
1001 } 1080 }
1002 break; 1081 break;
1003 } 1082 }
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index df51732608d9..8ef6ec2ca21c 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -28,6 +28,7 @@
28enum fw_device_state { 28enum fw_device_state {
29 FW_DEVICE_INITIALIZING, 29 FW_DEVICE_INITIALIZING,
30 FW_DEVICE_RUNNING, 30 FW_DEVICE_RUNNING,
31 FW_DEVICE_GONE,
31 FW_DEVICE_SHUTDOWN, 32 FW_DEVICE_SHUTDOWN,
32}; 33};
33 34
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index ab9c01e462ef..6d19828a93a5 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -226,7 +226,7 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
226#define CONTEXT_DEAD 0x0800 226#define CONTEXT_DEAD 0x0800
227#define CONTEXT_ACTIVE 0x0400 227#define CONTEXT_ACTIVE 0x0400
228 228
229#define OHCI1394_MAX_AT_REQ_RETRIES 0x2 229#define OHCI1394_MAX_AT_REQ_RETRIES 0xf
230#define OHCI1394_MAX_AT_RESP_RETRIES 0x2 230#define OHCI1394_MAX_AT_RESP_RETRIES 0x2
231#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 231#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8
232 232
@@ -896,11 +896,11 @@ static void context_stop(struct context *ctx)
896 for (i = 0; i < 10; i++) { 896 for (i = 0; i < 10; i++) {
897 reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); 897 reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs));
898 if ((reg & CONTEXT_ACTIVE) == 0) 898 if ((reg & CONTEXT_ACTIVE) == 0)
899 break; 899 return;
900 900
901 fw_notify("context_stop: still active (0x%08x)\n", reg);
902 mdelay(1); 901 mdelay(1);
903 } 902 }
903 fw_error("Error: DMA context still active (0x%08x)\n", reg);
904} 904}
905 905
906struct driver_data { 906struct driver_data {
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index e88d5067448c..c71c4419d9e8 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -168,6 +168,7 @@ struct sbp2_target {
168 int address_high; 168 int address_high;
169 unsigned int workarounds; 169 unsigned int workarounds;
170 unsigned int mgt_orb_timeout; 170 unsigned int mgt_orb_timeout;
171 unsigned int max_payload;
171 172
172 int dont_block; /* counter for each logical unit */ 173 int dont_block; /* counter for each logical unit */
173 int blocked; /* ditto */ 174 int blocked; /* ditto */
@@ -310,14 +311,16 @@ struct sbp2_command_orb {
310 dma_addr_t page_table_bus; 311 dma_addr_t page_table_bus;
311}; 312};
312 313
314#define SBP2_ROM_VALUE_WILDCARD ~0 /* match all */
315#define SBP2_ROM_VALUE_MISSING 0xff000000 /* not present in the unit dir. */
316
313/* 317/*
314 * List of devices with known bugs. 318 * List of devices with known bugs.
315 * 319 *
316 * The firmware_revision field, masked with 0xffff00, is the best 320 * The firmware_revision field, masked with 0xffff00, is the best
317 * indicator for the type of bridge chip of a device. It yields a few 321 * indicator for the type of bridge chip of a device. It yields a few
318 * false positives but this did not break correctly behaving devices 322 * false positives but this did not break correctly behaving devices
319 * so far. We use ~0 as a wildcard, since the 24 bit values we get 323 * so far.
320 * from the config rom can never match that.
321 */ 324 */
322static const struct { 325static const struct {
323 u32 firmware_revision; 326 u32 firmware_revision;
@@ -339,33 +342,35 @@ static const struct {
339 }, 342 },
340 /* Initio bridges, actually only needed for some older ones */ { 343 /* Initio bridges, actually only needed for some older ones */ {
341 .firmware_revision = 0x000200, 344 .firmware_revision = 0x000200,
342 .model = ~0, 345 .model = SBP2_ROM_VALUE_WILDCARD,
343 .workarounds = SBP2_WORKAROUND_INQUIRY_36, 346 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
344 }, 347 },
345 /* PL-3507 bridge with Prolific firmware */ { 348 /* PL-3507 bridge with Prolific firmware */ {
346 .firmware_revision = 0x012800, 349 .firmware_revision = 0x012800,
347 .model = ~0, 350 .model = SBP2_ROM_VALUE_WILDCARD,
348 .workarounds = SBP2_WORKAROUND_POWER_CONDITION, 351 .workarounds = SBP2_WORKAROUND_POWER_CONDITION,
349 }, 352 },
350 /* Symbios bridge */ { 353 /* Symbios bridge */ {
351 .firmware_revision = 0xa0b800, 354 .firmware_revision = 0xa0b800,
352 .model = ~0, 355 .model = SBP2_ROM_VALUE_WILDCARD,
353 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 356 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
354 }, 357 },
355 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { 358 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ {
356 .firmware_revision = 0x002600, 359 .firmware_revision = 0x002600,
357 .model = ~0, 360 .model = SBP2_ROM_VALUE_WILDCARD,
358 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 361 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
359 }, 362 },
360
361 /* 363 /*
362 * There are iPods (2nd gen, 3rd gen) with model_id == 0, but 364 * iPod 2nd generation: needs 128k max transfer size workaround
363 * these iPods do not feature the read_capacity bug according 365 * iPod 3rd generation: needs fix capacity workaround
364 * to one report. Read_capacity behaviour as well as model_id
365 * could change due to Apple-supplied firmware updates though.
366 */ 366 */
367 367 {
368 /* iPod 4th generation. */ { 368 .firmware_revision = 0x0a2700,
369 .model = 0x000000,
370 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS |
371 SBP2_WORKAROUND_FIX_CAPACITY,
372 },
373 /* iPod 4th generation */ {
369 .firmware_revision = 0x0a2700, 374 .firmware_revision = 0x0a2700,
370 .model = 0x000021, 375 .model = 0x000021,
371 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 376 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
@@ -1092,7 +1097,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
1092 continue; 1097 continue;
1093 1098
1094 if (sbp2_workarounds_table[i].model != model && 1099 if (sbp2_workarounds_table[i].model != model &&
1095 sbp2_workarounds_table[i].model != ~0) 1100 sbp2_workarounds_table[i].model != SBP2_ROM_VALUE_WILDCARD)
1096 continue; 1101 continue;
1097 1102
1098 w |= sbp2_workarounds_table[i].workarounds; 1103 w |= sbp2_workarounds_table[i].workarounds;
@@ -1142,20 +1147,28 @@ static int sbp2_probe(struct device *dev)
1142 fw_device_get(device); 1147 fw_device_get(device);
1143 fw_unit_get(unit); 1148 fw_unit_get(unit);
1144 1149
1145 /* Initialize to values that won't match anything in our table. */
1146 firmware_revision = 0xff000000;
1147 model = 0xff000000;
1148
1149 /* implicit directory ID */ 1150 /* implicit directory ID */
1150 tgt->directory_id = ((unit->directory - device->config_rom) * 4 1151 tgt->directory_id = ((unit->directory - device->config_rom) * 4
1151 + CSR_CONFIG_ROM) & 0xffffff; 1152 + CSR_CONFIG_ROM) & 0xffffff;
1152 1153
1154 firmware_revision = SBP2_ROM_VALUE_MISSING;
1155 model = SBP2_ROM_VALUE_MISSING;
1156
1153 if (sbp2_scan_unit_dir(tgt, unit->directory, &model, 1157 if (sbp2_scan_unit_dir(tgt, unit->directory, &model,
1154 &firmware_revision) < 0) 1158 &firmware_revision) < 0)
1155 goto fail_tgt_put; 1159 goto fail_tgt_put;
1156 1160
1157 sbp2_init_workarounds(tgt, model, firmware_revision); 1161 sbp2_init_workarounds(tgt, model, firmware_revision);
1158 1162
1163 /*
1164 * At S100 we can do 512 bytes per packet, at S200 1024 bytes,
1165 * and so on up to 4096 bytes. The SBP-2 max_payload field
1166 * specifies the max payload size as 2 ^ (max_payload + 2), so
1167 * if we set this to max_speed + 7, we get the right value.
1168 */
1169 tgt->max_payload = min(device->max_speed + 7, 10U);
1170 tgt->max_payload = min(tgt->max_payload, device->card->max_receive - 1);
1171
1159 /* Do the login in a workqueue so we can easily reschedule retries. */ 1172 /* Do the login in a workqueue so we can easily reschedule retries. */
1160 list_for_each_entry(lu, &tgt->lu_list, link) 1173 list_for_each_entry(lu, &tgt->lu_list, link)
1161 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); 1174 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
@@ -1273,6 +1286,19 @@ static struct fw_driver sbp2_driver = {
1273 .id_table = sbp2_id_table, 1286 .id_table = sbp2_id_table,
1274}; 1287};
1275 1288
1289static void sbp2_unmap_scatterlist(struct device *card_device,
1290 struct sbp2_command_orb *orb)
1291{
1292 if (scsi_sg_count(orb->cmd))
1293 dma_unmap_sg(card_device, scsi_sglist(orb->cmd),
1294 scsi_sg_count(orb->cmd),
1295 orb->cmd->sc_data_direction);
1296
1297 if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT))
1298 dma_unmap_single(card_device, orb->page_table_bus,
1299 sizeof(orb->page_table), DMA_TO_DEVICE);
1300}
1301
1276static unsigned int 1302static unsigned int
1277sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data) 1303sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
1278{ 1304{
@@ -1352,15 +1378,7 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
1352 1378
1353 dma_unmap_single(device->card->device, orb->base.request_bus, 1379 dma_unmap_single(device->card->device, orb->base.request_bus,
1354 sizeof(orb->request), DMA_TO_DEVICE); 1380 sizeof(orb->request), DMA_TO_DEVICE);
1355 1381 sbp2_unmap_scatterlist(device->card->device, orb);
1356 if (scsi_sg_count(orb->cmd) > 0)
1357 dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd),
1358 scsi_sg_count(orb->cmd),
1359 orb->cmd->sc_data_direction);
1360
1361 if (orb->page_table_bus != 0)
1362 dma_unmap_single(device->card->device, orb->page_table_bus,
1363 sizeof(orb->page_table), DMA_TO_DEVICE);
1364 1382
1365 orb->cmd->result = result; 1383 orb->cmd->result = result;
1366 orb->done(orb->cmd); 1384 orb->done(orb->cmd);
@@ -1434,7 +1452,6 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1434 struct sbp2_logical_unit *lu = cmd->device->hostdata; 1452 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1435 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 1453 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
1436 struct sbp2_command_orb *orb; 1454 struct sbp2_command_orb *orb;
1437 unsigned int max_payload;
1438 int generation, retval = SCSI_MLQUEUE_HOST_BUSY; 1455 int generation, retval = SCSI_MLQUEUE_HOST_BUSY;
1439 1456
1440 /* 1457 /*
@@ -1462,17 +1479,9 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1462 orb->done = done; 1479 orb->done = done;
1463 orb->cmd = cmd; 1480 orb->cmd = cmd;
1464 1481
1465 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL); 1482 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL);
1466 /*
1467 * At speed 100 we can do 512 bytes per packet, at speed 200,
1468 * 1024 bytes per packet etc. The SBP-2 max_payload field
1469 * specifies the max payload size as 2 ^ (max_payload + 2), so
1470 * if we set this to max_speed + 7, we get the right value.
1471 */
1472 max_payload = min(device->max_speed + 7,
1473 device->card->max_receive - 1);
1474 orb->request.misc = cpu_to_be32( 1483 orb->request.misc = cpu_to_be32(
1475 COMMAND_ORB_MAX_PAYLOAD(max_payload) | 1484 COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) |
1476 COMMAND_ORB_SPEED(device->max_speed) | 1485 COMMAND_ORB_SPEED(device->max_speed) |
1477 COMMAND_ORB_NOTIFY); 1486 COMMAND_ORB_NOTIFY);
1478 1487
@@ -1491,8 +1500,10 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1491 orb->base.request_bus = 1500 orb->base.request_bus =
1492 dma_map_single(device->card->device, &orb->request, 1501 dma_map_single(device->card->device, &orb->request,
1493 sizeof(orb->request), DMA_TO_DEVICE); 1502 sizeof(orb->request), DMA_TO_DEVICE);
1494 if (dma_mapping_error(device->card->device, orb->base.request_bus)) 1503 if (dma_mapping_error(device->card->device, orb->base.request_bus)) {
1504 sbp2_unmap_scatterlist(device->card->device, orb);
1495 goto out; 1505 goto out;
1506 }
1496 1507
1497 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation, 1508 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1498 lu->command_block_agent_address + SBP2_ORB_POINTER); 1509 lu->command_block_agent_address + SBP2_ORB_POINTER);
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
index c9be6e6948c4..8dd6703b55cd 100644
--- a/drivers/firewire/fw-topology.c
+++ b/drivers/firewire/fw-topology.c
@@ -518,6 +518,18 @@ fw_core_handle_bus_reset(struct fw_card *card,
518 struct fw_node *local_node; 518 struct fw_node *local_node;
519 unsigned long flags; 519 unsigned long flags;
520 520
521 /*
522 * If the selfID buffer is not the immediate successor of the
523 * previously processed one, we cannot reliably compare the
524 * old and new topologies.
525 */
526 if (!is_next_generation(generation, card->generation) &&
527 card->local_node != NULL) {
528 fw_notify("skipped bus generations, destroying all nodes\n");
529 fw_destroy_nodes(card);
530 card->bm_retries = 0;
531 }
532
521 spin_lock_irqsave(&card->lock, flags); 533 spin_lock_irqsave(&card->lock, flags);
522 534
523 card->node_id = node_id; 535 card->node_id = node_id;
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index c9ab12a15f6e..1d78e9cc5940 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -276,6 +276,15 @@ static inline void fw_card_put(struct fw_card *card)
276extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay); 276extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
277 277
278/* 278/*
279 * Check whether new_generation is the immediate successor of old_generation.
280 * Take counter roll-over at 255 (as per to OHCI) into account.
281 */
282static inline bool is_next_generation(int new_generation, int old_generation)
283{
284 return (new_generation & 0xff) == ((old_generation + 1) & 0xff);
285}
286
287/*
279 * The iso packet format allows for an immediate header/payload part 288 * The iso packet format allows for an immediate header/payload part
280 * stored in 'header' immediately after the packet info plus an 289 * stored in 'header' immediately after the packet info plus an
281 * indirect payload part that is pointer to by the 'payload' field. 290 * indirect payload part that is pointer to by the 'payload' field.
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 35e7aea4222c..42fb2fd24c0c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -789,6 +789,7 @@ int gpio_request(unsigned gpio, const char *label)
789 } else { 789 } else {
790 status = -EBUSY; 790 status = -EBUSY;
791 module_put(chip->owner); 791 module_put(chip->owner);
792 goto done;
792 } 793 }
793 794
794 if (chip->request) { 795 if (chip->request) {
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 6b1148fc2cbe..b36a5214d8df 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -311,7 +311,7 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
311 if (dev_priv->panel_fixed_mode != NULL) { 311 if (dev_priv->panel_fixed_mode != NULL) {
312 struct drm_display_mode *mode; 312 struct drm_display_mode *mode;
313 313
314 mutex_unlock(&dev->mode_config.mutex); 314 mutex_lock(&dev->mode_config.mutex);
315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); 315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode);
316 drm_mode_probed_add(connector, mode); 316 drm_mode_probed_add(connector, mode);
317 mutex_unlock(&dev->mode_config.mutex); 317 mutex_unlock(&dev->mode_config.mutex);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 5d7640e49dc5..6cad69ed21c5 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1218,6 +1218,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
1218} 1218}
1219EXPORT_SYMBOL_GPL(hid_connect); 1219EXPORT_SYMBOL_GPL(hid_connect);
1220 1220
1221/* a list of devices for which there is a specialized driver on HID bus */
1221static const struct hid_device_id hid_blacklist[] = { 1222static const struct hid_device_id hid_blacklist[] = {
1222 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 1223 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
1223 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, 1224 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
@@ -1476,6 +1477,7 @@ static struct bus_type hid_bus_type = {
1476 .uevent = hid_uevent, 1477 .uevent = hid_uevent,
1477}; 1478};
1478 1479
1480/* a list of devices that shouldn't be handled by HID core at all */
1479static const struct hid_device_id hid_ignore_list[] = { 1481static const struct hid_device_id hid_ignore_list[] = {
1480 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, 1482 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
1481 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, 1483 { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
@@ -1606,6 +1608,8 @@ static const struct hid_device_id hid_ignore_list[] = {
1606 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, 1608 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) },
1607 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) }, 1609 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) },
1608 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) }, 1610 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) },
1611 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD4) },
1612 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD5) },
1609 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) }, 1613 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1610 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) }, 1614 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1611 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1615 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index acc1abc834a4..e899f510ebeb 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -362,6 +362,8 @@
362#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038 362#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD 0x0038
363#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2 0x0036 363#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2 0x0036
364#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3 0x0034 364#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3 0x0034
365#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD4 0x0044
366#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD5 0x0045
365 367
366#define USB_VENDOR_ID_SUN 0x0430 368#define USB_VENDOR_ID_SUN 0x0430
367#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab 369#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index d718b1607d0f..25b10dcad90d 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -30,7 +30,7 @@
30#define MS_NOGET 0x10 30#define MS_NOGET 0x10
31 31
32/* 32/*
33 * Microsoft Wireless Desktop Receiver (Model 1028) has several 33 * Microsoft Wireless Desktop Receiver (Model 1028) has
34 * 'Usage Min/Max' where it ought to have 'Physical Min/Max' 34 * 'Usage Min/Max' where it ought to have 'Physical Min/Max'
35 */ 35 */
36static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, 36static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -38,17 +38,12 @@ static void ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
38{ 38{
39 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev); 39 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
40 40
41 if ((quirks & MS_RDESC) && rsize == 571 && rdesc[284] == 0x19 && 41 if ((quirks & MS_RDESC) && rsize == 571 && rdesc[557] == 0x19 &&
42 rdesc[286] == 0x2a && rdesc[304] == 0x19 &&
43 rdesc[306] == 0x29 && rdesc[352] == 0x1a &&
44 rdesc[355] == 0x2a && rdesc[557] == 0x19 &&
45 rdesc[559] == 0x29) { 42 rdesc[559] == 0x29) {
46 dev_info(&hdev->dev, "fixing up Microsoft Wireless Receiver " 43 dev_info(&hdev->dev, "fixing up Microsoft Wireless Receiver "
47 "Model 1028 report descriptor\n"); 44 "Model 1028 report descriptor\n");
48 rdesc[284] = rdesc[304] = rdesc[557] = 0x35; 45 rdesc[557] = 0x35;
49 rdesc[352] = 0x36; 46 rdesc[559] = 0x45;
50 rdesc[286] = rdesc[355] = 0x46;
51 rdesc[306] = rdesc[559] = 0x45;
52 } 47 }
53} 48}
54 49
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index d73eea382ab3..4940e4d70c2d 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -656,7 +656,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
656 656
657 case HIDIOCGSTRING: 657 case HIDIOCGSTRING:
658 mutex_lock(&hiddev->existancelock); 658 mutex_lock(&hiddev->existancelock);
659 if (!hiddev->exist) 659 if (hiddev->exist)
660 r = hiddev_ioctl_string(hiddev, cmd, user_arg); 660 r = hiddev_ioctl_string(hiddev, cmd, user_arg);
661 else 661 else
662 r = -ENODEV; 662 r = -ENODEV;
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index e30186236588..678e34b01e52 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -83,7 +83,7 @@
83/* 83/*
84 * Temperature sensors keys (sp78 - 2 bytes). 84 * Temperature sensors keys (sp78 - 2 bytes).
85 */ 85 */
86static const char* temperature_sensors_sets[][36] = { 86static const char *temperature_sensors_sets[][41] = {
87/* Set 0: Macbook Pro */ 87/* Set 0: Macbook Pro */
88 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H", 88 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
89 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL }, 89 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
@@ -135,6 +135,13 @@ static const char* temperature_sensors_sets[][36] = {
135 { "TB0T", "TB1S", "TB1T", "TB2S", "TB2T", "TC0D", "TN0D", "TTF0", 135 { "TB0T", "TB1S", "TB1T", "TB2S", "TB2T", "TC0D", "TN0D", "TTF0",
136 "TV0P", "TVFP", "TW0P", "Th0P", "Tp0P", "Tp1P", "TpFP", "Ts0P", 136 "TV0P", "TVFP", "TW0P", "Th0P", "Tp0P", "Tp1P", "TpFP", "Ts0P",
137 "Ts0S", NULL }, 137 "Ts0S", NULL },
138/* Set 16: Mac Pro 3,1 (2 x Quad-Core) */
139 { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", "TC0C", "TC0D", "TC0P",
140 "TC1C", "TC1D", "TC2C", "TC2D", "TC3C", "TC3D", "TH0P", "TH1P",
141 "TH2P", "TH3P", "TMAP", "TMAS", "TMBS", "TM0P", "TM0S", "TM1P",
142 "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P", "TM9S",
143 "TN0C", "TN0D", "TN0H", "TS0C", "Tp0C", "Tp1C", "Tv0S", "Tv1S",
144 NULL },
138}; 145};
139 146
140/* List of keys used to read/write fan speeds */ 147/* List of keys used to read/write fan speeds */
@@ -1153,6 +1160,16 @@ static SENSOR_DEVICE_ATTR(temp34_input, S_IRUGO,
1153 applesmc_show_temperature, NULL, 33); 1160 applesmc_show_temperature, NULL, 33);
1154static SENSOR_DEVICE_ATTR(temp35_input, S_IRUGO, 1161static SENSOR_DEVICE_ATTR(temp35_input, S_IRUGO,
1155 applesmc_show_temperature, NULL, 34); 1162 applesmc_show_temperature, NULL, 34);
1163static SENSOR_DEVICE_ATTR(temp36_input, S_IRUGO,
1164 applesmc_show_temperature, NULL, 35);
1165static SENSOR_DEVICE_ATTR(temp37_input, S_IRUGO,
1166 applesmc_show_temperature, NULL, 36);
1167static SENSOR_DEVICE_ATTR(temp38_input, S_IRUGO,
1168 applesmc_show_temperature, NULL, 37);
1169static SENSOR_DEVICE_ATTR(temp39_input, S_IRUGO,
1170 applesmc_show_temperature, NULL, 38);
1171static SENSOR_DEVICE_ATTR(temp40_input, S_IRUGO,
1172 applesmc_show_temperature, NULL, 39);
1156 1173
1157static struct attribute *temperature_attributes[] = { 1174static struct attribute *temperature_attributes[] = {
1158 &sensor_dev_attr_temp1_input.dev_attr.attr, 1175 &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -1190,6 +1207,11 @@ static struct attribute *temperature_attributes[] = {
1190 &sensor_dev_attr_temp33_input.dev_attr.attr, 1207 &sensor_dev_attr_temp33_input.dev_attr.attr,
1191 &sensor_dev_attr_temp34_input.dev_attr.attr, 1208 &sensor_dev_attr_temp34_input.dev_attr.attr,
1192 &sensor_dev_attr_temp35_input.dev_attr.attr, 1209 &sensor_dev_attr_temp35_input.dev_attr.attr,
1210 &sensor_dev_attr_temp36_input.dev_attr.attr,
1211 &sensor_dev_attr_temp37_input.dev_attr.attr,
1212 &sensor_dev_attr_temp38_input.dev_attr.attr,
1213 &sensor_dev_attr_temp39_input.dev_attr.attr,
1214 &sensor_dev_attr_temp40_input.dev_attr.attr,
1193 NULL 1215 NULL
1194}; 1216};
1195 1217
@@ -1312,6 +1334,8 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1312 { .accelerometer = 0, .light = 0, .temperature_set = 14 }, 1334 { .accelerometer = 0, .light = 0, .temperature_set = 14 },
1313/* MacBook Air 2,1: accelerometer, backlight and temperature set 15 */ 1335/* MacBook Air 2,1: accelerometer, backlight and temperature set 15 */
1314 { .accelerometer = 1, .light = 1, .temperature_set = 15 }, 1336 { .accelerometer = 1, .light = 1, .temperature_set = 15 },
1337/* MacPro3,1: temperature set 16 */
1338 { .accelerometer = 0, .light = 0, .temperature_set = 16 },
1315}; 1339};
1316 1340
1317/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1341/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
@@ -1369,6 +1393,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
1369 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), 1393 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
1370 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") }, 1394 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") },
1371 &applesmc_dmi_data[4]}, 1395 &applesmc_dmi_data[4]},
1396 { applesmc_dmi_match, "Apple MacPro3", {
1397 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1398 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro3") },
1399 &applesmc_dmi_data[16]},
1372 { applesmc_dmi_match, "Apple MacPro", { 1400 { applesmc_dmi_match, "Apple MacPro", {
1373 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1401 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1374 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, 1402 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
diff --git a/drivers/ieee1394/ieee1394.h b/drivers/ieee1394/ieee1394.h
index e0ae0d3d747f..af320e2c5079 100644
--- a/drivers/ieee1394/ieee1394.h
+++ b/drivers/ieee1394/ieee1394.h
@@ -54,9 +54,7 @@
54#define IEEE1394_SPEED_800 0x03 54#define IEEE1394_SPEED_800 0x03
55#define IEEE1394_SPEED_1600 0x04 55#define IEEE1394_SPEED_1600 0x04
56#define IEEE1394_SPEED_3200 0x05 56#define IEEE1394_SPEED_3200 0x05
57 57#define IEEE1394_SPEED_MAX IEEE1394_SPEED_3200
58/* The current highest tested speed supported by the subsystem */
59#define IEEE1394_SPEED_MAX IEEE1394_SPEED_800
60 58
61/* Maps speed values above to a string representation */ 59/* Maps speed values above to a string representation */
62extern const char *hpsb_speedto_str[]; 60extern const char *hpsb_speedto_str[];
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index dcdb71a7718d..2beb8d94f7bd 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -338,6 +338,7 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
338 u8 cldcnt[nodecount]; 338 u8 cldcnt[nodecount];
339 u8 *map = host->speed_map; 339 u8 *map = host->speed_map;
340 u8 *speedcap = host->speed; 340 u8 *speedcap = host->speed;
341 u8 local_link_speed = host->csr.lnk_spd;
341 struct selfid *sid; 342 struct selfid *sid;
342 struct ext_selfid *esid; 343 struct ext_selfid *esid;
343 int i, j, n; 344 int i, j, n;
@@ -373,8 +374,8 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
373 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++; 374 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++;
374 375
375 speedcap[n] = sid->speed; 376 speedcap[n] = sid->speed;
376 if (speedcap[n] > host->csr.lnk_spd) 377 if (speedcap[n] > local_link_speed)
377 speedcap[n] = host->csr.lnk_spd; 378 speedcap[n] = local_link_speed;
378 n--; 379 n--;
379 } 380 }
380 } 381 }
@@ -407,12 +408,11 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
407 } 408 }
408 } 409 }
409 410
410#if SELFID_SPEED_UNKNOWN != IEEE1394_SPEED_MAX 411 /* assume a maximum speed for 1394b PHYs, nodemgr will correct it */
411 /* assume maximum speed for 1394b PHYs, nodemgr will correct it */ 412 if (local_link_speed > SELFID_SPEED_UNKNOWN)
412 for (n = 0; n < nodecount; n++) 413 for (i = 0; i < nodecount; i++)
413 if (speedcap[n] == SELFID_SPEED_UNKNOWN) 414 if (speedcap[i] == SELFID_SPEED_UNKNOWN)
414 speedcap[n] = IEEE1394_SPEED_MAX; 415 speedcap[i] = local_link_speed;
415#endif
416} 416}
417 417
418 418
diff --git a/drivers/ieee1394/ohci1394.h b/drivers/ieee1394/ohci1394.h
index 4320bf010495..7fb8ab9780ae 100644
--- a/drivers/ieee1394/ohci1394.h
+++ b/drivers/ieee1394/ohci1394.h
@@ -26,7 +26,7 @@
26 26
27#define OHCI1394_DRIVER_NAME "ohci1394" 27#define OHCI1394_DRIVER_NAME "ohci1394"
28 28
29#define OHCI1394_MAX_AT_REQ_RETRIES 0x2 29#define OHCI1394_MAX_AT_REQ_RETRIES 0xf
30#define OHCI1394_MAX_AT_RESP_RETRIES 0x2 30#define OHCI1394_MAX_AT_RESP_RETRIES 0x2
31#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 31#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8
32#define OHCI1394_MAX_SELF_ID_ERRORS 16 32#define OHCI1394_MAX_SELF_ID_ERRORS 16
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index ab1034ccb7fb..f3fd8657ce4b 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -115,8 +115,8 @@
115 */ 115 */
116static int sbp2_max_speed = IEEE1394_SPEED_MAX; 116static int sbp2_max_speed = IEEE1394_SPEED_MAX;
117module_param_named(max_speed, sbp2_max_speed, int, 0644); 117module_param_named(max_speed, sbp2_max_speed, int, 0644);
118MODULE_PARM_DESC(max_speed, "Force max speed " 118MODULE_PARM_DESC(max_speed, "Limit data transfer speed (5 <= 3200, "
119 "(3 = 800Mb/s, 2 = 400Mb/s, 1 = 200Mb/s, 0 = 100Mb/s)"); 119 "4 <= 1600, 3 <= 800, 2 <= 400, 1 <= 200, 0 = 100 Mb/s)");
120 120
121/* 121/*
122 * Set serialize_io to 0 or N to use dynamically appended lists of command ORBs. 122 * Set serialize_io to 0 or N to use dynamically appended lists of command ORBs.
@@ -256,7 +256,7 @@ static int sbp2_set_busy_timeout(struct sbp2_lu *);
256static int sbp2_max_speed_and_size(struct sbp2_lu *); 256static int sbp2_max_speed_and_size(struct sbp2_lu *);
257 257
258 258
259static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC }; 259static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xa, 0xa, 0xa };
260 260
261static DEFINE_RWLOCK(sbp2_hi_logical_units_lock); 261static DEFINE_RWLOCK(sbp2_hi_logical_units_lock);
262 262
@@ -347,8 +347,8 @@ static struct scsi_host_template sbp2_shost_template = {
347 .sdev_attrs = sbp2_sysfs_sdev_attrs, 347 .sdev_attrs = sbp2_sysfs_sdev_attrs,
348}; 348};
349 349
350/* for match-all entries in sbp2_workarounds_table */ 350#define SBP2_ROM_VALUE_WILDCARD ~0 /* match all */
351#define SBP2_ROM_VALUE_WILDCARD 0x1000000 351#define SBP2_ROM_VALUE_MISSING 0xff000000 /* not present in the unit dir. */
352 352
353/* 353/*
354 * List of devices with known bugs. 354 * List of devices with known bugs.
@@ -359,60 +359,70 @@ static struct scsi_host_template sbp2_shost_template = {
359 */ 359 */
360static const struct { 360static const struct {
361 u32 firmware_revision; 361 u32 firmware_revision;
362 u32 model_id; 362 u32 model;
363 unsigned workarounds; 363 unsigned workarounds;
364} sbp2_workarounds_table[] = { 364} sbp2_workarounds_table[] = {
365 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ { 365 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
366 .firmware_revision = 0x002800, 366 .firmware_revision = 0x002800,
367 .model_id = 0x001010, 367 .model = 0x001010,
368 .workarounds = SBP2_WORKAROUND_INQUIRY_36 | 368 .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
369 SBP2_WORKAROUND_MODE_SENSE_8 | 369 SBP2_WORKAROUND_MODE_SENSE_8 |
370 SBP2_WORKAROUND_POWER_CONDITION, 370 SBP2_WORKAROUND_POWER_CONDITION,
371 }, 371 },
372 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ { 372 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
373 .firmware_revision = 0x002800, 373 .firmware_revision = 0x002800,
374 .model_id = 0x000000, 374 .model = 0x000000,
375 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY | 375 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY |
376 SBP2_WORKAROUND_POWER_CONDITION, 376 SBP2_WORKAROUND_POWER_CONDITION,
377 }, 377 },
378 /* Initio bridges, actually only needed for some older ones */ { 378 /* Initio bridges, actually only needed for some older ones */ {
379 .firmware_revision = 0x000200, 379 .firmware_revision = 0x000200,
380 .model_id = SBP2_ROM_VALUE_WILDCARD, 380 .model = SBP2_ROM_VALUE_WILDCARD,
381 .workarounds = SBP2_WORKAROUND_INQUIRY_36, 381 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
382 }, 382 },
383 /* PL-3507 bridge with Prolific firmware */ { 383 /* PL-3507 bridge with Prolific firmware */ {
384 .firmware_revision = 0x012800, 384 .firmware_revision = 0x012800,
385 .model_id = SBP2_ROM_VALUE_WILDCARD, 385 .model = SBP2_ROM_VALUE_WILDCARD,
386 .workarounds = SBP2_WORKAROUND_POWER_CONDITION, 386 .workarounds = SBP2_WORKAROUND_POWER_CONDITION,
387 }, 387 },
388 /* Symbios bridge */ { 388 /* Symbios bridge */ {
389 .firmware_revision = 0xa0b800, 389 .firmware_revision = 0xa0b800,
390 .model_id = SBP2_ROM_VALUE_WILDCARD, 390 .model = SBP2_ROM_VALUE_WILDCARD,
391 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 391 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
392 }, 392 },
393 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { 393 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ {
394 .firmware_revision = 0x002600, 394 .firmware_revision = 0x002600,
395 .model_id = SBP2_ROM_VALUE_WILDCARD, 395 .model = SBP2_ROM_VALUE_WILDCARD,
396 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, 396 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
397 }, 397 },
398 /*
399 * iPod 2nd generation: needs 128k max transfer size workaround
400 * iPod 3rd generation: needs fix capacity workaround
401 */
402 {
403 .firmware_revision = 0x0a2700,
404 .model = 0x000000,
405 .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS |
406 SBP2_WORKAROUND_FIX_CAPACITY,
407 },
398 /* iPod 4th generation */ { 408 /* iPod 4th generation */ {
399 .firmware_revision = 0x0a2700, 409 .firmware_revision = 0x0a2700,
400 .model_id = 0x000021, 410 .model = 0x000021,
401 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 411 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
402 }, 412 },
403 /* iPod mini */ { 413 /* iPod mini */ {
404 .firmware_revision = 0x0a2700, 414 .firmware_revision = 0x0a2700,
405 .model_id = 0x000022, 415 .model = 0x000022,
406 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 416 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
407 }, 417 },
408 /* iPod mini */ { 418 /* iPod mini */ {
409 .firmware_revision = 0x0a2700, 419 .firmware_revision = 0x0a2700,
410 .model_id = 0x000023, 420 .model = 0x000023,
411 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 421 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
412 }, 422 },
413 /* iPod Photo */ { 423 /* iPod Photo */ {
414 .firmware_revision = 0x0a2700, 424 .firmware_revision = 0x0a2700,
415 .model_id = 0x00007e, 425 .model = 0x00007e,
416 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, 426 .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
417 } 427 }
418}; 428};
@@ -1341,13 +1351,15 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1341 struct csr1212_keyval *kv; 1351 struct csr1212_keyval *kv;
1342 struct csr1212_dentry *dentry; 1352 struct csr1212_dentry *dentry;
1343 u64 management_agent_addr; 1353 u64 management_agent_addr;
1344 u32 unit_characteristics, firmware_revision; 1354 u32 unit_characteristics, firmware_revision, model;
1345 unsigned workarounds; 1355 unsigned workarounds;
1346 int i; 1356 int i;
1347 1357
1348 management_agent_addr = 0; 1358 management_agent_addr = 0;
1349 unit_characteristics = 0; 1359 unit_characteristics = 0;
1350 firmware_revision = 0; 1360 firmware_revision = SBP2_ROM_VALUE_MISSING;
1361 model = ud->flags & UNIT_DIRECTORY_MODEL_ID ?
1362 ud->model_id : SBP2_ROM_VALUE_MISSING;
1351 1363
1352 csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) { 1364 csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) {
1353 switch (kv->key.id) { 1365 switch (kv->key.id) {
@@ -1388,9 +1400,9 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1388 sbp2_workarounds_table[i].firmware_revision != 1400 sbp2_workarounds_table[i].firmware_revision !=
1389 (firmware_revision & 0xffff00)) 1401 (firmware_revision & 0xffff00))
1390 continue; 1402 continue;
1391 if (sbp2_workarounds_table[i].model_id != 1403 if (sbp2_workarounds_table[i].model !=
1392 SBP2_ROM_VALUE_WILDCARD && 1404 SBP2_ROM_VALUE_WILDCARD &&
1393 sbp2_workarounds_table[i].model_id != ud->model_id) 1405 sbp2_workarounds_table[i].model != model)
1394 continue; 1406 continue;
1395 workarounds |= sbp2_workarounds_table[i].workarounds; 1407 workarounds |= sbp2_workarounds_table[i].workarounds;
1396 break; 1408 break;
@@ -1403,7 +1415,7 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1403 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid), 1415 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
1404 workarounds, firmware_revision, 1416 workarounds, firmware_revision,
1405 ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id, 1417 ud->vendor_id ? ud->vendor_id : ud->ne->vendor_id,
1406 ud->model_id); 1418 model);
1407 1419
1408 /* We would need one SCSI host template for each target to adjust 1420 /* We would need one SCSI host template for each target to adjust
1409 * max_sectors on the fly, therefore warn only. */ 1421 * max_sectors on the fly, therefore warn only. */
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index 90663e01a56e..60156dfdc608 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -224,7 +224,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
224 break; 224 break;
225 225
226 /* If the Guest asked to be stopped, we sleep. The Guest's 226 /* If the Guest asked to be stopped, we sleep. The Guest's
227 * clock timer or LHCALL_BREAK from the Waker will wake us. */ 227 * clock timer or LHREQ_BREAK from the Waker will wake us. */
228 if (cpu->halted) { 228 if (cpu->halted) {
229 set_current_state(TASK_INTERRUPTIBLE); 229 set_current_state(TASK_INTERRUPTIBLE);
230 schedule(); 230 schedule();
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 34bc017b8b3c..b8ee103eed5f 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -307,9 +307,8 @@ static int close(struct inode *inode, struct file *file)
307 * kmalloc()ed string, either of which is ok to hand to kfree(). */ 307 * kmalloc()ed string, either of which is ok to hand to kfree(). */
308 if (!IS_ERR(lg->dead)) 308 if (!IS_ERR(lg->dead))
309 kfree(lg->dead); 309 kfree(lg->dead);
310 /* We clear the entire structure, which also marks it as free for the 310 /* Free the memory allocated to the lguest_struct */
311 * next user. */ 311 kfree(lg);
312 memset(lg, 0, sizeof(*lg));
313 /* Release lock and exit. */ 312 /* Release lock and exit. */
314 mutex_unlock(&lguest_lock); 313 mutex_unlock(&lguest_lock);
315 314
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index 05e298289238..10c421b73eaf 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -758,7 +758,7 @@ static void __exit ilo_exit(void)
758 class_destroy(ilo_class); 758 class_destroy(ilo_class);
759} 759}
760 760
761MODULE_VERSION("0.05"); 761MODULE_VERSION("0.06");
762MODULE_ALIAS(ILO_NAME); 762MODULE_ALIAS(ILO_NAME);
763MODULE_DESCRIPTION(ILO_NAME); 763MODULE_DESCRIPTION(ILO_NAME);
764MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>"); 764MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>");
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c
index 9cd2ebe2a3b6..45fd653dbe31 100644
--- a/drivers/misc/sgi-xp/xpc_channel.c
+++ b/drivers/misc/sgi-xp/xpc_channel.c
@@ -49,9 +49,6 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
49 49
50 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING)) 50 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING))
51 return; 51 return;
52
53 DBUG_ON(ch->local_msgqueue == NULL);
54 DBUG_ON(ch->remote_msgqueue == NULL);
55 } 52 }
56 53
57 if (!(ch->flags & XPC_C_OPENREPLY)) { 54 if (!(ch->flags & XPC_C_OPENREPLY)) {
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index 82fb9958f22f..2e975762c32b 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -1106,8 +1106,6 @@ xpc_process_activate_IRQ_rcvd_sn2(void)
1106 int n_IRQs_expected; 1106 int n_IRQs_expected;
1107 int n_IRQs_detected; 1107 int n_IRQs_detected;
1108 1108
1109 DBUG_ON(xpc_activate_IRQ_rcvd == 0);
1110
1111 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags); 1109 spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags);
1112 n_IRQs_expected = xpc_activate_IRQ_rcvd; 1110 n_IRQs_expected = xpc_activate_IRQ_rcvd;
1113 xpc_activate_IRQ_rcvd = 0; 1111 xpc_activate_IRQ_rcvd = 0;
@@ -1726,6 +1724,7 @@ xpc_clear_local_msgqueue_flags_sn2(struct xpc_channel *ch)
1726 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->local_msgqueue + 1724 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->local_msgqueue +
1727 (get % ch->local_nentries) * 1725 (get % ch->local_nentries) *
1728 ch->entry_size); 1726 ch->entry_size);
1727 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1729 msg->flags = 0; 1728 msg->flags = 0;
1730 } while (++get < ch_sn2->remote_GP.get); 1729 } while (++get < ch_sn2->remote_GP.get);
1731} 1730}
@@ -1740,11 +1739,18 @@ xpc_clear_remote_msgqueue_flags_sn2(struct xpc_channel *ch)
1740 struct xpc_msg_sn2 *msg; 1739 struct xpc_msg_sn2 *msg;
1741 s64 put; 1740 s64 put;
1742 1741
1743 put = ch_sn2->w_remote_GP.put; 1742 /* flags are zeroed when the buffer is allocated */
1743 if (ch_sn2->remote_GP.put < ch->remote_nentries)
1744 return;
1745
1746 put = max(ch_sn2->w_remote_GP.put, ch->remote_nentries);
1744 do { 1747 do {
1745 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->remote_msgqueue + 1748 msg = (struct xpc_msg_sn2 *)((u64)ch_sn2->remote_msgqueue +
1746 (put % ch->remote_nentries) * 1749 (put % ch->remote_nentries) *
1747 ch->entry_size); 1750 ch->entry_size);
1751 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1752 DBUG_ON(!(msg->flags & XPC_M_SN2_DONE));
1753 DBUG_ON(msg->number != put - ch->remote_nentries);
1748 msg->flags = 0; 1754 msg->flags = 0;
1749 } while (++put < ch_sn2->remote_GP.put); 1755 } while (++put < ch_sn2->remote_GP.put);
1750} 1756}
@@ -1836,6 +1842,7 @@ xpc_process_msg_chctl_flags_sn2(struct xpc_partition *part, int ch_number)
1836 */ 1842 */
1837 xpc_clear_remote_msgqueue_flags_sn2(ch); 1843 xpc_clear_remote_msgqueue_flags_sn2(ch);
1838 1844
1845 smp_wmb(); /* ensure flags have been cleared before bte_copy */
1839 ch_sn2->w_remote_GP.put = ch_sn2->remote_GP.put; 1846 ch_sn2->w_remote_GP.put = ch_sn2->remote_GP.put;
1840 1847
1841 dev_dbg(xpc_chan, "w_remote_GP.put changed to %ld, partid=%d, " 1848 dev_dbg(xpc_chan, "w_remote_GP.put changed to %ld, partid=%d, "
@@ -1934,7 +1941,7 @@ xpc_get_deliverable_payload_sn2(struct xpc_channel *ch)
1934 break; 1941 break;
1935 1942
1936 get = ch_sn2->w_local_GP.get; 1943 get = ch_sn2->w_local_GP.get;
1937 rmb(); /* guarantee that .get loads before .put */ 1944 smp_rmb(); /* guarantee that .get loads before .put */
1938 if (get == ch_sn2->w_remote_GP.put) 1945 if (get == ch_sn2->w_remote_GP.put)
1939 break; 1946 break;
1940 1947
@@ -1956,11 +1963,13 @@ xpc_get_deliverable_payload_sn2(struct xpc_channel *ch)
1956 1963
1957 msg = xpc_pull_remote_msg_sn2(ch, get); 1964 msg = xpc_pull_remote_msg_sn2(ch, get);
1958 1965
1959 DBUG_ON(msg != NULL && msg->number != get); 1966 if (msg != NULL) {
1960 DBUG_ON(msg != NULL && (msg->flags & XPC_M_SN2_DONE)); 1967 DBUG_ON(msg->number != get);
1961 DBUG_ON(msg != NULL && !(msg->flags & XPC_M_SN2_READY)); 1968 DBUG_ON(msg->flags & XPC_M_SN2_DONE);
1969 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
1962 1970
1963 payload = &msg->payload; 1971 payload = &msg->payload;
1972 }
1964 break; 1973 break;
1965 } 1974 }
1966 1975
@@ -2053,7 +2062,7 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
2053 while (1) { 2062 while (1) {
2054 2063
2055 put = ch_sn2->w_local_GP.put; 2064 put = ch_sn2->w_local_GP.put;
2056 rmb(); /* guarantee that .put loads before .get */ 2065 smp_rmb(); /* guarantee that .put loads before .get */
2057 if (put - ch_sn2->w_remote_GP.get < ch->local_nentries) { 2066 if (put - ch_sn2->w_remote_GP.get < ch->local_nentries) {
2058 2067
2059 /* There are available message entries. We need to try 2068 /* There are available message entries. We need to try
@@ -2186,7 +2195,7 @@ xpc_send_payload_sn2(struct xpc_channel *ch, u32 flags, void *payload,
2186 * The preceding store of msg->flags must occur before the following 2195 * The preceding store of msg->flags must occur before the following
2187 * load of local_GP->put. 2196 * load of local_GP->put.
2188 */ 2197 */
2189 mb(); 2198 smp_mb();
2190 2199
2191 /* see if the message is next in line to be sent, if so send it */ 2200 /* see if the message is next in line to be sent, if so send it */
2192 2201
@@ -2277,8 +2286,9 @@ xpc_received_payload_sn2(struct xpc_channel *ch, void *payload)
2277 dev_dbg(xpc_chan, "msg=0x%p, msg_number=%ld, partid=%d, channel=%d\n", 2286 dev_dbg(xpc_chan, "msg=0x%p, msg_number=%ld, partid=%d, channel=%d\n",
2278 (void *)msg, msg_number, ch->partid, ch->number); 2287 (void *)msg, msg_number, ch->partid, ch->number);
2279 2288
2280 DBUG_ON((((u64)msg - (u64)ch->remote_msgqueue) / ch->entry_size) != 2289 DBUG_ON((((u64)msg - (u64)ch->sn.sn2.remote_msgqueue) / ch->entry_size) !=
2281 msg_number % ch->remote_nentries); 2290 msg_number % ch->remote_nentries);
2291 DBUG_ON(!(msg->flags & XPC_M_SN2_READY));
2282 DBUG_ON(msg->flags & XPC_M_SN2_DONE); 2292 DBUG_ON(msg->flags & XPC_M_SN2_DONE);
2283 2293
2284 msg->flags |= XPC_M_SN2_DONE; 2294 msg->flags |= XPC_M_SN2_DONE;
@@ -2287,7 +2297,7 @@ xpc_received_payload_sn2(struct xpc_channel *ch, void *payload)
2287 * The preceding store of msg->flags must occur before the following 2297 * The preceding store of msg->flags must occur before the following
2288 * load of local_GP->get. 2298 * load of local_GP->get.
2289 */ 2299 */
2290 mb(); 2300 smp_mb();
2291 2301
2292 /* 2302 /*
2293 * See if this message is next in line to be acknowledged as having 2303 * See if this message is next in line to be acknowledged as having
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index 91a55b1b1037..f17f7d40ea2c 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -1423,7 +1423,7 @@ xpc_send_payload_uv(struct xpc_channel *ch, u32 flags, void *payload,
1423 atomic_inc(&ch->n_to_notify); 1423 atomic_inc(&ch->n_to_notify);
1424 1424
1425 msg_slot->key = key; 1425 msg_slot->key = key;
1426 wmb(); /* a non-NULL func must hit memory after the key */ 1426 smp_wmb(); /* a non-NULL func must hit memory after the key */
1427 msg_slot->func = func; 1427 msg_slot->func = func;
1428 1428
1429 if (ch->flags & XPC_C_DISCONNECTING) { 1429 if (ch->flags & XPC_C_DISCONNECTING) {
diff --git a/drivers/mtd/ubi/Kconfig.debug b/drivers/mtd/ubi/Kconfig.debug
index 1e2ee22edeff..2246f154e2f7 100644
--- a/drivers/mtd/ubi/Kconfig.debug
+++ b/drivers/mtd/ubi/Kconfig.debug
@@ -33,16 +33,6 @@ config MTD_UBI_DEBUG_DISABLE_BGT
33 This option switches the background thread off by default. The thread 33 This option switches the background thread off by default. The thread
34 may be also be enabled/disabled via UBI sysfs. 34 may be also be enabled/disabled via UBI sysfs.
35 35
36config MTD_UBI_DEBUG_USERSPACE_IO
37 bool "Direct user-space write/erase support"
38 default n
39 depends on MTD_UBI_DEBUG
40 help
41 By default, users cannot directly write and erase individual
42 eraseblocks of dynamic volumes, and have to use update operation
43 instead. This option enables this capability - it is very useful for
44 debugging and testing.
45
46config MTD_UBI_DEBUG_EMULATE_BITFLIPS 36config MTD_UBI_DEBUG_EMULATE_BITFLIPS
47 bool "Emulate flash bit-flips" 37 bool "Emulate flash bit-flips"
48 depends on MTD_UBI_DEBUG 38 depends on MTD_UBI_DEBUG
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 9082768cc6c3..4048db83aef6 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -263,8 +263,12 @@ static ssize_t dev_attribute_show(struct device *dev,
263 return ret; 263 return ret;
264} 264}
265 265
266/* Fake "release" method for UBI devices */ 266static void dev_release(struct device *dev)
267static void dev_release(struct device *dev) { } 267{
268 struct ubi_device *ubi = container_of(dev, struct ubi_device, dev);
269
270 kfree(ubi);
271}
268 272
269/** 273/**
270 * ubi_sysfs_init - initialize sysfs for an UBI device. 274 * ubi_sysfs_init - initialize sysfs for an UBI device.
@@ -380,7 +384,7 @@ static void free_user_volumes(struct ubi_device *ubi)
380 */ 384 */
381static int uif_init(struct ubi_device *ubi) 385static int uif_init(struct ubi_device *ubi)
382{ 386{
383 int i, err, do_free = 0; 387 int i, err;
384 dev_t dev; 388 dev_t dev;
385 389
386 sprintf(ubi->ubi_name, UBI_NAME_STR "%d", ubi->ubi_num); 390 sprintf(ubi->ubi_name, UBI_NAME_STR "%d", ubi->ubi_num);
@@ -427,13 +431,10 @@ static int uif_init(struct ubi_device *ubi)
427 431
428out_volumes: 432out_volumes:
429 kill_volumes(ubi); 433 kill_volumes(ubi);
430 do_free = 0;
431out_sysfs: 434out_sysfs:
432 ubi_sysfs_close(ubi); 435 ubi_sysfs_close(ubi);
433 cdev_del(&ubi->cdev); 436 cdev_del(&ubi->cdev);
434out_unreg: 437out_unreg:
435 if (do_free)
436 free_user_volumes(ubi);
437 unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1); 438 unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1);
438 ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err); 439 ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err);
439 return err; 440 return err;
@@ -947,6 +948,12 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
947 if (ubi->bgt_thread) 948 if (ubi->bgt_thread)
948 kthread_stop(ubi->bgt_thread); 949 kthread_stop(ubi->bgt_thread);
949 950
951 /*
952 * Get a reference to the device in order to prevent 'dev_release()'
953 * from freeing @ubi object.
954 */
955 get_device(&ubi->dev);
956
950 uif_close(ubi); 957 uif_close(ubi);
951 ubi_wl_close(ubi); 958 ubi_wl_close(ubi);
952 free_internal_volumes(ubi); 959 free_internal_volumes(ubi);
@@ -958,7 +965,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
958 vfree(ubi->dbg_peb_buf); 965 vfree(ubi->dbg_peb_buf);
959#endif 966#endif
960 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); 967 ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num);
961 kfree(ubi); 968 put_device(&ubi->dev);
962 return 0; 969 return 0;
963} 970}
964 971
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 98cf31ed0814..e63c8fc3df3a 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -40,9 +40,9 @@
40#include <linux/ioctl.h> 40#include <linux/ioctl.h>
41#include <linux/capability.h> 41#include <linux/capability.h>
42#include <linux/uaccess.h> 42#include <linux/uaccess.h>
43#include <linux/smp_lock.h> 43#include <linux/compat.h>
44#include <linux/math64.h>
44#include <mtd/ubi-user.h> 45#include <mtd/ubi-user.h>
45#include <asm/div64.h>
46#include "ubi.h" 46#include "ubi.h"
47 47
48/** 48/**
@@ -195,7 +195,6 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
195 int err, lnum, off, len, tbuf_size; 195 int err, lnum, off, len, tbuf_size;
196 size_t count_save = count; 196 size_t count_save = count;
197 void *tbuf; 197 void *tbuf;
198 uint64_t tmp;
199 198
200 dbg_gen("read %zd bytes from offset %lld of volume %d", 199 dbg_gen("read %zd bytes from offset %lld of volume %d",
201 count, *offp, vol->vol_id); 200 count, *offp, vol->vol_id);
@@ -225,10 +224,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
225 return -ENOMEM; 224 return -ENOMEM;
226 225
227 len = count > tbuf_size ? tbuf_size : count; 226 len = count > tbuf_size ? tbuf_size : count;
228 227 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
229 tmp = *offp;
230 off = do_div(tmp, vol->usable_leb_size);
231 lnum = tmp;
232 228
233 do { 229 do {
234 cond_resched(); 230 cond_resched();
@@ -263,12 +259,9 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
263 return err ? err : count_save - count; 259 return err ? err : count_save - count;
264} 260}
265 261
266#ifdef CONFIG_MTD_UBI_DEBUG_USERSPACE_IO
267
268/* 262/*
269 * This function allows to directly write to dynamic UBI volumes, without 263 * This function allows to directly write to dynamic UBI volumes, without
270 * issuing the volume update operation. Available only as a debugging feature. 264 * issuing the volume update operation.
271 * Very useful for testing UBI.
272 */ 265 */
273static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, 266static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
274 size_t count, loff_t *offp) 267 size_t count, loff_t *offp)
@@ -279,7 +272,9 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
279 int lnum, off, len, tbuf_size, err = 0; 272 int lnum, off, len, tbuf_size, err = 0;
280 size_t count_save = count; 273 size_t count_save = count;
281 char *tbuf; 274 char *tbuf;
282 uint64_t tmp; 275
276 if (!vol->direct_writes)
277 return -EPERM;
283 278
284 dbg_gen("requested: write %zd bytes to offset %lld of volume %u", 279 dbg_gen("requested: write %zd bytes to offset %lld of volume %u",
285 count, *offp, vol->vol_id); 280 count, *offp, vol->vol_id);
@@ -287,10 +282,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
287 if (vol->vol_type == UBI_STATIC_VOLUME) 282 if (vol->vol_type == UBI_STATIC_VOLUME)
288 return -EROFS; 283 return -EROFS;
289 284
290 tmp = *offp; 285 lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
291 off = do_div(tmp, vol->usable_leb_size);
292 lnum = tmp;
293
294 if (off & (ubi->min_io_size - 1)) { 286 if (off & (ubi->min_io_size - 1)) {
295 dbg_err("unaligned position"); 287 dbg_err("unaligned position");
296 return -EINVAL; 288 return -EINVAL;
@@ -347,10 +339,6 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
347 return err ? err : count_save - count; 339 return err ? err : count_save - count;
348} 340}
349 341
350#else
351#define vol_cdev_direct_write(file, buf, count, offp) (-EPERM)
352#endif /* CONFIG_MTD_UBI_DEBUG_USERSPACE_IO */
353
354static ssize_t vol_cdev_write(struct file *file, const char __user *buf, 342static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
355 size_t count, loff_t *offp) 343 size_t count, loff_t *offp)
356{ 344{
@@ -402,8 +390,8 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
402 return count; 390 return count;
403} 391}
404 392
405static int vol_cdev_ioctl(struct inode *inode, struct file *file, 393static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
406 unsigned int cmd, unsigned long arg) 394 unsigned long arg)
407{ 395{
408 int err = 0; 396 int err = 0;
409 struct ubi_volume_desc *desc = file->private_data; 397 struct ubi_volume_desc *desc = file->private_data;
@@ -487,7 +475,6 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
487 break; 475 break;
488 } 476 }
489 477
490#ifdef CONFIG_MTD_UBI_DEBUG_USERSPACE_IO
491 /* Logical eraseblock erasure command */ 478 /* Logical eraseblock erasure command */
492 case UBI_IOCEBER: 479 case UBI_IOCEBER:
493 { 480 {
@@ -518,13 +505,77 @@ static int vol_cdev_ioctl(struct inode *inode, struct file *file,
518 err = ubi_wl_flush(ubi); 505 err = ubi_wl_flush(ubi);
519 break; 506 break;
520 } 507 }
521#endif 508
509 /* Logical eraseblock map command */
510 case UBI_IOCEBMAP:
511 {
512 struct ubi_map_req req;
513
514 err = copy_from_user(&req, argp, sizeof(struct ubi_map_req));
515 if (err) {
516 err = -EFAULT;
517 break;
518 }
519 err = ubi_leb_map(desc, req.lnum, req.dtype);
520 break;
521 }
522
523 /* Logical eraseblock un-map command */
524 case UBI_IOCEBUNMAP:
525 {
526 int32_t lnum;
527
528 err = get_user(lnum, (__user int32_t *)argp);
529 if (err) {
530 err = -EFAULT;
531 break;
532 }
533 err = ubi_leb_unmap(desc, lnum);
534 break;
535 }
536
537 /* Check if logical eraseblock is mapped command */
538 case UBI_IOCEBISMAP:
539 {
540 int32_t lnum;
541
542 err = get_user(lnum, (__user int32_t *)argp);
543 if (err) {
544 err = -EFAULT;
545 break;
546 }
547 err = ubi_is_mapped(desc, lnum);
548 break;
549 }
550
551 /* Set volume property command*/
552 case UBI_IOCSETPROP:
553 {
554 struct ubi_set_prop_req req;
555
556 err = copy_from_user(&req, argp,
557 sizeof(struct ubi_set_prop_req));
558 if (err) {
559 err = -EFAULT;
560 break;
561 }
562 switch (req.property) {
563 case UBI_PROP_DIRECT_WRITE:
564 mutex_lock(&ubi->volumes_mutex);
565 desc->vol->direct_writes = !!req.value;
566 mutex_unlock(&ubi->volumes_mutex);
567 break;
568 default:
569 err = -EINVAL;
570 break;
571 }
572 break;
573 }
522 574
523 default: 575 default:
524 err = -ENOTTY; 576 err = -ENOTTY;
525 break; 577 break;
526 } 578 }
527
528 return err; 579 return err;
529} 580}
530 581
@@ -762,8 +813,8 @@ out_free:
762 return err; 813 return err;
763} 814}
764 815
765static int ubi_cdev_ioctl(struct inode *inode, struct file *file, 816static long ubi_cdev_ioctl(struct file *file, unsigned int cmd,
766 unsigned int cmd, unsigned long arg) 817 unsigned long arg)
767{ 818{
768 int err = 0; 819 int err = 0;
769 struct ubi_device *ubi; 820 struct ubi_device *ubi;
@@ -773,7 +824,7 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
773 if (!capable(CAP_SYS_RESOURCE)) 824 if (!capable(CAP_SYS_RESOURCE))
774 return -EPERM; 825 return -EPERM;
775 826
776 ubi = ubi_get_by_major(imajor(inode)); 827 ubi = ubi_get_by_major(imajor(file->f_mapping->host));
777 if (!ubi) 828 if (!ubi)
778 return -ENODEV; 829 return -ENODEV;
779 830
@@ -843,7 +894,6 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
843 case UBI_IOCRSVOL: 894 case UBI_IOCRSVOL:
844 { 895 {
845 int pebs; 896 int pebs;
846 uint64_t tmp;
847 struct ubi_rsvol_req req; 897 struct ubi_rsvol_req req;
848 898
849 dbg_gen("re-size volume"); 899 dbg_gen("re-size volume");
@@ -863,9 +913,8 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
863 break; 913 break;
864 } 914 }
865 915
866 tmp = req.bytes; 916 pebs = div_u64(req.bytes + desc->vol->usable_leb_size - 1,
867 pebs = !!do_div(tmp, desc->vol->usable_leb_size); 917 desc->vol->usable_leb_size);
868 pebs += tmp;
869 918
870 mutex_lock(&ubi->volumes_mutex); 919 mutex_lock(&ubi->volumes_mutex);
871 err = ubi_resize_volume(desc, pebs); 920 err = ubi_resize_volume(desc, pebs);
@@ -909,8 +958,8 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file,
909 return err; 958 return err;
910} 959}
911 960
912static int ctrl_cdev_ioctl(struct inode *inode, struct file *file, 961static long ctrl_cdev_ioctl(struct file *file, unsigned int cmd,
913 unsigned int cmd, unsigned long arg) 962 unsigned long arg)
914{ 963{
915 int err = 0; 964 int err = 0;
916 void __user *argp = (void __user *)arg; 965 void __user *argp = (void __user *)arg;
@@ -986,26 +1035,59 @@ static int ctrl_cdev_ioctl(struct inode *inode, struct file *file,
986 return err; 1035 return err;
987} 1036}
988 1037
989/* UBI control character device operations */ 1038#ifdef CONFIG_COMPAT
990struct file_operations ubi_ctrl_cdev_operations = { 1039static long vol_cdev_compat_ioctl(struct file *file, unsigned int cmd,
991 .ioctl = ctrl_cdev_ioctl, 1040 unsigned long arg)
992 .owner = THIS_MODULE, 1041{
1042 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1043
1044 return vol_cdev_ioctl(file, cmd, translated_arg);
1045}
1046
1047static long ubi_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1048 unsigned long arg)
1049{
1050 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1051
1052 return ubi_cdev_ioctl(file, cmd, translated_arg);
1053}
1054
1055static long ctrl_cdev_compat_ioctl(struct file *file, unsigned int cmd,
1056 unsigned long arg)
1057{
1058 unsigned long translated_arg = (unsigned long)compat_ptr(arg);
1059
1060 return ctrl_cdev_ioctl(file, cmd, translated_arg);
1061}
1062#else
1063#define vol_cdev_compat_ioctl NULL
1064#define ubi_cdev_compat_ioctl NULL
1065#define ctrl_cdev_compat_ioctl NULL
1066#endif
1067
1068/* UBI volume character device operations */
1069const struct file_operations ubi_vol_cdev_operations = {
1070 .owner = THIS_MODULE,
1071 .open = vol_cdev_open,
1072 .release = vol_cdev_release,
1073 .llseek = vol_cdev_llseek,
1074 .read = vol_cdev_read,
1075 .write = vol_cdev_write,
1076 .unlocked_ioctl = vol_cdev_ioctl,
1077 .compat_ioctl = vol_cdev_compat_ioctl,
993}; 1078};
994 1079
995/* UBI character device operations */ 1080/* UBI character device operations */
996struct file_operations ubi_cdev_operations = { 1081const struct file_operations ubi_cdev_operations = {
997 .owner = THIS_MODULE, 1082 .owner = THIS_MODULE,
998 .ioctl = ubi_cdev_ioctl, 1083 .llseek = no_llseek,
999 .llseek = no_llseek, 1084 .unlocked_ioctl = ubi_cdev_ioctl,
1085 .compat_ioctl = ubi_cdev_compat_ioctl,
1000}; 1086};
1001 1087
1002/* UBI volume character device operations */ 1088/* UBI control character device operations */
1003struct file_operations ubi_vol_cdev_operations = { 1089const struct file_operations ubi_ctrl_cdev_operations = {
1004 .owner = THIS_MODULE, 1090 .owner = THIS_MODULE,
1005 .open = vol_cdev_open, 1091 .unlocked_ioctl = ctrl_cdev_ioctl,
1006 .release = vol_cdev_release, 1092 .compat_ioctl = ctrl_cdev_compat_ioctl,
1007 .llseek = vol_cdev_llseek,
1008 .read = vol_cdev_read,
1009 .write = vol_cdev_write,
1010 .ioctl = vol_cdev_ioctl,
1011}; 1093};
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index 6dd4f5e77f82..49cd55ade9c8 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -28,7 +28,7 @@
28 * eraseblock size is equivalent to the logical eraseblock size of the volume. 28 * eraseblock size is equivalent to the logical eraseblock size of the volume.
29 */ 29 */
30 30
31#include <asm/div64.h> 31#include <linux/math64.h>
32#include "ubi.h" 32#include "ubi.h"
33 33
34/** 34/**
@@ -109,7 +109,6 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
109 int err = 0, lnum, offs, total_read; 109 int err = 0, lnum, offs, total_read;
110 struct ubi_volume *vol; 110 struct ubi_volume *vol;
111 struct ubi_device *ubi; 111 struct ubi_device *ubi;
112 uint64_t tmp = from;
113 112
114 dbg_gen("read %zd bytes from offset %lld", len, from); 113 dbg_gen("read %zd bytes from offset %lld", len, from);
115 114
@@ -119,9 +118,7 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
119 vol = container_of(mtd, struct ubi_volume, gluebi_mtd); 118 vol = container_of(mtd, struct ubi_volume, gluebi_mtd);
120 ubi = vol->ubi; 119 ubi = vol->ubi;
121 120
122 offs = do_div(tmp, mtd->erasesize); 121 lnum = div_u64_rem(from, mtd->erasesize, &offs);
123 lnum = tmp;
124
125 total_read = len; 122 total_read = len;
126 while (total_read) { 123 while (total_read) {
127 size_t to_read = mtd->erasesize - offs; 124 size_t to_read = mtd->erasesize - offs;
@@ -160,7 +157,6 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
160 int err = 0, lnum, offs, total_written; 157 int err = 0, lnum, offs, total_written;
161 struct ubi_volume *vol; 158 struct ubi_volume *vol;
162 struct ubi_device *ubi; 159 struct ubi_device *ubi;
163 uint64_t tmp = to;
164 160
165 dbg_gen("write %zd bytes to offset %lld", len, to); 161 dbg_gen("write %zd bytes to offset %lld", len, to);
166 162
@@ -173,8 +169,7 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
173 if (ubi->ro_mode) 169 if (ubi->ro_mode)
174 return -EROFS; 170 return -EROFS;
175 171
176 offs = do_div(tmp, mtd->erasesize); 172 lnum = div_u64_rem(to, mtd->erasesize, &offs);
177 lnum = tmp;
178 173
179 if (len % mtd->writesize || offs % mtd->writesize) 174 if (len % mtd->writesize || offs % mtd->writesize)
180 return -EINVAL; 175 return -EINVAL;
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index ecde202a5a12..c3d653ba5ca0 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -42,7 +42,7 @@
42 42
43#include <linux/err.h> 43#include <linux/err.h>
44#include <linux/crc32.h> 44#include <linux/crc32.h>
45#include <asm/div64.h> 45#include <linux/math64.h>
46#include "ubi.h" 46#include "ubi.h"
47 47
48#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 48#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
@@ -904,10 +904,8 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
904 dbg_msg("scanning is finished"); 904 dbg_msg("scanning is finished");
905 905
906 /* Calculate mean erase counter */ 906 /* Calculate mean erase counter */
907 if (si->ec_count) { 907 if (si->ec_count)
908 do_div(si->ec_sum, si->ec_count); 908 si->mean_ec = div_u64(si->ec_sum, si->ec_count);
909 si->mean_ec = si->ec_sum;
910 }
911 909
912 if (si->is_empty) 910 if (si->is_empty)
913 ubi_msg("empty MTD device detected"); 911 ubi_msg("empty MTD device detected");
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 4a8ec485c91d..c055511bb1b2 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -206,6 +206,7 @@ struct ubi_volume_desc;
206 * @upd_marker: %1 if the update marker is set for this volume 206 * @upd_marker: %1 if the update marker is set for this volume
207 * @updating: %1 if the volume is being updated 207 * @updating: %1 if the volume is being updated
208 * @changing_leb: %1 if the atomic LEB change ioctl command is in progress 208 * @changing_leb: %1 if the atomic LEB change ioctl command is in progress
209 * @direct_writes: %1 if direct writes are enabled for this volume
209 * 210 *
210 * @gluebi_desc: gluebi UBI volume descriptor 211 * @gluebi_desc: gluebi UBI volume descriptor
211 * @gluebi_refcount: reference count of the gluebi MTD device 212 * @gluebi_refcount: reference count of the gluebi MTD device
@@ -253,6 +254,7 @@ struct ubi_volume {
253 unsigned int upd_marker:1; 254 unsigned int upd_marker:1;
254 unsigned int updating:1; 255 unsigned int updating:1;
255 unsigned int changing_leb:1; 256 unsigned int changing_leb:1;
257 unsigned int direct_writes:1;
256 258
257#ifdef CONFIG_MTD_UBI_GLUEBI 259#ifdef CONFIG_MTD_UBI_GLUEBI
258 /* 260 /*
@@ -304,7 +306,8 @@ struct ubi_wl_entry;
304 * @vtbl_size: size of the volume table in bytes 306 * @vtbl_size: size of the volume table in bytes
305 * @vtbl: in-RAM volume table copy 307 * @vtbl: in-RAM volume table copy
306 * @volumes_mutex: protects on-flash volume table and serializes volume 308 * @volumes_mutex: protects on-flash volume table and serializes volume
307 * changes, like creation, deletion, update, re-size and re-name 309 * changes, like creation, deletion, update, re-size,
310 * re-name and set property
308 * 311 *
309 * @max_ec: current highest erase counter value 312 * @max_ec: current highest erase counter value
310 * @mean_ec: current mean erase counter value 313 * @mean_ec: current mean erase counter value
@@ -449,9 +452,9 @@ struct ubi_device {
449}; 452};
450 453
451extern struct kmem_cache *ubi_wl_entry_slab; 454extern struct kmem_cache *ubi_wl_entry_slab;
452extern struct file_operations ubi_ctrl_cdev_operations; 455extern const struct file_operations ubi_ctrl_cdev_operations;
453extern struct file_operations ubi_cdev_operations; 456extern const struct file_operations ubi_cdev_operations;
454extern struct file_operations ubi_vol_cdev_operations; 457extern const struct file_operations ubi_vol_cdev_operations;
455extern struct class *ubi_class; 458extern struct class *ubi_class;
456extern struct mutex ubi_devices_mutex; 459extern struct mutex ubi_devices_mutex;
457 460
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index 8b89cc18ff0b..6b4d1ae891ae 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -40,7 +40,7 @@
40 40
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/uaccess.h> 42#include <linux/uaccess.h>
43#include <asm/div64.h> 43#include <linux/math64.h>
44#include "ubi.h" 44#include "ubi.h"
45 45
46/** 46/**
@@ -89,7 +89,6 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
89 long long bytes) 89 long long bytes)
90{ 90{
91 int err; 91 int err;
92 uint64_t tmp;
93 struct ubi_vtbl_record vtbl_rec; 92 struct ubi_vtbl_record vtbl_rec;
94 93
95 dbg_gen("clear update marker for volume %d", vol->vol_id); 94 dbg_gen("clear update marker for volume %d", vol->vol_id);
@@ -101,9 +100,9 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol,
101 100
102 if (vol->vol_type == UBI_STATIC_VOLUME) { 101 if (vol->vol_type == UBI_STATIC_VOLUME) {
103 vol->corrupted = 0; 102 vol->corrupted = 0;
104 vol->used_bytes = tmp = bytes; 103 vol->used_bytes = bytes;
105 vol->last_eb_bytes = do_div(tmp, vol->usable_leb_size); 104 vol->used_ebs = div_u64_rem(bytes, vol->usable_leb_size,
106 vol->used_ebs = tmp; 105 &vol->last_eb_bytes);
107 if (vol->last_eb_bytes) 106 if (vol->last_eb_bytes)
108 vol->used_ebs += 1; 107 vol->used_ebs += 1;
109 else 108 else
@@ -131,7 +130,6 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
131 long long bytes) 130 long long bytes)
132{ 131{
133 int i, err; 132 int i, err;
134 uint64_t tmp;
135 133
136 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes); 134 dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes);
137 ubi_assert(!vol->updating && !vol->changing_leb); 135 ubi_assert(!vol->updating && !vol->changing_leb);
@@ -161,9 +159,8 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
161 if (!vol->upd_buf) 159 if (!vol->upd_buf)
162 return -ENOMEM; 160 return -ENOMEM;
163 161
164 tmp = bytes; 162 vol->upd_ebs = div_u64(bytes + vol->usable_leb_size - 1,
165 vol->upd_ebs = !!do_div(tmp, vol->usable_leb_size); 163 vol->usable_leb_size);
166 vol->upd_ebs += tmp;
167 vol->upd_bytes = bytes; 164 vol->upd_bytes = bytes;
168 vol->upd_received = 0; 165 vol->upd_received = 0;
169 return 0; 166 return 0;
@@ -282,7 +279,6 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
282int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol, 279int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
283 const void __user *buf, int count) 280 const void __user *buf, int count)
284{ 281{
285 uint64_t tmp;
286 int lnum, offs, err = 0, len, to_write = count; 282 int lnum, offs, err = 0, len, to_write = count;
287 283
288 dbg_gen("write %d of %lld bytes, %lld already passed", 284 dbg_gen("write %d of %lld bytes, %lld already passed",
@@ -291,10 +287,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
291 if (ubi->ro_mode) 287 if (ubi->ro_mode)
292 return -EROFS; 288 return -EROFS;
293 289
294 tmp = vol->upd_received; 290 lnum = div_u64_rem(vol->upd_received, vol->usable_leb_size, &offs);
295 offs = do_div(tmp, vol->usable_leb_size);
296 lnum = tmp;
297
298 if (vol->upd_received + count > vol->upd_bytes) 291 if (vol->upd_received + count > vol->upd_bytes)
299 to_write = count = vol->upd_bytes - vol->upd_received; 292 to_write = count = vol->upd_bytes - vol->upd_received;
300 293
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 22e1d7398fce..df5483562b7a 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include <linux/err.h> 26#include <linux/err.h>
27#include <asm/div64.h> 27#include <linux/math64.h>
28#include "ubi.h" 28#include "ubi.h"
29 29
30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
@@ -205,7 +205,6 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
205 int i, err, vol_id = req->vol_id, do_free = 1; 205 int i, err, vol_id = req->vol_id, do_free = 1;
206 struct ubi_volume *vol; 206 struct ubi_volume *vol;
207 struct ubi_vtbl_record vtbl_rec; 207 struct ubi_vtbl_record vtbl_rec;
208 uint64_t bytes;
209 dev_t dev; 208 dev_t dev;
210 209
211 if (ubi->ro_mode) 210 if (ubi->ro_mode)
@@ -255,10 +254,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
255 254
256 /* Calculate how many eraseblocks are requested */ 255 /* Calculate how many eraseblocks are requested */
257 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment; 256 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment;
258 bytes = req->bytes; 257 vol->reserved_pebs += div_u64(req->bytes + vol->usable_leb_size - 1,
259 if (do_div(bytes, vol->usable_leb_size)) 258 vol->usable_leb_size);
260 vol->reserved_pebs = 1;
261 vol->reserved_pebs += bytes;
262 259
263 /* Reserve physical eraseblocks */ 260 /* Reserve physical eraseblocks */
264 if (vol->reserved_pebs > ubi->avail_pebs) { 261 if (vol->reserved_pebs > ubi->avail_pebs) {
@@ -301,10 +298,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
301 vol->used_bytes = 298 vol->used_bytes =
302 (long long)vol->used_ebs * vol->usable_leb_size; 299 (long long)vol->used_ebs * vol->usable_leb_size;
303 } else { 300 } else {
304 bytes = vol->used_bytes; 301 vol->used_ebs = div_u64_rem(vol->used_bytes,
305 vol->last_eb_bytes = do_div(bytes, vol->usable_leb_size); 302 vol->usable_leb_size,
306 vol->used_ebs = bytes; 303 &vol->last_eb_bytes);
307 if (vol->last_eb_bytes) 304 if (vol->last_eb_bytes != 0)
308 vol->used_ebs += 1; 305 vol->used_ebs += 1;
309 else 306 else
310 vol->last_eb_bytes = vol->usable_leb_size; 307 vol->last_eb_bytes = vol->usable_leb_size;
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 7c789f0a94d7..de91ddab0a86 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -382,6 +382,11 @@ static int __init hp_wmi_input_setup(void)
382 case KE_SW: 382 case KE_SW:
383 set_bit(EV_SW, hp_wmi_input_dev->evbit); 383 set_bit(EV_SW, hp_wmi_input_dev->evbit);
384 set_bit(key->keycode, hp_wmi_input_dev->swbit); 384 set_bit(key->keycode, hp_wmi_input_dev->swbit);
385
386 /* Set initial dock state */
387 input_report_switch(hp_wmi_input_dev, key->keycode,
388 hp_wmi_dock_state());
389 input_sync(hp_wmi_input_dev);
385 break; 390 break;
386 } 391 }
387 } 392 }
@@ -441,6 +446,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
441 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; 446 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set;
442 bluetooth_rfkill->user_claim_unsupported = 1; 447 bluetooth_rfkill->user_claim_unsupported = 1;
443 err = rfkill_register(bluetooth_rfkill); 448 err = rfkill_register(bluetooth_rfkill);
449 if (err)
444 goto register_bluetooth_error; 450 goto register_bluetooth_error;
445 } 451 }
446 452
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index c94f71980c1b..f0267706cb45 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -41,7 +41,7 @@ menuconfig FB
41 You need an utility program called fbset to make full use of frame 41 You need an utility program called fbset to make full use of frame
42 buffer devices. Please read <file:Documentation/fb/framebuffer.txt> 42 buffer devices. Please read <file:Documentation/fb/framebuffer.txt>
43 and the Framebuffer-HOWTO at 43 and the Framebuffer-HOWTO at
44 <http://www.tahallah.demon.co.uk/programming/prog.html> for more 44 <http://www.munted.org.uk/programming/Framebuffer-HOWTO-1.2.html> for more
45 information. 45 information.
46 46
47 Say Y here and to the driver for your graphics board below if you 47 Say Y here and to the driver for your graphics board below if you
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ba2f9ec71192..011b9b8c90c6 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -234,8 +234,6 @@ struct ep_pqueue {
234/* 234/*
235 * Configuration options available inside /proc/sys/fs/epoll/ 235 * Configuration options available inside /proc/sys/fs/epoll/
236 */ 236 */
237/* Maximum number of epoll devices, per user */
238static int max_user_instances __read_mostly;
239/* Maximum number of epoll watched descriptors, per user */ 237/* Maximum number of epoll watched descriptors, per user */
240static int max_user_watches __read_mostly; 238static int max_user_watches __read_mostly;
241 239
@@ -261,14 +259,6 @@ static int zero;
261 259
262ctl_table epoll_table[] = { 260ctl_table epoll_table[] = {
263 { 261 {
264 .procname = "max_user_instances",
265 .data = &max_user_instances,
266 .maxlen = sizeof(int),
267 .mode = 0644,
268 .proc_handler = &proc_dointvec_minmax,
269 .extra1 = &zero,
270 },
271 {
272 .procname = "max_user_watches", 262 .procname = "max_user_watches",
273 .data = &max_user_watches, 263 .data = &max_user_watches,
274 .maxlen = sizeof(int), 264 .maxlen = sizeof(int),
@@ -491,7 +481,6 @@ static void ep_free(struct eventpoll *ep)
491 481
492 mutex_unlock(&epmutex); 482 mutex_unlock(&epmutex);
493 mutex_destroy(&ep->mtx); 483 mutex_destroy(&ep->mtx);
494 atomic_dec(&ep->user->epoll_devs);
495 free_uid(ep->user); 484 free_uid(ep->user);
496 kfree(ep); 485 kfree(ep);
497} 486}
@@ -581,10 +570,6 @@ static int ep_alloc(struct eventpoll **pep)
581 struct eventpoll *ep; 570 struct eventpoll *ep;
582 571
583 user = get_current_user(); 572 user = get_current_user();
584 error = -EMFILE;
585 if (unlikely(atomic_read(&user->epoll_devs) >=
586 max_user_instances))
587 goto free_uid;
588 error = -ENOMEM; 573 error = -ENOMEM;
589 ep = kzalloc(sizeof(*ep), GFP_KERNEL); 574 ep = kzalloc(sizeof(*ep), GFP_KERNEL);
590 if (unlikely(!ep)) 575 if (unlikely(!ep))
@@ -1141,7 +1126,6 @@ SYSCALL_DEFINE1(epoll_create1, int, flags)
1141 flags & O_CLOEXEC); 1126 flags & O_CLOEXEC);
1142 if (fd < 0) 1127 if (fd < 0)
1143 ep_free(ep); 1128 ep_free(ep);
1144 atomic_inc(&ep->user->epoll_devs);
1145 1129
1146error_return: 1130error_return:
1147 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", 1131 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n",
@@ -1366,8 +1350,10 @@ static int __init eventpoll_init(void)
1366 struct sysinfo si; 1350 struct sysinfo si;
1367 1351
1368 si_meminfo(&si); 1352 si_meminfo(&si);
1369 max_user_instances = 128; 1353 /*
1370 max_user_watches = (((si.totalram - si.totalhigh) / 32) << PAGE_SHIFT) / 1354 * Allows top 4% of lomem to be allocated for epoll watches (per user).
1355 */
1356 max_user_watches = (((si.totalram - si.totalhigh) / 25) << PAGE_SHIFT) /
1371 EP_ITEM_COST; 1357 EP_ITEM_COST;
1372 1358
1373 /* Initialize the structure used to perform safe poll wait head wake ups */ 1359 /* Initialize the structure used to perform safe poll wait head wake ups */
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index e267e62827bb..e4e8e117d27d 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -99,6 +99,7 @@ static inline bool css_tryget(struct cgroup_subsys_state *css)
99 while (!atomic_inc_not_zero(&css->refcnt)) { 99 while (!atomic_inc_not_zero(&css->refcnt)) {
100 if (test_bit(CSS_REMOVED, &css->flags)) 100 if (test_bit(CSS_REMOVED, &css->flags))
101 return false; 101 return false;
102 cpu_relax();
102 } 103 }
103 return true; 104 return true;
104} 105}
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index d6ea19e314bb..32851eef48f0 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -49,6 +49,13 @@
49 49
50/* Attach to insert probes on any functions which should be ignored*/ 50/* Attach to insert probes on any functions which should be ignored*/
51#define __kprobes __attribute__((__section__(".kprobes.text"))) notrace 51#define __kprobes __attribute__((__section__(".kprobes.text"))) notrace
52#else /* CONFIG_KPROBES */
53typedef int kprobe_opcode_t;
54struct arch_specific_insn {
55 int dummy;
56};
57#define __kprobes notrace
58#endif /* CONFIG_KPROBES */
52 59
53struct kprobe; 60struct kprobe;
54struct pt_regs; 61struct pt_regs;
@@ -131,23 +138,6 @@ struct jprobe {
131/* For backward compatibility with old code using JPROBE_ENTRY() */ 138/* For backward compatibility with old code using JPROBE_ENTRY() */
132#define JPROBE_ENTRY(handler) (handler) 139#define JPROBE_ENTRY(handler) (handler)
133 140
134DECLARE_PER_CPU(struct kprobe *, current_kprobe);
135DECLARE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
136
137#ifdef CONFIG_KRETPROBES
138extern void arch_prepare_kretprobe(struct kretprobe_instance *ri,
139 struct pt_regs *regs);
140extern int arch_trampoline_kprobe(struct kprobe *p);
141#else /* CONFIG_KRETPROBES */
142static inline void arch_prepare_kretprobe(struct kretprobe *rp,
143 struct pt_regs *regs)
144{
145}
146static inline int arch_trampoline_kprobe(struct kprobe *p)
147{
148 return 0;
149}
150#endif /* CONFIG_KRETPROBES */
151/* 141/*
152 * Function-return probe - 142 * Function-return probe -
153 * Note: 143 * Note:
@@ -188,6 +178,25 @@ struct kprobe_blackpoint {
188 unsigned long range; 178 unsigned long range;
189}; 179};
190 180
181#ifdef CONFIG_KPROBES
182DECLARE_PER_CPU(struct kprobe *, current_kprobe);
183DECLARE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
184
185#ifdef CONFIG_KRETPROBES
186extern void arch_prepare_kretprobe(struct kretprobe_instance *ri,
187 struct pt_regs *regs);
188extern int arch_trampoline_kprobe(struct kprobe *p);
189#else /* CONFIG_KRETPROBES */
190static inline void arch_prepare_kretprobe(struct kretprobe *rp,
191 struct pt_regs *regs)
192{
193}
194static inline int arch_trampoline_kprobe(struct kprobe *p)
195{
196 return 0;
197}
198#endif /* CONFIG_KRETPROBES */
199
191extern struct kretprobe_blackpoint kretprobe_blacklist[]; 200extern struct kretprobe_blackpoint kretprobe_blacklist[];
192 201
193static inline void kretprobe_assert(struct kretprobe_instance *ri, 202static inline void kretprobe_assert(struct kretprobe_instance *ri,
@@ -264,10 +273,6 @@ void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
264 273
265#else /* CONFIG_KPROBES */ 274#else /* CONFIG_KPROBES */
266 275
267#define __kprobes notrace
268struct jprobe;
269struct kretprobe;
270
271static inline struct kprobe *get_kprobe(void *addr) 276static inline struct kprobe *get_kprobe(void *addr)
272{ 277{
273 return NULL; 278 return NULL;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 02e16d207304..5a7c76388731 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -630,7 +630,6 @@ struct user_struct {
630 atomic_t inotify_devs; /* How many inotify devs does this user have opened? */ 630 atomic_t inotify_devs; /* How many inotify devs does this user have opened? */
631#endif 631#endif
632#ifdef CONFIG_EPOLL 632#ifdef CONFIG_EPOLL
633 atomic_t epoll_devs; /* The number of epoll descriptors currently open */
634 atomic_t epoll_watches; /* The number of file descriptors currently watched */ 633 atomic_t epoll_watches; /* The number of file descriptors currently watched */
635#endif 634#endif
636#ifdef CONFIG_POSIX_MQUEUE 635#ifdef CONFIG_POSIX_MQUEUE
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 16875f89e6a7..0eda02ff2414 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -108,9 +108,14 @@ struct old_linux_dirent;
108 asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \ 108 asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \
109 "\t.globl ." #alias "\n\t.set ." #alias ", ." #name) 109 "\t.globl ." #alias "\n\t.set ." #alias ", ." #name)
110#else 110#else
111#ifdef CONFIG_ALPHA
112#define SYSCALL_ALIAS(alias, name) \
113 asm ( #alias " = " #name "\n\t.globl " #alias)
114#else
111#define SYSCALL_ALIAS(alias, name) \ 115#define SYSCALL_ALIAS(alias, name) \
112 asm ("\t.globl " #alias "\n\t.set " #alias ", " #name) 116 asm ("\t.globl " #alias "\n\t.set " #alias ", " #name)
113#endif 117#endif
118#endif
114 119
115#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS 120#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
116 121
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h
index 2dc2eb2b8e22..296efae3525e 100644
--- a/include/mtd/ubi-user.h
+++ b/include/mtd/ubi-user.h
@@ -40,37 +40,37 @@
40 * UBI volume creation 40 * UBI volume creation
41 * ~~~~~~~~~~~~~~~~~~~ 41 * ~~~~~~~~~~~~~~~~~~~
42 * 42 *
43 * UBI volumes are created via the %UBI_IOCMKVOL IOCTL command of UBI character 43 * UBI volumes are created via the %UBI_IOCMKVOL ioctl command of UBI character
44 * device. A &struct ubi_mkvol_req object has to be properly filled and a 44 * device. A &struct ubi_mkvol_req object has to be properly filled and a
45 * pointer to it has to be passed to the IOCTL. 45 * pointer to it has to be passed to the ioctl.
46 * 46 *
47 * UBI volume deletion 47 * UBI volume deletion
48 * ~~~~~~~~~~~~~~~~~~~ 48 * ~~~~~~~~~~~~~~~~~~~
49 * 49 *
50 * To delete a volume, the %UBI_IOCRMVOL IOCTL command of the UBI character 50 * To delete a volume, the %UBI_IOCRMVOL ioctl command of the UBI character
51 * device should be used. A pointer to the 32-bit volume ID hast to be passed 51 * device should be used. A pointer to the 32-bit volume ID hast to be passed
52 * to the IOCTL. 52 * to the ioctl.
53 * 53 *
54 * UBI volume re-size 54 * UBI volume re-size
55 * ~~~~~~~~~~~~~~~~~~ 55 * ~~~~~~~~~~~~~~~~~~
56 * 56 *
57 * To re-size a volume, the %UBI_IOCRSVOL IOCTL command of the UBI character 57 * To re-size a volume, the %UBI_IOCRSVOL ioctl command of the UBI character
58 * device should be used. A &struct ubi_rsvol_req object has to be properly 58 * device should be used. A &struct ubi_rsvol_req object has to be properly
59 * filled and a pointer to it has to be passed to the IOCTL. 59 * filled and a pointer to it has to be passed to the ioctl.
60 * 60 *
61 * UBI volumes re-name 61 * UBI volumes re-name
62 * ~~~~~~~~~~~~~~~~~~~ 62 * ~~~~~~~~~~~~~~~~~~~
63 * 63 *
64 * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command 64 * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command
65 * of the UBI character device should be used. A &struct ubi_rnvol_req object 65 * of the UBI character device should be used. A &struct ubi_rnvol_req object
66 * has to be properly filled and a pointer to it has to be passed to the IOCTL. 66 * has to be properly filled and a pointer to it has to be passed to the ioctl.
67 * 67 *
68 * UBI volume update 68 * UBI volume update
69 * ~~~~~~~~~~~~~~~~~ 69 * ~~~~~~~~~~~~~~~~~
70 * 70 *
71 * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the 71 * Volume update should be done via the %UBI_IOCVOLUP ioctl command of the
72 * corresponding UBI volume character device. A pointer to a 64-bit update 72 * corresponding UBI volume character device. A pointer to a 64-bit update
73 * size should be passed to the IOCTL. After this, UBI expects user to write 73 * size should be passed to the ioctl. After this, UBI expects user to write
74 * this number of bytes to the volume character device. The update is finished 74 * this number of bytes to the volume character device. The update is finished
75 * when the claimed number of bytes is passed. So, the volume update sequence 75 * when the claimed number of bytes is passed. So, the volume update sequence
76 * is something like: 76 * is something like:
@@ -80,14 +80,58 @@
80 * write(fd, buf, image_size); 80 * write(fd, buf, image_size);
81 * close(fd); 81 * close(fd);
82 * 82 *
83 * Atomic eraseblock change 83 * Logical eraseblock erase
84 * ~~~~~~~~~~~~~~~~~~~~~~~~ 84 * ~~~~~~~~~~~~~~~~~~~~~~~~
85 * 85 *
86 * Atomic eraseblock change operation is done via the %UBI_IOCEBCH IOCTL 86 * To erase a logical eraseblock, the %UBI_IOCEBER ioctl command of the
87 * command of the corresponding UBI volume character device. A pointer to 87 * corresponding UBI volume character device should be used. This command
88 * &struct ubi_leb_change_req has to be passed to the IOCTL. Then the user is 88 * unmaps the requested logical eraseblock, makes sure the corresponding
89 * expected to write the requested amount of bytes. This is similar to the 89 * physical eraseblock is successfully erased, and returns.
90 * "volume update" IOCTL. 90 *
91 * Atomic logical eraseblock change
92 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93 *
94 * Atomic logical eraseblock change operation is called using the %UBI_IOCEBCH
95 * ioctl command of the corresponding UBI volume character device. A pointer to
96 * a &struct ubi_leb_change_req object has to be passed to the ioctl. Then the
97 * user is expected to write the requested amount of bytes (similarly to what
98 * should be done in case of the "volume update" ioctl).
99 *
100 * Logical eraseblock map
101 * ~~~~~~~~~~~~~~~~~~~~~
102 *
103 * To map a logical eraseblock to a physical eraseblock, the %UBI_IOCEBMAP
104 * ioctl command should be used. A pointer to a &struct ubi_map_req object is
105 * expected to be passed. The ioctl maps the requested logical eraseblock to
106 * a physical eraseblock and returns. Only non-mapped logical eraseblocks can
107 * be mapped. If the logical eraseblock specified in the request is already
108 * mapped to a physical eraseblock, the ioctl fails and returns error.
109 *
110 * Logical eraseblock unmap
111 * ~~~~~~~~~~~~~~~~~~~~~~~~
112 *
113 * To unmap a logical eraseblock to a physical eraseblock, the %UBI_IOCEBUNMAP
114 * ioctl command should be used. The ioctl unmaps the logical eraseblocks,
115 * schedules corresponding physical eraseblock for erasure, and returns. Unlike
116 * the "LEB erase" command, it does not wait for the physical eraseblock being
117 * erased. Note, the side effect of this is that if an unclean reboot happens
118 * after the unmap ioctl returns, you may find the LEB mapped again to the same
119 * physical eraseblock after the UBI is run again.
120 *
121 * Check if logical eraseblock is mapped
122 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123 *
124 * To check if a logical eraseblock is mapped to a physical eraseblock, the
125 * %UBI_IOCEBISMAP ioctl command should be used. It returns %0 if the LEB is
126 * not mapped, and %1 if it is mapped.
127 *
128 * Set an UBI volume property
129 * ~~~~~~~~~~~~~~~~~~~~~~~~~
130 *
131 * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be
132 * used. A pointer to a &struct ubi_set_prop_req object is expected to be
133 * passed. The object describes which property should be set, and to which value
134 * it should be set.
91 */ 135 */
92 136
93/* 137/*
@@ -101,7 +145,7 @@
101/* Maximum volume name length */ 145/* Maximum volume name length */
102#define UBI_MAX_VOLUME_NAME 127 146#define UBI_MAX_VOLUME_NAME 127
103 147
104/* IOCTL commands of UBI character devices */ 148/* ioctl commands of UBI character devices */
105 149
106#define UBI_IOC_MAGIC 'o' 150#define UBI_IOC_MAGIC 'o'
107 151
@@ -114,7 +158,7 @@
114/* Re-name volumes */ 158/* Re-name volumes */
115#define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req) 159#define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req)
116 160
117/* IOCTL commands of the UBI control character device */ 161/* ioctl commands of the UBI control character device */
118 162
119#define UBI_CTRL_IOC_MAGIC 'o' 163#define UBI_CTRL_IOC_MAGIC 'o'
120 164
@@ -123,16 +167,24 @@
123/* Detach an MTD device */ 167/* Detach an MTD device */
124#define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t) 168#define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t)
125 169
126/* IOCTL commands of UBI volume character devices */ 170/* ioctl commands of UBI volume character devices */
127 171
128#define UBI_VOL_IOC_MAGIC 'O' 172#define UBI_VOL_IOC_MAGIC 'O'
129 173
130/* Start UBI volume update */ 174/* Start UBI volume update */
131#define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) 175#define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t)
132/* An eraseblock erasure command, used for debugging, disabled by default */ 176/* LEB erasure command, used for debugging, disabled by default */
133#define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) 177#define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t)
134/* An atomic eraseblock change command */ 178/* Atomic LEB change command */
135#define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t) 179#define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t)
180/* Map LEB command */
181#define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req)
182/* Unmap LEB command */
183#define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, int32_t)
184/* Check if LEB is mapped command */
185#define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, int32_t)
186/* Set an UBI volume property */
187#define UBI_IOCSETPROP _IOW(UBI_VOL_IOC_MAGIC, 6, struct ubi_set_prop_req)
136 188
137/* Maximum MTD device name length supported by UBI */ 189/* Maximum MTD device name length supported by UBI */
138#define MAX_UBI_MTD_NAME_LEN 127 190#define MAX_UBI_MTD_NAME_LEN 127
@@ -168,6 +220,16 @@ enum {
168 UBI_STATIC_VOLUME = 4, 220 UBI_STATIC_VOLUME = 4,
169}; 221};
170 222
223/*
224 * UBI set property ioctl constants
225 *
226 * @UBI_PROP_DIRECT_WRITE: allow / disallow user to directly write and
227 * erase individual eraseblocks on dynamic volumes
228 */
229enum {
230 UBI_PROP_DIRECT_WRITE = 1,
231};
232
171/** 233/**
172 * struct ubi_attach_req - attach MTD device request. 234 * struct ubi_attach_req - attach MTD device request.
173 * @ubi_num: UBI device number to create 235 * @ubi_num: UBI device number to create
@@ -305,8 +367,8 @@ struct ubi_rnvol_req {
305} __attribute__ ((packed)); 367} __attribute__ ((packed));
306 368
307/** 369/**
308 * struct ubi_leb_change_req - a data structure used in atomic logical 370 * struct ubi_leb_change_req - a data structure used in atomic LEB change
309 * eraseblock change requests. 371 * requests.
310 * @lnum: logical eraseblock number to change 372 * @lnum: logical eraseblock number to change
311 * @bytes: how many bytes will be written to the logical eraseblock 373 * @bytes: how many bytes will be written to the logical eraseblock
312 * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) 374 * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
@@ -319,4 +381,30 @@ struct ubi_leb_change_req {
319 int8_t padding[7]; 381 int8_t padding[7];
320} __attribute__ ((packed)); 382} __attribute__ ((packed));
321 383
384/**
385 * struct ubi_map_req - a data structure used in map LEB requests.
386 * @lnum: logical eraseblock number to unmap
387 * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
388 * @padding: reserved for future, not used, has to be zeroed
389 */
390struct ubi_map_req {
391 int32_t lnum;
392 int8_t dtype;
393 int8_t padding[3];
394} __attribute__ ((packed));
395
396
397/**
398 * struct ubi_set_prop_req - a data structure used to set an ubi volume
399 * property.
400 * @property: property to set (%UBI_PROP_DIRECT_WRITE)
401 * @padding: reserved for future, not used, has to be zeroed
402 * @value: value to set
403 */
404struct ubi_set_prop_req {
405 uint8_t property;
406 uint8_t padding[7];
407 uint64_t value;
408} __attribute__ ((packed));
409
322#endif /* __UBI_USER_H__ */ 410#endif /* __UBI_USER_H__ */
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index c29831076e7a..5a54ff42874e 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1115,8 +1115,10 @@ static void cgroup_kill_sb(struct super_block *sb) {
1115 } 1115 }
1116 write_unlock(&css_set_lock); 1116 write_unlock(&css_set_lock);
1117 1117
1118 list_del(&root->root_list); 1118 if (!list_empty(&root->root_list)) {
1119 root_count--; 1119 list_del(&root->root_list);
1120 root_count--;
1121 }
1120 1122
1121 mutex_unlock(&cgroup_mutex); 1123 mutex_unlock(&cgroup_mutex);
1122 1124
@@ -2434,7 +2436,9 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
2434 2436
2435 err_remove: 2437 err_remove:
2436 2438
2439 cgroup_lock_hierarchy(root);
2437 list_del(&cgrp->sibling); 2440 list_del(&cgrp->sibling);
2441 cgroup_unlock_hierarchy(root);
2438 root->number_of_cgroups--; 2442 root->number_of_cgroups--;
2439 2443
2440 err_destroy: 2444 err_destroy:
@@ -2507,7 +2511,7 @@ static int cgroup_clear_css_refs(struct cgroup *cgrp)
2507 for_each_subsys(cgrp->root, ss) { 2511 for_each_subsys(cgrp->root, ss) {
2508 struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id]; 2512 struct cgroup_subsys_state *css = cgrp->subsys[ss->subsys_id];
2509 int refcnt; 2513 int refcnt;
2510 do { 2514 while (1) {
2511 /* We can only remove a CSS with a refcnt==1 */ 2515 /* We can only remove a CSS with a refcnt==1 */
2512 refcnt = atomic_read(&css->refcnt); 2516 refcnt = atomic_read(&css->refcnt);
2513 if (refcnt > 1) { 2517 if (refcnt > 1) {
@@ -2521,7 +2525,10 @@ static int cgroup_clear_css_refs(struct cgroup *cgrp)
2521 * css_tryget() to spin until we set the 2525 * css_tryget() to spin until we set the
2522 * CSS_REMOVED bits or abort 2526 * CSS_REMOVED bits or abort
2523 */ 2527 */
2524 } while (atomic_cmpxchg(&css->refcnt, refcnt, 0) != refcnt); 2528 if (atomic_cmpxchg(&css->refcnt, refcnt, 0) == refcnt)
2529 break;
2530 cpu_relax();
2531 }
2525 } 2532 }
2526 done: 2533 done:
2527 for_each_subsys(cgrp->root, ss) { 2534 for_each_subsys(cgrp->root, ss) {
@@ -2991,20 +2998,21 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
2991 mutex_unlock(&cgroup_mutex); 2998 mutex_unlock(&cgroup_mutex);
2992 return 0; 2999 return 0;
2993 } 3000 }
2994 task_lock(tsk);
2995 cg = tsk->cgroups;
2996 parent = task_cgroup(tsk, subsys->subsys_id);
2997 3001
2998 /* Pin the hierarchy */ 3002 /* Pin the hierarchy */
2999 if (!atomic_inc_not_zero(&parent->root->sb->s_active)) { 3003 if (!atomic_inc_not_zero(&root->sb->s_active)) {
3000 /* We race with the final deactivate_super() */ 3004 /* We race with the final deactivate_super() */
3001 mutex_unlock(&cgroup_mutex); 3005 mutex_unlock(&cgroup_mutex);
3002 return 0; 3006 return 0;
3003 } 3007 }
3004 3008
3005 /* Keep the cgroup alive */ 3009 /* Keep the cgroup alive */
3010 task_lock(tsk);
3011 parent = task_cgroup(tsk, subsys->subsys_id);
3012 cg = tsk->cgroups;
3006 get_css_set(cg); 3013 get_css_set(cg);
3007 task_unlock(tsk); 3014 task_unlock(tsk);
3015
3008 mutex_unlock(&cgroup_mutex); 3016 mutex_unlock(&cgroup_mutex);
3009 3017
3010 /* Now do the VFS work to create a cgroup */ 3018 /* Now do the VFS work to create a cgroup */
@@ -3043,7 +3051,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
3043 mutex_unlock(&inode->i_mutex); 3051 mutex_unlock(&inode->i_mutex);
3044 put_css_set(cg); 3052 put_css_set(cg);
3045 3053
3046 deactivate_super(parent->root->sb); 3054 deactivate_super(root->sb);
3047 /* The cgroup is still accessible in the VFS, but 3055 /* The cgroup is still accessible in the VFS, but
3048 * we're not going to try to rmdir() it at this 3056 * we're not going to try to rmdir() it at this
3049 * point. */ 3057 * point. */
@@ -3069,7 +3077,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
3069 mutex_lock(&cgroup_mutex); 3077 mutex_lock(&cgroup_mutex);
3070 put_css_set(cg); 3078 put_css_set(cg);
3071 mutex_unlock(&cgroup_mutex); 3079 mutex_unlock(&cgroup_mutex);
3072 deactivate_super(parent->root->sb); 3080 deactivate_super(root->sb);
3073 return ret; 3081 return ret;
3074} 3082}
3075 3083
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4d0ea3ceba6d..8e4be9cb2a6a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -202,6 +202,7 @@ pcg_default_flags[NR_CHARGE_TYPE] = {
202 202
203static void mem_cgroup_get(struct mem_cgroup *mem); 203static void mem_cgroup_get(struct mem_cgroup *mem);
204static void mem_cgroup_put(struct mem_cgroup *mem); 204static void mem_cgroup_put(struct mem_cgroup *mem);
205static struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *mem);
205 206
206static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, 207static void mem_cgroup_charge_statistics(struct mem_cgroup *mem,
207 struct page_cgroup *pc, 208 struct page_cgroup *pc,
@@ -1684,7 +1685,7 @@ move_account:
1684 /* This is for making all *used* pages to be on LRU. */ 1685 /* This is for making all *used* pages to be on LRU. */
1685 lru_add_drain_all(); 1686 lru_add_drain_all();
1686 ret = 0; 1687 ret = 0;
1687 for_each_node_state(node, N_POSSIBLE) { 1688 for_each_node_state(node, N_HIGH_MEMORY) {
1688 for (zid = 0; !ret && zid < MAX_NR_ZONES; zid++) { 1689 for (zid = 0; !ret && zid < MAX_NR_ZONES; zid++) {
1689 enum lru_list l; 1690 enum lru_list l;
1690 for_each_lru(l) { 1691 for_each_lru(l) {
@@ -2193,10 +2194,23 @@ static void mem_cgroup_get(struct mem_cgroup *mem)
2193 2194
2194static void mem_cgroup_put(struct mem_cgroup *mem) 2195static void mem_cgroup_put(struct mem_cgroup *mem)
2195{ 2196{
2196 if (atomic_dec_and_test(&mem->refcnt)) 2197 if (atomic_dec_and_test(&mem->refcnt)) {
2198 struct mem_cgroup *parent = parent_mem_cgroup(mem);
2197 __mem_cgroup_free(mem); 2199 __mem_cgroup_free(mem);
2200 if (parent)
2201 mem_cgroup_put(parent);
2202 }
2198} 2203}
2199 2204
2205/*
2206 * Returns the parent mem_cgroup in memcgroup hierarchy with hierarchy enabled.
2207 */
2208static struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *mem)
2209{
2210 if (!mem->res.parent)
2211 return NULL;
2212 return mem_cgroup_from_res_counter(mem->res.parent, res);
2213}
2200 2214
2201#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP 2215#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
2202static void __init enable_swap_cgroup(void) 2216static void __init enable_swap_cgroup(void)
@@ -2235,6 +2249,13 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
2235 if (parent && parent->use_hierarchy) { 2249 if (parent && parent->use_hierarchy) {
2236 res_counter_init(&mem->res, &parent->res); 2250 res_counter_init(&mem->res, &parent->res);
2237 res_counter_init(&mem->memsw, &parent->memsw); 2251 res_counter_init(&mem->memsw, &parent->memsw);
2252 /*
2253 * We increment refcnt of the parent to ensure that we can
2254 * safely access it on res_counter_charge/uncharge.
2255 * This refcnt will be decremented when freeing this
2256 * mem_cgroup(see mem_cgroup_put).
2257 */
2258 mem_cgroup_get(parent);
2238 } else { 2259 } else {
2239 res_counter_init(&mem->res, NULL); 2260 res_counter_init(&mem->res, NULL);
2240 res_counter_init(&mem->memsw, NULL); 2261 res_counter_init(&mem->memsw, NULL);
diff --git a/mm/mmap.c b/mm/mmap.c
index 8d95902e9a38..d3fa10a726cf 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1134,16 +1134,11 @@ munmap_back:
1134 } 1134 }
1135 1135
1136 /* 1136 /*
1137 * Can we just expand an old private anonymous mapping? 1137 * Can we just expand an old mapping?
1138 * The VM_SHARED test is necessary because shmem_zero_setup
1139 * will create the file object for a shared anonymous map below.
1140 */ 1138 */
1141 if (!file && !(vm_flags & VM_SHARED)) { 1139 vma = vma_merge(mm, prev, addr, addr + len, vm_flags, NULL, file, pgoff, NULL);
1142 vma = vma_merge(mm, prev, addr, addr + len, vm_flags, 1140 if (vma)
1143 NULL, NULL, pgoff, NULL); 1141 goto out;
1144 if (vma)
1145 goto out;
1146 }
1147 1142
1148 /* 1143 /*
1149 * Determine the object being mapped and call the appropriate 1144 * Determine the object being mapped and call the appropriate
@@ -1206,17 +1201,8 @@ munmap_back:
1206 if (vma_wants_writenotify(vma)) 1201 if (vma_wants_writenotify(vma))
1207 vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED); 1202 vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
1208 1203
1209 if (file && vma_merge(mm, prev, addr, vma->vm_end, 1204 vma_link(mm, vma, prev, rb_link, rb_parent);
1210 vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) { 1205 file = vma->vm_file;
1211 mpol_put(vma_policy(vma));
1212 kmem_cache_free(vm_area_cachep, vma);
1213 fput(file);
1214 if (vm_flags & VM_EXECUTABLE)
1215 removed_exe_file_vma(mm);
1216 } else {
1217 vma_link(mm, vma, prev, rb_link, rb_parent);
1218 file = vma->vm_file;
1219 }
1220 1206
1221 /* Once vma denies write, undo our temporary denial count */ 1207 /* Once vma denies write, undo our temporary denial count */
1222 if (correct_wcount) 1208 if (correct_wcount)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index f48b831e5e5c..7e6304dfafab 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -698,8 +698,10 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
698 pte_t *pte; 698 pte_t *pte;
699 int ret = 1; 699 int ret = 1;
700 700
701 if (mem_cgroup_try_charge_swapin(vma->vm_mm, page, GFP_KERNEL, &ptr)) 701 if (mem_cgroup_try_charge_swapin(vma->vm_mm, page, GFP_KERNEL, &ptr)) {
702 ret = -ENOMEM; 702 ret = -ENOMEM;
703 goto out_nolock;
704 }
703 705
704 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 706 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
705 if (unlikely(!pte_same(*pte, swp_entry_to_pte(entry)))) { 707 if (unlikely(!pte_same(*pte, swp_entry_to_pte(entry)))) {
@@ -723,6 +725,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
723 activate_page(page); 725 activate_page(page);
724out: 726out:
725 pte_unmap_unlock(pte, ptl); 727 pte_unmap_unlock(pte, ptl);
728out_nolock:
726 return ret; 729 return ret;
727} 730}
728 731
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 75de40aaab0a..0177ef8f4c9e 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -347,6 +347,7 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
347 &spec->cur_mux[adc_idx]); 347 &spec->cur_mux[adc_idx]);
348} 348}
349 349
350#ifdef CONFIG_SND_JACK
350static int conexant_add_jack(struct hda_codec *codec, 351static int conexant_add_jack(struct hda_codec *codec,
351 hda_nid_t nid, int type) 352 hda_nid_t nid, int type)
352{ 353{
@@ -394,7 +395,6 @@ static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
394 395
395static int conexant_init_jacks(struct hda_codec *codec) 396static int conexant_init_jacks(struct hda_codec *codec)
396{ 397{
397#ifdef CONFIG_SND_JACK
398 struct conexant_spec *spec = codec->spec; 398 struct conexant_spec *spec = codec->spec;
399 int i; 399 int i;
400 400
@@ -422,10 +422,19 @@ static int conexant_init_jacks(struct hda_codec *codec)
422 ++hv; 422 ++hv;
423 } 423 }
424 } 424 }
425#endif
426 return 0; 425 return 0;
427 426
428} 427}
428#else
429static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
430{
431}
432
433static inline int conexant_init_jacks(struct hda_codec *codec)
434{
435 return 0;
436}
437#endif
429 438
430static int conexant_init(struct hda_codec *codec) 439static int conexant_init(struct hda_codec *codec)
431{ 440{
@@ -1566,6 +1575,7 @@ static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1566 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1575 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1567 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP), 1576 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP),
1568 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP), 1577 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP),
1578 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6700", CXT5047_LAPTOP),
1569 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1579 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1570 {} 1580 {}
1571}; 1581};
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 5d249a547fbf..7884a4e07061 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7018,6 +7018,7 @@ static int patch_alc882(struct hda_codec *codec)
7018 case 0x106b00a4: /* MacbookPro4,1 */ 7018 case 0x106b00a4: /* MacbookPro4,1 */
7019 case 0x106b2c00: /* Macbook Pro rev3 */ 7019 case 0x106b2c00: /* Macbook Pro rev3 */
7020 case 0x106b3600: /* Macbook 3.1 */ 7020 case 0x106b3600: /* Macbook 3.1 */
7021 case 0x106b3800: /* MacbookPro4,1 - latter revision */
7021 board_config = ALC885_MBP3; 7022 board_config = ALC885_MBP3;
7022 break; 7023 break;
7023 default: 7024 default:
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 3dd4eee70b7c..b787b3cc096f 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -2539,6 +2539,8 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
2539 2539
2540 info->name = "STAC92xx Analog"; 2540 info->name = "STAC92xx Analog";
2541 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; 2541 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2542 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2543 spec->multiout.dac_nids[0];
2542 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; 2544 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2543 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 2545 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2544 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; 2546 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index 6c21b50c9375..77620ab98756 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -1451,7 +1451,14 @@ static const struct snd_soc_dai wm8753_all_dai[] = {
1451}, 1451},
1452}; 1452};
1453 1453
1454struct snd_soc_dai wm8753_dai[2]; 1454struct snd_soc_dai wm8753_dai[] = {
1455 {
1456 .name = "WM8753 DAI 0",
1457 },
1458 {
1459 .name = "WM8753 DAI 1",
1460 },
1461};
1455EXPORT_SYMBOL_GPL(wm8753_dai); 1462EXPORT_SYMBOL_GPL(wm8753_dai);
1456 1463
1457static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode) 1464static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode)
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index ec5e18a78758..05dd5abcddf4 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -302,6 +302,10 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
302 regs->spcr1 |= RINTM(3); 302 regs->spcr1 |= RINTM(3);
303 regs->rcr2 |= RFIG; 303 regs->rcr2 |= RFIG;
304 regs->xcr2 |= XFIG; 304 regs->xcr2 |= XFIG;
305 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
306 regs->xccr = DXENDLY(1) | XDMAEN;
307 regs->rccr = RFULL_CYCLE | RDMAEN;
308 }
305 309
306 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 310 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
307 case SND_SOC_DAIFMT_I2S: 311 case SND_SOC_DAIFMT_I2S: