aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2013-11-04 01:49:35 -0500
committerIngo Molnar <mingo@kernel.org>2013-11-04 01:49:35 -0500
commit2a3ede8cb2ddee5885518e4232aca13056f9a6e0 (patch)
tree79b2b4e060a97b1e7c60d58549f8c97cb15db5dd
parent0e73453e172aaa38fd59fd4d3fc589e8fc9b9a70 (diff)
parent215432ed30393ed4a8f77db0a1fe34523c48cdba (diff)
Merge branch 'perf/urgent' into perf/core to fix conflicts
Conflicts: tools/perf/bench/numa.c Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--MAINTAINERS53
-rw-r--r--Makefile2
-rw-r--r--arch/arc/mm/fault.c6
-rw-r--r--arch/mips/kernel/perf_event_mipsxx.c4
-rw-r--r--arch/mips/mti-malta/malta-int.c9
-rw-r--r--arch/mips/ralink/timer.c2
-rw-r--r--arch/um/kernel/exitcode.c4
-rw-r--r--arch/x86/include/asm/percpu.h3
-rw-r--r--arch/x86/kernel/cpu/perf_event.c6
-rw-r--r--arch/x86/kernel/kvm.c2
-rw-r--r--arch/x86/kernel/nmi.c4
-rw-r--r--arch/xtensa/kernel/entry.S49
-rw-r--r--arch/xtensa/kernel/signal.c2
-rw-r--r--arch/xtensa/platforms/iss/network.c3
-rw-r--r--drivers/clk/clk-nomadik.c21
-rw-r--r--drivers/clk/mvebu/armada-370.c4
-rw-r--r--drivers/clk/socfpga/clk.c2
-rw-r--r--drivers/clk/versatile/clk-icst.c2
-rw-r--r--drivers/gpu/drm/drm_drv.c2
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c28
-rw-r--r--drivers/gpu/drm/i915/intel_ddi.c21
-rw-r--r--drivers/gpu/drm/i915/intel_display.c131
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c20
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h2
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c16
-rw-r--r--drivers/gpu/drm/radeon/evergreen_hdmi.c1
-rw-r--r--drivers/gpu/drm/radeon/kv_dpm.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon.h4
-rw-r--r--drivers/input/input.c10
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c11
-rw-r--r--drivers/input/misc/cm109.c14
-rw-r--r--drivers/input/mouse/alps.c1
-rw-r--r--drivers/input/serio/i8042.c23
-rw-r--r--drivers/input/tablet/wacom_sys.c4
-rw-r--r--drivers/input/tablet/wacom_wac.c8
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c6
-rw-r--r--drivers/scsi/aacraid/linit.c2
-rw-r--r--drivers/scsi/sg.c176
-rw-r--r--drivers/staging/bcm/Bcmchar.c1
-rw-r--r--drivers/staging/ozwpan/ozcdev.c3
-rw-r--r--drivers/staging/sb105x/sb_pci_mp.c2
-rw-r--r--drivers/staging/wlags49_h2/wl_priv.c9
-rw-r--r--drivers/tty/serial/atmel_serial.c9
-rw-r--r--drivers/uio/uio.c17
-rw-r--r--drivers/usb/serial/ftdi_sio.c1
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h6
-rw-r--r--drivers/usb/serial/pl2303.c274
-rw-r--r--drivers/video/au1100fb.c26
-rw-r--r--drivers/video/au1200fb.c23
-rw-r--r--fs/dcache.c5
-rw-r--r--fs/eventpoll.c4
-rw-r--r--fs/select.c3
-rw-r--r--include/linux/ipc_namespace.h6
-rw-r--r--include/linux/percpu.h8
-rw-r--r--include/uapi/linux/perf_event.h12
-rw-r--r--ipc/ipc_sysctl.c20
-rw-r--r--kernel/events/ring_buffer.c31
-rw-r--r--lib/Kconfig.debug2
-rw-r--r--lib/scatterlist.c3
-rw-r--r--mm/huge_memory.c70
-rw-r--r--mm/list_lru.c3
-rw-r--r--mm/memcontrol.c57
-rw-r--r--mm/memory.c53
-rw-r--r--mm/migrate.c19
-rw-r--r--mm/mprotect.c2
-rw-r--r--mm/pagewalk.c2
-rw-r--r--scripts/kallsyms.c12
-rw-r--r--scripts/link-vmlinux.sh2
-rw-r--r--sound/core/pcm.c4
-rw-r--r--sound/pci/hda/hda_codec.c4
-rw-r--r--sound/pci/hda/hda_generic.c4
-rw-r--r--sound/pci/hda/patch_analog.c18
-rw-r--r--sound/pci/hda/patch_realtek.c1
-rw-r--r--sound/soc/codecs/wm_hubs.c1
-rw-r--r--sound/soc/soc-dapm.c4
-rw-r--r--tools/perf/tests/attr/README6
-rw-r--r--tools/perf/tests/attr/test-record-graph-default2
-rw-r--r--tools/perf/tests/attr/test-record-graph-dwarf2
-rw-r--r--tools/perf/tests/attr/test-record-graph-fp2
-rw-r--r--tools/perf/ui/hist.c2
-rw-r--r--tools/perf/util/color.c11
-rw-r--r--tools/perf/util/color.h2
-rw-r--r--virt/kvm/kvm_main.c2
83 files changed, 729 insertions, 681 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 3438384d270c..ffcaf975bed7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8917,61 +8917,14 @@ W: http://pegasus2.sourceforge.net/
8917S: Maintained 8917S: Maintained
8918F: drivers/net/usb/rtl8150.c 8918F: drivers/net/usb/rtl8150.c
8919 8919
8920USB SERIAL BELKIN F5U103 DRIVER 8920USB SERIAL SUBSYSTEM
8921M: William Greathouse <wgreathouse@smva.com> 8921M: Johan Hovold <jhovold@gmail.com>
8922L: linux-usb@vger.kernel.org 8922L: linux-usb@vger.kernel.org
8923S: Maintained 8923S: Maintained
8924F: drivers/usb/serial/belkin_sa.*
8925
8926USB SERIAL CYPRESS M8 DRIVER
8927M: Lonnie Mendez <dignome@gmail.com>
8928L: linux-usb@vger.kernel.org
8929S: Maintained
8930W: http://geocities.com/i0xox0i
8931W: http://firstlight.net/cvs
8932F: drivers/usb/serial/cypress_m8.*
8933
8934USB SERIAL CYBERJACK DRIVER
8935M: Matthias Bruestle and Harald Welte <support@reiner-sct.com>
8936W: http://www.reiner-sct.de/support/treiber_cyberjack.php
8937S: Maintained
8938F: drivers/usb/serial/cyberjack.c
8939
8940USB SERIAL DIGI ACCELEPORT DRIVER
8941M: Peter Berger <pberger@brimson.com>
8942M: Al Borchers <alborchers@steinerpoint.com>
8943L: linux-usb@vger.kernel.org
8944S: Maintained
8945F: drivers/usb/serial/digi_acceleport.c
8946
8947USB SERIAL DRIVER
8948M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8949L: linux-usb@vger.kernel.org
8950S: Supported
8951F: Documentation/usb/usb-serial.txt 8924F: Documentation/usb/usb-serial.txt
8952F: drivers/usb/serial/generic.c 8925F: drivers/usb/serial/
8953F: drivers/usb/serial/usb-serial.c
8954F: include/linux/usb/serial.h 8926F: include/linux/usb/serial.h
8955 8927
8956USB SERIAL EMPEG EMPEG-CAR MARK I/II DRIVER
8957M: Gary Brubaker <xavyer@ix.netcom.com>
8958L: linux-usb@vger.kernel.org
8959S: Maintained
8960F: drivers/usb/serial/empeg.c
8961
8962USB SERIAL KEYSPAN DRIVER
8963M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8964L: linux-usb@vger.kernel.org
8965S: Maintained
8966F: drivers/usb/serial/*keyspan*
8967
8968USB SERIAL WHITEHEAT DRIVER
8969M: Support Department <support@connecttech.com>
8970L: linux-usb@vger.kernel.org
8971W: http://www.connecttech.com
8972S: Supported
8973F: drivers/usb/serial/whiteheat*
8974
8975USB SMSC75XX ETHERNET DRIVER 8928USB SMSC75XX ETHERNET DRIVER
8976M: Steve Glendinning <steve.glendinning@shawell.net> 8929M: Steve Glendinning <steve.glendinning@shawell.net>
8977L: netdev@vger.kernel.org 8930L: netdev@vger.kernel.org
diff --git a/Makefile b/Makefile
index 868c0eb67b08..67077ad6edbb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 12 2PATCHLEVEL = 12
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc7 4EXTRAVERSION =
5NAME = One Giant Leap for Frogkind 5NAME = One Giant Leap for Frogkind
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index d63f3de0cd5b..0c14d8a52683 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -17,7 +17,7 @@
17#include <asm/pgalloc.h> 17#include <asm/pgalloc.h>
18#include <asm/mmu.h> 18#include <asm/mmu.h>
19 19
20static int handle_vmalloc_fault(struct mm_struct *mm, unsigned long address) 20static int handle_vmalloc_fault(unsigned long address)
21{ 21{
22 /* 22 /*
23 * Synchronize this task's top level page-table 23 * Synchronize this task's top level page-table
@@ -27,7 +27,7 @@ static int handle_vmalloc_fault(struct mm_struct *mm, unsigned long address)
27 pud_t *pud, *pud_k; 27 pud_t *pud, *pud_k;
28 pmd_t *pmd, *pmd_k; 28 pmd_t *pmd, *pmd_k;
29 29
30 pgd = pgd_offset_fast(mm, address); 30 pgd = pgd_offset_fast(current->active_mm, address);
31 pgd_k = pgd_offset_k(address); 31 pgd_k = pgd_offset_k(address);
32 32
33 if (!pgd_present(*pgd_k)) 33 if (!pgd_present(*pgd_k))
@@ -72,7 +72,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address)
72 * nothing more. 72 * nothing more.
73 */ 73 */
74 if (address >= VMALLOC_START && address <= VMALLOC_END) { 74 if (address >= VMALLOC_START && address <= VMALLOC_END) {
75 ret = handle_vmalloc_fault(mm, address); 75 ret = handle_vmalloc_fault(address);
76 if (unlikely(ret)) 76 if (unlikely(ret))
77 goto bad_area_nosemaphore; 77 goto bad_area_nosemaphore;
78 else 78 else
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
index 45f1ffcf1a4b..24cdf64789c3 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -971,11 +971,11 @@ static const struct mips_perf_event mipsxx74Kcore_cache_map
971[C(LL)] = { 971[C(LL)] = {
972 [C(OP_READ)] = { 972 [C(OP_READ)] = {
973 [C(RESULT_ACCESS)] = { 0x1c, CNTR_ODD, P }, 973 [C(RESULT_ACCESS)] = { 0x1c, CNTR_ODD, P },
974 [C(RESULT_MISS)] = { 0x1d, CNTR_EVEN | CNTR_ODD, P }, 974 [C(RESULT_MISS)] = { 0x1d, CNTR_EVEN, P },
975 }, 975 },
976 [C(OP_WRITE)] = { 976 [C(OP_WRITE)] = {
977 [C(RESULT_ACCESS)] = { 0x1c, CNTR_ODD, P }, 977 [C(RESULT_ACCESS)] = { 0x1c, CNTR_ODD, P },
978 [C(RESULT_MISS)] = { 0x1d, CNTR_EVEN | CNTR_ODD, P }, 978 [C(RESULT_MISS)] = { 0x1d, CNTR_EVEN, P },
979 }, 979 },
980}, 980},
981[C(ITLB)] = { 981[C(ITLB)] = {
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c
index c69da3734699..5b28e81d94a0 100644
--- a/arch/mips/mti-malta/malta-int.c
+++ b/arch/mips/mti-malta/malta-int.c
@@ -473,7 +473,7 @@ static void __init fill_ipi_map(void)
473{ 473{
474 int cpu; 474 int cpu;
475 475
476 for (cpu = 0; cpu < NR_CPUS; cpu++) { 476 for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
477 fill_ipi_map1(gic_resched_int_base, cpu, GIC_CPU_INT1); 477 fill_ipi_map1(gic_resched_int_base, cpu, GIC_CPU_INT1);
478 fill_ipi_map1(gic_call_int_base, cpu, GIC_CPU_INT2); 478 fill_ipi_map1(gic_call_int_base, cpu, GIC_CPU_INT2);
479 } 479 }
@@ -574,8 +574,9 @@ void __init arch_init_irq(void)
574 /* FIXME */ 574 /* FIXME */
575 int i; 575 int i;
576#if defined(CONFIG_MIPS_MT_SMP) 576#if defined(CONFIG_MIPS_MT_SMP)
577 gic_call_int_base = GIC_NUM_INTRS - NR_CPUS; 577 gic_call_int_base = GIC_NUM_INTRS -
578 gic_resched_int_base = gic_call_int_base - NR_CPUS; 578 (NR_CPUS - nr_cpu_ids) * 2 - nr_cpu_ids;
579 gic_resched_int_base = gic_call_int_base - nr_cpu_ids;
579 fill_ipi_map(); 580 fill_ipi_map();
580#endif 581#endif
581 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map, 582 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map,
@@ -599,7 +600,7 @@ void __init arch_init_irq(void)
599 printk("CPU%d: status register now %08x\n", smp_processor_id(), read_c0_status()); 600 printk("CPU%d: status register now %08x\n", smp_processor_id(), read_c0_status());
600 write_c0_status(0x1100dc00); 601 write_c0_status(0x1100dc00);
601 printk("CPU%d: status register frc %08x\n", smp_processor_id(), read_c0_status()); 602 printk("CPU%d: status register frc %08x\n", smp_processor_id(), read_c0_status());
602 for (i = 0; i < NR_CPUS; i++) { 603 for (i = 0; i < nr_cpu_ids; i++) {
603 arch_init_ipiirq(MIPS_GIC_IRQ_BASE + 604 arch_init_ipiirq(MIPS_GIC_IRQ_BASE +
604 GIC_RESCHED_INT(i), &irq_resched); 605 GIC_RESCHED_INT(i), &irq_resched);
605 arch_init_ipiirq(MIPS_GIC_IRQ_BASE + 606 arch_init_ipiirq(MIPS_GIC_IRQ_BASE +
diff --git a/arch/mips/ralink/timer.c b/arch/mips/ralink/timer.c
index e49241a2c39a..202785709441 100644
--- a/arch/mips/ralink/timer.c
+++ b/arch/mips/ralink/timer.c
@@ -126,7 +126,7 @@ static int rt_timer_probe(struct platform_device *pdev)
126 return -ENOENT; 126 return -ENOENT;
127 } 127 }
128 128
129 rt->membase = devm_request_and_ioremap(&pdev->dev, res); 129 rt->membase = devm_ioremap_resource(&pdev->dev, res);
130 if (IS_ERR(rt->membase)) 130 if (IS_ERR(rt->membase))
131 return PTR_ERR(rt->membase); 131 return PTR_ERR(rt->membase);
132 132
diff --git a/arch/um/kernel/exitcode.c b/arch/um/kernel/exitcode.c
index 829df49dee99..41ebbfebb333 100644
--- a/arch/um/kernel/exitcode.c
+++ b/arch/um/kernel/exitcode.c
@@ -40,9 +40,11 @@ static ssize_t exitcode_proc_write(struct file *file,
40 const char __user *buffer, size_t count, loff_t *pos) 40 const char __user *buffer, size_t count, loff_t *pos)
41{ 41{
42 char *end, buf[sizeof("nnnnn\0")]; 42 char *end, buf[sizeof("nnnnn\0")];
43 size_t size;
43 int tmp; 44 int tmp;
44 45
45 if (copy_from_user(buf, buffer, count)) 46 size = min(count, sizeof(buf));
47 if (copy_from_user(buf, buffer, size))
46 return -EFAULT; 48 return -EFAULT;
47 49
48 tmp = simple_strtol(buf, &end, 0); 50 tmp = simple_strtol(buf, &end, 0);
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 0da5200ee79d..b3e18f800302 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -128,7 +128,8 @@ do { \
128do { \ 128do { \
129 typedef typeof(var) pao_T__; \ 129 typedef typeof(var) pao_T__; \
130 const int pao_ID__ = (__builtin_constant_p(val) && \ 130 const int pao_ID__ = (__builtin_constant_p(val) && \
131 ((val) == 1 || (val) == -1)) ? (val) : 0; \ 131 ((val) == 1 || (val) == -1)) ? \
132 (int)(val) : 0; \
132 if (0) { \ 133 if (0) { \
133 pao_T__ pao_tmp__; \ 134 pao_T__ pao_tmp__; \
134 pao_tmp__ = (val); \ 135 pao_tmp__ = (val); \
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 9d8449158cf9..8a87a3224121 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1276,16 +1276,16 @@ void perf_events_lapic_init(void)
1276static int __kprobes 1276static int __kprobes
1277perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs) 1277perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs)
1278{ 1278{
1279 int ret;
1280 u64 start_clock; 1279 u64 start_clock;
1281 u64 finish_clock; 1280 u64 finish_clock;
1281 int ret;
1282 1282
1283 if (!atomic_read(&active_events)) 1283 if (!atomic_read(&active_events))
1284 return NMI_DONE; 1284 return NMI_DONE;
1285 1285
1286 start_clock = local_clock(); 1286 start_clock = sched_clock();
1287 ret = x86_pmu.handle_irq(regs); 1287 ret = x86_pmu.handle_irq(regs);
1288 finish_clock = local_clock(); 1288 finish_clock = sched_clock();
1289 1289
1290 perf_sample_event_took(finish_clock - start_clock); 1290 perf_sample_event_took(finish_clock - start_clock);
1291 1291
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index a0e2a8a80c94..b2046e4d0b59 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -609,7 +609,7 @@ static struct dentry *d_kvm_debug;
609 609
610struct dentry *kvm_init_debugfs(void) 610struct dentry *kvm_init_debugfs(void)
611{ 611{
612 d_kvm_debug = debugfs_create_dir("kvm", NULL); 612 d_kvm_debug = debugfs_create_dir("kvm-guest", NULL);
613 if (!d_kvm_debug) 613 if (!d_kvm_debug)
614 printk(KERN_WARNING "Could not create 'kvm' debugfs directory\n"); 614 printk(KERN_WARNING "Could not create 'kvm' debugfs directory\n");
615 615
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index ba77ebc2c353..6fcb49ce50a1 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -113,10 +113,10 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
113 u64 before, delta, whole_msecs; 113 u64 before, delta, whole_msecs;
114 int remainder_ns, decimal_msecs, thishandled; 114 int remainder_ns, decimal_msecs, thishandled;
115 115
116 before = local_clock(); 116 before = sched_clock();
117 thishandled = a->handler(type, regs); 117 thishandled = a->handler(type, regs);
118 handled += thishandled; 118 handled += thishandled;
119 delta = local_clock() - before; 119 delta = sched_clock() - before;
120 trace_nmi_handler(a->handler, (int)delta, thishandled); 120 trace_nmi_handler(a->handler, (int)delta, thishandled);
121 121
122 if (delta < nmi_longest_ns) 122 if (delta < nmi_longest_ns)
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index de1dfa18d0a1..21dbe6bdb8ed 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -1122,7 +1122,7 @@ ENDPROC(fast_syscall_spill_registers)
1122 * a3: exctable, original value in excsave1 1122 * a3: exctable, original value in excsave1
1123 */ 1123 */
1124 1124
1125fast_syscall_spill_registers_fixup: 1125ENTRY(fast_syscall_spill_registers_fixup)
1126 1126
1127 rsr a2, windowbase # get current windowbase (a2 is saved) 1127 rsr a2, windowbase # get current windowbase (a2 is saved)
1128 xsr a0, depc # restore depc and a0 1128 xsr a0, depc # restore depc and a0
@@ -1134,22 +1134,26 @@ fast_syscall_spill_registers_fixup:
1134 */ 1134 */
1135 1135
1136 xsr a3, excsave1 # get spill-mask 1136 xsr a3, excsave1 # get spill-mask
1137 slli a2, a3, 1 # shift left by one 1137 slli a3, a3, 1 # shift left by one
1138 1138
1139 slli a3, a2, 32-WSBITS 1139 slli a2, a3, 32-WSBITS
1140 src a2, a2, a3 # a1 = xxwww1yyxxxwww1yy...... 1140 src a2, a3, a2 # a2 = xxwww1yyxxxwww1yy......
1141 wsr a2, windowstart # set corrected windowstart 1141 wsr a2, windowstart # set corrected windowstart
1142 1142
1143 rsr a3, excsave1 1143 srli a3, a3, 1
1144 l32i a2, a3, EXC_TABLE_DOUBLE_SAVE # restore a2 1144 rsr a2, excsave1
1145 l32i a3, a3, EXC_TABLE_PARAM # original WB (in user task) 1145 l32i a2, a2, EXC_TABLE_DOUBLE_SAVE # restore a2
1146 xsr a2, excsave1
1147 s32i a3, a2, EXC_TABLE_DOUBLE_SAVE # save a3
1148 l32i a3, a2, EXC_TABLE_PARAM # original WB (in user task)
1149 xsr a2, excsave1
1146 1150
1147 /* Return to the original (user task) WINDOWBASE. 1151 /* Return to the original (user task) WINDOWBASE.
1148 * We leave the following frame behind: 1152 * We leave the following frame behind:
1149 * a0, a1, a2 same 1153 * a0, a1, a2 same
1150 * a3: trashed (saved in excsave_1) 1154 * a3: trashed (saved in EXC_TABLE_DOUBLE_SAVE)
1151 * depc: depc (we have to return to that address) 1155 * depc: depc (we have to return to that address)
1152 * excsave_1: a3 1156 * excsave_1: exctable
1153 */ 1157 */
1154 1158
1155 wsr a3, windowbase 1159 wsr a3, windowbase
@@ -1159,9 +1163,9 @@ fast_syscall_spill_registers_fixup:
1159 * a0: return address 1163 * a0: return address
1160 * a1: used, stack pointer 1164 * a1: used, stack pointer
1161 * a2: kernel stack pointer 1165 * a2: kernel stack pointer
1162 * a3: available, saved in EXCSAVE_1 1166 * a3: available
1163 * depc: exception address 1167 * depc: exception address
1164 * excsave: a3 1168 * excsave: exctable
1165 * Note: This frame might be the same as above. 1169 * Note: This frame might be the same as above.
1166 */ 1170 */
1167 1171
@@ -1181,9 +1185,12 @@ fast_syscall_spill_registers_fixup:
1181 rsr a0, exccause 1185 rsr a0, exccause
1182 addx4 a0, a0, a3 # find entry in table 1186 addx4 a0, a0, a3 # find entry in table
1183 l32i a0, a0, EXC_TABLE_FAST_USER # load handler 1187 l32i a0, a0, EXC_TABLE_FAST_USER # load handler
1188 l32i a3, a3, EXC_TABLE_DOUBLE_SAVE
1184 jx a0 1189 jx a0
1185 1190
1186fast_syscall_spill_registers_fixup_return: 1191ENDPROC(fast_syscall_spill_registers_fixup)
1192
1193ENTRY(fast_syscall_spill_registers_fixup_return)
1187 1194
1188 /* When we return here, all registers have been restored (a2: DEPC) */ 1195 /* When we return here, all registers have been restored (a2: DEPC) */
1189 1196
@@ -1191,13 +1198,13 @@ fast_syscall_spill_registers_fixup_return:
1191 1198
1192 /* Restore fixup handler. */ 1199 /* Restore fixup handler. */
1193 1200
1194 xsr a3, excsave1 1201 rsr a2, excsave1
1195 movi a2, fast_syscall_spill_registers_fixup 1202 s32i a3, a2, EXC_TABLE_DOUBLE_SAVE
1196 s32i a2, a3, EXC_TABLE_FIXUP 1203 movi a3, fast_syscall_spill_registers_fixup
1197 s32i a0, a3, EXC_TABLE_DOUBLE_SAVE 1204 s32i a3, a2, EXC_TABLE_FIXUP
1198 rsr a2, windowbase 1205 rsr a3, windowbase
1199 s32i a2, a3, EXC_TABLE_PARAM 1206 s32i a3, a2, EXC_TABLE_PARAM
1200 l32i a2, a3, EXC_TABLE_KSTK 1207 l32i a2, a2, EXC_TABLE_KSTK
1201 1208
1202 /* Load WB at the time the exception occurred. */ 1209 /* Load WB at the time the exception occurred. */
1203 1210
@@ -1206,8 +1213,12 @@ fast_syscall_spill_registers_fixup_return:
1206 wsr a3, windowbase 1213 wsr a3, windowbase
1207 rsync 1214 rsync
1208 1215
1216 rsr a3, excsave1
1217 l32i a3, a3, EXC_TABLE_DOUBLE_SAVE
1218
1209 rfde 1219 rfde
1210 1220
1221ENDPROC(fast_syscall_spill_registers_fixup_return)
1211 1222
1212/* 1223/*
1213 * spill all registers. 1224 * spill all registers.
diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c
index 718eca1850bd..98b67d5f1514 100644
--- a/arch/xtensa/kernel/signal.c
+++ b/arch/xtensa/kernel/signal.c
@@ -341,7 +341,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
341 341
342 sp = regs->areg[1]; 342 sp = regs->areg[1];
343 343
344 if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp)) { 344 if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && sas_ss_flags(sp) == 0) {
345 sp = current->sas_ss_sp + current->sas_ss_size; 345 sp = current->sas_ss_sp + current->sas_ss_size;
346 } 346 }
347 347
diff --git a/arch/xtensa/platforms/iss/network.c b/arch/xtensa/platforms/iss/network.c
index 56f88b7afe2f..e9e1aad8c271 100644
--- a/arch/xtensa/platforms/iss/network.c
+++ b/arch/xtensa/platforms/iss/network.c
@@ -737,7 +737,8 @@ static int __init iss_net_setup(char *str)
737 return 1; 737 return 1;
738 } 738 }
739 739
740 if ((new = alloc_bootmem(sizeof new)) == NULL) { 740 new = alloc_bootmem(sizeof(*new));
741 if (new == NULL) {
741 printk("Alloc_bootmem failed\n"); 742 printk("Alloc_bootmem failed\n");
742 return 1; 743 return 1;
743 } 744 }
diff --git a/drivers/clk/clk-nomadik.c b/drivers/clk/clk-nomadik.c
index 51410c2ac2cb..4d978a3c88f7 100644
--- a/drivers/clk/clk-nomadik.c
+++ b/drivers/clk/clk-nomadik.c
@@ -27,6 +27,14 @@
27 */ 27 */
28 28
29#define SRC_CR 0x00U 29#define SRC_CR 0x00U
30#define SRC_CR_T0_ENSEL BIT(15)
31#define SRC_CR_T1_ENSEL BIT(17)
32#define SRC_CR_T2_ENSEL BIT(19)
33#define SRC_CR_T3_ENSEL BIT(21)
34#define SRC_CR_T4_ENSEL BIT(23)
35#define SRC_CR_T5_ENSEL BIT(25)
36#define SRC_CR_T6_ENSEL BIT(27)
37#define SRC_CR_T7_ENSEL BIT(29)
30#define SRC_XTALCR 0x0CU 38#define SRC_XTALCR 0x0CU
31#define SRC_XTALCR_XTALTIMEN BIT(20) 39#define SRC_XTALCR_XTALTIMEN BIT(20)
32#define SRC_XTALCR_SXTALDIS BIT(19) 40#define SRC_XTALCR_SXTALDIS BIT(19)
@@ -543,6 +551,19 @@ void __init nomadik_clk_init(void)
543 __func__, np->name); 551 __func__, np->name);
544 return; 552 return;
545 } 553 }
554
555 /* Set all timers to use the 2.4 MHz TIMCLK */
556 val = readl(src_base + SRC_CR);
557 val |= SRC_CR_T0_ENSEL;
558 val |= SRC_CR_T1_ENSEL;
559 val |= SRC_CR_T2_ENSEL;
560 val |= SRC_CR_T3_ENSEL;
561 val |= SRC_CR_T4_ENSEL;
562 val |= SRC_CR_T5_ENSEL;
563 val |= SRC_CR_T6_ENSEL;
564 val |= SRC_CR_T7_ENSEL;
565 writel(val, src_base + SRC_CR);
566
546 val = readl(src_base + SRC_XTALCR); 567 val = readl(src_base + SRC_XTALCR);
547 pr_info("SXTALO is %s\n", 568 pr_info("SXTALO is %s\n",
548 (val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled"); 569 (val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled");
diff --git a/drivers/clk/mvebu/armada-370.c b/drivers/clk/mvebu/armada-370.c
index fc777bdc1886..81a202d12a7a 100644
--- a/drivers/clk/mvebu/armada-370.c
+++ b/drivers/clk/mvebu/armada-370.c
@@ -39,8 +39,8 @@ static const struct coreclk_ratio a370_coreclk_ratios[] __initconst = {
39}; 39};
40 40
41static const u32 a370_tclk_freqs[] __initconst = { 41static const u32 a370_tclk_freqs[] __initconst = {
42 16600000, 42 166000000,
43 20000000, 43 200000000,
44}; 44};
45 45
46static u32 __init a370_get_tclk_freq(void __iomem *sar) 46static u32 __init a370_get_tclk_freq(void __iomem *sar)
diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
index 5bb848cac6ec..81dd31a686df 100644
--- a/drivers/clk/socfpga/clk.c
+++ b/drivers/clk/socfpga/clk.c
@@ -49,7 +49,7 @@
49#define SOCFPGA_L4_SP_CLK "l4_sp_clk" 49#define SOCFPGA_L4_SP_CLK "l4_sp_clk"
50#define SOCFPGA_NAND_CLK "nand_clk" 50#define SOCFPGA_NAND_CLK "nand_clk"
51#define SOCFPGA_NAND_X_CLK "nand_x_clk" 51#define SOCFPGA_NAND_X_CLK "nand_x_clk"
52#define SOCFPGA_MMC_CLK "mmc_clk" 52#define SOCFPGA_MMC_CLK "sdmmc_clk"
53#define SOCFPGA_DB_CLK "gpio_db_clk" 53#define SOCFPGA_DB_CLK "gpio_db_clk"
54 54
55#define div_mask(width) ((1 << (width)) - 1) 55#define div_mask(width) ((1 << (width)) - 1)
diff --git a/drivers/clk/versatile/clk-icst.c b/drivers/clk/versatile/clk-icst.c
index 67ccf4aa7277..f5e4c21b301f 100644
--- a/drivers/clk/versatile/clk-icst.c
+++ b/drivers/clk/versatile/clk-icst.c
@@ -107,7 +107,7 @@ static int icst_set_rate(struct clk_hw *hw, unsigned long rate,
107 107
108 vco = icst_hz_to_vco(icst->params, rate); 108 vco = icst_hz_to_vco(icst->params, rate);
109 icst->rate = icst_hz(icst->params, vco); 109 icst->rate = icst_hz(icst->params, vco);
110 vco_set(icst->vcoreg, icst->lockreg, vco); 110 vco_set(icst->lockreg, icst->vcoreg, vco);
111 return 0; 111 return 0;
112} 112}
113 113
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 05ad9ba0a67e..fe58d0833a11 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -61,7 +61,7 @@ static int drm_version(struct drm_device *dev, void *data,
61 61
62/** Ioctl table */ 62/** Ioctl table */
63static const struct drm_ioctl_desc drm_ioctls[] = { 63static const struct drm_ioctl_desc drm_ioctls[] = {
64 DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_UNLOCKED), 64 DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_UNLOCKED|DRM_RENDER_ALLOW),
65 DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), 65 DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
66 DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), 66 DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
67 DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY), 67 DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY),
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index ea9022ef15d5..10d1de5bce6f 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -83,8 +83,7 @@ static bool intel_crt_get_hw_state(struct intel_encoder *encoder,
83 return true; 83 return true;
84} 84}
85 85
86static void intel_crt_get_config(struct intel_encoder *encoder, 86static unsigned int intel_crt_get_flags(struct intel_encoder *encoder)
87 struct intel_crtc_config *pipe_config)
88{ 87{
89 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; 88 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
90 struct intel_crt *crt = intel_encoder_to_crt(encoder); 89 struct intel_crt *crt = intel_encoder_to_crt(encoder);
@@ -102,7 +101,25 @@ static void intel_crt_get_config(struct intel_encoder *encoder,
102 else 101 else
103 flags |= DRM_MODE_FLAG_NVSYNC; 102 flags |= DRM_MODE_FLAG_NVSYNC;
104 103
105 pipe_config->adjusted_mode.flags |= flags; 104 return flags;
105}
106
107static void intel_crt_get_config(struct intel_encoder *encoder,
108 struct intel_crtc_config *pipe_config)
109{
110 pipe_config->adjusted_mode.flags |= intel_crt_get_flags(encoder);
111}
112
113static void hsw_crt_get_config(struct intel_encoder *encoder,
114 struct intel_crtc_config *pipe_config)
115{
116 intel_ddi_get_config(encoder, pipe_config);
117
118 pipe_config->adjusted_mode.flags &= ~(DRM_MODE_FLAG_PHSYNC |
119 DRM_MODE_FLAG_NHSYNC |
120 DRM_MODE_FLAG_PVSYNC |
121 DRM_MODE_FLAG_NVSYNC);
122 pipe_config->adjusted_mode.flags |= intel_crt_get_flags(encoder);
106} 123}
107 124
108/* Note: The caller is required to filter out dpms modes not supported by the 125/* Note: The caller is required to filter out dpms modes not supported by the
@@ -799,7 +816,10 @@ void intel_crt_init(struct drm_device *dev)
799 crt->base.mode_set = intel_crt_mode_set; 816 crt->base.mode_set = intel_crt_mode_set;
800 crt->base.disable = intel_disable_crt; 817 crt->base.disable = intel_disable_crt;
801 crt->base.enable = intel_enable_crt; 818 crt->base.enable = intel_enable_crt;
802 crt->base.get_config = intel_crt_get_config; 819 if (IS_HASWELL(dev))
820 crt->base.get_config = hsw_crt_get_config;
821 else
822 crt->base.get_config = intel_crt_get_config;
803 if (I915_HAS_HOTPLUG(dev)) 823 if (I915_HAS_HOTPLUG(dev))
804 crt->base.hpd_pin = HPD_CRT; 824 crt->base.hpd_pin = HPD_CRT;
805 if (HAS_DDI(dev)) 825 if (HAS_DDI(dev))
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 63de2701b974..b53fff84a7d5 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1249,8 +1249,8 @@ static void intel_ddi_hot_plug(struct intel_encoder *intel_encoder)
1249 intel_dp_check_link_status(intel_dp); 1249 intel_dp_check_link_status(intel_dp);
1250} 1250}
1251 1251
1252static void intel_ddi_get_config(struct intel_encoder *encoder, 1252void intel_ddi_get_config(struct intel_encoder *encoder,
1253 struct intel_crtc_config *pipe_config) 1253 struct intel_crtc_config *pipe_config)
1254{ 1254{
1255 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; 1255 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
1256 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc); 1256 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
@@ -1268,6 +1268,23 @@ static void intel_ddi_get_config(struct intel_encoder *encoder,
1268 flags |= DRM_MODE_FLAG_NVSYNC; 1268 flags |= DRM_MODE_FLAG_NVSYNC;
1269 1269
1270 pipe_config->adjusted_mode.flags |= flags; 1270 pipe_config->adjusted_mode.flags |= flags;
1271
1272 switch (temp & TRANS_DDI_BPC_MASK) {
1273 case TRANS_DDI_BPC_6:
1274 pipe_config->pipe_bpp = 18;
1275 break;
1276 case TRANS_DDI_BPC_8:
1277 pipe_config->pipe_bpp = 24;
1278 break;
1279 case TRANS_DDI_BPC_10:
1280 pipe_config->pipe_bpp = 30;
1281 break;
1282 case TRANS_DDI_BPC_12:
1283 pipe_config->pipe_bpp = 36;
1284 break;
1285 default:
1286 break;
1287 }
1271} 1288}
1272 1289
1273static void intel_ddi_destroy(struct drm_encoder *encoder) 1290static void intel_ddi_destroy(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 581fb4b2f766..d78d33f9337d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2327,9 +2327,10 @@ static void intel_fdi_normal_train(struct drm_crtc *crtc)
2327 FDI_FE_ERRC_ENABLE); 2327 FDI_FE_ERRC_ENABLE);
2328} 2328}
2329 2329
2330static bool pipe_has_enabled_pch(struct intel_crtc *intel_crtc) 2330static bool pipe_has_enabled_pch(struct intel_crtc *crtc)
2331{ 2331{
2332 return intel_crtc->base.enabled && intel_crtc->config.has_pch_encoder; 2332 return crtc->base.enabled && crtc->active &&
2333 crtc->config.has_pch_encoder;
2333} 2334}
2334 2335
2335static void ivb_modeset_global_resources(struct drm_device *dev) 2336static void ivb_modeset_global_resources(struct drm_device *dev)
@@ -2979,6 +2980,48 @@ static void ironlake_pch_transcoder_set_timings(struct intel_crtc *crtc,
2979 I915_READ(VSYNCSHIFT(cpu_transcoder))); 2980 I915_READ(VSYNCSHIFT(cpu_transcoder)));
2980} 2981}
2981 2982
2983static void cpt_enable_fdi_bc_bifurcation(struct drm_device *dev)
2984{
2985 struct drm_i915_private *dev_priv = dev->dev_private;
2986 uint32_t temp;
2987
2988 temp = I915_READ(SOUTH_CHICKEN1);
2989 if (temp & FDI_BC_BIFURCATION_SELECT)
2990 return;
2991
2992 WARN_ON(I915_READ(FDI_RX_CTL(PIPE_B)) & FDI_RX_ENABLE);
2993 WARN_ON(I915_READ(FDI_RX_CTL(PIPE_C)) & FDI_RX_ENABLE);
2994
2995 temp |= FDI_BC_BIFURCATION_SELECT;
2996 DRM_DEBUG_KMS("enabling fdi C rx\n");
2997 I915_WRITE(SOUTH_CHICKEN1, temp);
2998 POSTING_READ(SOUTH_CHICKEN1);
2999}
3000
3001static void ivybridge_update_fdi_bc_bifurcation(struct intel_crtc *intel_crtc)
3002{
3003 struct drm_device *dev = intel_crtc->base.dev;
3004 struct drm_i915_private *dev_priv = dev->dev_private;
3005
3006 switch (intel_crtc->pipe) {
3007 case PIPE_A:
3008 break;
3009 case PIPE_B:
3010 if (intel_crtc->config.fdi_lanes > 2)
3011 WARN_ON(I915_READ(SOUTH_CHICKEN1) & FDI_BC_BIFURCATION_SELECT);
3012 else
3013 cpt_enable_fdi_bc_bifurcation(dev);
3014
3015 break;
3016 case PIPE_C:
3017 cpt_enable_fdi_bc_bifurcation(dev);
3018
3019 break;
3020 default:
3021 BUG();
3022 }
3023}
3024
2982/* 3025/*
2983 * Enable PCH resources required for PCH ports: 3026 * Enable PCH resources required for PCH ports:
2984 * - PCH PLLs 3027 * - PCH PLLs
@@ -2997,6 +3040,9 @@ static void ironlake_pch_enable(struct drm_crtc *crtc)
2997 3040
2998 assert_pch_transcoder_disabled(dev_priv, pipe); 3041 assert_pch_transcoder_disabled(dev_priv, pipe);
2999 3042
3043 if (IS_IVYBRIDGE(dev))
3044 ivybridge_update_fdi_bc_bifurcation(intel_crtc);
3045
3000 /* Write the TU size bits before fdi link training, so that error 3046 /* Write the TU size bits before fdi link training, so that error
3001 * detection works. */ 3047 * detection works. */
3002 I915_WRITE(FDI_RX_TUSIZE1(pipe), 3048 I915_WRITE(FDI_RX_TUSIZE1(pipe),
@@ -4983,6 +5029,22 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
4983 if (!(tmp & PIPECONF_ENABLE)) 5029 if (!(tmp & PIPECONF_ENABLE))
4984 return false; 5030 return false;
4985 5031
5032 if (IS_G4X(dev) || IS_VALLEYVIEW(dev)) {
5033 switch (tmp & PIPECONF_BPC_MASK) {
5034 case PIPECONF_6BPC:
5035 pipe_config->pipe_bpp = 18;
5036 break;
5037 case PIPECONF_8BPC:
5038 pipe_config->pipe_bpp = 24;
5039 break;
5040 case PIPECONF_10BPC:
5041 pipe_config->pipe_bpp = 30;
5042 break;
5043 default:
5044 break;
5045 }
5046 }
5047
4986 intel_get_pipe_timings(crtc, pipe_config); 5048 intel_get_pipe_timings(crtc, pipe_config);
4987 5049
4988 i9xx_get_pfit_config(crtc, pipe_config); 5050 i9xx_get_pfit_config(crtc, pipe_config);
@@ -5576,48 +5638,6 @@ static bool ironlake_compute_clocks(struct drm_crtc *crtc,
5576 return true; 5638 return true;
5577} 5639}
5578 5640
5579static void cpt_enable_fdi_bc_bifurcation(struct drm_device *dev)
5580{
5581 struct drm_i915_private *dev_priv = dev->dev_private;
5582 uint32_t temp;
5583
5584 temp = I915_READ(SOUTH_CHICKEN1);
5585 if (temp & FDI_BC_BIFURCATION_SELECT)
5586 return;
5587
5588 WARN_ON(I915_READ(FDI_RX_CTL(PIPE_B)) & FDI_RX_ENABLE);
5589 WARN_ON(I915_READ(FDI_RX_CTL(PIPE_C)) & FDI_RX_ENABLE);
5590
5591 temp |= FDI_BC_BIFURCATION_SELECT;
5592 DRM_DEBUG_KMS("enabling fdi C rx\n");
5593 I915_WRITE(SOUTH_CHICKEN1, temp);
5594 POSTING_READ(SOUTH_CHICKEN1);
5595}
5596
5597static void ivybridge_update_fdi_bc_bifurcation(struct intel_crtc *intel_crtc)
5598{
5599 struct drm_device *dev = intel_crtc->base.dev;
5600 struct drm_i915_private *dev_priv = dev->dev_private;
5601
5602 switch (intel_crtc->pipe) {
5603 case PIPE_A:
5604 break;
5605 case PIPE_B:
5606 if (intel_crtc->config.fdi_lanes > 2)
5607 WARN_ON(I915_READ(SOUTH_CHICKEN1) & FDI_BC_BIFURCATION_SELECT);
5608 else
5609 cpt_enable_fdi_bc_bifurcation(dev);
5610
5611 break;
5612 case PIPE_C:
5613 cpt_enable_fdi_bc_bifurcation(dev);
5614
5615 break;
5616 default:
5617 BUG();
5618 }
5619}
5620
5621int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp) 5641int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp)
5622{ 5642{
5623 /* 5643 /*
@@ -5811,9 +5831,6 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5811 &intel_crtc->config.fdi_m_n); 5831 &intel_crtc->config.fdi_m_n);
5812 } 5832 }
5813 5833
5814 if (IS_IVYBRIDGE(dev))
5815 ivybridge_update_fdi_bc_bifurcation(intel_crtc);
5816
5817 ironlake_set_pipeconf(crtc); 5834 ironlake_set_pipeconf(crtc);
5818 5835
5819 /* Set up the display plane register */ 5836 /* Set up the display plane register */
@@ -5881,6 +5898,23 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
5881 if (!(tmp & PIPECONF_ENABLE)) 5898 if (!(tmp & PIPECONF_ENABLE))
5882 return false; 5899 return false;
5883 5900
5901 switch (tmp & PIPECONF_BPC_MASK) {
5902 case PIPECONF_6BPC:
5903 pipe_config->pipe_bpp = 18;
5904 break;
5905 case PIPECONF_8BPC:
5906 pipe_config->pipe_bpp = 24;
5907 break;
5908 case PIPECONF_10BPC:
5909 pipe_config->pipe_bpp = 30;
5910 break;
5911 case PIPECONF_12BPC:
5912 pipe_config->pipe_bpp = 36;
5913 break;
5914 default:
5915 break;
5916 }
5917
5884 if (I915_READ(PCH_TRANSCONF(crtc->pipe)) & TRANS_ENABLE) { 5918 if (I915_READ(PCH_TRANSCONF(crtc->pipe)) & TRANS_ENABLE) {
5885 struct intel_shared_dpll *pll; 5919 struct intel_shared_dpll *pll;
5886 5920
@@ -8612,6 +8646,9 @@ intel_pipe_config_compare(struct drm_device *dev,
8612 PIPE_CONF_CHECK_X(dpll_hw_state.fp0); 8646 PIPE_CONF_CHECK_X(dpll_hw_state.fp0);
8613 PIPE_CONF_CHECK_X(dpll_hw_state.fp1); 8647 PIPE_CONF_CHECK_X(dpll_hw_state.fp1);
8614 8648
8649 if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5)
8650 PIPE_CONF_CHECK_I(pipe_bpp);
8651
8615#undef PIPE_CONF_CHECK_X 8652#undef PIPE_CONF_CHECK_X
8616#undef PIPE_CONF_CHECK_I 8653#undef PIPE_CONF_CHECK_I
8617#undef PIPE_CONF_CHECK_FLAGS 8654#undef PIPE_CONF_CHECK_FLAGS
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 2c555f91bfae..1a431377d83b 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1401,6 +1401,26 @@ static void intel_dp_get_config(struct intel_encoder *encoder,
1401 else 1401 else
1402 pipe_config->port_clock = 270000; 1402 pipe_config->port_clock = 270000;
1403 } 1403 }
1404
1405 if (is_edp(intel_dp) && dev_priv->vbt.edp_bpp &&
1406 pipe_config->pipe_bpp > dev_priv->vbt.edp_bpp) {
1407 /*
1408 * This is a big fat ugly hack.
1409 *
1410 * Some machines in UEFI boot mode provide us a VBT that has 18
1411 * bpp and 1.62 GHz link bandwidth for eDP, which for reasons
1412 * unknown we fail to light up. Yet the same BIOS boots up with
1413 * 24 bpp and 2.7 GHz link. Use the same bpp as the BIOS uses as
1414 * max, not what it tells us to use.
1415 *
1416 * Note: This will still be broken if the eDP panel is not lit
1417 * up by the BIOS, and thus we can't get the mode at module
1418 * load.
1419 */
1420 DRM_DEBUG_KMS("pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n",
1421 pipe_config->pipe_bpp, dev_priv->vbt.edp_bpp);
1422 dev_priv->vbt.edp_bpp = pipe_config->pipe_bpp;
1423 }
1404} 1424}
1405 1425
1406static bool is_edp_psr(struct intel_dp *intel_dp) 1426static bool is_edp_psr(struct intel_dp *intel_dp)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 9b7b68fd5d47..7f2b384ac939 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -765,6 +765,8 @@ extern void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
765extern bool 765extern bool
766intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector); 766intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
767extern void intel_ddi_fdi_disable(struct drm_crtc *crtc); 767extern void intel_ddi_fdi_disable(struct drm_crtc *crtc);
768extern void intel_ddi_get_config(struct intel_encoder *encoder,
769 struct intel_crtc_config *pipe_config);
768 770
769extern void intel_display_handle_reset(struct drm_device *dev); 771extern void intel_display_handle_reset(struct drm_device *dev);
770extern bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev, 772extern bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 831a5c021c4b..b8af94a5be39 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -700,6 +700,22 @@ static const struct dmi_system_id intel_no_lvds[] = {
700 }, 700 },
701 { 701 {
702 .callback = intel_no_lvds_dmi_callback, 702 .callback = intel_no_lvds_dmi_callback,
703 .ident = "Intel D410PT",
704 .matches = {
705 DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
706 DMI_MATCH(DMI_BOARD_NAME, "D410PT"),
707 },
708 },
709 {
710 .callback = intel_no_lvds_dmi_callback,
711 .ident = "Intel D425KT",
712 .matches = {
713 DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
714 DMI_EXACT_MATCH(DMI_BOARD_NAME, "D425KT"),
715 },
716 },
717 {
718 .callback = intel_no_lvds_dmi_callback,
703 .ident = "Intel D510MO", 719 .ident = "Intel D510MO",
704 .matches = { 720 .matches = {
705 DMI_MATCH(DMI_BOARD_VENDOR, "Intel"), 721 DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
index fe1de855775e..57fcc4b16a52 100644
--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
+++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
@@ -291,6 +291,7 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
291 /* fglrx clears sth in AFMT_AUDIO_PACKET_CONTROL2 here */ 291 /* fglrx clears sth in AFMT_AUDIO_PACKET_CONTROL2 here */
292 292
293 WREG32(HDMI_ACR_PACKET_CONTROL + offset, 293 WREG32(HDMI_ACR_PACKET_CONTROL + offset,
294 HDMI_ACR_SOURCE | /* select SW CTS value */
294 HDMI_ACR_AUTO_SEND); /* allow hw to sent ACR packets when required */ 295 HDMI_ACR_AUTO_SEND); /* allow hw to sent ACR packets when required */
295 296
296 evergreen_hdmi_update_ACR(encoder, mode->clock); 297 evergreen_hdmi_update_ACR(encoder, mode->clock);
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c
index 71399065db04..b41905573cd2 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.c
+++ b/drivers/gpu/drm/radeon/kv_dpm.c
@@ -2635,7 +2635,7 @@ int kv_dpm_init(struct radeon_device *rdev)
2635 pi->caps_sclk_ds = true; 2635 pi->caps_sclk_ds = true;
2636 pi->enable_auto_thermal_throttling = true; 2636 pi->enable_auto_thermal_throttling = true;
2637 pi->disable_nb_ps3_in_battery = false; 2637 pi->disable_nb_ps3_in_battery = false;
2638 pi->bapm_enable = true; 2638 pi->bapm_enable = false;
2639 pi->voltage_drop_t = 0; 2639 pi->voltage_drop_t = 0;
2640 pi->caps_sclk_throttle_low_notification = false; 2640 pi->caps_sclk_throttle_low_notification = false;
2641 pi->caps_fps = false; /* true? */ 2641 pi->caps_fps = false; /* true? */
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index a400ac1c4147..24f4960f59ee 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1272,8 +1272,8 @@ struct radeon_blacklist_clocks
1272struct radeon_clock_and_voltage_limits { 1272struct radeon_clock_and_voltage_limits {
1273 u32 sclk; 1273 u32 sclk;
1274 u32 mclk; 1274 u32 mclk;
1275 u32 vddc; 1275 u16 vddc;
1276 u32 vddci; 1276 u16 vddci;
1277}; 1277};
1278 1278
1279struct radeon_clock_array { 1279struct radeon_clock_array {
diff --git a/drivers/input/input.c b/drivers/input/input.c
index c04469928925..e75d015024a1 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1734,6 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
1734 */ 1734 */
1735struct input_dev *input_allocate_device(void) 1735struct input_dev *input_allocate_device(void)
1736{ 1736{
1737 static atomic_t input_no = ATOMIC_INIT(0);
1737 struct input_dev *dev; 1738 struct input_dev *dev;
1738 1739
1739 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL); 1740 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
@@ -1743,9 +1744,13 @@ struct input_dev *input_allocate_device(void)
1743 device_initialize(&dev->dev); 1744 device_initialize(&dev->dev);
1744 mutex_init(&dev->mutex); 1745 mutex_init(&dev->mutex);
1745 spin_lock_init(&dev->event_lock); 1746 spin_lock_init(&dev->event_lock);
1747 init_timer(&dev->timer);
1746 INIT_LIST_HEAD(&dev->h_list); 1748 INIT_LIST_HEAD(&dev->h_list);
1747 INIT_LIST_HEAD(&dev->node); 1749 INIT_LIST_HEAD(&dev->node);
1748 1750
1751 dev_set_name(&dev->dev, "input%ld",
1752 (unsigned long) atomic_inc_return(&input_no) - 1);
1753
1749 __module_get(THIS_MODULE); 1754 __module_get(THIS_MODULE);
1750 } 1755 }
1751 1756
@@ -2019,7 +2024,6 @@ static void devm_input_device_unregister(struct device *dev, void *res)
2019 */ 2024 */
2020int input_register_device(struct input_dev *dev) 2025int input_register_device(struct input_dev *dev)
2021{ 2026{
2022 static atomic_t input_no = ATOMIC_INIT(0);
2023 struct input_devres *devres = NULL; 2027 struct input_devres *devres = NULL;
2024 struct input_handler *handler; 2028 struct input_handler *handler;
2025 unsigned int packet_size; 2029 unsigned int packet_size;
@@ -2059,7 +2063,6 @@ int input_register_device(struct input_dev *dev)
2059 * If delay and period are pre-set by the driver, then autorepeating 2063 * If delay and period are pre-set by the driver, then autorepeating
2060 * is handled by the driver itself and we don't do it in input.c. 2064 * is handled by the driver itself and we don't do it in input.c.
2061 */ 2065 */
2062 init_timer(&dev->timer);
2063 if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) { 2066 if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) {
2064 dev->timer.data = (long) dev; 2067 dev->timer.data = (long) dev;
2065 dev->timer.function = input_repeat_key; 2068 dev->timer.function = input_repeat_key;
@@ -2073,9 +2076,6 @@ int input_register_device(struct input_dev *dev)
2073 if (!dev->setkeycode) 2076 if (!dev->setkeycode)
2074 dev->setkeycode = input_default_setkeycode; 2077 dev->setkeycode = input_default_setkeycode;
2075 2078
2076 dev_set_name(&dev->dev, "input%ld",
2077 (unsigned long) atomic_inc_return(&input_no) - 1);
2078
2079 error = device_add(&dev->dev); 2079 error = device_add(&dev->dev);
2080 if (error) 2080 if (error)
2081 goto err_free_vals; 2081 goto err_free_vals;
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 134c3b404a54..a2e758d27584 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -786,10 +786,17 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
786 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 786 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
787 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 787 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
788 788
789 if (pdata) 789 if (pdata) {
790 error = pxa27x_keypad_build_keycode(keypad); 790 error = pxa27x_keypad_build_keycode(keypad);
791 else 791 } else {
792 error = pxa27x_keypad_build_keycode_from_dt(keypad); 792 error = pxa27x_keypad_build_keycode_from_dt(keypad);
793 /*
794 * Data that we get from DT resides in dynamically
795 * allocated memory so we need to update our pdata
796 * pointer.
797 */
798 pdata = keypad->pdata;
799 }
793 if (error) { 800 if (error) {
794 dev_err(&pdev->dev, "failed to build keycode\n"); 801 dev_err(&pdev->dev, "failed to build keycode\n");
795 goto failed_put_clk; 802 goto failed_put_clk;
diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
index 082684e7f390..9365535ba7f1 100644
--- a/drivers/input/misc/cm109.c
+++ b/drivers/input/misc/cm109.c
@@ -351,7 +351,9 @@ static void cm109_urb_irq_callback(struct urb *urb)
351 if (status) { 351 if (status) {
352 if (status == -ESHUTDOWN) 352 if (status == -ESHUTDOWN)
353 return; 353 return;
354 dev_err(&dev->intf->dev, "%s: urb status %d\n", __func__, status); 354 dev_err_ratelimited(&dev->intf->dev, "%s: urb status %d\n",
355 __func__, status);
356 goto out;
355 } 357 }
356 358
357 /* Special keys */ 359 /* Special keys */
@@ -418,8 +420,12 @@ static void cm109_urb_ctl_callback(struct urb *urb)
418 dev->ctl_data->byte[2], 420 dev->ctl_data->byte[2],
419 dev->ctl_data->byte[3]); 421 dev->ctl_data->byte[3]);
420 422
421 if (status) 423 if (status) {
422 dev_err(&dev->intf->dev, "%s: urb status %d\n", __func__, status); 424 if (status == -ESHUTDOWN)
425 return;
426 dev_err_ratelimited(&dev->intf->dev, "%s: urb status %d\n",
427 __func__, status);
428 }
423 429
424 spin_lock(&dev->ctl_submit_lock); 430 spin_lock(&dev->ctl_submit_lock);
425 431
@@ -427,7 +433,7 @@ static void cm109_urb_ctl_callback(struct urb *urb)
427 433
428 if (likely(!dev->shutdown)) { 434 if (likely(!dev->shutdown)) {
429 435
430 if (dev->buzzer_pending) { 436 if (dev->buzzer_pending || status) {
431 dev->buzzer_pending = 0; 437 dev->buzzer_pending = 0;
432 dev->ctl_urb_pending = 1; 438 dev->ctl_urb_pending = 1;
433 cm109_submit_buzz_toggle(dev); 439 cm109_submit_buzz_toggle(dev);
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 7c5d72a6a26a..83658472ad25 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -103,6 +103,7 @@ static const struct alps_model_info alps_model_data[] = {
103 /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ 103 /* Dell Latitude E5500, E6400, E6500, Precision M4400 */
104 { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, 104 { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf,
105 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, 105 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED },
106 { { 0x73, 0x00, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_DUALPOINT }, /* Dell XT2 */
106 { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ 107 { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */
107 { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, 108 { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff,
108 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ 109 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 78e4de42efaa..52c9ebf94729 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -223,21 +223,26 @@ static int i8042_flush(void)
223{ 223{
224 unsigned long flags; 224 unsigned long flags;
225 unsigned char data, str; 225 unsigned char data, str;
226 int i = 0; 226 int count = 0;
227 int retval = 0;
227 228
228 spin_lock_irqsave(&i8042_lock, flags); 229 spin_lock_irqsave(&i8042_lock, flags);
229 230
230 while (((str = i8042_read_status()) & I8042_STR_OBF) && (i < I8042_BUFFER_SIZE)) { 231 while ((str = i8042_read_status()) & I8042_STR_OBF) {
231 udelay(50); 232 if (count++ < I8042_BUFFER_SIZE) {
232 data = i8042_read_data(); 233 udelay(50);
233 i++; 234 data = i8042_read_data();
234 dbg("%02x <- i8042 (flush, %s)\n", 235 dbg("%02x <- i8042 (flush, %s)\n",
235 data, str & I8042_STR_AUXDATA ? "aux" : "kbd"); 236 data, str & I8042_STR_AUXDATA ? "aux" : "kbd");
237 } else {
238 retval = -EIO;
239 break;
240 }
236 } 241 }
237 242
238 spin_unlock_irqrestore(&i8042_lock, flags); 243 spin_unlock_irqrestore(&i8042_lock, flags);
239 244
240 return i; 245 return retval;
241} 246}
242 247
243/* 248/*
@@ -849,7 +854,7 @@ static int __init i8042_check_aux(void)
849 854
850static int i8042_controller_check(void) 855static int i8042_controller_check(void)
851{ 856{
852 if (i8042_flush() == I8042_BUFFER_SIZE) { 857 if (i8042_flush()) {
853 pr_err("No controller found\n"); 858 pr_err("No controller found\n");
854 return -ENODEV; 859 return -ENODEV;
855 } 860 }
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 79b69ea47f74..e53416a4d7f3 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -1031,6 +1031,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
1031} 1031}
1032 1032
1033static enum power_supply_property wacom_battery_props[] = { 1033static enum power_supply_property wacom_battery_props[] = {
1034 POWER_SUPPLY_PROP_SCOPE,
1034 POWER_SUPPLY_PROP_CAPACITY 1035 POWER_SUPPLY_PROP_CAPACITY
1035}; 1036};
1036 1037
@@ -1042,6 +1043,9 @@ static int wacom_battery_get_property(struct power_supply *psy,
1042 int ret = 0; 1043 int ret = 0;
1043 1044
1044 switch (psp) { 1045 switch (psp) {
1046 case POWER_SUPPLY_PROP_SCOPE:
1047 val->intval = POWER_SUPPLY_SCOPE_DEVICE;
1048 break;
1045 case POWER_SUPPLY_PROP_CAPACITY: 1049 case POWER_SUPPLY_PROP_CAPACITY:
1046 val->intval = 1050 val->intval =
1047 wacom->wacom_wac.battery_capacity * 100 / 31; 1051 wacom->wacom_wac.battery_capacity * 100 / 31;
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index b2aa503c16b1..c59b797eeafa 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -2054,6 +2054,12 @@ static const struct wacom_features wacom_features_0x101 =
2054static const struct wacom_features wacom_features_0x10D = 2054static const struct wacom_features wacom_features_0x10D =
2055 { "Wacom ISDv4 10D", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, 2055 { "Wacom ISDv4 10D", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
2056 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2056 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2057static const struct wacom_features wacom_features_0x10E =
2058 { "Wacom ISDv4 10E", WACOM_PKGLEN_MTTPC, 27760, 15694, 255,
2059 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2060static const struct wacom_features wacom_features_0x10F =
2061 { "Wacom ISDv4 10F", WACOM_PKGLEN_MTTPC, 27760, 15694, 255,
2062 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2057static const struct wacom_features wacom_features_0x4001 = 2063static const struct wacom_features wacom_features_0x4001 =
2058 { "Wacom ISDv4 4001", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, 2064 { "Wacom ISDv4 4001", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
2059 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2065 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2248,6 +2254,8 @@ const struct usb_device_id wacom_ids[] = {
2248 { USB_DEVICE_WACOM(0x100) }, 2254 { USB_DEVICE_WACOM(0x100) },
2249 { USB_DEVICE_WACOM(0x101) }, 2255 { USB_DEVICE_WACOM(0x101) },
2250 { USB_DEVICE_WACOM(0x10D) }, 2256 { USB_DEVICE_WACOM(0x10D) },
2257 { USB_DEVICE_WACOM(0x10E) },
2258 { USB_DEVICE_WACOM(0x10F) },
2251 { USB_DEVICE_WACOM(0x300) }, 2259 { USB_DEVICE_WACOM(0x300) },
2252 { USB_DEVICE_WACOM(0x301) }, 2260 { USB_DEVICE_WACOM(0x301) },
2253 { USB_DEVICE_WACOM(0x304) }, 2261 { USB_DEVICE_WACOM(0x304) },
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index be12fbfcae10..1ea75236a15f 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -552,9 +552,8 @@ static void __ref enable_slot(struct acpiphp_slot *slot)
552 struct acpiphp_func *func; 552 struct acpiphp_func *func;
553 int max, pass; 553 int max, pass;
554 LIST_HEAD(add_list); 554 LIST_HEAD(add_list);
555 int nr_found;
556 555
557 nr_found = acpiphp_rescan_slot(slot); 556 acpiphp_rescan_slot(slot);
558 max = acpiphp_max_busnr(bus); 557 max = acpiphp_max_busnr(bus);
559 for (pass = 0; pass < 2; pass++) { 558 for (pass = 0; pass < 2; pass++) {
560 list_for_each_entry(dev, &bus->devices, bus_list) { 559 list_for_each_entry(dev, &bus->devices, bus_list) {
@@ -574,9 +573,6 @@ static void __ref enable_slot(struct acpiphp_slot *slot)
574 } 573 }
575 } 574 }
576 __pci_bus_assign_resources(bus, &add_list, NULL); 575 __pci_bus_assign_resources(bus, &add_list, NULL);
577 /* Nothing more to do here if there are no new devices on this bus. */
578 if (!nr_found && (slot->flags & SLOT_ENABLED))
579 return;
580 576
581 acpiphp_sanitize_bus(bus); 577 acpiphp_sanitize_bus(bus);
582 acpiphp_set_hpp_values(bus); 578 acpiphp_set_hpp_values(bus);
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 408a42ef787a..f0d432c139d0 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -771,6 +771,8 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long
771static int aac_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) 771static int aac_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
772{ 772{
773 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata; 773 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
774 if (!capable(CAP_SYS_RAWIO))
775 return -EPERM;
774 return aac_compat_do_ioctl(dev, cmd, (unsigned long)arg); 776 return aac_compat_do_ioctl(dev, cmd, (unsigned long)arg);
775} 777}
776 778
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 5cbc4bb1b395..df5e961484e1 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -105,8 +105,11 @@ static int scatter_elem_sz_prev = SG_SCATTER_SZ;
105static int sg_add(struct device *, struct class_interface *); 105static int sg_add(struct device *, struct class_interface *);
106static void sg_remove(struct device *, struct class_interface *); 106static void sg_remove(struct device *, struct class_interface *);
107 107
108static DEFINE_SPINLOCK(sg_open_exclusive_lock);
109
108static DEFINE_IDR(sg_index_idr); 110static DEFINE_IDR(sg_index_idr);
109static DEFINE_RWLOCK(sg_index_lock); 111static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock
112 file descriptor list for device */
110 113
111static struct class_interface sg_interface = { 114static struct class_interface sg_interface = {
112 .add_dev = sg_add, 115 .add_dev = sg_add,
@@ -143,7 +146,8 @@ typedef struct sg_request { /* SG_MAX_QUEUE requests outstanding per file */
143} Sg_request; 146} Sg_request;
144 147
145typedef struct sg_fd { /* holds the state of a file descriptor */ 148typedef struct sg_fd { /* holds the state of a file descriptor */
146 struct list_head sfd_siblings; /* protected by sfd_lock of device */ 149 /* sfd_siblings is protected by sg_index_lock */
150 struct list_head sfd_siblings;
147 struct sg_device *parentdp; /* owning device */ 151 struct sg_device *parentdp; /* owning device */
148 wait_queue_head_t read_wait; /* queue read until command done */ 152 wait_queue_head_t read_wait; /* queue read until command done */
149 rwlock_t rq_list_lock; /* protect access to list in req_arr */ 153 rwlock_t rq_list_lock; /* protect access to list in req_arr */
@@ -166,12 +170,13 @@ typedef struct sg_fd { /* holds the state of a file descriptor */
166 170
167typedef struct sg_device { /* holds the state of each scsi generic device */ 171typedef struct sg_device { /* holds the state of each scsi generic device */
168 struct scsi_device *device; 172 struct scsi_device *device;
173 wait_queue_head_t o_excl_wait; /* queue open() when O_EXCL in use */
169 int sg_tablesize; /* adapter's max scatter-gather table size */ 174 int sg_tablesize; /* adapter's max scatter-gather table size */
170 u32 index; /* device index number */ 175 u32 index; /* device index number */
171 spinlock_t sfd_lock; /* protect file descriptor list for device */ 176 /* sfds is protected by sg_index_lock */
172 struct list_head sfds; 177 struct list_head sfds;
173 struct rw_semaphore o_sem; /* exclude open should hold this rwsem */
174 volatile char detached; /* 0->attached, 1->detached pending removal */ 178 volatile char detached; /* 0->attached, 1->detached pending removal */
179 /* exclude protected by sg_open_exclusive_lock */
175 char exclude; /* opened for exclusive access */ 180 char exclude; /* opened for exclusive access */
176 char sgdebug; /* 0->off, 1->sense, 9->dump dev, 10-> all devs */ 181 char sgdebug; /* 0->off, 1->sense, 9->dump dev, 10-> all devs */
177 struct gendisk *disk; 182 struct gendisk *disk;
@@ -220,14 +225,35 @@ static int sg_allow_access(struct file *filp, unsigned char *cmd)
220 return blk_verify_command(cmd, filp->f_mode & FMODE_WRITE); 225 return blk_verify_command(cmd, filp->f_mode & FMODE_WRITE);
221} 226}
222 227
228static int get_exclude(Sg_device *sdp)
229{
230 unsigned long flags;
231 int ret;
232
233 spin_lock_irqsave(&sg_open_exclusive_lock, flags);
234 ret = sdp->exclude;
235 spin_unlock_irqrestore(&sg_open_exclusive_lock, flags);
236 return ret;
237}
238
239static int set_exclude(Sg_device *sdp, char val)
240{
241 unsigned long flags;
242
243 spin_lock_irqsave(&sg_open_exclusive_lock, flags);
244 sdp->exclude = val;
245 spin_unlock_irqrestore(&sg_open_exclusive_lock, flags);
246 return val;
247}
248
223static int sfds_list_empty(Sg_device *sdp) 249static int sfds_list_empty(Sg_device *sdp)
224{ 250{
225 unsigned long flags; 251 unsigned long flags;
226 int ret; 252 int ret;
227 253
228 spin_lock_irqsave(&sdp->sfd_lock, flags); 254 read_lock_irqsave(&sg_index_lock, flags);
229 ret = list_empty(&sdp->sfds); 255 ret = list_empty(&sdp->sfds);
230 spin_unlock_irqrestore(&sdp->sfd_lock, flags); 256 read_unlock_irqrestore(&sg_index_lock, flags);
231 return ret; 257 return ret;
232} 258}
233 259
@@ -239,6 +265,7 @@ sg_open(struct inode *inode, struct file *filp)
239 struct request_queue *q; 265 struct request_queue *q;
240 Sg_device *sdp; 266 Sg_device *sdp;
241 Sg_fd *sfp; 267 Sg_fd *sfp;
268 int res;
242 int retval; 269 int retval;
243 270
244 nonseekable_open(inode, filp); 271 nonseekable_open(inode, filp);
@@ -267,52 +294,54 @@ sg_open(struct inode *inode, struct file *filp)
267 goto error_out; 294 goto error_out;
268 } 295 }
269 296
270 if ((flags & O_EXCL) && (O_RDONLY == (flags & O_ACCMODE))) { 297 if (flags & O_EXCL) {
271 retval = -EPERM; /* Can't lock it with read only access */ 298 if (O_RDONLY == (flags & O_ACCMODE)) {
272 goto error_out; 299 retval = -EPERM; /* Can't lock it with read only access */
273 } 300 goto error_out;
274 if (flags & O_NONBLOCK) { 301 }
275 if (flags & O_EXCL) { 302 if (!sfds_list_empty(sdp) && (flags & O_NONBLOCK)) {
276 if (!down_write_trylock(&sdp->o_sem)) { 303 retval = -EBUSY;
277 retval = -EBUSY; 304 goto error_out;
278 goto error_out; 305 }
279 } 306 res = wait_event_interruptible(sdp->o_excl_wait,
280 } else { 307 ((!sfds_list_empty(sdp) || get_exclude(sdp)) ? 0 : set_exclude(sdp, 1)));
281 if (!down_read_trylock(&sdp->o_sem)) { 308 if (res) {
282 retval = -EBUSY; 309 retval = res; /* -ERESTARTSYS because signal hit process */
283 goto error_out; 310 goto error_out;
284 } 311 }
312 } else if (get_exclude(sdp)) { /* some other fd has an exclusive lock on dev */
313 if (flags & O_NONBLOCK) {
314 retval = -EBUSY;
315 goto error_out;
316 }
317 res = wait_event_interruptible(sdp->o_excl_wait, !get_exclude(sdp));
318 if (res) {
319 retval = res; /* -ERESTARTSYS because signal hit process */
320 goto error_out;
285 } 321 }
286 } else {
287 if (flags & O_EXCL)
288 down_write(&sdp->o_sem);
289 else
290 down_read(&sdp->o_sem);
291 } 322 }
292 /* Since write lock is held, no need to check sfd_list */ 323 if (sdp->detached) {
293 if (flags & O_EXCL) 324 retval = -ENODEV;
294 sdp->exclude = 1; /* used by release lock */ 325 goto error_out;
295 326 }
296 if (sfds_list_empty(sdp)) { /* no existing opens on this device */ 327 if (sfds_list_empty(sdp)) { /* no existing opens on this device */
297 sdp->sgdebug = 0; 328 sdp->sgdebug = 0;
298 q = sdp->device->request_queue; 329 q = sdp->device->request_queue;
299 sdp->sg_tablesize = queue_max_segments(q); 330 sdp->sg_tablesize = queue_max_segments(q);
300 } 331 }
301 sfp = sg_add_sfp(sdp, dev); 332 if ((sfp = sg_add_sfp(sdp, dev)))
302 if (!IS_ERR(sfp))
303 filp->private_data = sfp; 333 filp->private_data = sfp;
304 /* retval is already provably zero at this point because of the
305 * check after retval = scsi_autopm_get_device(sdp->device))
306 */
307 else { 334 else {
308 retval = PTR_ERR(sfp);
309
310 if (flags & O_EXCL) { 335 if (flags & O_EXCL) {
311 sdp->exclude = 0; /* undo if error */ 336 set_exclude(sdp, 0); /* undo if error */
312 up_write(&sdp->o_sem); 337 wake_up_interruptible(&sdp->o_excl_wait);
313 } else 338 }
314 up_read(&sdp->o_sem); 339 retval = -ENOMEM;
340 goto error_out;
341 }
342 retval = 0;
315error_out: 343error_out:
344 if (retval) {
316 scsi_autopm_put_device(sdp->device); 345 scsi_autopm_put_device(sdp->device);
317sdp_put: 346sdp_put:
318 scsi_device_put(sdp->device); 347 scsi_device_put(sdp->device);
@@ -329,18 +358,13 @@ sg_release(struct inode *inode, struct file *filp)
329{ 358{
330 Sg_device *sdp; 359 Sg_device *sdp;
331 Sg_fd *sfp; 360 Sg_fd *sfp;
332 int excl;
333 361
334 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) 362 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
335 return -ENXIO; 363 return -ENXIO;
336 SCSI_LOG_TIMEOUT(3, printk("sg_release: %s\n", sdp->disk->disk_name)); 364 SCSI_LOG_TIMEOUT(3, printk("sg_release: %s\n", sdp->disk->disk_name));
337 365
338 excl = sdp->exclude; 366 set_exclude(sdp, 0);
339 sdp->exclude = 0; 367 wake_up_interruptible(&sdp->o_excl_wait);
340 if (excl)
341 up_write(&sdp->o_sem);
342 else
343 up_read(&sdp->o_sem);
344 368
345 scsi_autopm_put_device(sdp->device); 369 scsi_autopm_put_device(sdp->device);
346 kref_put(&sfp->f_ref, sg_remove_sfp); 370 kref_put(&sfp->f_ref, sg_remove_sfp);
@@ -1391,9 +1415,8 @@ static Sg_device *sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1391 disk->first_minor = k; 1415 disk->first_minor = k;
1392 sdp->disk = disk; 1416 sdp->disk = disk;
1393 sdp->device = scsidp; 1417 sdp->device = scsidp;
1394 spin_lock_init(&sdp->sfd_lock);
1395 INIT_LIST_HEAD(&sdp->sfds); 1418 INIT_LIST_HEAD(&sdp->sfds);
1396 init_rwsem(&sdp->o_sem); 1419 init_waitqueue_head(&sdp->o_excl_wait);
1397 sdp->sg_tablesize = queue_max_segments(q); 1420 sdp->sg_tablesize = queue_max_segments(q);
1398 sdp->index = k; 1421 sdp->index = k;
1399 kref_init(&sdp->d_ref); 1422 kref_init(&sdp->d_ref);
@@ -1526,13 +1549,11 @@ static void sg_remove(struct device *cl_dev, struct class_interface *cl_intf)
1526 1549
1527 /* Need a write lock to set sdp->detached. */ 1550 /* Need a write lock to set sdp->detached. */
1528 write_lock_irqsave(&sg_index_lock, iflags); 1551 write_lock_irqsave(&sg_index_lock, iflags);
1529 spin_lock(&sdp->sfd_lock);
1530 sdp->detached = 1; 1552 sdp->detached = 1;
1531 list_for_each_entry(sfp, &sdp->sfds, sfd_siblings) { 1553 list_for_each_entry(sfp, &sdp->sfds, sfd_siblings) {
1532 wake_up_interruptible(&sfp->read_wait); 1554 wake_up_interruptible(&sfp->read_wait);
1533 kill_fasync(&sfp->async_qp, SIGPOLL, POLL_HUP); 1555 kill_fasync(&sfp->async_qp, SIGPOLL, POLL_HUP);
1534 } 1556 }
1535 spin_unlock(&sdp->sfd_lock);
1536 write_unlock_irqrestore(&sg_index_lock, iflags); 1557 write_unlock_irqrestore(&sg_index_lock, iflags);
1537 1558
1538 sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic"); 1559 sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic");
@@ -2043,7 +2064,7 @@ sg_add_sfp(Sg_device * sdp, int dev)
2043 2064
2044 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); 2065 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN);
2045 if (!sfp) 2066 if (!sfp)
2046 return ERR_PTR(-ENOMEM); 2067 return NULL;
2047 2068
2048 init_waitqueue_head(&sfp->read_wait); 2069 init_waitqueue_head(&sfp->read_wait);
2049 rwlock_init(&sfp->rq_list_lock); 2070 rwlock_init(&sfp->rq_list_lock);
@@ -2057,13 +2078,9 @@ sg_add_sfp(Sg_device * sdp, int dev)
2057 sfp->cmd_q = SG_DEF_COMMAND_Q; 2078 sfp->cmd_q = SG_DEF_COMMAND_Q;
2058 sfp->keep_orphan = SG_DEF_KEEP_ORPHAN; 2079 sfp->keep_orphan = SG_DEF_KEEP_ORPHAN;
2059 sfp->parentdp = sdp; 2080 sfp->parentdp = sdp;
2060 spin_lock_irqsave(&sdp->sfd_lock, iflags); 2081 write_lock_irqsave(&sg_index_lock, iflags);
2061 if (sdp->detached) {
2062 spin_unlock_irqrestore(&sdp->sfd_lock, iflags);
2063 return ERR_PTR(-ENODEV);
2064 }
2065 list_add_tail(&sfp->sfd_siblings, &sdp->sfds); 2082 list_add_tail(&sfp->sfd_siblings, &sdp->sfds);
2066 spin_unlock_irqrestore(&sdp->sfd_lock, iflags); 2083 write_unlock_irqrestore(&sg_index_lock, iflags);
2067 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p\n", sfp)); 2084 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p\n", sfp));
2068 if (unlikely(sg_big_buff != def_reserved_size)) 2085 if (unlikely(sg_big_buff != def_reserved_size))
2069 sg_big_buff = def_reserved_size; 2086 sg_big_buff = def_reserved_size;
@@ -2113,9 +2130,10 @@ static void sg_remove_sfp(struct kref *kref)
2113 struct sg_device *sdp = sfp->parentdp; 2130 struct sg_device *sdp = sfp->parentdp;
2114 unsigned long iflags; 2131 unsigned long iflags;
2115 2132
2116 spin_lock_irqsave(&sdp->sfd_lock, iflags); 2133 write_lock_irqsave(&sg_index_lock, iflags);
2117 list_del(&sfp->sfd_siblings); 2134 list_del(&sfp->sfd_siblings);
2118 spin_unlock_irqrestore(&sdp->sfd_lock, iflags); 2135 write_unlock_irqrestore(&sg_index_lock, iflags);
2136 wake_up_interruptible(&sdp->o_excl_wait);
2119 2137
2120 INIT_WORK(&sfp->ew.work, sg_remove_sfp_usercontext); 2138 INIT_WORK(&sfp->ew.work, sg_remove_sfp_usercontext);
2121 schedule_work(&sfp->ew.work); 2139 schedule_work(&sfp->ew.work);
@@ -2502,7 +2520,7 @@ static int sg_proc_seq_show_devstrs(struct seq_file *s, void *v)
2502 return 0; 2520 return 0;
2503} 2521}
2504 2522
2505/* must be called while holding sg_index_lock and sfd_lock */ 2523/* must be called while holding sg_index_lock */
2506static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) 2524static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)
2507{ 2525{
2508 int k, m, new_interface, blen, usg; 2526 int k, m, new_interface, blen, usg;
@@ -2587,26 +2605,22 @@ static int sg_proc_seq_show_debug(struct seq_file *s, void *v)
2587 2605
2588 read_lock_irqsave(&sg_index_lock, iflags); 2606 read_lock_irqsave(&sg_index_lock, iflags);
2589 sdp = it ? sg_lookup_dev(it->index) : NULL; 2607 sdp = it ? sg_lookup_dev(it->index) : NULL;
2590 if (sdp) { 2608 if (sdp && !list_empty(&sdp->sfds)) {
2591 spin_lock(&sdp->sfd_lock); 2609 struct scsi_device *scsidp = sdp->device;
2592 if (!list_empty(&sdp->sfds)) {
2593 struct scsi_device *scsidp = sdp->device;
2594 2610
2595 seq_printf(s, " >>> device=%s ", sdp->disk->disk_name); 2611 seq_printf(s, " >>> device=%s ", sdp->disk->disk_name);
2596 if (sdp->detached) 2612 if (sdp->detached)
2597 seq_printf(s, "detached pending close "); 2613 seq_printf(s, "detached pending close ");
2598 else 2614 else
2599 seq_printf 2615 seq_printf
2600 (s, "scsi%d chan=%d id=%d lun=%d em=%d", 2616 (s, "scsi%d chan=%d id=%d lun=%d em=%d",
2601 scsidp->host->host_no, 2617 scsidp->host->host_no,
2602 scsidp->channel, scsidp->id, 2618 scsidp->channel, scsidp->id,
2603 scsidp->lun, 2619 scsidp->lun,
2604 scsidp->host->hostt->emulated); 2620 scsidp->host->hostt->emulated);
2605 seq_printf(s, " sg_tablesize=%d excl=%d\n", 2621 seq_printf(s, " sg_tablesize=%d excl=%d\n",
2606 sdp->sg_tablesize, sdp->exclude); 2622 sdp->sg_tablesize, get_exclude(sdp));
2607 sg_proc_debug_helper(s, sdp); 2623 sg_proc_debug_helper(s, sdp);
2608 }
2609 spin_unlock(&sdp->sfd_lock);
2610 } 2624 }
2611 read_unlock_irqrestore(&sg_index_lock, iflags); 2625 read_unlock_irqrestore(&sg_index_lock, iflags);
2612 return 0; 2626 return 0;
diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
index f91bc1fdd895..639ba96adb36 100644
--- a/drivers/staging/bcm/Bcmchar.c
+++ b/drivers/staging/bcm/Bcmchar.c
@@ -1960,6 +1960,7 @@ cntrlEnd:
1960 1960
1961 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); 1961 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n");
1962 1962
1963 memset(&DevInfo, 0, sizeof(DevInfo));
1963 DevInfo.MaxRDMBufferSize = BUFFER_4K; 1964 DevInfo.MaxRDMBufferSize = BUFFER_4K;
1964 DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START; 1965 DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START;
1965 DevInfo.u32RxAlignmentCorrection = 0; 1966 DevInfo.u32RxAlignmentCorrection = 0;
diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
index 6ccb64fb0786..6ce0af9977d8 100644
--- a/drivers/staging/ozwpan/ozcdev.c
+++ b/drivers/staging/ozwpan/ozcdev.c
@@ -155,6 +155,9 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf,
155 struct oz_app_hdr *app_hdr; 155 struct oz_app_hdr *app_hdr;
156 struct oz_serial_ctx *ctx; 156 struct oz_serial_ctx *ctx;
157 157
158 if (count > sizeof(ei->data) - sizeof(*elt) - sizeof(*app_hdr))
159 return -EINVAL;
160
158 spin_lock_bh(&g_cdev.lock); 161 spin_lock_bh(&g_cdev.lock);
159 pd = g_cdev.active_pd; 162 pd = g_cdev.active_pd;
160 if (pd) 163 if (pd)
diff --git a/drivers/staging/sb105x/sb_pci_mp.c b/drivers/staging/sb105x/sb_pci_mp.c
index 23db32f07fd5..a10cdb17038b 100644
--- a/drivers/staging/sb105x/sb_pci_mp.c
+++ b/drivers/staging/sb105x/sb_pci_mp.c
@@ -1063,7 +1063,7 @@ static int mp_wait_modem_status(struct sb_uart_state *state, unsigned long arg)
1063 1063
1064static int mp_get_count(struct sb_uart_state *state, struct serial_icounter_struct *icnt) 1064static int mp_get_count(struct sb_uart_state *state, struct serial_icounter_struct *icnt)
1065{ 1065{
1066 struct serial_icounter_struct icount; 1066 struct serial_icounter_struct icount = {};
1067 struct sb_uart_icount cnow; 1067 struct sb_uart_icount cnow;
1068 struct sb_uart_port *port = state->port; 1068 struct sb_uart_port *port = state->port;
1069 1069
diff --git a/drivers/staging/wlags49_h2/wl_priv.c b/drivers/staging/wlags49_h2/wl_priv.c
index c97e0e154d28..7e10dcdc3090 100644
--- a/drivers/staging/wlags49_h2/wl_priv.c
+++ b/drivers/staging/wlags49_h2/wl_priv.c
@@ -570,6 +570,7 @@ int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp)
570 ltv_t *pLtv; 570 ltv_t *pLtv;
571 bool_t ltvAllocated = FALSE; 571 bool_t ltvAllocated = FALSE;
572 ENCSTRCT sEncryption; 572 ENCSTRCT sEncryption;
573 size_t len;
573 574
574#ifdef USE_WDS 575#ifdef USE_WDS
575 hcf_16 hcfPort = HCF_PORT_0; 576 hcf_16 hcfPort = HCF_PORT_0;
@@ -686,7 +687,8 @@ int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp)
686 break; 687 break;
687 case CFG_CNF_OWN_NAME: 688 case CFG_CNF_OWN_NAME:
688 memset(lp->StationName, 0, sizeof(lp->StationName)); 689 memset(lp->StationName, 0, sizeof(lp->StationName));
689 memcpy((void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]); 690 len = min_t(size_t, pLtv->u.u16[0], sizeof(lp->StationName));
691 strlcpy(lp->StationName, &pLtv->u.u8[2], len);
690 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]); 692 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
691 break; 693 break;
692 case CFG_CNF_LOAD_BALANCING: 694 case CFG_CNF_LOAD_BALANCING:
@@ -1783,6 +1785,7 @@ int wvlan_set_station_nickname(struct net_device *dev,
1783{ 1785{
1784 struct wl_private *lp = wl_priv(dev); 1786 struct wl_private *lp = wl_priv(dev);
1785 unsigned long flags; 1787 unsigned long flags;
1788 size_t len;
1786 int ret = 0; 1789 int ret = 0;
1787 /*------------------------------------------------------------------------*/ 1790 /*------------------------------------------------------------------------*/
1788 1791
@@ -1793,8 +1796,8 @@ int wvlan_set_station_nickname(struct net_device *dev,
1793 wl_lock(lp, &flags); 1796 wl_lock(lp, &flags);
1794 1797
1795 memset(lp->StationName, 0, sizeof(lp->StationName)); 1798 memset(lp->StationName, 0, sizeof(lp->StationName));
1796 1799 len = min_t(size_t, wrqu->data.length, sizeof(lp->StationName));
1797 memcpy(lp->StationName, extra, wrqu->data.length); 1800 strlcpy(lp->StationName, extra, len);
1798 1801
1799 /* Commit the adapter parameters */ 1802 /* Commit the adapter parameters */
1800 wl_apply(lp); 1803 wl_apply(lp);
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index d067285a2d20..6b0f75eac8a2 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1499,7 +1499,7 @@ static void atmel_set_ops(struct uart_port *port)
1499/* 1499/*
1500 * Get ip name usart or uart 1500 * Get ip name usart or uart
1501 */ 1501 */
1502static int atmel_get_ip_name(struct uart_port *port) 1502static void atmel_get_ip_name(struct uart_port *port)
1503{ 1503{
1504 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 1504 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
1505 int name = UART_GET_IP_NAME(port); 1505 int name = UART_GET_IP_NAME(port);
@@ -1518,10 +1518,7 @@ static int atmel_get_ip_name(struct uart_port *port)
1518 atmel_port->is_usart = false; 1518 atmel_port->is_usart = false;
1519 } else { 1519 } else {
1520 dev_err(port->dev, "Not supported ip name, set to uart\n"); 1520 dev_err(port->dev, "Not supported ip name, set to uart\n");
1521 return -EINVAL;
1522 } 1521 }
1523
1524 return 0;
1525} 1522}
1526 1523
1527/* 1524/*
@@ -2405,9 +2402,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
2405 /* 2402 /*
2406 * Get port name of usart or uart 2403 * Get port name of usart or uart
2407 */ 2404 */
2408 ret = atmel_get_ip_name(&port->uart); 2405 atmel_get_ip_name(&port->uart);
2409 if (ret < 0)
2410 goto err_add_port;
2411 2406
2412 return 0; 2407 return 0;
2413 2408
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index ba475632c5fa..0e808cf91d97 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -642,16 +642,29 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
642{ 642{
643 struct uio_device *idev = vma->vm_private_data; 643 struct uio_device *idev = vma->vm_private_data;
644 int mi = uio_find_mem_index(vma); 644 int mi = uio_find_mem_index(vma);
645 struct uio_mem *mem;
645 if (mi < 0) 646 if (mi < 0)
646 return -EINVAL; 647 return -EINVAL;
648 mem = idev->info->mem + mi;
647 649
648 vma->vm_ops = &uio_physical_vm_ops; 650 if (vma->vm_end - vma->vm_start > mem->size)
651 return -EINVAL;
649 652
653 vma->vm_ops = &uio_physical_vm_ops;
650 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 654 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
651 655
656 /*
657 * We cannot use the vm_iomap_memory() helper here,
658 * because vma->vm_pgoff is the map index we looked
659 * up above in uio_find_mem_index(), rather than an
660 * actual page offset into the mmap.
661 *
662 * So we just do the physical mmap without a page
663 * offset.
664 */
652 return remap_pfn_range(vma, 665 return remap_pfn_range(vma,
653 vma->vm_start, 666 vma->vm_start,
654 idev->info->mem[mi].addr >> PAGE_SHIFT, 667 mem->addr >> PAGE_SHIFT,
655 vma->vm_end - vma->vm_start, 668 vma->vm_end - vma->vm_start,
656 vma->vm_page_prot); 669 vma->vm_page_prot);
657} 670}
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index c45f9c0a1b34..b21d553c245b 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -904,6 +904,7 @@ static struct usb_device_id id_table_combined [] = {
904 { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) }, 904 { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) },
905 /* Crucible Devices */ 905 /* Crucible Devices */
906 { USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) }, 906 { USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) },
907 { USB_DEVICE(FTDI_VID, FTDI_Z3X_PID) },
907 { } /* Terminating entry */ 908 { } /* Terminating entry */
908}; 909};
909 910
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 1b8af461b522..a7019d1e3058 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -1307,3 +1307,9 @@
1307 * Manufacturer: Crucible Technologies 1307 * Manufacturer: Crucible Technologies
1308 */ 1308 */
1309#define FTDI_CT_COMET_PID 0x8e08 1309#define FTDI_CT_COMET_PID 0x8e08
1310
1311/*
1312 * Product: Z3X Box
1313 * Manufacturer: Smart GSM Team
1314 */
1315#define FTDI_Z3X_PID 0x0011
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index bedf8e47713b..1e6de4cd079d 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -4,11 +4,6 @@
4 * Copyright (C) 2001-2007 Greg Kroah-Hartman (greg@kroah.com) 4 * Copyright (C) 2001-2007 Greg Kroah-Hartman (greg@kroah.com)
5 * Copyright (C) 2003 IBM Corp. 5 * Copyright (C) 2003 IBM Corp.
6 * 6 *
7 * Copyright (C) 2009, 2013 Frank Schäfer <fschaefer.oss@googlemail.com>
8 * - fixes, improvements and documentation for the baud rate encoding methods
9 * Copyright (C) 2013 Reinhard Max <max@suse.de>
10 * - fixes and improvements for the divisor based baud rate encoding method
11 *
12 * Original driver for 2.2.x by anonymous 7 * Original driver for 2.2.x by anonymous
13 * 8 *
14 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
@@ -134,18 +129,10 @@ MODULE_DEVICE_TABLE(usb, id_table);
134 129
135 130
136enum pl2303_type { 131enum pl2303_type {
137 type_0, /* H version ? */ 132 type_0, /* don't know the difference between type 0 and */
138 type_1, /* H version ? */ 133 type_1, /* type 1, until someone from prolific tells us... */
139 HX_TA, /* HX(A) / X(A) / TA version */ /* TODO: improve */ 134 HX, /* HX version of the pl2303 chip */
140 HXD_EA_RA_SA, /* HXD / EA / RA / SA version */ /* TODO: improve */
141 TB, /* TB version */
142 HX_CLONE, /* Cheap and less functional clone of the HX chip */
143}; 135};
144/*
145 * NOTE: don't know the difference between type 0 and type 1,
146 * until someone from Prolific tells us...
147 * TODO: distinguish between X/HX, TA and HXD, EA, RA, SA variants
148 */
149 136
150struct pl2303_serial_private { 137struct pl2303_serial_private {
151 enum pl2303_type type; 138 enum pl2303_type type;
@@ -185,7 +172,6 @@ static int pl2303_startup(struct usb_serial *serial)
185{ 172{
186 struct pl2303_serial_private *spriv; 173 struct pl2303_serial_private *spriv;
187 enum pl2303_type type = type_0; 174 enum pl2303_type type = type_0;
188 char *type_str = "unknown (treating as type_0)";
189 unsigned char *buf; 175 unsigned char *buf;
190 176
191 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); 177 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
@@ -198,53 +184,15 @@ static int pl2303_startup(struct usb_serial *serial)
198 return -ENOMEM; 184 return -ENOMEM;
199 } 185 }
200 186
201 if (serial->dev->descriptor.bDeviceClass == 0x02) { 187 if (serial->dev->descriptor.bDeviceClass == 0x02)
202 type = type_0; 188 type = type_0;
203 type_str = "type_0"; 189 else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40)
204 } else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) { 190 type = HX;
205 /* 191 else if (serial->dev->descriptor.bDeviceClass == 0x00)
206 * NOTE: The bcdDevice version is the only difference between
207 * the device descriptors of the X/HX, HXD, EA, RA, SA, TA, TB
208 */
209 if (le16_to_cpu(serial->dev->descriptor.bcdDevice) == 0x300) {
210 /* Check if the device is a clone */
211 pl2303_vendor_read(0x9494, 0, serial, buf);
212 /*
213 * NOTE: Not sure if this read is really needed.
214 * The HX returns 0x00, the clone 0x02, but the Windows
215 * driver seems to ignore the value and continues.
216 */
217 pl2303_vendor_write(0x0606, 0xaa, serial);
218 pl2303_vendor_read(0x8686, 0, serial, buf);
219 if (buf[0] != 0xaa) {
220 type = HX_CLONE;
221 type_str = "X/HX clone (limited functionality)";
222 } else {
223 type = HX_TA;
224 type_str = "X/HX/TA";
225 }
226 pl2303_vendor_write(0x0606, 0x00, serial);
227 } else if (le16_to_cpu(serial->dev->descriptor.bcdDevice)
228 == 0x400) {
229 type = HXD_EA_RA_SA;
230 type_str = "HXD/EA/RA/SA";
231 } else if (le16_to_cpu(serial->dev->descriptor.bcdDevice)
232 == 0x500) {
233 type = TB;
234 type_str = "TB";
235 } else {
236 dev_info(&serial->interface->dev,
237 "unknown/unsupported device type\n");
238 kfree(spriv);
239 kfree(buf);
240 return -ENODEV;
241 }
242 } else if (serial->dev->descriptor.bDeviceClass == 0x00
243 || serial->dev->descriptor.bDeviceClass == 0xFF) {
244 type = type_1; 192 type = type_1;
245 type_str = "type_1"; 193 else if (serial->dev->descriptor.bDeviceClass == 0xFF)
246 } 194 type = type_1;
247 dev_dbg(&serial->interface->dev, "device type: %s\n", type_str); 195 dev_dbg(&serial->interface->dev, "device type: %d\n", type);
248 196
249 spriv->type = type; 197 spriv->type = type;
250 usb_set_serial_data(serial, spriv); 198 usb_set_serial_data(serial, spriv);
@@ -259,10 +207,10 @@ static int pl2303_startup(struct usb_serial *serial)
259 pl2303_vendor_read(0x8383, 0, serial, buf); 207 pl2303_vendor_read(0x8383, 0, serial, buf);
260 pl2303_vendor_write(0, 1, serial); 208 pl2303_vendor_write(0, 1, serial);
261 pl2303_vendor_write(1, 0, serial); 209 pl2303_vendor_write(1, 0, serial);
262 if (type == type_0 || type == type_1) 210 if (type == HX)
263 pl2303_vendor_write(2, 0x24, serial);
264 else
265 pl2303_vendor_write(2, 0x44, serial); 211 pl2303_vendor_write(2, 0x44, serial);
212 else
213 pl2303_vendor_write(2, 0x24, serial);
266 214
267 kfree(buf); 215 kfree(buf);
268 return 0; 216 return 0;
@@ -316,174 +264,65 @@ static int pl2303_set_control_lines(struct usb_serial_port *port, u8 value)
316 return retval; 264 return retval;
317} 265}
318 266
319static int pl2303_baudrate_encode_direct(int baud, enum pl2303_type type, 267static void pl2303_encode_baudrate(struct tty_struct *tty,
320 u8 buf[4]) 268 struct usb_serial_port *port,
269 u8 buf[4])
321{ 270{
322 /*
323 * NOTE: Only the values defined in baud_sup are supported !
324 * => if unsupported values are set, the PL2303 uses 9600 baud instead
325 * => HX clones just don't work at unsupported baud rates < 115200 baud,
326 * for baud rates > 115200 they run at 115200 baud
327 */
328 const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600, 271 const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600,
329 4800, 7200, 9600, 14400, 19200, 28800, 38400, 272 4800, 7200, 9600, 14400, 19200, 28800, 38400,
330 57600, 115200, 230400, 460800, 614400, 921600, 273 57600, 115200, 230400, 460800, 500000, 614400,
331 1228800, 2457600, 3000000, 6000000, 12000000 }; 274 921600, 1228800, 2457600, 3000000, 6000000 };
275
276 struct usb_serial *serial = port->serial;
277 struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
278 int baud;
279 int i;
280
332 /* 281 /*
333 * NOTE: With the exception of type_0/1 devices, the following 282 * NOTE: Only the values defined in baud_sup are supported!
334 * additional baud rates are supported (tested with HX rev. 3A only): 283 * => if unsupported values are set, the PL2303 seems to use
335 * 110*, 56000*, 128000, 134400, 161280, 201600, 256000*, 268800, 284 * 9600 baud (at least my PL2303X always does)
336 * 403200, 806400. (*: not HX and HX clones)
337 *
338 * Maximum values: HXD, TB: 12000000; HX, TA: 6000000;
339 * type_0+1: 1228800; RA: 921600; HX clones, SA: 115200
340 *
341 * As long as we are not using this encoding method for anything else
342 * than the type_0+1, HX and HX clone chips, there is no point in
343 * complicating the code to support them.
344 */ 285 */
345 int i; 286 baud = tty_get_baud_rate(tty);
287 dev_dbg(&port->dev, "baud requested = %d\n", baud);
288 if (!baud)
289 return;
346 290
347 /* Set baudrate to nearest supported value */ 291 /* Set baudrate to nearest supported value */
348 for (i = 0; i < ARRAY_SIZE(baud_sup); ++i) { 292 for (i = 0; i < ARRAY_SIZE(baud_sup); ++i) {
349 if (baud_sup[i] > baud) 293 if (baud_sup[i] > baud)
350 break; 294 break;
351 } 295 }
296
352 if (i == ARRAY_SIZE(baud_sup)) 297 if (i == ARRAY_SIZE(baud_sup))
353 baud = baud_sup[i - 1]; 298 baud = baud_sup[i - 1];
354 else if (i > 0 && (baud_sup[i] - baud) > (baud - baud_sup[i - 1])) 299 else if (i > 0 && (baud_sup[i] - baud) > (baud - baud_sup[i - 1]))
355 baud = baud_sup[i - 1]; 300 baud = baud_sup[i - 1];
356 else 301 else
357 baud = baud_sup[i]; 302 baud = baud_sup[i];
358 /* Respect the chip type specific baud rate limits */
359 /*
360 * FIXME: as long as we don't know how to distinguish between the
361 * HXD, EA, RA, and SA chip variants, allow the max. value of 12M.
362 */
363 if (type == HX_TA)
364 baud = min_t(int, baud, 6000000);
365 else if (type == type_0 || type == type_1)
366 baud = min_t(int, baud, 1228800);
367 else if (type == HX_CLONE)
368 baud = min_t(int, baud, 115200);
369 /* Direct (standard) baud rate encoding method */
370 put_unaligned_le32(baud, buf);
371
372 return baud;
373}
374 303
375static int pl2303_baudrate_encode_divisor(int baud, enum pl2303_type type, 304 /* type_0, type_1 only support up to 1228800 baud */
376 u8 buf[4]) 305 if (spriv->type != HX)
377{ 306 baud = min_t(int, baud, 1228800);
378 /*
379 * Divisor based baud rate encoding method
380 *
381 * NOTE: HX clones do NOT support this method.
382 * It's not clear if the type_0/1 chips support it.
383 *
384 * divisor = 12MHz * 32 / baudrate = 2^A * B
385 *
386 * with
387 *
388 * A = buf[1] & 0x0e
389 * B = buf[0] + (buf[1] & 0x01) << 8
390 *
391 * Special cases:
392 * => 8 < B < 16: device seems to work not properly
393 * => B <= 8: device uses the max. value B = 512 instead
394 */
395 unsigned int A, B;
396 307
397 /* 308 if (baud <= 115200) {
398 * NOTE: The Windows driver allows maximum baud rates of 110% of the 309 put_unaligned_le32(baud, buf);
399 * specified maximium value.
400 * Quick tests with early (2004) HX (rev. A) chips suggest, that even
401 * higher baud rates (up to the maximum of 24M baud !) are working fine,
402 * but that should really be tested carefully in "real life" scenarios
403 * before removing the upper limit completely.
404 * Baud rates smaller than the specified 75 baud are definitely working
405 * fine.
406 */
407 if (type == type_0 || type == type_1)
408 baud = min_t(int, baud, 1228800 * 1.1);
409 else if (type == HX_TA)
410 baud = min_t(int, baud, 6000000 * 1.1);
411 else if (type == HXD_EA_RA_SA)
412 /* HXD, EA: 12Mbps; RA: 1Mbps; SA: 115200 bps */
413 /*
414 * FIXME: as long as we don't know how to distinguish between
415 * these chip variants, allow the max. of these values
416 */
417 baud = min_t(int, baud, 12000000 * 1.1);
418 else if (type == TB)
419 baud = min_t(int, baud, 12000000 * 1.1);
420 /* Determine factors A and B */
421 A = 0;
422 B = 12000000 * 32 / baud; /* 12MHz */
423 B <<= 1; /* Add one bit for rounding */
424 while (B > (512 << 1) && A <= 14) {
425 A += 2;
426 B >>= 2;
427 }
428 if (A > 14) { /* max. divisor = min. baudrate reached */
429 A = 14;
430 B = 512;
431 /* => ~45.78 baud */
432 } else { 310 } else {
433 B = (B + 1) >> 1; /* Round the last bit */
434 }
435 /* Handle special cases */
436 if (B == 512)
437 B = 0; /* also: 1 to 8 */
438 else if (B < 16)
439 /* 311 /*
440 * NOTE: With the current algorithm this happens 312 * Apparently the formula for higher speeds is:
441 * only for A=0 and means that the min. divisor 313 * baudrate = 12M * 32 / (2^buf[1]) / buf[0]
442 * (respectively: the max. baudrate) is reached.
443 */ 314 */
444 B = 16; /* => 24 MBaud */ 315 unsigned tmp = 12000000 * 32 / baud;
445 /* Encode the baud rate */ 316 buf[3] = 0x80;
446 buf[3] = 0x80; /* Select divisor encoding method */ 317 buf[2] = 0;
447 buf[2] = 0; 318 buf[1] = (tmp >= 256);
448 buf[1] = (A & 0x0e); /* A */ 319 while (tmp >= 256) {
449 buf[1] |= ((B & 0x100) >> 8); /* MSB of B */ 320 tmp >>= 2;
450 buf[0] = B & 0xff; /* 8 LSBs of B */ 321 buf[1] <<= 1;
451 /* Calculate the actual/resulting baud rate */ 322 }
452 if (B <= 8) 323 buf[0] = tmp;
453 B = 512; 324 }
454 baud = 12000000 * 32 / ((1 << A) * B);
455
456 return baud;
457}
458
459static void pl2303_encode_baudrate(struct tty_struct *tty,
460 struct usb_serial_port *port,
461 enum pl2303_type type,
462 u8 buf[4])
463{
464 int baud;
465 325
466 baud = tty_get_baud_rate(tty);
467 dev_dbg(&port->dev, "baud requested = %d\n", baud);
468 if (!baud)
469 return;
470 /*
471 * There are two methods for setting/encoding the baud rate
472 * 1) Direct method: encodes the baud rate value directly
473 * => supported by all chip types
474 * 2) Divisor based method: encodes a divisor to a base value (12MHz*32)
475 * => not supported by HX clones (and likely type_0/1 chips)
476 *
477 * NOTE: Although the divisor based baud rate encoding method is much
478 * more flexible, some of the standard baud rate values can not be
479 * realized exactly. But the difference is very small (max. 0.2%) and
480 * the device likely uses the same baud rate generator for both methods
481 * so that there is likley no difference.
482 */
483 if (type == type_0 || type == type_1 || type == HX_CLONE)
484 baud = pl2303_baudrate_encode_direct(baud, type, buf);
485 else
486 baud = pl2303_baudrate_encode_divisor(baud, type, buf);
487 /* Save resulting baud rate */ 326 /* Save resulting baud rate */
488 tty_encode_baud_rate(tty, baud, baud); 327 tty_encode_baud_rate(tty, baud, baud);
489 dev_dbg(&port->dev, "baud set = %d\n", baud); 328 dev_dbg(&port->dev, "baud set = %d\n", baud);
@@ -540,8 +379,8 @@ static void pl2303_set_termios(struct tty_struct *tty,
540 dev_dbg(&port->dev, "data bits = %d\n", buf[6]); 379 dev_dbg(&port->dev, "data bits = %d\n", buf[6]);
541 } 380 }
542 381
543 /* For reference: buf[0]:buf[3] baud rate value */ 382 /* For reference buf[0]:buf[3] baud rate value */
544 pl2303_encode_baudrate(tty, port, spriv->type, buf); 383 pl2303_encode_baudrate(tty, port, &buf[0]);
545 384
546 /* For reference buf[4]=0 is 1 stop bits */ 385 /* For reference buf[4]=0 is 1 stop bits */
547 /* For reference buf[4]=1 is 1.5 stop bits */ 386 /* For reference buf[4]=1 is 1.5 stop bits */
@@ -618,10 +457,10 @@ static void pl2303_set_termios(struct tty_struct *tty,
618 dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf); 457 dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf);
619 458
620 if (C_CRTSCTS(tty)) { 459 if (C_CRTSCTS(tty)) {
621 if (spriv->type == type_0 || spriv->type == type_1) 460 if (spriv->type == HX)
622 pl2303_vendor_write(0x0, 0x41, serial);
623 else
624 pl2303_vendor_write(0x0, 0x61, serial); 461 pl2303_vendor_write(0x0, 0x61, serial);
462 else
463 pl2303_vendor_write(0x0, 0x41, serial);
625 } else { 464 } else {
626 pl2303_vendor_write(0x0, 0x0, serial); 465 pl2303_vendor_write(0x0, 0x0, serial);
627 } 466 }
@@ -658,7 +497,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
658 struct pl2303_serial_private *spriv = usb_get_serial_data(serial); 497 struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
659 int result; 498 int result;
660 499
661 if (spriv->type == type_0 || spriv->type == type_1) { 500 if (spriv->type != HX) {
662 usb_clear_halt(serial->dev, port->write_urb->pipe); 501 usb_clear_halt(serial->dev, port->write_urb->pipe);
663 usb_clear_halt(serial->dev, port->read_urb->pipe); 502 usb_clear_halt(serial->dev, port->read_urb->pipe);
664 } else { 503 } else {
@@ -833,7 +672,6 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
833 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 672 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
834 BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 673 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
835 0, NULL, 0, 100); 674 0, NULL, 0, 100);
836 /* NOTE: HX clones don't support sending breaks, -EPIPE is returned */
837 if (result) 675 if (result)
838 dev_err(&port->dev, "error sending break = %d\n", result); 676 dev_err(&port->dev, "error sending break = %d\n", result);
839} 677}
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index a54ccdc4d661..22ad85242e5b 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -361,37 +361,13 @@ void au1100fb_fb_rotate(struct fb_info *fbi, int angle)
361int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) 361int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
362{ 362{
363 struct au1100fb_device *fbdev; 363 struct au1100fb_device *fbdev;
364 unsigned int len;
365 unsigned long start=0, off;
366 364
367 fbdev = to_au1100fb_device(fbi); 365 fbdev = to_au1100fb_device(fbi);
368 366
369 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
370 return -EINVAL;
371 }
372
373 start = fbdev->fb_phys & PAGE_MASK;
374 len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
375
376 off = vma->vm_pgoff << PAGE_SHIFT;
377
378 if ((vma->vm_end - vma->vm_start + off) > len) {
379 return -EINVAL;
380 }
381
382 off += start;
383 vma->vm_pgoff = off >> PAGE_SHIFT;
384
385 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 367 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
386 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6 368 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6
387 369
388 if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, 370 return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
389 vma->vm_end - vma->vm_start,
390 vma->vm_page_prot)) {
391 return -EAGAIN;
392 }
393
394 return 0;
395} 371}
396 372
397static struct fb_ops au1100fb_ops = 373static struct fb_ops au1100fb_ops =
diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index 301224ecc950..1d02897d17f2 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -1233,34 +1233,13 @@ static int au1200fb_fb_blank(int blank_mode, struct fb_info *fbi)
1233 * method mainly to allow the use of the TLB streaming flag (CCA=6) 1233 * method mainly to allow the use of the TLB streaming flag (CCA=6)
1234 */ 1234 */
1235static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) 1235static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
1236
1237{ 1236{
1238 unsigned int len;
1239 unsigned long start=0, off;
1240 struct au1200fb_device *fbdev = info->par; 1237 struct au1200fb_device *fbdev = info->par;
1241 1238
1242 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
1243 return -EINVAL;
1244 }
1245
1246 start = fbdev->fb_phys & PAGE_MASK;
1247 len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
1248
1249 off = vma->vm_pgoff << PAGE_SHIFT;
1250
1251 if ((vma->vm_end - vma->vm_start + off) > len) {
1252 return -EINVAL;
1253 }
1254
1255 off += start;
1256 vma->vm_pgoff = off >> PAGE_SHIFT;
1257
1258 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 1239 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1259 pgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */ 1240 pgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */
1260 1241
1261 return io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, 1242 return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
1262 vma->vm_end - vma->vm_start,
1263 vma->vm_page_prot);
1264} 1243}
1265 1244
1266static void set_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata) 1245static void set_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata)
diff --git a/fs/dcache.c b/fs/dcache.c
index 20532cb0b06e..ae6ebb88ceff 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -542,7 +542,7 @@ EXPORT_SYMBOL(d_drop);
542 * If ref is non-zero, then decrement the refcount too. 542 * If ref is non-zero, then decrement the refcount too.
543 * Returns dentry requiring refcount drop, or NULL if we're done. 543 * Returns dentry requiring refcount drop, or NULL if we're done.
544 */ 544 */
545static inline struct dentry * 545static struct dentry *
546dentry_kill(struct dentry *dentry, int unlock_on_failure) 546dentry_kill(struct dentry *dentry, int unlock_on_failure)
547 __releases(dentry->d_lock) 547 __releases(dentry->d_lock)
548{ 548{
@@ -630,7 +630,8 @@ repeat:
630 goto kill_it; 630 goto kill_it;
631 } 631 }
632 632
633 dentry->d_flags |= DCACHE_REFERENCED; 633 if (!(dentry->d_flags & DCACHE_REFERENCED))
634 dentry->d_flags |= DCACHE_REFERENCED;
634 dentry_lru_add(dentry); 635 dentry_lru_add(dentry);
635 636
636 dentry->d_lockref.count--; 637 dentry->d_lockref.count--;
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 473e09da7d02..810c28fb8c3c 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -34,7 +34,6 @@
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/anon_inodes.h> 35#include <linux/anon_inodes.h>
36#include <linux/device.h> 36#include <linux/device.h>
37#include <linux/freezer.h>
38#include <asm/uaccess.h> 37#include <asm/uaccess.h>
39#include <asm/io.h> 38#include <asm/io.h>
40#include <asm/mman.h> 39#include <asm/mman.h>
@@ -1605,8 +1604,7 @@ fetch_events:
1605 } 1604 }
1606 1605
1607 spin_unlock_irqrestore(&ep->lock, flags); 1606 spin_unlock_irqrestore(&ep->lock, flags);
1608 if (!freezable_schedule_hrtimeout_range(to, slack, 1607 if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS))
1609 HRTIMER_MODE_ABS))
1610 timed_out = 1; 1608 timed_out = 1;
1611 1609
1612 spin_lock_irqsave(&ep->lock, flags); 1610 spin_lock_irqsave(&ep->lock, flags);
diff --git a/fs/select.c b/fs/select.c
index 35d4adc749d9..dfd5cb18c012 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -238,8 +238,7 @@ int poll_schedule_timeout(struct poll_wqueues *pwq, int state,
238 238
239 set_current_state(state); 239 set_current_state(state);
240 if (!pwq->triggered) 240 if (!pwq->triggered)
241 rc = freezable_schedule_hrtimeout_range(expires, slack, 241 rc = schedule_hrtimeout_range(expires, slack, HRTIMER_MODE_ABS);
242 HRTIMER_MODE_ABS);
243 __set_current_state(TASK_RUNNING); 242 __set_current_state(TASK_RUNNING);
244 243
245 /* 244 /*
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index 19c19a5eee29..f6c82de12541 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -34,9 +34,9 @@ struct ipc_namespace {
34 int sem_ctls[4]; 34 int sem_ctls[4];
35 int used_sems; 35 int used_sems;
36 36
37 int msg_ctlmax; 37 unsigned int msg_ctlmax;
38 int msg_ctlmnb; 38 unsigned int msg_ctlmnb;
39 int msg_ctlmni; 39 unsigned int msg_ctlmni;
40 atomic_t msg_bytes; 40 atomic_t msg_bytes;
41 atomic_t msg_hdrs; 41 atomic_t msg_hdrs;
42 int auto_msgmni; 42 int auto_msgmni;
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index cc88172c7d9a..c74088ab103b 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -332,7 +332,7 @@ do { \
332#endif 332#endif
333 333
334#ifndef this_cpu_sub 334#ifndef this_cpu_sub
335# define this_cpu_sub(pcp, val) this_cpu_add((pcp), -(val)) 335# define this_cpu_sub(pcp, val) this_cpu_add((pcp), -(typeof(pcp))(val))
336#endif 336#endif
337 337
338#ifndef this_cpu_inc 338#ifndef this_cpu_inc
@@ -418,7 +418,7 @@ do { \
418# define this_cpu_add_return(pcp, val) __pcpu_size_call_return2(this_cpu_add_return_, pcp, val) 418# define this_cpu_add_return(pcp, val) __pcpu_size_call_return2(this_cpu_add_return_, pcp, val)
419#endif 419#endif
420 420
421#define this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val)) 421#define this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(typeof(pcp))(val))
422#define this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1) 422#define this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
423#define this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1) 423#define this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)
424 424
@@ -586,7 +586,7 @@ do { \
586#endif 586#endif
587 587
588#ifndef __this_cpu_sub 588#ifndef __this_cpu_sub
589# define __this_cpu_sub(pcp, val) __this_cpu_add((pcp), -(val)) 589# define __this_cpu_sub(pcp, val) __this_cpu_add((pcp), -(typeof(pcp))(val))
590#endif 590#endif
591 591
592#ifndef __this_cpu_inc 592#ifndef __this_cpu_inc
@@ -668,7 +668,7 @@ do { \
668 __pcpu_size_call_return2(__this_cpu_add_return_, pcp, val) 668 __pcpu_size_call_return2(__this_cpu_add_return_, pcp, val)
669#endif 669#endif
670 670
671#define __this_cpu_sub_return(pcp, val) __this_cpu_add_return(pcp, -(val)) 671#define __this_cpu_sub_return(pcp, val) __this_cpu_add_return(pcp, -(typeof(pcp))(val))
672#define __this_cpu_inc_return(pcp) __this_cpu_add_return(pcp, 1) 672#define __this_cpu_inc_return(pcp) __this_cpu_add_return(pcp, 1)
673#define __this_cpu_dec_return(pcp) __this_cpu_add_return(pcp, -1) 673#define __this_cpu_dec_return(pcp) __this_cpu_add_return(pcp, -1)
674 674
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index da48837d617d..e1802d6153ae 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -479,13 +479,15 @@ struct perf_event_mmap_page {
479 /* 479 /*
480 * Control data for the mmap() data buffer. 480 * Control data for the mmap() data buffer.
481 * 481 *
482 * User-space reading the @data_head value should issue an rmb(), on 482 * User-space reading the @data_head value should issue an smp_rmb(),
483 * SMP capable platforms, after reading this value -- see 483 * after reading this value.
484 * perf_event_wakeup().
485 * 484 *
486 * When the mapping is PROT_WRITE the @data_tail value should be 485 * When the mapping is PROT_WRITE the @data_tail value should be
487 * written by userspace to reflect the last read data. In this case 486 * written by userspace to reflect the last read data, after issueing
488 * the kernel will not over-write unread data. 487 * an smp_mb() to separate the data read from the ->data_tail store.
488 * In this case the kernel will not over-write unread data.
489 *
490 * See perf_output_put_handle() for the data ordering.
489 */ 491 */
490 __u64 data_head; /* head in the data section */ 492 __u64 data_head; /* head in the data section */
491 __u64 data_tail; /* user-space written tail */ 493 __u64 data_tail; /* user-space written tail */
diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
index 130dfece27ac..b0e99deb6d05 100644
--- a/ipc/ipc_sysctl.c
+++ b/ipc/ipc_sysctl.c
@@ -62,7 +62,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
62 return err; 62 return err;
63} 63}
64 64
65static int proc_ipc_callback_dointvec(ctl_table *table, int write, 65static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
66 void __user *buffer, size_t *lenp, loff_t *ppos) 66 void __user *buffer, size_t *lenp, loff_t *ppos)
67{ 67{
68 struct ctl_table ipc_table; 68 struct ctl_table ipc_table;
@@ -72,7 +72,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
72 memcpy(&ipc_table, table, sizeof(ipc_table)); 72 memcpy(&ipc_table, table, sizeof(ipc_table));
73 ipc_table.data = get_ipc(table); 73 ipc_table.data = get_ipc(table);
74 74
75 rc = proc_dointvec(&ipc_table, write, buffer, lenp, ppos); 75 rc = proc_dointvec_minmax(&ipc_table, write, buffer, lenp, ppos);
76 76
77 if (write && !rc && lenp_bef == *lenp) 77 if (write && !rc && lenp_bef == *lenp)
78 /* 78 /*
@@ -152,15 +152,13 @@ static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
152#define proc_ipc_dointvec NULL 152#define proc_ipc_dointvec NULL
153#define proc_ipc_dointvec_minmax NULL 153#define proc_ipc_dointvec_minmax NULL
154#define proc_ipc_dointvec_minmax_orphans NULL 154#define proc_ipc_dointvec_minmax_orphans NULL
155#define proc_ipc_callback_dointvec NULL 155#define proc_ipc_callback_dointvec_minmax NULL
156#define proc_ipcauto_dointvec_minmax NULL 156#define proc_ipcauto_dointvec_minmax NULL
157#endif 157#endif
158 158
159static int zero; 159static int zero;
160static int one = 1; 160static int one = 1;
161#ifdef CONFIG_CHECKPOINT_RESTORE
162static int int_max = INT_MAX; 161static int int_max = INT_MAX;
163#endif
164 162
165static struct ctl_table ipc_kern_table[] = { 163static struct ctl_table ipc_kern_table[] = {
166 { 164 {
@@ -198,21 +196,27 @@ static struct ctl_table ipc_kern_table[] = {
198 .data = &init_ipc_ns.msg_ctlmax, 196 .data = &init_ipc_ns.msg_ctlmax,
199 .maxlen = sizeof (init_ipc_ns.msg_ctlmax), 197 .maxlen = sizeof (init_ipc_ns.msg_ctlmax),
200 .mode = 0644, 198 .mode = 0644,
201 .proc_handler = proc_ipc_dointvec, 199 .proc_handler = proc_ipc_dointvec_minmax,
200 .extra1 = &zero,
201 .extra2 = &int_max,
202 }, 202 },
203 { 203 {
204 .procname = "msgmni", 204 .procname = "msgmni",
205 .data = &init_ipc_ns.msg_ctlmni, 205 .data = &init_ipc_ns.msg_ctlmni,
206 .maxlen = sizeof (init_ipc_ns.msg_ctlmni), 206 .maxlen = sizeof (init_ipc_ns.msg_ctlmni),
207 .mode = 0644, 207 .mode = 0644,
208 .proc_handler = proc_ipc_callback_dointvec, 208 .proc_handler = proc_ipc_callback_dointvec_minmax,
209 .extra1 = &zero,
210 .extra2 = &int_max,
209 }, 211 },
210 { 212 {
211 .procname = "msgmnb", 213 .procname = "msgmnb",
212 .data = &init_ipc_ns.msg_ctlmnb, 214 .data = &init_ipc_ns.msg_ctlmnb,
213 .maxlen = sizeof (init_ipc_ns.msg_ctlmnb), 215 .maxlen = sizeof (init_ipc_ns.msg_ctlmnb),
214 .mode = 0644, 216 .mode = 0644,
215 .proc_handler = proc_ipc_dointvec, 217 .proc_handler = proc_ipc_dointvec_minmax,
218 .extra1 = &zero,
219 .extra2 = &int_max,
216 }, 220 },
217 { 221 {
218 .procname = "sem", 222 .procname = "sem",
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index cd55144270b5..9c2ddfbf4525 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -87,10 +87,31 @@ again:
87 goto out; 87 goto out;
88 88
89 /* 89 /*
90 * Publish the known good head. Rely on the full barrier implied 90 * Since the mmap() consumer (userspace) can run on a different CPU:
91 * by atomic_dec_and_test() order the rb->head read and this 91 *
92 * write. 92 * kernel user
93 *
94 * READ ->data_tail READ ->data_head
95 * smp_mb() (A) smp_rmb() (C)
96 * WRITE $data READ $data
97 * smp_wmb() (B) smp_mb() (D)
98 * STORE ->data_head WRITE ->data_tail
99 *
100 * Where A pairs with D, and B pairs with C.
101 *
102 * I don't think A needs to be a full barrier because we won't in fact
103 * write data until we see the store from userspace. So we simply don't
104 * issue the data WRITE until we observe it. Be conservative for now.
105 *
106 * OTOH, D needs to be a full barrier since it separates the data READ
107 * from the tail WRITE.
108 *
109 * For B a WMB is sufficient since it separates two WRITEs, and for C
110 * an RMB is sufficient since it separates two READs.
111 *
112 * See perf_output_begin().
93 */ 113 */
114 smp_wmb();
94 rb->user_page->data_head = head; 115 rb->user_page->data_head = head;
95 116
96 /* 117 /*
@@ -154,9 +175,11 @@ int perf_output_begin(struct perf_output_handle *handle,
154 * Userspace could choose to issue a mb() before updating the 175 * Userspace could choose to issue a mb() before updating the
155 * tail pointer. So that all reads will be completed before the 176 * tail pointer. So that all reads will be completed before the
156 * write is issued. 177 * write is issued.
178 *
179 * See perf_output_put_handle().
157 */ 180 */
158 tail = ACCESS_ONCE(rb->user_page->data_tail); 181 tail = ACCESS_ONCE(rb->user_page->data_tail);
159 smp_rmb(); 182 smp_mb();
160 offset = head = local_read(&rb->head); 183 offset = head = local_read(&rb->head);
161 head += size; 184 head += size;
162 if (unlikely(!perf_output_space(rb, tail, offset, head))) 185 if (unlikely(!perf_output_space(rb, tail, offset, head)))
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 06344d986eb9..094f3152ec2b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -983,7 +983,7 @@ config DEBUG_KOBJECT
983 983
984config DEBUG_KOBJECT_RELEASE 984config DEBUG_KOBJECT_RELEASE
985 bool "kobject release debugging" 985 bool "kobject release debugging"
986 depends on DEBUG_KERNEL 986 depends on DEBUG_OBJECTS_TIMERS
987 help 987 help
988 kobjects are reference counted objects. This means that their 988 kobjects are reference counted objects. This means that their
989 last reference count put is not predictable, and the kobject can 989 last reference count put is not predictable, and the kobject can
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index a685c8a79578..d16fa295ae1d 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -577,7 +577,8 @@ void sg_miter_stop(struct sg_mapping_iter *miter)
577 miter->__offset += miter->consumed; 577 miter->__offset += miter->consumed;
578 miter->__remaining -= miter->consumed; 578 miter->__remaining -= miter->consumed;
579 579
580 if (miter->__flags & SG_MITER_TO_SG) 580 if ((miter->__flags & SG_MITER_TO_SG) &&
581 !PageSlab(miter->page))
581 flush_kernel_dcache_page(miter->page); 582 flush_kernel_dcache_page(miter->page);
582 583
583 if (miter->__flags & SG_MITER_ATOMIC) { 584 if (miter->__flags & SG_MITER_ATOMIC) {
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 610e3df2768a..cca80d96e509 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1278,64 +1278,90 @@ out:
1278int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, 1278int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
1279 unsigned long addr, pmd_t pmd, pmd_t *pmdp) 1279 unsigned long addr, pmd_t pmd, pmd_t *pmdp)
1280{ 1280{
1281 struct anon_vma *anon_vma = NULL;
1281 struct page *page; 1282 struct page *page;
1282 unsigned long haddr = addr & HPAGE_PMD_MASK; 1283 unsigned long haddr = addr & HPAGE_PMD_MASK;
1284 int page_nid = -1, this_nid = numa_node_id();
1283 int target_nid; 1285 int target_nid;
1284 int current_nid = -1; 1286 bool page_locked;
1285 bool migrated; 1287 bool migrated = false;
1286 1288
1287 spin_lock(&mm->page_table_lock); 1289 spin_lock(&mm->page_table_lock);
1288 if (unlikely(!pmd_same(pmd, *pmdp))) 1290 if (unlikely(!pmd_same(pmd, *pmdp)))
1289 goto out_unlock; 1291 goto out_unlock;
1290 1292
1291 page = pmd_page(pmd); 1293 page = pmd_page(pmd);
1292 get_page(page); 1294 page_nid = page_to_nid(page);
1293 current_nid = page_to_nid(page);
1294 count_vm_numa_event(NUMA_HINT_FAULTS); 1295 count_vm_numa_event(NUMA_HINT_FAULTS);
1295 if (current_nid == numa_node_id()) 1296 if (page_nid == this_nid)
1296 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL); 1297 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL);
1297 1298
1299 /*
1300 * Acquire the page lock to serialise THP migrations but avoid dropping
1301 * page_table_lock if at all possible
1302 */
1303 page_locked = trylock_page(page);
1298 target_nid = mpol_misplaced(page, vma, haddr); 1304 target_nid = mpol_misplaced(page, vma, haddr);
1299 if (target_nid == -1) { 1305 if (target_nid == -1) {
1300 put_page(page); 1306 /* If the page was locked, there are no parallel migrations */
1301 goto clear_pmdnuma; 1307 if (page_locked)
1308 goto clear_pmdnuma;
1309
1310 /*
1311 * Otherwise wait for potential migrations and retry. We do
1312 * relock and check_same as the page may no longer be mapped.
1313 * As the fault is being retried, do not account for it.
1314 */
1315 spin_unlock(&mm->page_table_lock);
1316 wait_on_page_locked(page);
1317 page_nid = -1;
1318 goto out;
1302 } 1319 }
1303 1320
1304 /* Acquire the page lock to serialise THP migrations */ 1321 /* Page is misplaced, serialise migrations and parallel THP splits */
1322 get_page(page);
1305 spin_unlock(&mm->page_table_lock); 1323 spin_unlock(&mm->page_table_lock);
1306 lock_page(page); 1324 if (!page_locked)
1325 lock_page(page);
1326 anon_vma = page_lock_anon_vma_read(page);
1307 1327
1308 /* Confirm the PTE did not while locked */ 1328 /* Confirm the PTE did not while locked */
1309 spin_lock(&mm->page_table_lock); 1329 spin_lock(&mm->page_table_lock);
1310 if (unlikely(!pmd_same(pmd, *pmdp))) { 1330 if (unlikely(!pmd_same(pmd, *pmdp))) {
1311 unlock_page(page); 1331 unlock_page(page);
1312 put_page(page); 1332 put_page(page);
1333 page_nid = -1;
1313 goto out_unlock; 1334 goto out_unlock;
1314 } 1335 }
1315 spin_unlock(&mm->page_table_lock);
1316 1336
1317 /* Migrate the THP to the requested node */ 1337 /*
1338 * Migrate the THP to the requested node, returns with page unlocked
1339 * and pmd_numa cleared.
1340 */
1341 spin_unlock(&mm->page_table_lock);
1318 migrated = migrate_misplaced_transhuge_page(mm, vma, 1342 migrated = migrate_misplaced_transhuge_page(mm, vma,
1319 pmdp, pmd, addr, page, target_nid); 1343 pmdp, pmd, addr, page, target_nid);
1320 if (!migrated) 1344 if (migrated)
1321 goto check_same; 1345 page_nid = target_nid;
1322
1323 task_numa_fault(target_nid, HPAGE_PMD_NR, true);
1324 return 0;
1325 1346
1326check_same: 1347 goto out;
1327 spin_lock(&mm->page_table_lock);
1328 if (unlikely(!pmd_same(pmd, *pmdp)))
1329 goto out_unlock;
1330clear_pmdnuma: 1348clear_pmdnuma:
1349 BUG_ON(!PageLocked(page));
1331 pmd = pmd_mknonnuma(pmd); 1350 pmd = pmd_mknonnuma(pmd);
1332 set_pmd_at(mm, haddr, pmdp, pmd); 1351 set_pmd_at(mm, haddr, pmdp, pmd);
1333 VM_BUG_ON(pmd_numa(*pmdp)); 1352 VM_BUG_ON(pmd_numa(*pmdp));
1334 update_mmu_cache_pmd(vma, addr, pmdp); 1353 update_mmu_cache_pmd(vma, addr, pmdp);
1354 unlock_page(page);
1335out_unlock: 1355out_unlock:
1336 spin_unlock(&mm->page_table_lock); 1356 spin_unlock(&mm->page_table_lock);
1337 if (current_nid != -1) 1357
1338 task_numa_fault(current_nid, HPAGE_PMD_NR, false); 1358out:
1359 if (anon_vma)
1360 page_unlock_anon_vma_read(anon_vma);
1361
1362 if (page_nid != -1)
1363 task_numa_fault(page_nid, HPAGE_PMD_NR, migrated);
1364
1339 return 0; 1365 return 0;
1340} 1366}
1341 1367
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 72467914b856..72f9decb0104 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -81,8 +81,9 @@ restart:
81 * decrement nr_to_walk first so that we don't livelock if we 81 * decrement nr_to_walk first so that we don't livelock if we
82 * get stuck on large numbesr of LRU_RETRY items 82 * get stuck on large numbesr of LRU_RETRY items
83 */ 83 */
84 if (--(*nr_to_walk) == 0) 84 if (!*nr_to_walk)
85 break; 85 break;
86 --*nr_to_walk;
86 87
87 ret = isolate(item, &nlru->lock, cb_arg); 88 ret = isolate(item, &nlru->lock, cb_arg);
88 switch (ret) { 89 switch (ret) {
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 34d3ca9572d6..13b9d0f221b8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -54,6 +54,7 @@
54#include <linux/page_cgroup.h> 54#include <linux/page_cgroup.h>
55#include <linux/cpu.h> 55#include <linux/cpu.h>
56#include <linux/oom.h> 56#include <linux/oom.h>
57#include <linux/lockdep.h>
57#include "internal.h" 58#include "internal.h"
58#include <net/sock.h> 59#include <net/sock.h>
59#include <net/ip.h> 60#include <net/ip.h>
@@ -2046,6 +2047,12 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_memcg,
2046 return total; 2047 return total;
2047} 2048}
2048 2049
2050#ifdef CONFIG_LOCKDEP
2051static struct lockdep_map memcg_oom_lock_dep_map = {
2052 .name = "memcg_oom_lock",
2053};
2054#endif
2055
2049static DEFINE_SPINLOCK(memcg_oom_lock); 2056static DEFINE_SPINLOCK(memcg_oom_lock);
2050 2057
2051/* 2058/*
@@ -2083,7 +2090,8 @@ static bool mem_cgroup_oom_trylock(struct mem_cgroup *memcg)
2083 } 2090 }
2084 iter->oom_lock = false; 2091 iter->oom_lock = false;
2085 } 2092 }
2086 } 2093 } else
2094 mutex_acquire(&memcg_oom_lock_dep_map, 0, 1, _RET_IP_);
2087 2095
2088 spin_unlock(&memcg_oom_lock); 2096 spin_unlock(&memcg_oom_lock);
2089 2097
@@ -2095,6 +2103,7 @@ static void mem_cgroup_oom_unlock(struct mem_cgroup *memcg)
2095 struct mem_cgroup *iter; 2103 struct mem_cgroup *iter;
2096 2104
2097 spin_lock(&memcg_oom_lock); 2105 spin_lock(&memcg_oom_lock);
2106 mutex_release(&memcg_oom_lock_dep_map, 1, _RET_IP_);
2098 for_each_mem_cgroup_tree(iter, memcg) 2107 for_each_mem_cgroup_tree(iter, memcg)
2099 iter->oom_lock = false; 2108 iter->oom_lock = false;
2100 spin_unlock(&memcg_oom_lock); 2109 spin_unlock(&memcg_oom_lock);
@@ -2765,10 +2774,10 @@ done:
2765 *ptr = memcg; 2774 *ptr = memcg;
2766 return 0; 2775 return 0;
2767nomem: 2776nomem:
2768 *ptr = NULL; 2777 if (!(gfp_mask & __GFP_NOFAIL)) {
2769 if (gfp_mask & __GFP_NOFAIL) 2778 *ptr = NULL;
2770 return 0; 2779 return -ENOMEM;
2771 return -ENOMEM; 2780 }
2772bypass: 2781bypass:
2773 *ptr = root_mem_cgroup; 2782 *ptr = root_mem_cgroup;
2774 return -EINTR; 2783 return -EINTR;
@@ -3773,8 +3782,7 @@ void mem_cgroup_move_account_page_stat(struct mem_cgroup *from,
3773{ 3782{
3774 /* Update stat data for mem_cgroup */ 3783 /* Update stat data for mem_cgroup */
3775 preempt_disable(); 3784 preempt_disable();
3776 WARN_ON_ONCE(from->stat->count[idx] < nr_pages); 3785 __this_cpu_sub(from->stat->count[idx], nr_pages);
3777 __this_cpu_add(from->stat->count[idx], -nr_pages);
3778 __this_cpu_add(to->stat->count[idx], nr_pages); 3786 __this_cpu_add(to->stat->count[idx], nr_pages);
3779 preempt_enable(); 3787 preempt_enable();
3780} 3788}
@@ -4950,31 +4958,18 @@ static void mem_cgroup_reparent_charges(struct mem_cgroup *memcg)
4950 } while (usage > 0); 4958 } while (usage > 0);
4951} 4959}
4952 4960
4953/*
4954 * This mainly exists for tests during the setting of set of use_hierarchy.
4955 * Since this is the very setting we are changing, the current hierarchy value
4956 * is meaningless
4957 */
4958static inline bool __memcg_has_children(struct mem_cgroup *memcg)
4959{
4960 struct cgroup_subsys_state *pos;
4961
4962 /* bounce at first found */
4963 css_for_each_child(pos, &memcg->css)
4964 return true;
4965 return false;
4966}
4967
4968/*
4969 * Must be called with memcg_create_mutex held, unless the cgroup is guaranteed
4970 * to be already dead (as in mem_cgroup_force_empty, for instance). This is
4971 * from mem_cgroup_count_children(), in the sense that we don't really care how
4972 * many children we have; we only need to know if we have any. It also counts
4973 * any memcg without hierarchy as infertile.
4974 */
4975static inline bool memcg_has_children(struct mem_cgroup *memcg) 4961static inline bool memcg_has_children(struct mem_cgroup *memcg)
4976{ 4962{
4977 return memcg->use_hierarchy && __memcg_has_children(memcg); 4963 lockdep_assert_held(&memcg_create_mutex);
4964 /*
4965 * The lock does not prevent addition or deletion to the list
4966 * of children, but it prevents a new child from being
4967 * initialized based on this parent in css_online(), so it's
4968 * enough to decide whether hierarchically inherited
4969 * attributes can still be changed or not.
4970 */
4971 return memcg->use_hierarchy &&
4972 !list_empty(&memcg->css.cgroup->children);
4978} 4973}
4979 4974
4980/* 4975/*
@@ -5054,7 +5049,7 @@ static int mem_cgroup_hierarchy_write(struct cgroup_subsys_state *css,
5054 */ 5049 */
5055 if ((!parent_memcg || !parent_memcg->use_hierarchy) && 5050 if ((!parent_memcg || !parent_memcg->use_hierarchy) &&
5056 (val == 1 || val == 0)) { 5051 (val == 1 || val == 0)) {
5057 if (!__memcg_has_children(memcg)) 5052 if (list_empty(&memcg->css.cgroup->children))
5058 memcg->use_hierarchy = val; 5053 memcg->use_hierarchy = val;
5059 else 5054 else
5060 retval = -EBUSY; 5055 retval = -EBUSY;
diff --git a/mm/memory.c b/mm/memory.c
index 1311f26497e6..d176154c243f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3521,12 +3521,12 @@ static int do_nonlinear_fault(struct mm_struct *mm, struct vm_area_struct *vma,
3521} 3521}
3522 3522
3523int numa_migrate_prep(struct page *page, struct vm_area_struct *vma, 3523int numa_migrate_prep(struct page *page, struct vm_area_struct *vma,
3524 unsigned long addr, int current_nid) 3524 unsigned long addr, int page_nid)
3525{ 3525{
3526 get_page(page); 3526 get_page(page);
3527 3527
3528 count_vm_numa_event(NUMA_HINT_FAULTS); 3528 count_vm_numa_event(NUMA_HINT_FAULTS);
3529 if (current_nid == numa_node_id()) 3529 if (page_nid == numa_node_id())
3530 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL); 3530 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL);
3531 3531
3532 return mpol_misplaced(page, vma, addr); 3532 return mpol_misplaced(page, vma, addr);
@@ -3537,7 +3537,7 @@ int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3537{ 3537{
3538 struct page *page = NULL; 3538 struct page *page = NULL;
3539 spinlock_t *ptl; 3539 spinlock_t *ptl;
3540 int current_nid = -1; 3540 int page_nid = -1;
3541 int target_nid; 3541 int target_nid;
3542 bool migrated = false; 3542 bool migrated = false;
3543 3543
@@ -3567,15 +3567,10 @@ int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3567 return 0; 3567 return 0;
3568 } 3568 }
3569 3569
3570 current_nid = page_to_nid(page); 3570 page_nid = page_to_nid(page);
3571 target_nid = numa_migrate_prep(page, vma, addr, current_nid); 3571 target_nid = numa_migrate_prep(page, vma, addr, page_nid);
3572 pte_unmap_unlock(ptep, ptl); 3572 pte_unmap_unlock(ptep, ptl);
3573 if (target_nid == -1) { 3573 if (target_nid == -1) {
3574 /*
3575 * Account for the fault against the current node if it not
3576 * being replaced regardless of where the page is located.
3577 */
3578 current_nid = numa_node_id();
3579 put_page(page); 3574 put_page(page);
3580 goto out; 3575 goto out;
3581 } 3576 }
@@ -3583,11 +3578,11 @@ int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3583 /* Migrate to the requested node */ 3578 /* Migrate to the requested node */
3584 migrated = migrate_misplaced_page(page, target_nid); 3579 migrated = migrate_misplaced_page(page, target_nid);
3585 if (migrated) 3580 if (migrated)
3586 current_nid = target_nid; 3581 page_nid = target_nid;
3587 3582
3588out: 3583out:
3589 if (current_nid != -1) 3584 if (page_nid != -1)
3590 task_numa_fault(current_nid, 1, migrated); 3585 task_numa_fault(page_nid, 1, migrated);
3591 return 0; 3586 return 0;
3592} 3587}
3593 3588
@@ -3602,7 +3597,6 @@ static int do_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3602 unsigned long offset; 3597 unsigned long offset;
3603 spinlock_t *ptl; 3598 spinlock_t *ptl;
3604 bool numa = false; 3599 bool numa = false;
3605 int local_nid = numa_node_id();
3606 3600
3607 spin_lock(&mm->page_table_lock); 3601 spin_lock(&mm->page_table_lock);
3608 pmd = *pmdp; 3602 pmd = *pmdp;
@@ -3625,9 +3619,10 @@ static int do_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3625 for (addr = _addr + offset; addr < _addr + PMD_SIZE; pte++, addr += PAGE_SIZE) { 3619 for (addr = _addr + offset; addr < _addr + PMD_SIZE; pte++, addr += PAGE_SIZE) {
3626 pte_t pteval = *pte; 3620 pte_t pteval = *pte;
3627 struct page *page; 3621 struct page *page;
3628 int curr_nid = local_nid; 3622 int page_nid = -1;
3629 int target_nid; 3623 int target_nid;
3630 bool migrated; 3624 bool migrated = false;
3625
3631 if (!pte_present(pteval)) 3626 if (!pte_present(pteval))
3632 continue; 3627 continue;
3633 if (!pte_numa(pteval)) 3628 if (!pte_numa(pteval))
@@ -3649,25 +3644,19 @@ static int do_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3649 if (unlikely(page_mapcount(page) != 1)) 3644 if (unlikely(page_mapcount(page) != 1))
3650 continue; 3645 continue;
3651 3646
3652 /* 3647 page_nid = page_to_nid(page);
3653 * Note that the NUMA fault is later accounted to either 3648 target_nid = numa_migrate_prep(page, vma, addr, page_nid);
3654 * the node that is currently running or where the page is 3649 pte_unmap_unlock(pte, ptl);
3655 * migrated to. 3650 if (target_nid != -1) {
3656 */ 3651 migrated = migrate_misplaced_page(page, target_nid);
3657 curr_nid = local_nid; 3652 if (migrated)
3658 target_nid = numa_migrate_prep(page, vma, addr, 3653 page_nid = target_nid;
3659 page_to_nid(page)); 3654 } else {
3660 if (target_nid == -1) {
3661 put_page(page); 3655 put_page(page);
3662 continue;
3663 } 3656 }
3664 3657
3665 /* Migrate to the requested node */ 3658 if (page_nid != -1)
3666 pte_unmap_unlock(pte, ptl); 3659 task_numa_fault(page_nid, 1, migrated);
3667 migrated = migrate_misplaced_page(page, target_nid);
3668 if (migrated)
3669 curr_nid = target_nid;
3670 task_numa_fault(curr_nid, 1, migrated);
3671 3660
3672 pte = pte_offset_map_lock(mm, pmdp, addr, &ptl); 3661 pte = pte_offset_map_lock(mm, pmdp, addr, &ptl);
3673 } 3662 }
diff --git a/mm/migrate.c b/mm/migrate.c
index 7a7325ee1d08..c04692774e88 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1715,12 +1715,12 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
1715 unlock_page(new_page); 1715 unlock_page(new_page);
1716 put_page(new_page); /* Free it */ 1716 put_page(new_page); /* Free it */
1717 1717
1718 unlock_page(page); 1718 /* Retake the callers reference and putback on LRU */
1719 get_page(page);
1719 putback_lru_page(page); 1720 putback_lru_page(page);
1720 1721 mod_zone_page_state(page_zone(page),
1721 count_vm_events(PGMIGRATE_FAIL, HPAGE_PMD_NR); 1722 NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR);
1722 isolated = 0; 1723 goto out_fail;
1723 goto out;
1724 } 1724 }
1725 1725
1726 /* 1726 /*
@@ -1737,9 +1737,9 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
1737 entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); 1737 entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
1738 entry = pmd_mkhuge(entry); 1738 entry = pmd_mkhuge(entry);
1739 1739
1740 page_add_new_anon_rmap(new_page, vma, haddr); 1740 pmdp_clear_flush(vma, haddr, pmd);
1741
1742 set_pmd_at(mm, haddr, pmd, entry); 1741 set_pmd_at(mm, haddr, pmd, entry);
1742 page_add_new_anon_rmap(new_page, vma, haddr);
1743 update_mmu_cache_pmd(vma, address, &entry); 1743 update_mmu_cache_pmd(vma, address, &entry);
1744 page_remove_rmap(page); 1744 page_remove_rmap(page);
1745 /* 1745 /*
@@ -1758,7 +1758,6 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
1758 count_vm_events(PGMIGRATE_SUCCESS, HPAGE_PMD_NR); 1758 count_vm_events(PGMIGRATE_SUCCESS, HPAGE_PMD_NR);
1759 count_vm_numa_events(NUMA_PAGE_MIGRATE, HPAGE_PMD_NR); 1759 count_vm_numa_events(NUMA_PAGE_MIGRATE, HPAGE_PMD_NR);
1760 1760
1761out:
1762 mod_zone_page_state(page_zone(page), 1761 mod_zone_page_state(page_zone(page),
1763 NR_ISOLATED_ANON + page_lru, 1762 NR_ISOLATED_ANON + page_lru,
1764 -HPAGE_PMD_NR); 1763 -HPAGE_PMD_NR);
@@ -1767,6 +1766,10 @@ out:
1767out_fail: 1766out_fail:
1768 count_vm_events(PGMIGRATE_FAIL, HPAGE_PMD_NR); 1767 count_vm_events(PGMIGRATE_FAIL, HPAGE_PMD_NR);
1769out_dropref: 1768out_dropref:
1769 entry = pmd_mknonnuma(entry);
1770 set_pmd_at(mm, haddr, pmd, entry);
1771 update_mmu_cache_pmd(vma, address, &entry);
1772
1770 unlock_page(page); 1773 unlock_page(page);
1771 put_page(page); 1774 put_page(page);
1772 return 0; 1775 return 0;
diff --git a/mm/mprotect.c b/mm/mprotect.c
index a3af058f68e4..412ba2b7326a 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -148,7 +148,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma,
148 split_huge_page_pmd(vma, addr, pmd); 148 split_huge_page_pmd(vma, addr, pmd);
149 else if (change_huge_pmd(vma, pmd, addr, newprot, 149 else if (change_huge_pmd(vma, pmd, addr, newprot,
150 prot_numa)) { 150 prot_numa)) {
151 pages += HPAGE_PMD_NR; 151 pages++;
152 continue; 152 continue;
153 } 153 }
154 /* fall through */ 154 /* fall through */
diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index 5da2cbcfdbb5..2beeabf502c5 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -242,7 +242,7 @@ int walk_page_range(unsigned long addr, unsigned long end,
242 if (err) 242 if (err)
243 break; 243 break;
244 pgd++; 244 pgd++;
245 } while (addr = next, addr != end); 245 } while (addr = next, addr < end);
246 246
247 return err; 247 return err;
248} 248}
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 487ac6f37ca2..9a11f9f799f4 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -55,6 +55,7 @@ static struct sym_entry *table;
55static unsigned int table_size, table_cnt; 55static unsigned int table_size, table_cnt;
56static int all_symbols = 0; 56static int all_symbols = 0;
57static char symbol_prefix_char = '\0'; 57static char symbol_prefix_char = '\0';
58static unsigned long long kernel_start_addr = 0;
58 59
59int token_profit[0x10000]; 60int token_profit[0x10000];
60 61
@@ -65,7 +66,10 @@ unsigned char best_table_len[256];
65 66
66static void usage(void) 67static void usage(void)
67{ 68{
68 fprintf(stderr, "Usage: kallsyms [--all-symbols] [--symbol-prefix=<prefix char>] < in.map > out.S\n"); 69 fprintf(stderr, "Usage: kallsyms [--all-symbols] "
70 "[--symbol-prefix=<prefix char>] "
71 "[--page-offset=<CONFIG_PAGE_OFFSET>] "
72 "< in.map > out.S\n");
69 exit(1); 73 exit(1);
70} 74}
71 75
@@ -194,6 +198,9 @@ static int symbol_valid(struct sym_entry *s)
194 int i; 198 int i;
195 int offset = 1; 199 int offset = 1;
196 200
201 if (s->addr < kernel_start_addr)
202 return 0;
203
197 /* skip prefix char */ 204 /* skip prefix char */
198 if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char) 205 if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char)
199 offset++; 206 offset++;
@@ -646,6 +653,9 @@ int main(int argc, char **argv)
646 if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) 653 if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\''))
647 p++; 654 p++;
648 symbol_prefix_char = *p; 655 symbol_prefix_char = *p;
656 } else if (strncmp(argv[i], "--page-offset=", 14) == 0) {
657 const char *p = &argv[i][14];
658 kernel_start_addr = strtoull(p, NULL, 16);
649 } else 659 } else
650 usage(); 660 usage();
651 } 661 }
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 014994936b1c..32b10f53d0b4 100644
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -82,6 +82,8 @@ kallsyms()
82 kallsymopt="${kallsymopt} --all-symbols" 82 kallsymopt="${kallsymopt} --all-symbols"
83 fi 83 fi
84 84
85 kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
86
85 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \ 87 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
86 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}" 88 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
87 89
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 17f45e8aa89c..e1e9e0c999fe 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -49,6 +49,8 @@ static struct snd_pcm *snd_pcm_get(struct snd_card *card, int device)
49 struct snd_pcm *pcm; 49 struct snd_pcm *pcm;
50 50
51 list_for_each_entry(pcm, &snd_pcm_devices, list) { 51 list_for_each_entry(pcm, &snd_pcm_devices, list) {
52 if (pcm->internal)
53 continue;
52 if (pcm->card == card && pcm->device == device) 54 if (pcm->card == card && pcm->device == device)
53 return pcm; 55 return pcm;
54 } 56 }
@@ -60,6 +62,8 @@ static int snd_pcm_next(struct snd_card *card, int device)
60 struct snd_pcm *pcm; 62 struct snd_pcm *pcm;
61 63
62 list_for_each_entry(pcm, &snd_pcm_devices, list) { 64 list_for_each_entry(pcm, &snd_pcm_devices, list) {
65 if (pcm->internal)
66 continue;
63 if (pcm->card == card && pcm->device > device) 67 if (pcm->card == card && pcm->device > device)
64 return pcm->device; 68 return pcm->device;
65 else if (pcm->card->number > card->number) 69 else if (pcm->card->number > card->number)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 5b6c4e3c92ca..748c6a941963 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4864,8 +4864,8 @@ static void hda_power_work(struct work_struct *work)
4864 spin_unlock(&codec->power_lock); 4864 spin_unlock(&codec->power_lock);
4865 4865
4866 state = hda_call_codec_suspend(codec, true); 4866 state = hda_call_codec_suspend(codec, true);
4867 codec->pm_down_notified = 0; 4867 if (!codec->pm_down_notified &&
4868 if (!bus->power_keep_link_on && (state & AC_PWRST_CLK_STOP_OK)) { 4868 !bus->power_keep_link_on && (state & AC_PWRST_CLK_STOP_OK)) {
4869 codec->pm_down_notified = 1; 4869 codec->pm_down_notified = 1;
4870 hda_call_pm_notify(bus, false); 4870 hda_call_pm_notify(bus, false);
4871 } 4871 }
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 26ad4f0aade3..b7c89dff7066 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -4475,9 +4475,11 @@ int snd_hda_gen_build_controls(struct hda_codec *codec)
4475 true, &spec->vmaster_mute.sw_kctl); 4475 true, &spec->vmaster_mute.sw_kctl);
4476 if (err < 0) 4476 if (err < 0)
4477 return err; 4477 return err;
4478 if (spec->vmaster_mute.hook) 4478 if (spec->vmaster_mute.hook) {
4479 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, 4479 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute,
4480 spec->vmaster_mute_enum); 4480 spec->vmaster_mute_enum);
4481 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
4482 }
4481 } 4483 }
4482 4484
4483 free_kctls(spec); /* no longer needed */ 4485 free_kctls(spec); /* no longer needed */
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 0cbdd87dde6d..2aa2f579b4d6 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -968,6 +968,15 @@ static void ad1884_fixup_hp_eapd(struct hda_codec *codec,
968 } 968 }
969} 969}
970 970
971static void ad1884_fixup_thinkpad(struct hda_codec *codec,
972 const struct hda_fixup *fix, int action)
973{
974 struct ad198x_spec *spec = codec->spec;
975
976 if (action == HDA_FIXUP_ACT_PRE_PROBE)
977 spec->gen.keep_eapd_on = 1;
978}
979
971/* set magic COEFs for dmic */ 980/* set magic COEFs for dmic */
972static const struct hda_verb ad1884_dmic_init_verbs[] = { 981static const struct hda_verb ad1884_dmic_init_verbs[] = {
973 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7}, 982 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
@@ -979,6 +988,7 @@ enum {
979 AD1884_FIXUP_AMP_OVERRIDE, 988 AD1884_FIXUP_AMP_OVERRIDE,
980 AD1884_FIXUP_HP_EAPD, 989 AD1884_FIXUP_HP_EAPD,
981 AD1884_FIXUP_DMIC_COEF, 990 AD1884_FIXUP_DMIC_COEF,
991 AD1884_FIXUP_THINKPAD,
982 AD1884_FIXUP_HP_TOUCHSMART, 992 AD1884_FIXUP_HP_TOUCHSMART,
983}; 993};
984 994
@@ -997,6 +1007,12 @@ static const struct hda_fixup ad1884_fixups[] = {
997 .type = HDA_FIXUP_VERBS, 1007 .type = HDA_FIXUP_VERBS,
998 .v.verbs = ad1884_dmic_init_verbs, 1008 .v.verbs = ad1884_dmic_init_verbs,
999 }, 1009 },
1010 [AD1884_FIXUP_THINKPAD] = {
1011 .type = HDA_FIXUP_FUNC,
1012 .v.func = ad1884_fixup_thinkpad,
1013 .chained = true,
1014 .chain_id = AD1884_FIXUP_DMIC_COEF,
1015 },
1000 [AD1884_FIXUP_HP_TOUCHSMART] = { 1016 [AD1884_FIXUP_HP_TOUCHSMART] = {
1001 .type = HDA_FIXUP_VERBS, 1017 .type = HDA_FIXUP_VERBS,
1002 .v.verbs = ad1884_dmic_init_verbs, 1018 .v.verbs = ad1884_dmic_init_verbs,
@@ -1008,7 +1024,7 @@ static const struct hda_fixup ad1884_fixups[] = {
1008static const struct snd_pci_quirk ad1884_fixup_tbl[] = { 1024static const struct snd_pci_quirk ad1884_fixup_tbl[] = {
1009 SND_PCI_QUIRK(0x103c, 0x2a82, "HP Touchsmart", AD1884_FIXUP_HP_TOUCHSMART), 1025 SND_PCI_QUIRK(0x103c, 0x2a82, "HP Touchsmart", AD1884_FIXUP_HP_TOUCHSMART),
1010 SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1884_FIXUP_HP_EAPD), 1026 SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1884_FIXUP_HP_EAPD),
1011 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1884_FIXUP_DMIC_COEF), 1027 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1884_FIXUP_THINKPAD),
1012 {} 1028 {}
1013}; 1029};
1014 1030
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index bf313bea7085..8ad554312b69 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4623,6 +4623,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
4623 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 4623 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
4624 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 4624 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
4625 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_ASUS_MODE4), 4625 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_ASUS_MODE4),
4626 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_ASUS_MODE4),
4626 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), 4627 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
4627 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), 4628 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
4628 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), 4629 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 8b50e5958de5..01daf655e20b 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -530,6 +530,7 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w,
530 hubs->hp_startup_mode); 530 hubs->hp_startup_mode);
531 break; 531 break;
532 } 532 }
533 break;
533 534
534 case SND_SOC_DAPM_PRE_PMD: 535 case SND_SOC_DAPM_PRE_PMD:
535 snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, 536 snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1,
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index c17c14c394df..b2949aed1ac2 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1949,7 +1949,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
1949 w->active ? "active" : "inactive"); 1949 w->active ? "active" : "inactive");
1950 1950
1951 list_for_each_entry(p, &w->sources, list_sink) { 1951 list_for_each_entry(p, &w->sources, list_sink) {
1952 if (p->connected && !p->connected(w, p->sink)) 1952 if (p->connected && !p->connected(w, p->source))
1953 continue; 1953 continue;
1954 1954
1955 if (p->connect) 1955 if (p->connect)
@@ -3495,6 +3495,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
3495 if (!w) { 3495 if (!w) {
3496 dev_err(dapm->dev, "ASoC: Failed to create %s widget\n", 3496 dev_err(dapm->dev, "ASoC: Failed to create %s widget\n",
3497 dai->driver->playback.stream_name); 3497 dai->driver->playback.stream_name);
3498 return -ENOMEM;
3498 } 3499 }
3499 3500
3500 w->priv = dai; 3501 w->priv = dai;
@@ -3513,6 +3514,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
3513 if (!w) { 3514 if (!w) {
3514 dev_err(dapm->dev, "ASoC: Failed to create %s widget\n", 3515 dev_err(dapm->dev, "ASoC: Failed to create %s widget\n",
3515 dai->driver->capture.stream_name); 3516 dai->driver->capture.stream_name);
3517 return -ENOMEM;
3516 } 3518 }
3517 3519
3518 w->priv = dai; 3520 w->priv = dai;
diff --git a/tools/perf/tests/attr/README b/tools/perf/tests/attr/README
index d102957cd59a..430024f618f1 100644
--- a/tools/perf/tests/attr/README
+++ b/tools/perf/tests/attr/README
@@ -44,9 +44,9 @@ Following tests are defined (with perf commands):
44 perf record -c 123 kill (test-record-count) 44 perf record -c 123 kill (test-record-count)
45 perf record -d kill (test-record-data) 45 perf record -d kill (test-record-data)
46 perf record -F 100 kill (test-record-freq) 46 perf record -F 100 kill (test-record-freq)
47 perf record -g -- kill (test-record-graph-default) 47 perf record -g kill (test-record-graph-default)
48 perf record -g dwarf -- kill (test-record-graph-dwarf) 48 perf record --call-graph dwarf kill (test-record-graph-dwarf)
49 perf record -g fp kill (test-record-graph-fp) 49 perf record --call-graph fp kill (test-record-graph-fp)
50 perf record --group -e cycles,instructions kill (test-record-group) 50 perf record --group -e cycles,instructions kill (test-record-group)
51 perf record -e '{cycles,instructions}' kill (test-record-group1) 51 perf record -e '{cycles,instructions}' kill (test-record-group1)
52 perf record -D kill (test-record-no-delay) 52 perf record -D kill (test-record-no-delay)
diff --git a/tools/perf/tests/attr/test-record-graph-default b/tools/perf/tests/attr/test-record-graph-default
index 833d1849d767..853597a9a8f6 100644
--- a/tools/perf/tests/attr/test-record-graph-default
+++ b/tools/perf/tests/attr/test-record-graph-default
@@ -1,6 +1,6 @@
1[config] 1[config]
2command = record 2command = record
3args = -g -- kill >/dev/null 2>&1 3args = -g kill >/dev/null 2>&1
4 4
5[event:base-record] 5[event:base-record]
6sample_type=295 6sample_type=295
diff --git a/tools/perf/tests/attr/test-record-graph-dwarf b/tools/perf/tests/attr/test-record-graph-dwarf
index e93e082f5208..d6f324ea578c 100644
--- a/tools/perf/tests/attr/test-record-graph-dwarf
+++ b/tools/perf/tests/attr/test-record-graph-dwarf
@@ -1,6 +1,6 @@
1[config] 1[config]
2command = record 2command = record
3args = -g dwarf -- kill >/dev/null 2>&1 3args = --call-graph dwarf -- kill >/dev/null 2>&1
4 4
5[event:base-record] 5[event:base-record]
6sample_type=12583 6sample_type=12583
diff --git a/tools/perf/tests/attr/test-record-graph-fp b/tools/perf/tests/attr/test-record-graph-fp
index 7cef3743f03f..055e3bee7993 100644
--- a/tools/perf/tests/attr/test-record-graph-fp
+++ b/tools/perf/tests/attr/test-record-graph-fp
@@ -1,6 +1,6 @@
1[config] 1[config]
2command = record 2command = record
3args = -g fp kill >/dev/null 2>&1 3args = --call-graph fp kill >/dev/null 2>&1
4 4
5[event:base-record] 5[event:base-record]
6sample_type=295 6sample_type=295
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0a193281eba8..78f4c92e9b73 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -117,7 +117,7 @@ static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
117 struct perf_hpp *hpp, struct hist_entry *he) \ 117 struct perf_hpp *hpp, struct hist_entry *he) \
118{ \ 118{ \
119 return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \ 119 return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
120 (hpp_snprint_fn)percent_color_snprintf, true); \ 120 percent_color_snprintf, true); \
121} 121}
122 122
123#define __HPP_ENTRY_PERCENT_FN(_type, _field) \ 123#define __HPP_ENTRY_PERCENT_FN(_type, _field) \
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index 11e46da17bbb..66e44a5019d5 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -318,8 +318,15 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)
318 return r; 318 return r;
319} 319}
320 320
321int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent) 321int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
322{ 322{
323 const char *color = get_percent_color(percent); 323 va_list args;
324 double percent;
325 const char *color;
326
327 va_start(args, fmt);
328 percent = va_arg(args, double);
329 va_end(args);
330 color = get_percent_color(percent);
324 return color_snprintf(bf, size, color, fmt, percent); 331 return color_snprintf(bf, size, color, fmt, percent);
325} 332}
diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h
index dea082b79602..fced3840e99c 100644
--- a/tools/perf/util/color.h
+++ b/tools/perf/util/color.h
@@ -39,7 +39,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
39int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...); 39int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
40int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...); 40int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
41int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf); 41int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
42int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent); 42int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...);
43int percent_color_fprintf(FILE *fp, const char *fmt, double percent); 43int percent_color_fprintf(FILE *fp, const char *fmt, double percent);
44const char *get_percent_color(double percent); 44const char *get_percent_color(double percent);
45 45
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a9dd682cf5e3..1cf9ccb01013 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3091,7 +3091,7 @@ static const struct file_operations *stat_fops[] = {
3091 3091
3092static int kvm_init_debug(void) 3092static int kvm_init_debug(void)
3093{ 3093{
3094 int r = -EFAULT; 3094 int r = -EEXIST;
3095 struct kvm_stats_debugfs_item *p; 3095 struct kvm_stats_debugfs_item *p;
3096 3096
3097 kvm_debugfs_dir = debugfs_create_dir("kvm", NULL); 3097 kvm_debugfs_dir = debugfs_create_dir("kvm", NULL);