diff options
80 files changed, 889 insertions, 858 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a48712ed0444..9916e4d206a3 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -30,9 +30,9 @@ config ARM | |||
30 | select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT) | 30 | select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT) |
31 | select HAVE_ARCH_TRACEHOOK | 31 | select HAVE_ARCH_TRACEHOOK |
32 | select HAVE_BPF_JIT | 32 | select HAVE_BPF_JIT |
33 | select HAVE_CC_STACKPROTECTOR | ||
33 | select HAVE_CONTEXT_TRACKING | 34 | select HAVE_CONTEXT_TRACKING |
34 | select HAVE_C_RECORDMCOUNT | 35 | select HAVE_C_RECORDMCOUNT |
35 | select HAVE_CC_STACKPROTECTOR | ||
36 | select HAVE_DEBUG_KMEMLEAK | 36 | select HAVE_DEBUG_KMEMLEAK |
37 | select HAVE_DMA_API_DEBUG | 37 | select HAVE_DMA_API_DEBUG |
38 | select HAVE_DMA_ATTRS | 38 | select HAVE_DMA_ATTRS |
@@ -423,8 +423,8 @@ config ARCH_EFM32 | |||
423 | bool "Energy Micro efm32" | 423 | bool "Energy Micro efm32" |
424 | depends on !MMU | 424 | depends on !MMU |
425 | select ARCH_REQUIRE_GPIOLIB | 425 | select ARCH_REQUIRE_GPIOLIB |
426 | select AUTO_ZRELADDR | ||
427 | select ARM_NVIC | 426 | select ARM_NVIC |
427 | select AUTO_ZRELADDR | ||
428 | select CLKSRC_OF | 428 | select CLKSRC_OF |
429 | select COMMON_CLK | 429 | select COMMON_CLK |
430 | select CPU_V7M | 430 | select CPU_V7M |
@@ -512,8 +512,8 @@ config ARCH_IXP4XX | |||
512 | bool "IXP4xx-based" | 512 | bool "IXP4xx-based" |
513 | depends on MMU | 513 | depends on MMU |
514 | select ARCH_HAS_DMA_SET_COHERENT_MASK | 514 | select ARCH_HAS_DMA_SET_COHERENT_MASK |
515 | select ARCH_SUPPORTS_BIG_ENDIAN | ||
516 | select ARCH_REQUIRE_GPIOLIB | 515 | select ARCH_REQUIRE_GPIOLIB |
516 | select ARCH_SUPPORTS_BIG_ENDIAN | ||
517 | select CLKSRC_MMIO | 517 | select CLKSRC_MMIO |
518 | select CPU_XSCALE | 518 | select CPU_XSCALE |
519 | select DMABOUNCE if PCI | 519 | select DMABOUNCE if PCI |
@@ -1576,8 +1576,8 @@ config BIG_LITTLE | |||
1576 | config BL_SWITCHER | 1576 | config BL_SWITCHER |
1577 | bool "big.LITTLE switcher support" | 1577 | bool "big.LITTLE switcher support" |
1578 | depends on BIG_LITTLE && MCPM && HOTPLUG_CPU | 1578 | depends on BIG_LITTLE && MCPM && HOTPLUG_CPU |
1579 | select CPU_PM | ||
1580 | select ARM_CPU_SUSPEND | 1579 | select ARM_CPU_SUSPEND |
1580 | select CPU_PM | ||
1581 | help | 1581 | help |
1582 | The big.LITTLE "switcher" provides the core functionality to | 1582 | The big.LITTLE "switcher" provides the core functionality to |
1583 | transparently handle transition between a cluster of A15's | 1583 | transparently handle transition between a cluster of A15's |
@@ -1921,9 +1921,9 @@ config XEN | |||
1921 | depends on CPU_V7 && !CPU_V6 | 1921 | depends on CPU_V7 && !CPU_V6 |
1922 | depends on !GENERIC_ATOMIC64 | 1922 | depends on !GENERIC_ATOMIC64 |
1923 | depends on MMU | 1923 | depends on MMU |
1924 | select ARCH_DMA_ADDR_T_64BIT | ||
1924 | select ARM_PSCI | 1925 | select ARM_PSCI |
1925 | select SWIOTLB_XEN | 1926 | select SWIOTLB_XEN |
1926 | select ARCH_DMA_ADDR_T_64BIT | ||
1927 | help | 1927 | help |
1928 | Say Y if you want to run Linux in a Virtual Machine on Xen on ARM. | 1928 | Say Y if you want to run Linux in a Virtual Machine on Xen on ARM. |
1929 | 1929 | ||
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index 4a2fc0bf6fc9..eab8ecbe69c1 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug | |||
@@ -1030,9 +1030,9 @@ config DEBUG_UART_PHYS | |||
1030 | default 0x40100000 if DEBUG_PXA_UART1 | 1030 | default 0x40100000 if DEBUG_PXA_UART1 |
1031 | default 0x42000000 if ARCH_GEMINI | 1031 | default 0x42000000 if ARCH_GEMINI |
1032 | default 0x7c0003f8 if FOOTBRIDGE | 1032 | default 0x7c0003f8 if FOOTBRIDGE |
1033 | default 0x80230000 if DEBUG_PICOXCELL_UART | ||
1034 | default 0x80070000 if DEBUG_IMX23_UART | 1033 | default 0x80070000 if DEBUG_IMX23_UART |
1035 | default 0x80074000 if DEBUG_IMX28_UART | 1034 | default 0x80074000 if DEBUG_IMX28_UART |
1035 | default 0x80230000 if DEBUG_PICOXCELL_UART | ||
1036 | default 0x808c0000 if ARCH_EP93XX | 1036 | default 0x808c0000 if ARCH_EP93XX |
1037 | default 0x90020000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART | 1037 | default 0x90020000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART |
1038 | default 0xb0090000 if DEBUG_VEXPRESS_UART0_CRX | 1038 | default 0xb0090000 if DEBUG_VEXPRESS_UART0_CRX |
@@ -1096,22 +1096,22 @@ config DEBUG_UART_VIRT | |||
1096 | default 0xfeb26000 if DEBUG_RK3X_UART1 | 1096 | default 0xfeb26000 if DEBUG_RK3X_UART1 |
1097 | default 0xfeb30c00 if DEBUG_KEYSTONE_UART0 | 1097 | default 0xfeb30c00 if DEBUG_KEYSTONE_UART0 |
1098 | default 0xfeb31000 if DEBUG_KEYSTONE_UART1 | 1098 | default 0xfeb31000 if DEBUG_KEYSTONE_UART1 |
1099 | default 0xfec12000 if DEBUG_MVEBU_UART || DEBUG_MVEBU_UART_ALTERNATE | ||
1100 | default 0xfed60000 if DEBUG_RK29_UART0 | ||
1101 | default 0xfed64000 if DEBUG_RK29_UART1 || DEBUG_RK3X_UART2 | ||
1102 | default 0xfed68000 if DEBUG_RK29_UART2 || DEBUG_RK3X_UART3 | ||
1103 | default 0xfec02000 if DEBUG_SOCFPGA_UART | 1099 | default 0xfec02000 if DEBUG_SOCFPGA_UART |
1100 | default 0xfec12000 if DEBUG_MVEBU_UART || DEBUG_MVEBU_UART_ALTERNATE | ||
1104 | default 0xfec20000 if DEBUG_DAVINCI_DMx_UART0 | 1101 | default 0xfec20000 if DEBUG_DAVINCI_DMx_UART0 |
1105 | default 0xfed0c000 if DEBUG_DAVINCI_DA8XX_UART1 | 1102 | default 0xfed0c000 if DEBUG_DAVINCI_DA8XX_UART1 |
1106 | default 0xfed0d000 if DEBUG_DAVINCI_DA8XX_UART2 | 1103 | default 0xfed0d000 if DEBUG_DAVINCI_DA8XX_UART2 |
1107 | default 0xfed12000 if ARCH_KIRKWOOD | 1104 | default 0xfed12000 if ARCH_KIRKWOOD |
1105 | default 0xfed60000 if DEBUG_RK29_UART0 | ||
1106 | default 0xfed64000 if DEBUG_RK29_UART1 || DEBUG_RK3X_UART2 | ||
1107 | default 0xfed68000 if DEBUG_RK29_UART2 || DEBUG_RK3X_UART3 | ||
1108 | default 0xfedc0000 if ARCH_EP93XX | 1108 | default 0xfedc0000 if ARCH_EP93XX |
1109 | default 0xfee003f8 if FOOTBRIDGE | 1109 | default 0xfee003f8 if FOOTBRIDGE |
1110 | default 0xfee20000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART | 1110 | default 0xfee20000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART |
1111 | default 0xfef36000 if DEBUG_HIGHBANK_UART | ||
1112 | default 0xfee82340 if ARCH_IOP13XX | 1111 | default 0xfee82340 if ARCH_IOP13XX |
1113 | default 0xfef00000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN | 1112 | default 0xfef00000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN |
1114 | default 0xfef00003 if ARCH_IXP4XX && CPU_BIG_ENDIAN | 1113 | default 0xfef00003 if ARCH_IXP4XX && CPU_BIG_ENDIAN |
1114 | default 0xfef36000 if DEBUG_HIGHBANK_UART | ||
1115 | default 0xfefff700 if ARCH_IOP33X | 1115 | default 0xfefff700 if ARCH_IOP33X |
1116 | default 0xff003000 if DEBUG_U300_UART | 1116 | default 0xff003000 if DEBUG_U300_UART |
1117 | default DEBUG_UART_PHYS if !MMU | 1117 | default DEBUG_UART_PHYS if !MMU |
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c index 5774b6ea7ad5..f01c0ee0c87e 100644 --- a/arch/arm/common/bL_switcher.c +++ b/arch/arm/common/bL_switcher.c | |||
@@ -797,10 +797,8 @@ static int __init bL_switcher_init(void) | |||
797 | { | 797 | { |
798 | int ret; | 798 | int ret; |
799 | 799 | ||
800 | if (MAX_NR_CLUSTERS != 2) { | 800 | if (!mcpm_is_available()) |
801 | pr_err("%s: only dual cluster systems are supported\n", __func__); | 801 | return -ENODEV; |
802 | return -EINVAL; | ||
803 | } | ||
804 | 802 | ||
805 | cpu_notifier(bL_switcher_hotplug_callback, 0); | 803 | cpu_notifier(bL_switcher_hotplug_callback, 0); |
806 | 804 | ||
diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c index 1e361abc29eb..86fd60fefbc9 100644 --- a/arch/arm/common/mcpm_entry.c +++ b/arch/arm/common/mcpm_entry.c | |||
@@ -48,6 +48,11 @@ int __init mcpm_platform_register(const struct mcpm_platform_ops *ops) | |||
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | bool mcpm_is_available(void) | ||
52 | { | ||
53 | return (platform_ops) ? true : false; | ||
54 | } | ||
55 | |||
51 | int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster) | 56 | int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster) |
52 | { | 57 | { |
53 | if (!platform_ops) | 58 | if (!platform_ops) |
diff --git a/arch/arm/include/asm/div64.h b/arch/arm/include/asm/div64.h index 191ada6e4d2d..662c7bd06108 100644 --- a/arch/arm/include/asm/div64.h +++ b/arch/arm/include/asm/div64.h | |||
@@ -156,7 +156,7 @@ | |||
156 | /* Select the best insn combination to perform the */ \ | 156 | /* Select the best insn combination to perform the */ \ |
157 | /* actual __m * __n / (__p << 64) operation. */ \ | 157 | /* actual __m * __n / (__p << 64) operation. */ \ |
158 | if (!__c) { \ | 158 | if (!__c) { \ |
159 | asm ( "umull %Q0, %R0, %1, %Q2\n\t" \ | 159 | asm ( "umull %Q0, %R0, %Q1, %Q2\n\t" \ |
160 | "mov %Q0, #0" \ | 160 | "mov %Q0, #0" \ |
161 | : "=&r" (__res) \ | 161 | : "=&r" (__res) \ |
162 | : "r" (__m), "r" (__n) \ | 162 | : "r" (__m), "r" (__n) \ |
diff --git a/arch/arm/include/asm/mcpm.h b/arch/arm/include/asm/mcpm.h index 608516ebabfe..a5ff410dcdb6 100644 --- a/arch/arm/include/asm/mcpm.h +++ b/arch/arm/include/asm/mcpm.h | |||
@@ -54,6 +54,13 @@ void mcpm_set_early_poke(unsigned cpu, unsigned cluster, | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * mcpm_is_available - returns whether MCPM is initialized and available | ||
58 | * | ||
59 | * This returns true or false accordingly. | ||
60 | */ | ||
61 | bool mcpm_is_available(void); | ||
62 | |||
63 | /** | ||
57 | * mcpm_cpu_power_up - make given CPU in given cluster runable | 64 | * mcpm_cpu_power_up - make given CPU in given cluster runable |
58 | * | 65 | * |
59 | * @cpu: CPU number within given cluster | 66 | * @cpu: CPU number within given cluster |
diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h index fb5584d0cc05..ba94446c72d9 100644 --- a/arch/arm/include/uapi/asm/unistd.h +++ b/arch/arm/include/uapi/asm/unistd.h | |||
@@ -408,6 +408,7 @@ | |||
408 | #define __NR_finit_module (__NR_SYSCALL_BASE+379) | 408 | #define __NR_finit_module (__NR_SYSCALL_BASE+379) |
409 | #define __NR_sched_setattr (__NR_SYSCALL_BASE+380) | 409 | #define __NR_sched_setattr (__NR_SYSCALL_BASE+380) |
410 | #define __NR_sched_getattr (__NR_SYSCALL_BASE+381) | 410 | #define __NR_sched_getattr (__NR_SYSCALL_BASE+381) |
411 | #define __NR_renameat2 (__NR_SYSCALL_BASE+382) | ||
411 | 412 | ||
412 | /* | 413 | /* |
413 | * This may need to be greater than __NR_last_syscall+1 in order to | 414 | * This may need to be greater than __NR_last_syscall+1 in order to |
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index 166e945de832..8f51bdcdacbb 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S | |||
@@ -391,6 +391,7 @@ | |||
391 | CALL(sys_finit_module) | 391 | CALL(sys_finit_module) |
392 | /* 380 */ CALL(sys_sched_setattr) | 392 | /* 380 */ CALL(sys_sched_setattr) |
393 | CALL(sys_sched_getattr) | 393 | CALL(sys_sched_getattr) |
394 | CALL(sys_renameat2) | ||
394 | #ifndef syscalls_counted | 395 | #ifndef syscalls_counted |
395 | .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls | 396 | .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls |
396 | #define syscalls_counted | 397 | #define syscalls_counted |
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index f8c08839edf3..591d6e4a6492 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S | |||
@@ -587,7 +587,7 @@ __fixup_pv_table: | |||
587 | add r6, r6, r3 @ adjust __pv_phys_pfn_offset address | 587 | add r6, r6, r3 @ adjust __pv_phys_pfn_offset address |
588 | add r7, r7, r3 @ adjust __pv_offset address | 588 | add r7, r7, r3 @ adjust __pv_offset address |
589 | mov r0, r8, lsr #12 @ convert to PFN | 589 | mov r0, r8, lsr #12 @ convert to PFN |
590 | str r0, [r6, #LOW_OFFSET] @ save computed PHYS_OFFSET to __pv_phys_pfn_offset | 590 | str r0, [r6] @ save computed PHYS_OFFSET to __pv_phys_pfn_offset |
591 | strcc ip, [r7, #HIGH_OFFSET] @ save to __pv_offset high bits | 591 | strcc ip, [r7, #HIGH_OFFSET] @ save to __pv_offset high bits |
592 | mov r6, r3, lsr #24 @ constant for add/sub instructions | 592 | mov r6, r3, lsr #24 @ constant for add/sub instructions |
593 | teq r3, r6, lsl #24 @ must be 16MiB aligned | 593 | teq r3, r6, lsl #24 @ must be 16MiB aligned |
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c index f0d180d8b29f..8cf0996aa1a8 100644 --- a/arch/arm/kernel/machine_kexec.c +++ b/arch/arm/kernel/machine_kexec.c | |||
@@ -184,3 +184,10 @@ void machine_kexec(struct kimage *image) | |||
184 | 184 | ||
185 | soft_restart(reboot_entry_phys); | 185 | soft_restart(reboot_entry_phys); |
186 | } | 186 | } |
187 | |||
188 | void arch_crash_save_vmcoreinfo(void) | ||
189 | { | ||
190 | #ifdef CONFIG_ARM_LPAE | ||
191 | VMCOREINFO_CONFIG(ARM_LPAE); | ||
192 | #endif | ||
193 | } | ||
diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c index 702bd329d9d0..e90a3148f385 100644 --- a/arch/arm/kernel/sys_oabi-compat.c +++ b/arch/arm/kernel/sys_oabi-compat.c | |||
@@ -203,9 +203,9 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, | |||
203 | int ret; | 203 | int ret; |
204 | 204 | ||
205 | switch (cmd) { | 205 | switch (cmd) { |
206 | case F_GETLKP: | 206 | case F_OFD_GETLK: |
207 | case F_SETLKP: | 207 | case F_OFD_SETLK: |
208 | case F_SETLKPW: | 208 | case F_OFD_SETLKW: |
209 | case F_GETLK64: | 209 | case F_GETLK64: |
210 | case F_SETLK64: | 210 | case F_SETLK64: |
211 | case F_SETLKW64: | 211 | case F_SETLKW64: |
diff --git a/arch/arm/mach-shmobile/clock-r8a7778.c b/arch/arm/mach-shmobile/clock-r8a7778.c index 2009a9bc6356..9989b1b06ffd 100644 --- a/arch/arm/mach-shmobile/clock-r8a7778.c +++ b/arch/arm/mach-shmobile/clock-r8a7778.c | |||
@@ -170,7 +170,7 @@ static struct clk mstp_clks[MSTP_NR] = { | |||
170 | [MSTP010] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 10, 0), /* SSI2 */ | 170 | [MSTP010] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 10, 0), /* SSI2 */ |
171 | [MSTP009] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 9, 0), /* SSI3 */ | 171 | [MSTP009] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 9, 0), /* SSI3 */ |
172 | [MSTP008] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 8, 0), /* SRU */ | 172 | [MSTP008] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 8, 0), /* SRU */ |
173 | [MSTP007] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 7, 0), /* HSPI */ | 173 | [MSTP007] = SH_CLK_MSTP32(&s_clk, MSTPCR0, 7, 0), /* HSPI */ |
174 | }; | 174 | }; |
175 | 175 | ||
176 | static struct clk_lookup lookups[] = { | 176 | static struct clk_lookup lookups[] = { |
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index f5ad9ee70426..5bf7c3c3b301 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig | |||
@@ -420,29 +420,29 @@ config CPU_32v3 | |||
420 | bool | 420 | bool |
421 | select CPU_USE_DOMAINS if MMU | 421 | select CPU_USE_DOMAINS if MMU |
422 | select NEEDS_SYSCALL_FOR_CMPXCHG if SMP | 422 | select NEEDS_SYSCALL_FOR_CMPXCHG if SMP |
423 | select TLS_REG_EMUL if SMP || !MMU | ||
424 | select NEED_KUSER_HELPERS | 423 | select NEED_KUSER_HELPERS |
424 | select TLS_REG_EMUL if SMP || !MMU | ||
425 | 425 | ||
426 | config CPU_32v4 | 426 | config CPU_32v4 |
427 | bool | 427 | bool |
428 | select CPU_USE_DOMAINS if MMU | 428 | select CPU_USE_DOMAINS if MMU |
429 | select NEEDS_SYSCALL_FOR_CMPXCHG if SMP | 429 | select NEEDS_SYSCALL_FOR_CMPXCHG if SMP |
430 | select TLS_REG_EMUL if SMP || !MMU | ||
431 | select NEED_KUSER_HELPERS | 430 | select NEED_KUSER_HELPERS |
431 | select TLS_REG_EMUL if SMP || !MMU | ||
432 | 432 | ||
433 | config CPU_32v4T | 433 | config CPU_32v4T |
434 | bool | 434 | bool |
435 | select CPU_USE_DOMAINS if MMU | 435 | select CPU_USE_DOMAINS if MMU |
436 | select NEEDS_SYSCALL_FOR_CMPXCHG if SMP | 436 | select NEEDS_SYSCALL_FOR_CMPXCHG if SMP |
437 | select TLS_REG_EMUL if SMP || !MMU | ||
438 | select NEED_KUSER_HELPERS | 437 | select NEED_KUSER_HELPERS |
438 | select TLS_REG_EMUL if SMP || !MMU | ||
439 | 439 | ||
440 | config CPU_32v5 | 440 | config CPU_32v5 |
441 | bool | 441 | bool |
442 | select CPU_USE_DOMAINS if MMU | 442 | select CPU_USE_DOMAINS if MMU |
443 | select NEEDS_SYSCALL_FOR_CMPXCHG if SMP | 443 | select NEEDS_SYSCALL_FOR_CMPXCHG if SMP |
444 | select TLS_REG_EMUL if SMP || !MMU | ||
445 | select NEED_KUSER_HELPERS | 444 | select NEED_KUSER_HELPERS |
445 | select TLS_REG_EMUL if SMP || !MMU | ||
446 | 446 | ||
447 | config CPU_32v6 | 447 | config CPU_32v6 |
448 | bool | 448 | bool |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index f62aa0677e5c..6b00be1f971e 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -1963,8 +1963,8 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size) | |||
1963 | mapping->nr_bitmaps = 1; | 1963 | mapping->nr_bitmaps = 1; |
1964 | mapping->extensions = extensions; | 1964 | mapping->extensions = extensions; |
1965 | mapping->base = base; | 1965 | mapping->base = base; |
1966 | mapping->size = bitmap_size << PAGE_SHIFT; | ||
1967 | mapping->bits = BITS_PER_BYTE * bitmap_size; | 1966 | mapping->bits = BITS_PER_BYTE * bitmap_size; |
1967 | mapping->size = mapping->bits << PAGE_SHIFT; | ||
1968 | 1968 | ||
1969 | spin_lock_init(&mapping->lock); | 1969 | spin_lock_init(&mapping->lock); |
1970 | 1970 | ||
diff --git a/arch/arm/vfp/vfpdouble.c b/arch/arm/vfp/vfpdouble.c index 6cac43bd1d86..423f56dd4028 100644 --- a/arch/arm/vfp/vfpdouble.c +++ b/arch/arm/vfp/vfpdouble.c | |||
@@ -866,6 +866,8 @@ vfp_double_multiply_accumulate(int dd, int dn, int dm, u32 fpscr, u32 negate, ch | |||
866 | vdp.sign = vfp_sign_negate(vdp.sign); | 866 | vdp.sign = vfp_sign_negate(vdp.sign); |
867 | 867 | ||
868 | vfp_double_unpack(&vdn, vfp_get_double(dd)); | 868 | vfp_double_unpack(&vdn, vfp_get_double(dd)); |
869 | if (vdn.exponent == 0 && vdn.significand) | ||
870 | vfp_double_normalise_denormal(&vdn); | ||
869 | if (negate & NEG_SUBTRACT) | 871 | if (negate & NEG_SUBTRACT) |
870 | vdn.sign = vfp_sign_negate(vdn.sign); | 872 | vdn.sign = vfp_sign_negate(vdn.sign); |
871 | 873 | ||
diff --git a/arch/arm/vfp/vfpsingle.c b/arch/arm/vfp/vfpsingle.c index b252631b406b..4f96c1617aae 100644 --- a/arch/arm/vfp/vfpsingle.c +++ b/arch/arm/vfp/vfpsingle.c | |||
@@ -915,6 +915,8 @@ vfp_single_multiply_accumulate(int sd, int sn, s32 m, u32 fpscr, u32 negate, cha | |||
915 | v = vfp_get_float(sd); | 915 | v = vfp_get_float(sd); |
916 | pr_debug("VFP: s%u = %08x\n", sd, v); | 916 | pr_debug("VFP: s%u = %08x\n", sd, v); |
917 | vfp_single_unpack(&vsn, v); | 917 | vfp_single_unpack(&vsn, v); |
918 | if (vsn.exponent == 0 && vsn.significand) | ||
919 | vfp_single_normalise_denormal(&vsn); | ||
918 | if (negate & NEG_SUBTRACT) | 920 | if (negate & NEG_SUBTRACT) |
919 | vsn.sign = vfp_sign_negate(vsn.sign); | 921 | vsn.sign = vfp_sign_negate(vsn.sign); |
920 | 922 | ||
diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 75298d3358e7..08eec0b691b0 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h | |||
@@ -136,6 +136,7 @@ extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg); | |||
136 | extern int os_get_ifname(int fd, char *namebuf); | 136 | extern int os_get_ifname(int fd, char *namebuf); |
137 | extern int os_set_slip(int fd); | 137 | extern int os_set_slip(int fd); |
138 | extern int os_mode_fd(int fd, int mode); | 138 | extern int os_mode_fd(int fd, int mode); |
139 | extern int os_fsync_file(int fd); | ||
139 | 140 | ||
140 | extern int os_seek_file(int fd, unsigned long long offset); | 141 | extern int os_seek_file(int fd, unsigned long long offset); |
141 | extern int os_open_file(const char *file, struct openflags flags, int mode); | 142 | extern int os_open_file(const char *file, struct openflags flags, int mode); |
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index f116db15d402..30fdd5d0067b 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c | |||
@@ -103,6 +103,7 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end, | |||
103 | */ | 103 | */ |
104 | os_seek_file(physmem_fd, __pa(&__syscall_stub_start)); | 104 | os_seek_file(physmem_fd, __pa(&__syscall_stub_start)); |
105 | os_write_file(physmem_fd, &__syscall_stub_start, PAGE_SIZE); | 105 | os_write_file(physmem_fd, &__syscall_stub_start, PAGE_SIZE); |
106 | os_fsync_file(physmem_fd); | ||
106 | 107 | ||
107 | bootmap_size = init_bootmem(pfn, pfn + delta); | 108 | bootmap_size = init_bootmem(pfn, pfn + delta); |
108 | free_bootmem(__pa(reserve_end) + bootmap_size, | 109 | free_bootmem(__pa(reserve_end) + bootmap_size, |
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index 07a750197bb0..08d90fba952c 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
@@ -237,6 +237,12 @@ void os_close_file(int fd) | |||
237 | { | 237 | { |
238 | close(fd); | 238 | close(fd); |
239 | } | 239 | } |
240 | int os_fsync_file(int fd) | ||
241 | { | ||
242 | if (fsync(fd) < 0) | ||
243 | return -errno; | ||
244 | return 0; | ||
245 | } | ||
240 | 246 | ||
241 | int os_seek_file(int fd, unsigned long long offset) | 247 | int os_seek_file(int fd, unsigned long long offset) |
242 | { | 248 | { |
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c index e1704ff600ff..df9191acd926 100644 --- a/arch/um/os-Linux/main.c +++ b/arch/um/os-Linux/main.c | |||
@@ -151,6 +151,7 @@ int __init main(int argc, char **argv, char **envp) | |||
151 | #endif | 151 | #endif |
152 | 152 | ||
153 | do_uml_initcalls(); | 153 | do_uml_initcalls(); |
154 | change_sig(SIGPIPE, 0); | ||
154 | ret = linux_main(argc, argv); | 155 | ret = linux_main(argc, argv); |
155 | 156 | ||
156 | /* | 157 | /* |
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index 3c4af77e51a2..897e9ad0c108 100644 --- a/arch/um/os-Linux/mem.c +++ b/arch/um/os-Linux/mem.c | |||
@@ -12,337 +12,117 @@ | |||
12 | #include <string.h> | 12 | #include <string.h> |
13 | #include <sys/stat.h> | 13 | #include <sys/stat.h> |
14 | #include <sys/mman.h> | 14 | #include <sys/mman.h> |
15 | #include <sys/param.h> | 15 | #include <sys/vfs.h> |
16 | #include <linux/magic.h> | ||
16 | #include <init.h> | 17 | #include <init.h> |
17 | #include <os.h> | 18 | #include <os.h> |
18 | 19 | ||
19 | /* Modified by which_tmpdir, which is called during early boot */ | 20 | /* Set by make_tempfile() during early boot. */ |
20 | static char *default_tmpdir = "/tmp"; | ||
21 | |||
22 | /* | ||
23 | * Modified when creating the physical memory file and when checking | ||
24 | * the tmp filesystem for usability, both happening during early boot. | ||
25 | */ | ||
26 | static char *tempdir = NULL; | 21 | static char *tempdir = NULL; |
27 | 22 | ||
28 | static void __init find_tempdir(void) | 23 | /* Check if dir is on tmpfs. Return 0 if yes, -1 if no or error. */ |
24 | static int __init check_tmpfs(const char *dir) | ||
29 | { | 25 | { |
30 | const char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; | 26 | struct statfs st; |
31 | int i; | ||
32 | char *dir = NULL; | ||
33 | |||
34 | if (tempdir != NULL) | ||
35 | /* We've already been called */ | ||
36 | return; | ||
37 | for (i = 0; dirs[i]; i++) { | ||
38 | dir = getenv(dirs[i]); | ||
39 | if ((dir != NULL) && (*dir != '\0')) | ||
40 | break; | ||
41 | } | ||
42 | if ((dir == NULL) || (*dir == '\0')) | ||
43 | dir = default_tmpdir; | ||
44 | 27 | ||
45 | tempdir = malloc(strlen(dir) + 2); | 28 | printf("Checking if %s is on tmpfs...", dir); |
46 | if (tempdir == NULL) { | 29 | if (statfs(dir, &st) < 0) { |
47 | fprintf(stderr, "Failed to malloc tempdir, " | 30 | printf("%s\n", strerror(errno)); |
48 | "errno = %d\n", errno); | 31 | } else if (st.f_type != TMPFS_MAGIC) { |
49 | return; | 32 | printf("no\n"); |
50 | } | 33 | } else { |
51 | strcpy(tempdir, dir); | 34 | printf("OK\n"); |
52 | strcat(tempdir, "/"); | 35 | return 0; |
53 | } | ||
54 | |||
55 | /* | ||
56 | * Remove bytes from the front of the buffer and refill it so that if there's a | ||
57 | * partial string that we care about, it will be completed, and we can recognize | ||
58 | * it. | ||
59 | */ | ||
60 | static int pop(int fd, char *buf, size_t size, size_t npop) | ||
61 | { | ||
62 | ssize_t n; | ||
63 | size_t len = strlen(&buf[npop]); | ||
64 | |||
65 | memmove(buf, &buf[npop], len + 1); | ||
66 | n = read(fd, &buf[len], size - len - 1); | ||
67 | if (n < 0) | ||
68 | return -errno; | ||
69 | |||
70 | buf[len + n] = '\0'; | ||
71 | return 1; | ||
72 | } | ||
73 | |||
74 | /* | ||
75 | * This will return 1, with the first character in buf being the | ||
76 | * character following the next instance of c in the file. This will | ||
77 | * read the file as needed. If there's an error, -errno is returned; | ||
78 | * if the end of the file is reached, 0 is returned. | ||
79 | */ | ||
80 | static int next(int fd, char *buf, size_t size, char c) | ||
81 | { | ||
82 | ssize_t n; | ||
83 | char *ptr; | ||
84 | |||
85 | while ((ptr = strchr(buf, c)) == NULL) { | ||
86 | n = read(fd, buf, size - 1); | ||
87 | if (n == 0) | ||
88 | return 0; | ||
89 | else if (n < 0) | ||
90 | return -errno; | ||
91 | |||
92 | buf[n] = '\0'; | ||
93 | } | 36 | } |
94 | 37 | return -1; | |
95 | return pop(fd, buf, size, ptr - buf + 1); | ||
96 | } | 38 | } |
97 | 39 | ||
98 | /* | 40 | /* |
99 | * Decode an octal-escaped and space-terminated path of the form used by | 41 | * Choose the tempdir to use. We want something on tmpfs so that our memory is |
100 | * /proc/mounts. May be used to decode a path in-place. "out" must be at least | 42 | * not subject to the host's vm.dirty_ratio. If a tempdir is specified in the |
101 | * as large as the input. The output is always null-terminated. "len" gets the | 43 | * environment, we use that even if it's not on tmpfs, but we warn the user. |
102 | * length of the output, excluding the trailing null. Returns 0 if a full path | 44 | * Otherwise, we try common tmpfs locations, and if no tmpfs directory is found |
103 | * was successfully decoded, otherwise an error. | 45 | * then we fall back to /tmp. |
104 | */ | 46 | */ |
105 | static int decode_path(const char *in, char *out, size_t *len) | 47 | static char * __init choose_tempdir(void) |
106 | { | 48 | { |
107 | char *first = out; | 49 | static const char * const vars[] = { |
108 | int c; | 50 | "TMPDIR", |
51 | "TMP", | ||
52 | "TEMP", | ||
53 | NULL | ||
54 | }; | ||
55 | static const char fallback_dir[] = "/tmp"; | ||
56 | static const char * const tmpfs_dirs[] = { | ||
57 | "/dev/shm", | ||
58 | fallback_dir, | ||
59 | NULL | ||
60 | }; | ||
109 | int i; | 61 | int i; |
110 | int ret = -EINVAL; | 62 | const char *dir; |
111 | while (1) { | 63 | |
112 | switch (*in) { | 64 | printf("Checking environment variables for a tempdir..."); |
113 | case '\0': | 65 | for (i = 0; vars[i]; i++) { |
114 | goto out; | 66 | dir = getenv(vars[i]); |
115 | 67 | if ((dir != NULL) && (*dir != '\0')) { | |
116 | case ' ': | 68 | printf("%s\n", dir); |
117 | ret = 0; | 69 | if (check_tmpfs(dir) >= 0) |
118 | goto out; | 70 | goto done; |
119 | 71 | else | |
120 | case '\\': | 72 | goto warn; |
121 | in++; | ||
122 | c = 0; | ||
123 | for (i = 0; i < 3; i++) { | ||
124 | if (*in < '0' || *in > '7') | ||
125 | goto out; | ||
126 | c = (c << 3) | (*in++ - '0'); | ||
127 | } | ||
128 | *(unsigned char *)out++ = (unsigned char) c; | ||
129 | break; | ||
130 | |||
131 | default: | ||
132 | *out++ = *in++; | ||
133 | break; | ||
134 | } | 73 | } |
135 | } | 74 | } |
75 | printf("none found\n"); | ||
136 | 76 | ||
137 | out: | 77 | for (i = 0; tmpfs_dirs[i]; i++) { |
138 | *out = '\0'; | 78 | dir = tmpfs_dirs[i]; |
139 | *len = out - first; | 79 | if (check_tmpfs(dir) >= 0) |
140 | return ret; | 80 | goto done; |
141 | } | ||
142 | |||
143 | /* | ||
144 | * Computes the length of s when encoded with three-digit octal escape sequences | ||
145 | * for the characters in chars. | ||
146 | */ | ||
147 | static size_t octal_encoded_length(const char *s, const char *chars) | ||
148 | { | ||
149 | size_t len = strlen(s); | ||
150 | while ((s = strpbrk(s, chars)) != NULL) { | ||
151 | len += 3; | ||
152 | s++; | ||
153 | } | ||
154 | |||
155 | return len; | ||
156 | } | ||
157 | |||
158 | enum { | ||
159 | OUTCOME_NOTHING_MOUNTED, | ||
160 | OUTCOME_TMPFS_MOUNT, | ||
161 | OUTCOME_NON_TMPFS_MOUNT, | ||
162 | }; | ||
163 | |||
164 | /* Read a line of /proc/mounts data looking for a tmpfs mount at "path". */ | ||
165 | static int read_mount(int fd, char *buf, size_t bufsize, const char *path, | ||
166 | int *outcome) | ||
167 | { | ||
168 | int found; | ||
169 | int match; | ||
170 | char *space; | ||
171 | size_t len; | ||
172 | |||
173 | enum { | ||
174 | MATCH_NONE, | ||
175 | MATCH_EXACT, | ||
176 | MATCH_PARENT, | ||
177 | }; | ||
178 | |||
179 | found = next(fd, buf, bufsize, ' '); | ||
180 | if (found != 1) | ||
181 | return found; | ||
182 | |||
183 | /* | ||
184 | * If there's no following space in the buffer, then this path is | ||
185 | * truncated, so it can't be the one we're looking for. | ||
186 | */ | ||
187 | space = strchr(buf, ' '); | ||
188 | if (space) { | ||
189 | match = MATCH_NONE; | ||
190 | if (!decode_path(buf, buf, &len)) { | ||
191 | if (!strcmp(buf, path)) | ||
192 | match = MATCH_EXACT; | ||
193 | else if (!strncmp(buf, path, len) | ||
194 | && (path[len] == '/' || !strcmp(buf, "/"))) | ||
195 | match = MATCH_PARENT; | ||
196 | } | ||
197 | |||
198 | found = pop(fd, buf, bufsize, space - buf + 1); | ||
199 | if (found != 1) | ||
200 | return found; | ||
201 | |||
202 | switch (match) { | ||
203 | case MATCH_EXACT: | ||
204 | if (!strncmp(buf, "tmpfs", strlen("tmpfs"))) | ||
205 | *outcome = OUTCOME_TMPFS_MOUNT; | ||
206 | else | ||
207 | *outcome = OUTCOME_NON_TMPFS_MOUNT; | ||
208 | break; | ||
209 | |||
210 | case MATCH_PARENT: | ||
211 | /* This mount obscures any previous ones. */ | ||
212 | *outcome = OUTCOME_NOTHING_MOUNTED; | ||
213 | break; | ||
214 | } | ||
215 | } | 81 | } |
216 | 82 | ||
217 | return next(fd, buf, bufsize, '\n'); | 83 | dir = fallback_dir; |
84 | warn: | ||
85 | printf("Warning: tempdir %s is not on tmpfs\n", dir); | ||
86 | done: | ||
87 | /* Make a copy since getenv results may not remain valid forever. */ | ||
88 | return strdup(dir); | ||
218 | } | 89 | } |
219 | 90 | ||
220 | /* which_tmpdir is called only during early boot */ | ||
221 | static int checked_tmpdir = 0; | ||
222 | |||
223 | /* | 91 | /* |
224 | * Look for a tmpfs mounted at /dev/shm. I couldn't find a cleaner | 92 | * Create an unlinked tempfile in a suitable tempdir. template must be the |
225 | * way to do this than to parse /proc/mounts. statfs will return the | 93 | * basename part of the template with a leading '/'. |
226 | * same filesystem magic number and fs id for both /dev and /dev/shm | ||
227 | * when they are both tmpfs, so you can't tell if they are different | ||
228 | * filesystems. Also, there seems to be no other way of finding the | ||
229 | * mount point of a filesystem from within it. | ||
230 | * | ||
231 | * If a /dev/shm tmpfs entry is found, then we switch to using it. | ||
232 | * Otherwise, we stay with the default /tmp. | ||
233 | */ | 94 | */ |
234 | static void which_tmpdir(void) | 95 | static int __init make_tempfile(const char *template) |
235 | { | 96 | { |
97 | char *tempname; | ||
236 | int fd; | 98 | int fd; |
237 | int found; | ||
238 | int outcome; | ||
239 | char *path; | ||
240 | char *buf; | ||
241 | size_t bufsize; | ||
242 | 99 | ||
243 | if (checked_tmpdir) | 100 | if (tempdir == NULL) { |
244 | return; | 101 | tempdir = choose_tempdir(); |
245 | 102 | if (tempdir == NULL) { | |
246 | checked_tmpdir = 1; | 103 | fprintf(stderr, "Failed to choose tempdir: %s\n", |
247 | 104 | strerror(errno)); | |
248 | printf("Checking for tmpfs mount on /dev/shm..."); | 105 | return -1; |
249 | |||
250 | path = realpath("/dev/shm", NULL); | ||
251 | if (!path) { | ||
252 | printf("failed to check real path, errno = %d\n", errno); | ||
253 | return; | ||
254 | } | ||
255 | printf("%s...", path); | ||
256 | |||
257 | /* | ||
258 | * The buffer needs to be able to fit the full octal-escaped path, a | ||
259 | * space, and a trailing null in order to successfully decode it. | ||
260 | */ | ||
261 | bufsize = octal_encoded_length(path, " \t\n\\") + 2; | ||
262 | |||
263 | if (bufsize < 128) | ||
264 | bufsize = 128; | ||
265 | |||
266 | buf = malloc(bufsize); | ||
267 | if (!buf) { | ||
268 | printf("malloc failed, errno = %d\n", errno); | ||
269 | goto out; | ||
270 | } | ||
271 | buf[0] = '\0'; | ||
272 | |||
273 | fd = open("/proc/mounts", O_RDONLY); | ||
274 | if (fd < 0) { | ||
275 | printf("failed to open /proc/mounts, errno = %d\n", errno); | ||
276 | goto out1; | ||
277 | } | ||
278 | |||
279 | outcome = OUTCOME_NOTHING_MOUNTED; | ||
280 | while (1) { | ||
281 | found = read_mount(fd, buf, bufsize, path, &outcome); | ||
282 | if (found != 1) | ||
283 | break; | ||
284 | } | ||
285 | |||
286 | if (found < 0) { | ||
287 | printf("read returned errno %d\n", -found); | ||
288 | } else { | ||
289 | switch (outcome) { | ||
290 | case OUTCOME_TMPFS_MOUNT: | ||
291 | printf("OK\n"); | ||
292 | default_tmpdir = "/dev/shm"; | ||
293 | break; | ||
294 | |||
295 | case OUTCOME_NON_TMPFS_MOUNT: | ||
296 | printf("not tmpfs\n"); | ||
297 | break; | ||
298 | |||
299 | default: | ||
300 | printf("nothing mounted on /dev/shm\n"); | ||
301 | break; | ||
302 | } | 106 | } |
303 | } | 107 | } |
304 | 108 | ||
305 | close(fd); | 109 | tempname = malloc(strlen(tempdir) + strlen(template) + 1); |
306 | out1: | ||
307 | free(buf); | ||
308 | out: | ||
309 | free(path); | ||
310 | } | ||
311 | |||
312 | static int __init make_tempfile(const char *template, char **out_tempname, | ||
313 | int do_unlink) | ||
314 | { | ||
315 | char *tempname; | ||
316 | int fd; | ||
317 | |||
318 | which_tmpdir(); | ||
319 | tempname = malloc(MAXPATHLEN); | ||
320 | if (tempname == NULL) | 110 | if (tempname == NULL) |
321 | return -1; | 111 | return -1; |
322 | 112 | ||
323 | find_tempdir(); | 113 | strcpy(tempname, tempdir); |
324 | if ((tempdir == NULL) || (strlen(tempdir) >= MAXPATHLEN)) | 114 | strcat(tempname, template); |
325 | goto out; | ||
326 | |||
327 | if (template[0] != '/') | ||
328 | strcpy(tempname, tempdir); | ||
329 | else | ||
330 | tempname[0] = '\0'; | ||
331 | strncat(tempname, template, MAXPATHLEN-1-strlen(tempname)); | ||
332 | fd = mkstemp(tempname); | 115 | fd = mkstemp(tempname); |
333 | if (fd < 0) { | 116 | if (fd < 0) { |
334 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | 117 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, |
335 | strerror(errno)); | 118 | strerror(errno)); |
336 | goto out; | 119 | goto out; |
337 | } | 120 | } |
338 | if (do_unlink && (unlink(tempname) < 0)) { | 121 | if (unlink(tempname) < 0) { |
339 | perror("unlink"); | 122 | perror("unlink"); |
340 | goto close; | 123 | goto close; |
341 | } | 124 | } |
342 | if (out_tempname) { | 125 | free(tempname); |
343 | *out_tempname = tempname; | ||
344 | } else | ||
345 | free(tempname); | ||
346 | return fd; | 126 | return fd; |
347 | close: | 127 | close: |
348 | close(fd); | 128 | close(fd); |
@@ -351,14 +131,14 @@ out: | |||
351 | return -1; | 131 | return -1; |
352 | } | 132 | } |
353 | 133 | ||
354 | #define TEMPNAME_TEMPLATE "vm_file-XXXXXX" | 134 | #define TEMPNAME_TEMPLATE "/vm_file-XXXXXX" |
355 | 135 | ||
356 | static int __init create_tmp_file(unsigned long long len) | 136 | static int __init create_tmp_file(unsigned long long len) |
357 | { | 137 | { |
358 | int fd, err; | 138 | int fd, err; |
359 | char zero; | 139 | char zero; |
360 | 140 | ||
361 | fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1); | 141 | fd = make_tempfile(TEMPNAME_TEMPLATE); |
362 | if (fd < 0) | 142 | if (fd < 0) |
363 | exit(1); | 143 | exit(1); |
364 | 144 | ||
@@ -402,7 +182,6 @@ int __init create_mem_file(unsigned long long len) | |||
402 | return fd; | 182 | return fd; |
403 | } | 183 | } |
404 | 184 | ||
405 | |||
406 | void __init check_tmpexec(void) | 185 | void __init check_tmpexec(void) |
407 | { | 186 | { |
408 | void *addr; | 187 | void *addr; |
@@ -410,14 +189,13 @@ void __init check_tmpexec(void) | |||
410 | 189 | ||
411 | addr = mmap(NULL, UM_KERN_PAGE_SIZE, | 190 | addr = mmap(NULL, UM_KERN_PAGE_SIZE, |
412 | PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); | 191 | PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); |
413 | printf("Checking PROT_EXEC mmap in %s...",tempdir); | 192 | printf("Checking PROT_EXEC mmap in %s...", tempdir); |
414 | fflush(stdout); | ||
415 | if (addr == MAP_FAILED) { | 193 | if (addr == MAP_FAILED) { |
416 | err = errno; | 194 | err = errno; |
417 | perror("failed"); | 195 | printf("%s\n", strerror(err)); |
418 | close(fd); | 196 | close(fd); |
419 | if (err == EPERM) | 197 | if (err == EPERM) |
420 | printf("%s must be not mounted noexec\n",tempdir); | 198 | printf("%s must be not mounted noexec\n", tempdir); |
421 | exit(1); | 199 | exit(1); |
422 | } | 200 | } |
423 | printf("OK\n"); | 201 | printf("OK\n"); |
diff --git a/arch/x86/vdso/vdso-layout.lds.S b/arch/x86/vdso/vdso-layout.lds.S index 2e263f367b13..9df017ab2285 100644 --- a/arch/x86/vdso/vdso-layout.lds.S +++ b/arch/x86/vdso/vdso-layout.lds.S | |||
@@ -9,12 +9,9 @@ SECTIONS | |||
9 | #ifdef BUILD_VDSO32 | 9 | #ifdef BUILD_VDSO32 |
10 | #include <asm/vdso32.h> | 10 | #include <asm/vdso32.h> |
11 | 11 | ||
12 | .hpet_sect : { | 12 | hpet_page = . - VDSO_OFFSET(VDSO_HPET_PAGE); |
13 | hpet_page = . - VDSO_OFFSET(VDSO_HPET_PAGE); | ||
14 | } :text :hpet_sect | ||
15 | 13 | ||
16 | .vvar_sect : { | 14 | vvar = . - VDSO_OFFSET(VDSO_VVAR_PAGE); |
17 | vvar = . - VDSO_OFFSET(VDSO_VVAR_PAGE); | ||
18 | 15 | ||
19 | /* Place all vvars at the offsets in asm/vvar.h. */ | 16 | /* Place all vvars at the offsets in asm/vvar.h. */ |
20 | #define EMIT_VVAR(name, offset) vvar_ ## name = vvar + offset; | 17 | #define EMIT_VVAR(name, offset) vvar_ ## name = vvar + offset; |
@@ -22,7 +19,6 @@ SECTIONS | |||
22 | #include <asm/vvar.h> | 19 | #include <asm/vvar.h> |
23 | #undef __VVAR_KERNEL_LDS | 20 | #undef __VVAR_KERNEL_LDS |
24 | #undef EMIT_VVAR | 21 | #undef EMIT_VVAR |
25 | } :text :vvar_sect | ||
26 | #endif | 22 | #endif |
27 | . = SIZEOF_HEADERS; | 23 | . = SIZEOF_HEADERS; |
28 | 24 | ||
@@ -61,7 +57,12 @@ SECTIONS | |||
61 | */ | 57 | */ |
62 | . = ALIGN(0x100); | 58 | . = ALIGN(0x100); |
63 | 59 | ||
64 | .text : { *(.text*) } :text =0x90909090 | 60 | .text : { *(.text*) } :text =0x90909090, |
61 | |||
62 | /* | ||
63 | * The comma above works around a bug in gold: | ||
64 | * https://sourceware.org/bugzilla/show_bug.cgi?id=16804 | ||
65 | */ | ||
65 | 66 | ||
66 | /DISCARD/ : { | 67 | /DISCARD/ : { |
67 | *(.discard) | 68 | *(.discard) |
@@ -84,8 +85,4 @@ PHDRS | |||
84 | dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ | 85 | dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ |
85 | note PT_NOTE FLAGS(4); /* PF_R */ | 86 | note PT_NOTE FLAGS(4); /* PF_R */ |
86 | eh_frame_hdr PT_GNU_EH_FRAME; | 87 | eh_frame_hdr PT_GNU_EH_FRAME; |
87 | #ifdef BUILD_VDSO32 | ||
88 | vvar_sect PT_NULL FLAGS(4); /* PF_R */ | ||
89 | hpet_sect PT_NULL FLAGS(4); /* PF_R */ | ||
90 | #endif | ||
91 | } | 88 | } |
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 20e03a7eb8b4..c2706047337f 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -116,7 +116,7 @@ config AHCI_ST | |||
116 | 116 | ||
117 | config AHCI_IMX | 117 | config AHCI_IMX |
118 | tristate "Freescale i.MX AHCI SATA support" | 118 | tristate "Freescale i.MX AHCI SATA support" |
119 | depends on MFD_SYSCON | 119 | depends on MFD_SYSCON && (ARCH_MXC || COMPILE_TEST) |
120 | help | 120 | help |
121 | This option enables support for the Freescale i.MX SoC's | 121 | This option enables support for the Freescale i.MX SoC's |
122 | onboard AHCI SATA. | 122 | onboard AHCI SATA. |
@@ -134,8 +134,7 @@ config AHCI_SUNXI | |||
134 | 134 | ||
135 | config AHCI_XGENE | 135 | config AHCI_XGENE |
136 | tristate "APM X-Gene 6.0Gbps AHCI SATA host controller support" | 136 | tristate "APM X-Gene 6.0Gbps AHCI SATA host controller support" |
137 | depends on ARM64 || COMPILE_TEST | 137 | depends on PHY_XGENE |
138 | select PHY_XGENE | ||
139 | help | 138 | help |
140 | This option enables support for APM X-Gene SoC SATA host controller. | 139 | This option enables support for APM X-Gene SoC SATA host controller. |
141 | 140 | ||
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 5a0bf8ed649b..71e15b73513d 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -1164,9 +1164,9 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host) | |||
1164 | #endif | 1164 | #endif |
1165 | 1165 | ||
1166 | static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports, | 1166 | static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports, |
1167 | struct ahci_host_priv *hpriv) | 1167 | struct ahci_host_priv *hpriv) |
1168 | { | 1168 | { |
1169 | int nvec; | 1169 | int rc, nvec; |
1170 | 1170 | ||
1171 | if (hpriv->flags & AHCI_HFLAG_NO_MSI) | 1171 | if (hpriv->flags & AHCI_HFLAG_NO_MSI) |
1172 | goto intx; | 1172 | goto intx; |
@@ -1183,12 +1183,19 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports, | |||
1183 | if (nvec < n_ports) | 1183 | if (nvec < n_ports) |
1184 | goto single_msi; | 1184 | goto single_msi; |
1185 | 1185 | ||
1186 | nvec = pci_enable_msi_range(pdev, nvec, nvec); | 1186 | rc = pci_enable_msi_exact(pdev, nvec); |
1187 | if (nvec == -ENOSPC) | 1187 | if (rc == -ENOSPC) |
1188 | goto single_msi; | 1188 | goto single_msi; |
1189 | else if (nvec < 0) | 1189 | else if (rc < 0) |
1190 | goto intx; | 1190 | goto intx; |
1191 | 1191 | ||
1192 | /* fallback to single MSI mode if the controller enforced MRSM mode */ | ||
1193 | if (readl(hpriv->mmio + HOST_CTL) & HOST_MRSM) { | ||
1194 | pci_disable_msi(pdev); | ||
1195 | printk(KERN_INFO "ahci: MRSM is on, fallback to single MSI\n"); | ||
1196 | goto single_msi; | ||
1197 | } | ||
1198 | |||
1192 | return nvec; | 1199 | return nvec; |
1193 | 1200 | ||
1194 | single_msi: | 1201 | single_msi: |
@@ -1232,18 +1239,18 @@ int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis) | |||
1232 | return rc; | 1239 | return rc; |
1233 | 1240 | ||
1234 | for (i = 0; i < host->n_ports; i++) { | 1241 | for (i = 0; i < host->n_ports; i++) { |
1235 | const char* desc; | ||
1236 | struct ahci_port_priv *pp = host->ports[i]->private_data; | 1242 | struct ahci_port_priv *pp = host->ports[i]->private_data; |
1237 | 1243 | ||
1238 | /* pp is NULL for dummy ports */ | 1244 | /* Do not receive interrupts sent by dummy ports */ |
1239 | if (pp) | 1245 | if (!pp) { |
1240 | desc = pp->irq_desc; | 1246 | disable_irq(irq + i); |
1241 | else | 1247 | continue; |
1242 | desc = dev_driver_string(host->dev); | 1248 | } |
1243 | 1249 | ||
1244 | rc = devm_request_threaded_irq(host->dev, | 1250 | rc = devm_request_threaded_irq(host->dev, irq + i, |
1245 | irq + i, ahci_hw_interrupt, ahci_thread_fn, IRQF_SHARED, | 1251 | ahci_hw_interrupt, |
1246 | desc, host->ports[i]); | 1252 | ahci_thread_fn, IRQF_SHARED, |
1253 | pp->irq_desc, host->ports[i]); | ||
1247 | if (rc) | 1254 | if (rc) |
1248 | goto out_free_irqs; | 1255 | goto out_free_irqs; |
1249 | } | 1256 | } |
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 51af275b3388..b5eb886da226 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h | |||
@@ -94,6 +94,7 @@ enum { | |||
94 | /* HOST_CTL bits */ | 94 | /* HOST_CTL bits */ |
95 | HOST_RESET = (1 << 0), /* reset controller; self-clear */ | 95 | HOST_RESET = (1 << 0), /* reset controller; self-clear */ |
96 | HOST_IRQ_EN = (1 << 1), /* global IRQ enable */ | 96 | HOST_IRQ_EN = (1 << 1), /* global IRQ enable */ |
97 | HOST_MRSM = (1 << 2), /* MSI Revert to Single Message */ | ||
97 | HOST_AHCI_EN = (1 << 31), /* AHCI enabled */ | 98 | HOST_AHCI_EN = (1 << 31), /* AHCI enabled */ |
98 | 99 | ||
99 | /* HOST_CAP bits */ | 100 | /* HOST_CAP bits */ |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index c19734d96d7e..943cc8b83e59 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -4224,8 +4224,10 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4224 | { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, | 4224 | { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, |
4225 | 4225 | ||
4226 | /* devices that don't properly handle queued TRIM commands */ | 4226 | /* devices that don't properly handle queued TRIM commands */ |
4227 | { "Micron_M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, | 4227 | { "Micron_M500*", "MU0[1-4]*", ATA_HORKAGE_NO_NCQ_TRIM, }, |
4228 | { "Crucial_CT???M500SSD*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, | 4228 | { "Crucial_CT???M500SSD*", "MU0[1-4]*", ATA_HORKAGE_NO_NCQ_TRIM, }, |
4229 | { "Micron_M550*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, | ||
4230 | { "Crucial_CT???M550SSD*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, | ||
4229 | 4231 | ||
4230 | /* | 4232 | /* |
4231 | * Some WD SATA-I drives spin up and down erratically when the link | 4233 | * Some WD SATA-I drives spin up and down erratically when the link |
@@ -4792,21 +4794,26 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) | |||
4792 | static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) | 4794 | static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) |
4793 | { | 4795 | { |
4794 | struct ata_queued_cmd *qc = NULL; | 4796 | struct ata_queued_cmd *qc = NULL; |
4795 | unsigned int i; | 4797 | unsigned int i, tag; |
4796 | 4798 | ||
4797 | /* no command while frozen */ | 4799 | /* no command while frozen */ |
4798 | if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) | 4800 | if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) |
4799 | return NULL; | 4801 | return NULL; |
4800 | 4802 | ||
4801 | /* the last tag is reserved for internal command. */ | 4803 | for (i = 0; i < ATA_MAX_QUEUE; i++) { |
4802 | for (i = 0; i < ATA_MAX_QUEUE - 1; i++) | 4804 | tag = (i + ap->last_tag + 1) % ATA_MAX_QUEUE; |
4803 | if (!test_and_set_bit(i, &ap->qc_allocated)) { | 4805 | |
4804 | qc = __ata_qc_from_tag(ap, i); | 4806 | /* the last tag is reserved for internal command. */ |
4807 | if (tag == ATA_TAG_INTERNAL) | ||
4808 | continue; | ||
4809 | |||
4810 | if (!test_and_set_bit(tag, &ap->qc_allocated)) { | ||
4811 | qc = __ata_qc_from_tag(ap, tag); | ||
4812 | qc->tag = tag; | ||
4813 | ap->last_tag = tag; | ||
4805 | break; | 4814 | break; |
4806 | } | 4815 | } |
4807 | 4816 | } | |
4808 | if (qc) | ||
4809 | qc->tag = i; | ||
4810 | 4817 | ||
4811 | return qc; | 4818 | return qc; |
4812 | } | 4819 | } |
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c index 6fac524c2f50..4edb1a81f63f 100644 --- a/drivers/ata/pata_arasan_cf.c +++ b/drivers/ata/pata_arasan_cf.c | |||
@@ -898,9 +898,12 @@ static int arasan_cf_probe(struct platform_device *pdev) | |||
898 | 898 | ||
899 | cf_card_detect(acdev, 0); | 899 | cf_card_detect(acdev, 0); |
900 | 900 | ||
901 | return ata_host_activate(host, acdev->irq, irq_handler, 0, | 901 | ret = ata_host_activate(host, acdev->irq, irq_handler, 0, |
902 | &arasan_cf_sht); | 902 | &arasan_cf_sht); |
903 | if (!ret) | ||
904 | return 0; | ||
903 | 905 | ||
906 | cf_exit(acdev); | ||
904 | free_clk: | 907 | free_clk: |
905 | clk_put(acdev->clk); | 908 | clk_put(acdev->clk); |
906 | return ret; | 909 | return ret; |
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c index e9c87274a781..8a66f23af4c4 100644 --- a/drivers/ata/pata_at91.c +++ b/drivers/ata/pata_at91.c | |||
@@ -407,12 +407,13 @@ static int pata_at91_probe(struct platform_device *pdev) | |||
407 | 407 | ||
408 | host->private_data = info; | 408 | host->private_data = info; |
409 | 409 | ||
410 | return ata_host_activate(host, gpio_is_valid(irq) ? gpio_to_irq(irq) : 0, | 410 | ret = ata_host_activate(host, gpio_is_valid(irq) ? gpio_to_irq(irq) : 0, |
411 | gpio_is_valid(irq) ? ata_sff_interrupt : NULL, | 411 | gpio_is_valid(irq) ? ata_sff_interrupt : NULL, |
412 | irq_flags, &pata_at91_sht); | 412 | irq_flags, &pata_at91_sht); |
413 | if (ret) | ||
414 | goto err_put; | ||
413 | 415 | ||
414 | if (!ret) | 416 | return 0; |
415 | return 0; | ||
416 | 417 | ||
417 | err_put: | 418 | err_put: |
418 | clk_put(info->mck); | 419 | clk_put(info->mck); |
diff --git a/drivers/ata/pata_samsung_cf.c b/drivers/ata/pata_samsung_cf.c index a79566d05666..0610e78c8a2a 100644 --- a/drivers/ata/pata_samsung_cf.c +++ b/drivers/ata/pata_samsung_cf.c | |||
@@ -594,9 +594,13 @@ static int __init pata_s3c_probe(struct platform_device *pdev) | |||
594 | 594 | ||
595 | platform_set_drvdata(pdev, host); | 595 | platform_set_drvdata(pdev, host); |
596 | 596 | ||
597 | return ata_host_activate(host, info->irq, | 597 | ret = ata_host_activate(host, info->irq, |
598 | info->irq ? pata_s3c_irq : NULL, | 598 | info->irq ? pata_s3c_irq : NULL, |
599 | 0, &pata_s3c_sht); | 599 | 0, &pata_s3c_sht); |
600 | if (ret) | ||
601 | goto stop_clk; | ||
602 | |||
603 | return 0; | ||
600 | 604 | ||
601 | stop_clk: | 605 | stop_clk: |
602 | clk_disable(info->clk); | 606 | clk_disable(info->clk); |
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index bf0f8b476696..401add28933f 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -233,7 +233,7 @@ static void acpi_gpiochip_request_interrupts(struct acpi_gpio_chip *acpi_gpio) | |||
233 | { | 233 | { |
234 | struct gpio_chip *chip = acpi_gpio->chip; | 234 | struct gpio_chip *chip = acpi_gpio->chip; |
235 | 235 | ||
236 | if (!chip->dev || !chip->to_irq) | 236 | if (!chip->to_irq) |
237 | return; | 237 | return; |
238 | 238 | ||
239 | INIT_LIST_HEAD(&acpi_gpio->events); | 239 | INIT_LIST_HEAD(&acpi_gpio->events); |
@@ -253,7 +253,7 @@ static void acpi_gpiochip_free_interrupts(struct acpi_gpio_chip *acpi_gpio) | |||
253 | struct acpi_gpio_event *event, *ep; | 253 | struct acpi_gpio_event *event, *ep; |
254 | struct gpio_chip *chip = acpi_gpio->chip; | 254 | struct gpio_chip *chip = acpi_gpio->chip; |
255 | 255 | ||
256 | if (!chip->dev || !chip->to_irq) | 256 | if (!chip->to_irq) |
257 | return; | 257 | return; |
258 | 258 | ||
259 | list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) { | 259 | list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) { |
@@ -451,7 +451,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, | |||
451 | if (function == ACPI_WRITE) | 451 | if (function == ACPI_WRITE) |
452 | gpiod_set_raw_value(desc, !!((1 << i) & *value)); | 452 | gpiod_set_raw_value(desc, !!((1 << i) & *value)); |
453 | else | 453 | else |
454 | *value |= gpiod_get_raw_value(desc) << i; | 454 | *value |= (u64)gpiod_get_raw_value(desc) << i; |
455 | } | 455 | } |
456 | 456 | ||
457 | out: | 457 | out: |
@@ -501,6 +501,9 @@ void acpi_gpiochip_add(struct gpio_chip *chip) | |||
501 | acpi_handle handle; | 501 | acpi_handle handle; |
502 | acpi_status status; | 502 | acpi_status status; |
503 | 503 | ||
504 | if (!chip || !chip->dev) | ||
505 | return; | ||
506 | |||
504 | handle = ACPI_HANDLE(chip->dev); | 507 | handle = ACPI_HANDLE(chip->dev); |
505 | if (!handle) | 508 | if (!handle) |
506 | return; | 509 | return; |
@@ -531,6 +534,9 @@ void acpi_gpiochip_remove(struct gpio_chip *chip) | |||
531 | acpi_handle handle; | 534 | acpi_handle handle; |
532 | acpi_status status; | 535 | acpi_status status; |
533 | 536 | ||
537 | if (!chip || !chip->dev) | ||
538 | return; | ||
539 | |||
534 | handle = ACPI_HANDLE(chip->dev); | 540 | handle = ACPI_HANDLE(chip->dev); |
535 | if (!handle) | 541 | if (!handle) |
536 | return; | 542 | return; |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 761013f8b82f..f48817d97480 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1387,8 +1387,8 @@ static int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, | |||
1387 | { | 1387 | { |
1388 | struct gpio_chip *chip = d->host_data; | 1388 | struct gpio_chip *chip = d->host_data; |
1389 | 1389 | ||
1390 | irq_set_chip_and_handler(irq, chip->irqchip, chip->irq_handler); | ||
1391 | irq_set_chip_data(irq, chip); | 1390 | irq_set_chip_data(irq, chip); |
1391 | irq_set_chip_and_handler(irq, chip->irqchip, chip->irq_handler); | ||
1392 | #ifdef CONFIG_ARM | 1392 | #ifdef CONFIG_ARM |
1393 | set_irq_flags(irq, IRQF_VALID); | 1393 | set_irq_flags(irq, IRQF_VALID); |
1394 | #else | 1394 | #else |
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c index 15936524f226..bc0119fb6c12 100644 --- a/drivers/gpu/drm/radeon/atombios_dp.c +++ b/drivers/gpu/drm/radeon/atombios_dp.c | |||
@@ -209,6 +209,7 @@ void radeon_dp_aux_init(struct radeon_connector *radeon_connector) | |||
209 | { | 209 | { |
210 | int ret; | 210 | int ret; |
211 | 211 | ||
212 | radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd; | ||
212 | radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; | 213 | radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; |
213 | radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer; | 214 | radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer; |
214 | ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux); | 215 | ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux); |
diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c index 89b4afa5041c..f7e46cf682af 100644 --- a/drivers/gpu/drm/radeon/cik_sdma.c +++ b/drivers/gpu/drm/radeon/cik_sdma.c | |||
@@ -597,7 +597,7 @@ int cik_sdma_ring_test(struct radeon_device *rdev, | |||
597 | tmp = 0xCAFEDEAD; | 597 | tmp = 0xCAFEDEAD; |
598 | writel(tmp, ptr); | 598 | writel(tmp, ptr); |
599 | 599 | ||
600 | r = radeon_ring_lock(rdev, ring, 4); | 600 | r = radeon_ring_lock(rdev, ring, 5); |
601 | if (r) { | 601 | if (r) { |
602 | DRM_ERROR("radeon: dma failed to lock ring %d (%d).\n", ring->idx, r); | 602 | DRM_ERROR("radeon: dma failed to lock ring %d (%d).\n", ring->idx, r); |
603 | return r; | 603 | return r; |
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c index cbf7e3269f84..9c61b74ef441 100644 --- a/drivers/gpu/drm/radeon/r600_dpm.c +++ b/drivers/gpu/drm/radeon/r600_dpm.c | |||
@@ -158,16 +158,18 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev) | |||
158 | u32 line_time_us, vblank_lines; | 158 | u32 line_time_us, vblank_lines; |
159 | u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ | 159 | u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ |
160 | 160 | ||
161 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 161 | if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { |
162 | radeon_crtc = to_radeon_crtc(crtc); | 162 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
163 | if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { | 163 | radeon_crtc = to_radeon_crtc(crtc); |
164 | line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) / | 164 | if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { |
165 | radeon_crtc->hw_mode.clock; | 165 | line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) / |
166 | vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end - | 166 | radeon_crtc->hw_mode.clock; |
167 | radeon_crtc->hw_mode.crtc_vdisplay + | 167 | vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end - |
168 | (radeon_crtc->v_border * 2); | 168 | radeon_crtc->hw_mode.crtc_vdisplay + |
169 | vblank_time_us = vblank_lines * line_time_us; | 169 | (radeon_crtc->v_border * 2); |
170 | break; | 170 | vblank_time_us = vblank_lines * line_time_us; |
171 | break; | ||
172 | } | ||
171 | } | 173 | } |
172 | } | 174 | } |
173 | 175 | ||
@@ -181,14 +183,15 @@ u32 r600_dpm_get_vrefresh(struct radeon_device *rdev) | |||
181 | struct radeon_crtc *radeon_crtc; | 183 | struct radeon_crtc *radeon_crtc; |
182 | u32 vrefresh = 0; | 184 | u32 vrefresh = 0; |
183 | 185 | ||
184 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 186 | if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { |
185 | radeon_crtc = to_radeon_crtc(crtc); | 187 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
186 | if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { | 188 | radeon_crtc = to_radeon_crtc(crtc); |
187 | vrefresh = radeon_crtc->hw_mode.vrefresh; | 189 | if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { |
188 | break; | 190 | vrefresh = radeon_crtc->hw_mode.vrefresh; |
191 | break; | ||
192 | } | ||
189 | } | 193 | } |
190 | } | 194 | } |
191 | |||
192 | return vrefresh; | 195 | return vrefresh; |
193 | } | 196 | } |
194 | 197 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c index dedea72f48c4..a9fb0d016d38 100644 --- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c +++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c | |||
@@ -528,6 +528,13 @@ static bool radeon_atpx_detect(void) | |||
528 | has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); | 528 | has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); |
529 | } | 529 | } |
530 | 530 | ||
531 | /* some newer PX laptops mark the dGPU as a non-VGA display device */ | ||
532 | while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { | ||
533 | vga_count++; | ||
534 | |||
535 | has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); | ||
536 | } | ||
537 | |||
531 | if (has_atpx && vga_count == 2) { | 538 | if (has_atpx && vga_count == 2) { |
532 | acpi_get_name(radeon_atpx_priv.atpx.handle, ACPI_FULL_PATHNAME, &buffer); | 539 | acpi_get_name(radeon_atpx_priv.atpx.handle, ACPI_FULL_PATHNAME, &buffer); |
533 | printk(KERN_INFO "VGA switcheroo: detected switching method %s handle\n", | 540 | printk(KERN_INFO "VGA switcheroo: detected switching method %s handle\n", |
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 2f7cbb901fb1..8d99d5ee8014 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
@@ -840,6 +840,38 @@ static void avivo_reduce_ratio(unsigned *nom, unsigned *den, | |||
840 | } | 840 | } |
841 | 841 | ||
842 | /** | 842 | /** |
843 | * avivo_get_fb_ref_div - feedback and ref divider calculation | ||
844 | * | ||
845 | * @nom: nominator | ||
846 | * @den: denominator | ||
847 | * @post_div: post divider | ||
848 | * @fb_div_max: feedback divider maximum | ||
849 | * @ref_div_max: reference divider maximum | ||
850 | * @fb_div: resulting feedback divider | ||
851 | * @ref_div: resulting reference divider | ||
852 | * | ||
853 | * Calculate feedback and reference divider for a given post divider. Makes | ||
854 | * sure we stay within the limits. | ||
855 | */ | ||
856 | static void avivo_get_fb_ref_div(unsigned nom, unsigned den, unsigned post_div, | ||
857 | unsigned fb_div_max, unsigned ref_div_max, | ||
858 | unsigned *fb_div, unsigned *ref_div) | ||
859 | { | ||
860 | /* limit reference * post divider to a maximum */ | ||
861 | ref_div_max = min(210 / post_div, ref_div_max); | ||
862 | |||
863 | /* get matching reference and feedback divider */ | ||
864 | *ref_div = min(max(DIV_ROUND_CLOSEST(den, post_div), 1u), ref_div_max); | ||
865 | *fb_div = DIV_ROUND_CLOSEST(nom * *ref_div * post_div, den); | ||
866 | |||
867 | /* limit fb divider to its maximum */ | ||
868 | if (*fb_div > fb_div_max) { | ||
869 | *ref_div = DIV_ROUND_CLOSEST(*ref_div * fb_div_max, *fb_div); | ||
870 | *fb_div = fb_div_max; | ||
871 | } | ||
872 | } | ||
873 | |||
874 | /** | ||
843 | * radeon_compute_pll_avivo - compute PLL paramaters | 875 | * radeon_compute_pll_avivo - compute PLL paramaters |
844 | * | 876 | * |
845 | * @pll: information about the PLL | 877 | * @pll: information about the PLL |
@@ -860,6 +892,9 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
860 | u32 *ref_div_p, | 892 | u32 *ref_div_p, |
861 | u32 *post_div_p) | 893 | u32 *post_div_p) |
862 | { | 894 | { |
895 | unsigned target_clock = pll->flags & RADEON_PLL_USE_FRAC_FB_DIV ? | ||
896 | freq : freq / 10; | ||
897 | |||
863 | unsigned fb_div_min, fb_div_max, fb_div; | 898 | unsigned fb_div_min, fb_div_max, fb_div; |
864 | unsigned post_div_min, post_div_max, post_div; | 899 | unsigned post_div_min, post_div_max, post_div; |
865 | unsigned ref_div_min, ref_div_max, ref_div; | 900 | unsigned ref_div_min, ref_div_max, ref_div; |
@@ -880,14 +915,18 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
880 | ref_div_min = pll->reference_div; | 915 | ref_div_min = pll->reference_div; |
881 | else | 916 | else |
882 | ref_div_min = pll->min_ref_div; | 917 | ref_div_min = pll->min_ref_div; |
883 | ref_div_max = pll->max_ref_div; | 918 | |
919 | if (pll->flags & RADEON_PLL_USE_FRAC_FB_DIV && | ||
920 | pll->flags & RADEON_PLL_USE_REF_DIV) | ||
921 | ref_div_max = pll->reference_div; | ||
922 | else | ||
923 | ref_div_max = pll->max_ref_div; | ||
884 | 924 | ||
885 | /* determine allowed post divider range */ | 925 | /* determine allowed post divider range */ |
886 | if (pll->flags & RADEON_PLL_USE_POST_DIV) { | 926 | if (pll->flags & RADEON_PLL_USE_POST_DIV) { |
887 | post_div_min = pll->post_div; | 927 | post_div_min = pll->post_div; |
888 | post_div_max = pll->post_div; | 928 | post_div_max = pll->post_div; |
889 | } else { | 929 | } else { |
890 | unsigned target_clock = freq / 10; | ||
891 | unsigned vco_min, vco_max; | 930 | unsigned vco_min, vco_max; |
892 | 931 | ||
893 | if (pll->flags & RADEON_PLL_IS_LCD) { | 932 | if (pll->flags & RADEON_PLL_IS_LCD) { |
@@ -898,6 +937,11 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
898 | vco_max = pll->pll_out_max; | 937 | vco_max = pll->pll_out_max; |
899 | } | 938 | } |
900 | 939 | ||
940 | if (pll->flags & RADEON_PLL_USE_FRAC_FB_DIV) { | ||
941 | vco_min *= 10; | ||
942 | vco_max *= 10; | ||
943 | } | ||
944 | |||
901 | post_div_min = vco_min / target_clock; | 945 | post_div_min = vco_min / target_clock; |
902 | if ((target_clock * post_div_min) < vco_min) | 946 | if ((target_clock * post_div_min) < vco_min) |
903 | ++post_div_min; | 947 | ++post_div_min; |
@@ -912,7 +956,7 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
912 | } | 956 | } |
913 | 957 | ||
914 | /* represent the searched ratio as fractional number */ | 958 | /* represent the searched ratio as fractional number */ |
915 | nom = pll->flags & RADEON_PLL_USE_FRAC_FB_DIV ? freq : freq / 10; | 959 | nom = target_clock; |
916 | den = pll->reference_freq; | 960 | den = pll->reference_freq; |
917 | 961 | ||
918 | /* reduce the numbers to a simpler ratio */ | 962 | /* reduce the numbers to a simpler ratio */ |
@@ -926,7 +970,12 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
926 | diff_best = ~0; | 970 | diff_best = ~0; |
927 | 971 | ||
928 | for (post_div = post_div_min; post_div <= post_div_max; ++post_div) { | 972 | for (post_div = post_div_min; post_div <= post_div_max; ++post_div) { |
929 | unsigned diff = abs(den - den / post_div * post_div); | 973 | unsigned diff; |
974 | avivo_get_fb_ref_div(nom, den, post_div, fb_div_max, | ||
975 | ref_div_max, &fb_div, &ref_div); | ||
976 | diff = abs(target_clock - (pll->reference_freq * fb_div) / | ||
977 | (ref_div * post_div)); | ||
978 | |||
930 | if (diff < diff_best || (diff == diff_best && | 979 | if (diff < diff_best || (diff == diff_best && |
931 | !(pll->flags & RADEON_PLL_PREFER_MINM_OVER_MAXP))) { | 980 | !(pll->flags & RADEON_PLL_PREFER_MINM_OVER_MAXP))) { |
932 | 981 | ||
@@ -936,28 +985,9 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
936 | } | 985 | } |
937 | post_div = post_div_best; | 986 | post_div = post_div_best; |
938 | 987 | ||
939 | /* limit reference * post divider to a maximum */ | 988 | /* get the feedback and reference divider for the optimal value */ |
940 | ref_div_max = min(210 / post_div, ref_div_max); | 989 | avivo_get_fb_ref_div(nom, den, post_div, fb_div_max, ref_div_max, |
941 | 990 | &fb_div, &ref_div); | |
942 | /* get matching reference and feedback divider */ | ||
943 | ref_div = max(DIV_ROUND_CLOSEST(den, post_div), 1u); | ||
944 | fb_div = DIV_ROUND_CLOSEST(nom * ref_div * post_div, den); | ||
945 | |||
946 | /* we're almost done, but reference and feedback | ||
947 | divider might be to large now */ | ||
948 | |||
949 | nom = fb_div; | ||
950 | den = ref_div; | ||
951 | |||
952 | if (fb_div > fb_div_max) { | ||
953 | ref_div = DIV_ROUND_CLOSEST(den * fb_div_max, nom); | ||
954 | fb_div = fb_div_max; | ||
955 | } | ||
956 | |||
957 | if (ref_div > ref_div_max) { | ||
958 | ref_div = ref_div_max; | ||
959 | fb_div = DIV_ROUND_CLOSEST(nom * ref_div_max, den); | ||
960 | } | ||
961 | 991 | ||
962 | /* reduce the numbers to a simpler ratio once more */ | 992 | /* reduce the numbers to a simpler ratio once more */ |
963 | /* this also makes sure that the reference divider is large enough */ | 993 | /* this also makes sure that the reference divider is large enough */ |
@@ -979,7 +1009,7 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
979 | *post_div_p = post_div; | 1009 | *post_div_p = post_div; |
980 | 1010 | ||
981 | DRM_DEBUG_KMS("%d - %d, pll dividers - fb: %d.%d ref: %d, post %d\n", | 1011 | DRM_DEBUG_KMS("%d - %d, pll dividers - fb: %d.%d ref: %d, post %d\n", |
982 | freq, *dot_clock_p, *fb_div_p, *frac_fb_div_p, | 1012 | freq, *dot_clock_p * 10, *fb_div_p, *frac_fb_div_p, |
983 | ref_div, post_div); | 1013 | ref_div, post_div); |
984 | } | 1014 | } |
985 | 1015 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index fb3d13f693dd..0cc47f12d995 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -107,11 +107,9 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) | |||
107 | flags |= RADEON_IS_PCI; | 107 | flags |= RADEON_IS_PCI; |
108 | } | 108 | } |
109 | 109 | ||
110 | if (radeon_runtime_pm == 1) | 110 | if ((radeon_runtime_pm != 0) && |
111 | flags |= RADEON_IS_PX; | 111 | radeon_has_atpx() && |
112 | else if ((radeon_runtime_pm == -1) && | 112 | ((flags & RADEON_IS_IGP) == 0)) |
113 | radeon_has_atpx() && | ||
114 | ((flags & RADEON_IS_IGP) == 0)) | ||
115 | flags |= RADEON_IS_PX; | 113 | flags |= RADEON_IS_PX; |
116 | 114 | ||
117 | /* radeon_device_init should report only fatal error | 115 | /* radeon_device_init should report only fatal error |
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index ee738a524639..6fac8efe8340 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
@@ -603,7 +603,6 @@ static const struct attribute_group *hwmon_groups[] = { | |||
603 | static int radeon_hwmon_init(struct radeon_device *rdev) | 603 | static int radeon_hwmon_init(struct radeon_device *rdev) |
604 | { | 604 | { |
605 | int err = 0; | 605 | int err = 0; |
606 | struct device *hwmon_dev; | ||
607 | 606 | ||
608 | switch (rdev->pm.int_thermal_type) { | 607 | switch (rdev->pm.int_thermal_type) { |
609 | case THERMAL_TYPE_RV6XX: | 608 | case THERMAL_TYPE_RV6XX: |
@@ -616,11 +615,11 @@ static int radeon_hwmon_init(struct radeon_device *rdev) | |||
616 | case THERMAL_TYPE_KV: | 615 | case THERMAL_TYPE_KV: |
617 | if (rdev->asic->pm.get_temperature == NULL) | 616 | if (rdev->asic->pm.get_temperature == NULL) |
618 | return err; | 617 | return err; |
619 | hwmon_dev = hwmon_device_register_with_groups(rdev->dev, | 618 | rdev->pm.int_hwmon_dev = hwmon_device_register_with_groups(rdev->dev, |
620 | "radeon", rdev, | 619 | "radeon", rdev, |
621 | hwmon_groups); | 620 | hwmon_groups); |
622 | if (IS_ERR(hwmon_dev)) { | 621 | if (IS_ERR(rdev->pm.int_hwmon_dev)) { |
623 | err = PTR_ERR(hwmon_dev); | 622 | err = PTR_ERR(rdev->pm.int_hwmon_dev); |
624 | dev_err(rdev->dev, | 623 | dev_err(rdev->dev, |
625 | "Unable to register hwmon device: %d\n", err); | 624 | "Unable to register hwmon device: %d\n", err); |
626 | } | 625 | } |
@@ -632,6 +631,12 @@ static int radeon_hwmon_init(struct radeon_device *rdev) | |||
632 | return err; | 631 | return err; |
633 | } | 632 | } |
634 | 633 | ||
634 | static void radeon_hwmon_fini(struct radeon_device *rdev) | ||
635 | { | ||
636 | if (rdev->pm.int_hwmon_dev) | ||
637 | hwmon_device_unregister(rdev->pm.int_hwmon_dev); | ||
638 | } | ||
639 | |||
635 | static void radeon_dpm_thermal_work_handler(struct work_struct *work) | 640 | static void radeon_dpm_thermal_work_handler(struct work_struct *work) |
636 | { | 641 | { |
637 | struct radeon_device *rdev = | 642 | struct radeon_device *rdev = |
@@ -1257,6 +1262,7 @@ int radeon_pm_init(struct radeon_device *rdev) | |||
1257 | case CHIP_RV670: | 1262 | case CHIP_RV670: |
1258 | case CHIP_RS780: | 1263 | case CHIP_RS780: |
1259 | case CHIP_RS880: | 1264 | case CHIP_RS880: |
1265 | case CHIP_RV770: | ||
1260 | case CHIP_BARTS: | 1266 | case CHIP_BARTS: |
1261 | case CHIP_TURKS: | 1267 | case CHIP_TURKS: |
1262 | case CHIP_CAICOS: | 1268 | case CHIP_CAICOS: |
@@ -1273,7 +1279,6 @@ int radeon_pm_init(struct radeon_device *rdev) | |||
1273 | else | 1279 | else |
1274 | rdev->pm.pm_method = PM_METHOD_PROFILE; | 1280 | rdev->pm.pm_method = PM_METHOD_PROFILE; |
1275 | break; | 1281 | break; |
1276 | case CHIP_RV770: | ||
1277 | case CHIP_RV730: | 1282 | case CHIP_RV730: |
1278 | case CHIP_RV710: | 1283 | case CHIP_RV710: |
1279 | case CHIP_RV740: | 1284 | case CHIP_RV740: |
@@ -1353,6 +1358,8 @@ static void radeon_pm_fini_old(struct radeon_device *rdev) | |||
1353 | device_remove_file(rdev->dev, &dev_attr_power_method); | 1358 | device_remove_file(rdev->dev, &dev_attr_power_method); |
1354 | } | 1359 | } |
1355 | 1360 | ||
1361 | radeon_hwmon_fini(rdev); | ||
1362 | |||
1356 | if (rdev->pm.power_state) | 1363 | if (rdev->pm.power_state) |
1357 | kfree(rdev->pm.power_state); | 1364 | kfree(rdev->pm.power_state); |
1358 | } | 1365 | } |
@@ -1372,6 +1379,8 @@ static void radeon_pm_fini_dpm(struct radeon_device *rdev) | |||
1372 | } | 1379 | } |
1373 | radeon_dpm_fini(rdev); | 1380 | radeon_dpm_fini(rdev); |
1374 | 1381 | ||
1382 | radeon_hwmon_fini(rdev); | ||
1383 | |||
1375 | if (rdev->pm.power_state) | 1384 | if (rdev->pm.power_state) |
1376 | kfree(rdev->pm.power_state); | 1385 | kfree(rdev->pm.power_state); |
1377 | } | 1386 | } |
@@ -1397,12 +1406,14 @@ static void radeon_pm_compute_clocks_old(struct radeon_device *rdev) | |||
1397 | 1406 | ||
1398 | rdev->pm.active_crtcs = 0; | 1407 | rdev->pm.active_crtcs = 0; |
1399 | rdev->pm.active_crtc_count = 0; | 1408 | rdev->pm.active_crtc_count = 0; |
1400 | list_for_each_entry(crtc, | 1409 | if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { |
1401 | &ddev->mode_config.crtc_list, head) { | 1410 | list_for_each_entry(crtc, |
1402 | radeon_crtc = to_radeon_crtc(crtc); | 1411 | &ddev->mode_config.crtc_list, head) { |
1403 | if (radeon_crtc->enabled) { | 1412 | radeon_crtc = to_radeon_crtc(crtc); |
1404 | rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id); | 1413 | if (radeon_crtc->enabled) { |
1405 | rdev->pm.active_crtc_count++; | 1414 | rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id); |
1415 | rdev->pm.active_crtc_count++; | ||
1416 | } | ||
1406 | } | 1417 | } |
1407 | } | 1418 | } |
1408 | 1419 | ||
@@ -1469,12 +1480,14 @@ static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev) | |||
1469 | /* update active crtc counts */ | 1480 | /* update active crtc counts */ |
1470 | rdev->pm.dpm.new_active_crtcs = 0; | 1481 | rdev->pm.dpm.new_active_crtcs = 0; |
1471 | rdev->pm.dpm.new_active_crtc_count = 0; | 1482 | rdev->pm.dpm.new_active_crtc_count = 0; |
1472 | list_for_each_entry(crtc, | 1483 | if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) { |
1473 | &ddev->mode_config.crtc_list, head) { | 1484 | list_for_each_entry(crtc, |
1474 | radeon_crtc = to_radeon_crtc(crtc); | 1485 | &ddev->mode_config.crtc_list, head) { |
1475 | if (crtc->enabled) { | 1486 | radeon_crtc = to_radeon_crtc(crtc); |
1476 | rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id); | 1487 | if (crtc->enabled) { |
1477 | rdev->pm.dpm.new_active_crtc_count++; | 1488 | rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id); |
1489 | rdev->pm.dpm.new_active_crtc_count++; | ||
1490 | } | ||
1478 | } | 1491 | } |
1479 | } | 1492 | } |
1480 | 1493 | ||
diff --git a/drivers/input/misc/da9055_onkey.c b/drivers/input/misc/da9055_onkey.c index 4b11ede34950..4765799fef74 100644 --- a/drivers/input/misc/da9055_onkey.c +++ b/drivers/input/misc/da9055_onkey.c | |||
@@ -109,7 +109,6 @@ static int da9055_onkey_probe(struct platform_device *pdev) | |||
109 | 109 | ||
110 | INIT_DELAYED_WORK(&onkey->work, da9055_onkey_work); | 110 | INIT_DELAYED_WORK(&onkey->work, da9055_onkey_work); |
111 | 111 | ||
112 | irq = regmap_irq_get_virq(da9055->irq_data, irq); | ||
113 | err = request_threaded_irq(irq, NULL, da9055_onkey_irq, | 112 | err = request_threaded_irq(irq, NULL, da9055_onkey_irq, |
114 | IRQF_TRIGGER_HIGH | IRQF_ONESHOT, | 113 | IRQF_TRIGGER_HIGH | IRQF_ONESHOT, |
115 | "ONKEY", onkey); | 114 | "ONKEY", onkey); |
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index 08ead2aaede5..20c80f543d5e 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c | |||
@@ -169,6 +169,7 @@ static int soc_button_pnp_probe(struct pnp_dev *pdev, | |||
169 | soc_button_remove(pdev); | 169 | soc_button_remove(pdev); |
170 | return error; | 170 | return error; |
171 | } | 171 | } |
172 | continue; | ||
172 | } | 173 | } |
173 | 174 | ||
174 | priv->children[i] = pd; | 175 | priv->children[i] = pd; |
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index ef1cf52f8bb9..088d3541c7d3 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
@@ -1353,6 +1353,7 @@ static int elantech_set_properties(struct elantech_data *etd) | |||
1353 | case 6: | 1353 | case 6: |
1354 | case 7: | 1354 | case 7: |
1355 | case 8: | 1355 | case 8: |
1356 | case 9: | ||
1356 | etd->hw_version = 4; | 1357 | etd->hw_version = 4; |
1357 | break; | 1358 | break; |
1358 | default: | 1359 | default: |
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index d8d49d10f9bb..ef9f4913450d 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c | |||
@@ -117,6 +117,44 @@ void synaptics_reset(struct psmouse *psmouse) | |||
117 | } | 117 | } |
118 | 118 | ||
119 | #ifdef CONFIG_MOUSE_PS2_SYNAPTICS | 119 | #ifdef CONFIG_MOUSE_PS2_SYNAPTICS |
120 | /* This list has been kindly provided by Synaptics. */ | ||
121 | static const char * const topbuttonpad_pnp_ids[] = { | ||
122 | "LEN0017", | ||
123 | "LEN0018", | ||
124 | "LEN0019", | ||
125 | "LEN0023", | ||
126 | "LEN002A", | ||
127 | "LEN002B", | ||
128 | "LEN002C", | ||
129 | "LEN002D", | ||
130 | "LEN002E", | ||
131 | "LEN0033", /* Helix */ | ||
132 | "LEN0034", /* T431s, T540, X1 Carbon 2nd */ | ||
133 | "LEN0035", /* X240 */ | ||
134 | "LEN0036", /* T440 */ | ||
135 | "LEN0037", | ||
136 | "LEN0038", | ||
137 | "LEN0041", | ||
138 | "LEN0042", /* Yoga */ | ||
139 | "LEN0045", | ||
140 | "LEN0046", | ||
141 | "LEN0047", | ||
142 | "LEN0048", | ||
143 | "LEN0049", | ||
144 | "LEN2000", | ||
145 | "LEN2001", | ||
146 | "LEN2002", | ||
147 | "LEN2003", | ||
148 | "LEN2004", /* L440 */ | ||
149 | "LEN2005", | ||
150 | "LEN2006", | ||
151 | "LEN2007", | ||
152 | "LEN2008", | ||
153 | "LEN2009", | ||
154 | "LEN200A", | ||
155 | "LEN200B", | ||
156 | NULL | ||
157 | }; | ||
120 | 158 | ||
121 | /***************************************************************************** | 159 | /***************************************************************************** |
122 | * Synaptics communications functions | 160 | * Synaptics communications functions |
@@ -1255,8 +1293,10 @@ static void set_abs_position_params(struct input_dev *dev, | |||
1255 | input_abs_set_res(dev, y_code, priv->y_res); | 1293 | input_abs_set_res(dev, y_code, priv->y_res); |
1256 | } | 1294 | } |
1257 | 1295 | ||
1258 | static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) | 1296 | static void set_input_params(struct psmouse *psmouse, |
1297 | struct synaptics_data *priv) | ||
1259 | { | 1298 | { |
1299 | struct input_dev *dev = psmouse->dev; | ||
1260 | int i; | 1300 | int i; |
1261 | 1301 | ||
1262 | /* Things that apply to both modes */ | 1302 | /* Things that apply to both modes */ |
@@ -1325,6 +1365,17 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) | |||
1325 | 1365 | ||
1326 | if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { | 1366 | if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { |
1327 | __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); | 1367 | __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); |
1368 | /* See if this buttonpad has a top button area */ | ||
1369 | if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4)) { | ||
1370 | for (i = 0; topbuttonpad_pnp_ids[i]; i++) { | ||
1371 | if (strstr(psmouse->ps2dev.serio->firmware_id, | ||
1372 | topbuttonpad_pnp_ids[i])) { | ||
1373 | __set_bit(INPUT_PROP_TOPBUTTONPAD, | ||
1374 | dev->propbit); | ||
1375 | break; | ||
1376 | } | ||
1377 | } | ||
1378 | } | ||
1328 | /* Clickpads report only left button */ | 1379 | /* Clickpads report only left button */ |
1329 | __clear_bit(BTN_RIGHT, dev->keybit); | 1380 | __clear_bit(BTN_RIGHT, dev->keybit); |
1330 | __clear_bit(BTN_MIDDLE, dev->keybit); | 1381 | __clear_bit(BTN_MIDDLE, dev->keybit); |
@@ -1515,6 +1566,14 @@ static const struct dmi_system_id min_max_dmi_table[] __initconst = { | |||
1515 | .driver_data = (int []){1232, 5710, 1156, 4696}, | 1566 | .driver_data = (int []){1232, 5710, 1156, 4696}, |
1516 | }, | 1567 | }, |
1517 | { | 1568 | { |
1569 | /* Lenovo ThinkPad T431s */ | ||
1570 | .matches = { | ||
1571 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | ||
1572 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T431"), | ||
1573 | }, | ||
1574 | .driver_data = (int []){1024, 5112, 2024, 4832}, | ||
1575 | }, | ||
1576 | { | ||
1518 | /* Lenovo ThinkPad T440s */ | 1577 | /* Lenovo ThinkPad T440s */ |
1519 | .matches = { | 1578 | .matches = { |
1520 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | 1579 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
@@ -1523,6 +1582,14 @@ static const struct dmi_system_id min_max_dmi_table[] __initconst = { | |||
1523 | .driver_data = (int []){1024, 5112, 2024, 4832}, | 1582 | .driver_data = (int []){1024, 5112, 2024, 4832}, |
1524 | }, | 1583 | }, |
1525 | { | 1584 | { |
1585 | /* Lenovo ThinkPad L440 */ | ||
1586 | .matches = { | ||
1587 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | ||
1588 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L440"), | ||
1589 | }, | ||
1590 | .driver_data = (int []){1024, 5112, 2024, 4832}, | ||
1591 | }, | ||
1592 | { | ||
1526 | /* Lenovo ThinkPad T540p */ | 1593 | /* Lenovo ThinkPad T540p */ |
1527 | .matches = { | 1594 | .matches = { |
1528 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | 1595 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
@@ -1530,6 +1597,32 @@ static const struct dmi_system_id min_max_dmi_table[] __initconst = { | |||
1530 | }, | 1597 | }, |
1531 | .driver_data = (int []){1024, 5056, 2058, 4832}, | 1598 | .driver_data = (int []){1024, 5056, 2058, 4832}, |
1532 | }, | 1599 | }, |
1600 | { | ||
1601 | /* Lenovo ThinkPad L540 */ | ||
1602 | .matches = { | ||
1603 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | ||
1604 | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L540"), | ||
1605 | }, | ||
1606 | .driver_data = (int []){1024, 5112, 2024, 4832}, | ||
1607 | }, | ||
1608 | { | ||
1609 | /* Lenovo Yoga S1 */ | ||
1610 | .matches = { | ||
1611 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | ||
1612 | DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, | ||
1613 | "ThinkPad S1 Yoga"), | ||
1614 | }, | ||
1615 | .driver_data = (int []){1232, 5710, 1156, 4696}, | ||
1616 | }, | ||
1617 | { | ||
1618 | /* Lenovo ThinkPad X1 Carbon Haswell (3rd generation) */ | ||
1619 | .matches = { | ||
1620 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | ||
1621 | DMI_MATCH(DMI_PRODUCT_VERSION, | ||
1622 | "ThinkPad X1 Carbon 2nd"), | ||
1623 | }, | ||
1624 | .driver_data = (int []){1024, 5112, 2024, 4832}, | ||
1625 | }, | ||
1533 | #endif | 1626 | #endif |
1534 | { } | 1627 | { } |
1535 | }; | 1628 | }; |
@@ -1593,7 +1686,7 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode) | |||
1593 | priv->capabilities, priv->ext_cap, priv->ext_cap_0c, | 1686 | priv->capabilities, priv->ext_cap, priv->ext_cap_0c, |
1594 | priv->board_id, priv->firmware_id); | 1687 | priv->board_id, priv->firmware_id); |
1595 | 1688 | ||
1596 | set_input_params(psmouse->dev, priv); | 1689 | set_input_params(psmouse, priv); |
1597 | 1690 | ||
1598 | /* | 1691 | /* |
1599 | * Encode touchpad model so that it can be used to set | 1692 | * Encode touchpad model so that it can be used to set |
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 0ec9abbe31fe..381b20d4c561 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h | |||
@@ -702,6 +702,17 @@ static int i8042_pnp_aux_irq; | |||
702 | static char i8042_pnp_kbd_name[32]; | 702 | static char i8042_pnp_kbd_name[32]; |
703 | static char i8042_pnp_aux_name[32]; | 703 | static char i8042_pnp_aux_name[32]; |
704 | 704 | ||
705 | static void i8042_pnp_id_to_string(struct pnp_id *id, char *dst, int dst_size) | ||
706 | { | ||
707 | strlcpy(dst, "PNP:", dst_size); | ||
708 | |||
709 | while (id) { | ||
710 | strlcat(dst, " ", dst_size); | ||
711 | strlcat(dst, id->id, dst_size); | ||
712 | id = id->next; | ||
713 | } | ||
714 | } | ||
715 | |||
705 | static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did) | 716 | static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did) |
706 | { | 717 | { |
707 | if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1) | 718 | if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1) |
@@ -718,6 +729,8 @@ static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id * | |||
718 | strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name)); | 729 | strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name)); |
719 | strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name)); | 730 | strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name)); |
720 | } | 731 | } |
732 | i8042_pnp_id_to_string(dev->id, i8042_kbd_firmware_id, | ||
733 | sizeof(i8042_kbd_firmware_id)); | ||
721 | 734 | ||
722 | /* Keyboard ports are always supposed to be wakeup-enabled */ | 735 | /* Keyboard ports are always supposed to be wakeup-enabled */ |
723 | device_set_wakeup_enable(&dev->dev, true); | 736 | device_set_wakeup_enable(&dev->dev, true); |
@@ -742,6 +755,8 @@ static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id * | |||
742 | strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name)); | 755 | strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name)); |
743 | strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name)); | 756 | strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name)); |
744 | } | 757 | } |
758 | i8042_pnp_id_to_string(dev->id, i8042_aux_firmware_id, | ||
759 | sizeof(i8042_aux_firmware_id)); | ||
745 | 760 | ||
746 | i8042_pnp_aux_devices++; | 761 | i8042_pnp_aux_devices++; |
747 | return 0; | 762 | return 0; |
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 020053fa5aaa..3807c3e971cc 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
@@ -87,6 +87,8 @@ MODULE_PARM_DESC(debug, "Turn i8042 debugging mode on and off"); | |||
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | static bool i8042_bypass_aux_irq_test; | 89 | static bool i8042_bypass_aux_irq_test; |
90 | static char i8042_kbd_firmware_id[128]; | ||
91 | static char i8042_aux_firmware_id[128]; | ||
90 | 92 | ||
91 | #include "i8042.h" | 93 | #include "i8042.h" |
92 | 94 | ||
@@ -1218,6 +1220,8 @@ static int __init i8042_create_kbd_port(void) | |||
1218 | serio->dev.parent = &i8042_platform_device->dev; | 1220 | serio->dev.parent = &i8042_platform_device->dev; |
1219 | strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name)); | 1221 | strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name)); |
1220 | strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); | 1222 | strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); |
1223 | strlcpy(serio->firmware_id, i8042_kbd_firmware_id, | ||
1224 | sizeof(serio->firmware_id)); | ||
1221 | 1225 | ||
1222 | port->serio = serio; | 1226 | port->serio = serio; |
1223 | port->irq = I8042_KBD_IRQ; | 1227 | port->irq = I8042_KBD_IRQ; |
@@ -1244,6 +1248,8 @@ static int __init i8042_create_aux_port(int idx) | |||
1244 | if (idx < 0) { | 1248 | if (idx < 0) { |
1245 | strlcpy(serio->name, "i8042 AUX port", sizeof(serio->name)); | 1249 | strlcpy(serio->name, "i8042 AUX port", sizeof(serio->name)); |
1246 | strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); | 1250 | strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); |
1251 | strlcpy(serio->firmware_id, i8042_aux_firmware_id, | ||
1252 | sizeof(serio->firmware_id)); | ||
1247 | serio->close = i8042_port_close; | 1253 | serio->close = i8042_port_close; |
1248 | } else { | 1254 | } else { |
1249 | snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx); | 1255 | snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx); |
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 8f4c4ab04bc2..b29134de983b 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
@@ -451,6 +451,13 @@ static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute * | |||
451 | return retval; | 451 | return retval; |
452 | } | 452 | } |
453 | 453 | ||
454 | static ssize_t firmware_id_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
455 | { | ||
456 | struct serio *serio = to_serio_port(dev); | ||
457 | |||
458 | return sprintf(buf, "%s\n", serio->firmware_id); | ||
459 | } | ||
460 | |||
454 | static DEVICE_ATTR_RO(type); | 461 | static DEVICE_ATTR_RO(type); |
455 | static DEVICE_ATTR_RO(proto); | 462 | static DEVICE_ATTR_RO(proto); |
456 | static DEVICE_ATTR_RO(id); | 463 | static DEVICE_ATTR_RO(id); |
@@ -473,12 +480,14 @@ static DEVICE_ATTR_RO(modalias); | |||
473 | static DEVICE_ATTR_WO(drvctl); | 480 | static DEVICE_ATTR_WO(drvctl); |
474 | static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL); | 481 | static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL); |
475 | static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode); | 482 | static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode); |
483 | static DEVICE_ATTR_RO(firmware_id); | ||
476 | 484 | ||
477 | static struct attribute *serio_device_attrs[] = { | 485 | static struct attribute *serio_device_attrs[] = { |
478 | &dev_attr_modalias.attr, | 486 | &dev_attr_modalias.attr, |
479 | &dev_attr_description.attr, | 487 | &dev_attr_description.attr, |
480 | &dev_attr_drvctl.attr, | 488 | &dev_attr_drvctl.attr, |
481 | &dev_attr_bind_mode.attr, | 489 | &dev_attr_bind_mode.attr, |
490 | &dev_attr_firmware_id.attr, | ||
482 | NULL | 491 | NULL |
483 | }; | 492 | }; |
484 | 493 | ||
@@ -921,9 +930,14 @@ static int serio_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
921 | SERIO_ADD_UEVENT_VAR("SERIO_PROTO=%02x", serio->id.proto); | 930 | SERIO_ADD_UEVENT_VAR("SERIO_PROTO=%02x", serio->id.proto); |
922 | SERIO_ADD_UEVENT_VAR("SERIO_ID=%02x", serio->id.id); | 931 | SERIO_ADD_UEVENT_VAR("SERIO_ID=%02x", serio->id.id); |
923 | SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra); | 932 | SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra); |
933 | |||
924 | SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", | 934 | SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", |
925 | serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); | 935 | serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); |
926 | 936 | ||
937 | if (serio->firmware_id[0]) | ||
938 | SERIO_ADD_UEVENT_VAR("SERIO_FIRMWARE_ID=%s", | ||
939 | serio->firmware_id); | ||
940 | |||
927 | return 0; | 941 | return 0; |
928 | } | 942 | } |
929 | #undef SERIO_ADD_UEVENT_VAR | 943 | #undef SERIO_ADD_UEVENT_VAR |
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index b16ebef5b911..611fc3905d00 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -22,23 +22,18 @@ | |||
22 | #define HID_USAGE_PAGE_DIGITIZER 0x0d | 22 | #define HID_USAGE_PAGE_DIGITIZER 0x0d |
23 | #define HID_USAGE_PAGE_DESKTOP 0x01 | 23 | #define HID_USAGE_PAGE_DESKTOP 0x01 |
24 | #define HID_USAGE 0x09 | 24 | #define HID_USAGE 0x09 |
25 | #define HID_USAGE_X 0x30 | 25 | #define HID_USAGE_X ((HID_USAGE_PAGE_DESKTOP << 16) | 0x30) |
26 | #define HID_USAGE_Y 0x31 | 26 | #define HID_USAGE_Y ((HID_USAGE_PAGE_DESKTOP << 16) | 0x31) |
27 | #define HID_USAGE_X_TILT 0x3d | 27 | #define HID_USAGE_PRESSURE ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x30) |
28 | #define HID_USAGE_Y_TILT 0x3e | 28 | #define HID_USAGE_X_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3d) |
29 | #define HID_USAGE_FINGER 0x22 | 29 | #define HID_USAGE_Y_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3e) |
30 | #define HID_USAGE_STYLUS 0x20 | 30 | #define HID_USAGE_FINGER ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x22) |
31 | #define HID_USAGE_CONTACTMAX 0x55 | 31 | #define HID_USAGE_STYLUS ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x20) |
32 | #define HID_USAGE_CONTACTMAX ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x55) | ||
32 | #define HID_COLLECTION 0xa1 | 33 | #define HID_COLLECTION 0xa1 |
33 | #define HID_COLLECTION_LOGICAL 0x02 | 34 | #define HID_COLLECTION_LOGICAL 0x02 |
34 | #define HID_COLLECTION_END 0xc0 | 35 | #define HID_COLLECTION_END 0xc0 |
35 | 36 | ||
36 | enum { | ||
37 | WCM_UNDEFINED = 0, | ||
38 | WCM_DESKTOP, | ||
39 | WCM_DIGITIZER, | ||
40 | }; | ||
41 | |||
42 | struct hid_descriptor { | 37 | struct hid_descriptor { |
43 | struct usb_descriptor_header header; | 38 | struct usb_descriptor_header header; |
44 | __le16 bcdHID; | 39 | __le16 bcdHID; |
@@ -305,7 +300,7 @@ static int wacom_parse_hid(struct usb_interface *intf, | |||
305 | char limit = 0; | 300 | char limit = 0; |
306 | /* result has to be defined as int for some devices */ | 301 | /* result has to be defined as int for some devices */ |
307 | int result = 0, touch_max = 0; | 302 | int result = 0, touch_max = 0; |
308 | int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0; | 303 | int i = 0, page = 0, finger = 0, pen = 0; |
309 | unsigned char *report; | 304 | unsigned char *report; |
310 | 305 | ||
311 | report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL); | 306 | report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL); |
@@ -332,134 +327,121 @@ static int wacom_parse_hid(struct usb_interface *intf, | |||
332 | 327 | ||
333 | switch (report[i]) { | 328 | switch (report[i]) { |
334 | case HID_USAGE_PAGE: | 329 | case HID_USAGE_PAGE: |
335 | switch (report[i + 1]) { | 330 | page = report[i + 1]; |
336 | case HID_USAGE_PAGE_DIGITIZER: | 331 | i++; |
337 | usage = WCM_DIGITIZER; | ||
338 | i++; | ||
339 | break; | ||
340 | |||
341 | case HID_USAGE_PAGE_DESKTOP: | ||
342 | usage = WCM_DESKTOP; | ||
343 | i++; | ||
344 | break; | ||
345 | } | ||
346 | break; | 332 | break; |
347 | 333 | ||
348 | case HID_USAGE: | 334 | case HID_USAGE: |
349 | switch (report[i + 1]) { | 335 | switch (page << 16 | report[i + 1]) { |
350 | case HID_USAGE_X: | 336 | case HID_USAGE_X: |
351 | if (usage == WCM_DESKTOP) { | 337 | if (finger) { |
352 | if (finger) { | 338 | features->device_type = BTN_TOOL_FINGER; |
353 | features->device_type = BTN_TOOL_FINGER; | 339 | /* touch device at least supports one touch point */ |
354 | /* touch device at least supports one touch point */ | 340 | touch_max = 1; |
355 | touch_max = 1; | 341 | switch (features->type) { |
356 | switch (features->type) { | 342 | case TABLETPC2FG: |
357 | case TABLETPC2FG: | 343 | features->pktlen = WACOM_PKGLEN_TPC2FG; |
358 | features->pktlen = WACOM_PKGLEN_TPC2FG; | 344 | break; |
359 | break; | 345 | |
360 | 346 | case MTSCREEN: | |
361 | case MTSCREEN: | 347 | case WACOM_24HDT: |
362 | case WACOM_24HDT: | 348 | features->pktlen = WACOM_PKGLEN_MTOUCH; |
363 | features->pktlen = WACOM_PKGLEN_MTOUCH; | 349 | break; |
364 | break; | 350 | |
365 | 351 | case MTTPC: | |
366 | case MTTPC: | 352 | features->pktlen = WACOM_PKGLEN_MTTPC; |
367 | features->pktlen = WACOM_PKGLEN_MTTPC; | 353 | break; |
368 | break; | 354 | |
369 | 355 | case BAMBOO_PT: | |
370 | case BAMBOO_PT: | 356 | features->pktlen = WACOM_PKGLEN_BBTOUCH; |
371 | features->pktlen = WACOM_PKGLEN_BBTOUCH; | 357 | break; |
372 | break; | 358 | |
373 | 359 | default: | |
374 | default: | 360 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; |
375 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | 361 | break; |
376 | break; | 362 | } |
377 | } | 363 | |
378 | 364 | switch (features->type) { | |
379 | switch (features->type) { | 365 | case BAMBOO_PT: |
380 | case BAMBOO_PT: | 366 | features->x_phy = |
381 | features->x_phy = | 367 | get_unaligned_le16(&report[i + 5]); |
382 | get_unaligned_le16(&report[i + 5]); | 368 | features->x_max = |
383 | features->x_max = | 369 | get_unaligned_le16(&report[i + 8]); |
384 | get_unaligned_le16(&report[i + 8]); | 370 | i += 15; |
385 | i += 15; | 371 | break; |
386 | break; | 372 | |
387 | 373 | case WACOM_24HDT: | |
388 | case WACOM_24HDT: | ||
389 | features->x_max = | ||
390 | get_unaligned_le16(&report[i + 3]); | ||
391 | features->x_phy = | ||
392 | get_unaligned_le16(&report[i + 8]); | ||
393 | features->unit = report[i - 1]; | ||
394 | features->unitExpo = report[i - 3]; | ||
395 | i += 12; | ||
396 | break; | ||
397 | |||
398 | default: | ||
399 | features->x_max = | ||
400 | get_unaligned_le16(&report[i + 3]); | ||
401 | features->x_phy = | ||
402 | get_unaligned_le16(&report[i + 6]); | ||
403 | features->unit = report[i + 9]; | ||
404 | features->unitExpo = report[i + 11]; | ||
405 | i += 12; | ||
406 | break; | ||
407 | } | ||
408 | } else if (pen) { | ||
409 | /* penabled only accepts exact bytes of data */ | ||
410 | if (features->type >= TABLETPC) | ||
411 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | ||
412 | features->device_type = BTN_TOOL_PEN; | ||
413 | features->x_max = | 374 | features->x_max = |
414 | get_unaligned_le16(&report[i + 3]); | 375 | get_unaligned_le16(&report[i + 3]); |
415 | i += 4; | 376 | features->x_phy = |
377 | get_unaligned_le16(&report[i + 8]); | ||
378 | features->unit = report[i - 1]; | ||
379 | features->unitExpo = report[i - 3]; | ||
380 | i += 12; | ||
381 | break; | ||
382 | |||
383 | default: | ||
384 | features->x_max = | ||
385 | get_unaligned_le16(&report[i + 3]); | ||
386 | features->x_phy = | ||
387 | get_unaligned_le16(&report[i + 6]); | ||
388 | features->unit = report[i + 9]; | ||
389 | features->unitExpo = report[i + 11]; | ||
390 | i += 12; | ||
391 | break; | ||
416 | } | 392 | } |
393 | } else if (pen) { | ||
394 | /* penabled only accepts exact bytes of data */ | ||
395 | if (features->type >= TABLETPC) | ||
396 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; | ||
397 | features->device_type = BTN_TOOL_PEN; | ||
398 | features->x_max = | ||
399 | get_unaligned_le16(&report[i + 3]); | ||
400 | i += 4; | ||
417 | } | 401 | } |
418 | break; | 402 | break; |
419 | 403 | ||
420 | case HID_USAGE_Y: | 404 | case HID_USAGE_Y: |
421 | if (usage == WCM_DESKTOP) { | 405 | if (finger) { |
422 | if (finger) { | 406 | switch (features->type) { |
423 | switch (features->type) { | 407 | case TABLETPC2FG: |
424 | case TABLETPC2FG: | 408 | case MTSCREEN: |
425 | case MTSCREEN: | 409 | case MTTPC: |
426 | case MTTPC: | 410 | features->y_max = |
427 | features->y_max = | 411 | get_unaligned_le16(&report[i + 3]); |
428 | get_unaligned_le16(&report[i + 3]); | 412 | features->y_phy = |
429 | features->y_phy = | 413 | get_unaligned_le16(&report[i + 6]); |
430 | get_unaligned_le16(&report[i + 6]); | 414 | i += 7; |
431 | i += 7; | 415 | break; |
432 | break; | 416 | |
433 | 417 | case WACOM_24HDT: | |
434 | case WACOM_24HDT: | 418 | features->y_max = |
435 | features->y_max = | 419 | get_unaligned_le16(&report[i + 3]); |
436 | get_unaligned_le16(&report[i + 3]); | 420 | features->y_phy = |
437 | features->y_phy = | 421 | get_unaligned_le16(&report[i - 2]); |
438 | get_unaligned_le16(&report[i - 2]); | 422 | i += 7; |
439 | i += 7; | 423 | break; |
440 | break; | 424 | |
441 | 425 | case BAMBOO_PT: | |
442 | case BAMBOO_PT: | 426 | features->y_phy = |
443 | features->y_phy = | 427 | get_unaligned_le16(&report[i + 3]); |
444 | get_unaligned_le16(&report[i + 3]); | 428 | features->y_max = |
445 | features->y_max = | 429 | get_unaligned_le16(&report[i + 6]); |
446 | get_unaligned_le16(&report[i + 6]); | 430 | i += 12; |
447 | i += 12; | 431 | break; |
448 | break; | 432 | |
449 | 433 | default: | |
450 | default: | ||
451 | features->y_max = | ||
452 | features->x_max; | ||
453 | features->y_phy = | ||
454 | get_unaligned_le16(&report[i + 3]); | ||
455 | i += 4; | ||
456 | break; | ||
457 | } | ||
458 | } else if (pen) { | ||
459 | features->y_max = | 434 | features->y_max = |
435 | features->x_max; | ||
436 | features->y_phy = | ||
460 | get_unaligned_le16(&report[i + 3]); | 437 | get_unaligned_le16(&report[i + 3]); |
461 | i += 4; | 438 | i += 4; |
439 | break; | ||
462 | } | 440 | } |
441 | } else if (pen) { | ||
442 | features->y_max = | ||
443 | get_unaligned_le16(&report[i + 3]); | ||
444 | i += 4; | ||
463 | } | 445 | } |
464 | break; | 446 | break; |
465 | 447 | ||
@@ -484,12 +466,20 @@ static int wacom_parse_hid(struct usb_interface *intf, | |||
484 | wacom_retrieve_report_data(intf, features); | 466 | wacom_retrieve_report_data(intf, features); |
485 | i++; | 467 | i++; |
486 | break; | 468 | break; |
469 | |||
470 | case HID_USAGE_PRESSURE: | ||
471 | if (pen) { | ||
472 | features->pressure_max = | ||
473 | get_unaligned_le16(&report[i + 3]); | ||
474 | i += 4; | ||
475 | } | ||
476 | break; | ||
487 | } | 477 | } |
488 | break; | 478 | break; |
489 | 479 | ||
490 | case HID_COLLECTION_END: | 480 | case HID_COLLECTION_END: |
491 | /* reset UsagePage and Finger */ | 481 | /* reset UsagePage and Finger */ |
492 | finger = usage = 0; | 482 | finger = page = 0; |
493 | break; | 483 | break; |
494 | 484 | ||
495 | case HID_COLLECTION: | 485 | case HID_COLLECTION: |
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 05f371df6c40..4822c57a3756 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -178,10 +178,9 @@ static int wacom_ptu_irq(struct wacom_wac *wacom) | |||
178 | 178 | ||
179 | static int wacom_dtu_irq(struct wacom_wac *wacom) | 179 | static int wacom_dtu_irq(struct wacom_wac *wacom) |
180 | { | 180 | { |
181 | struct wacom_features *features = &wacom->features; | 181 | unsigned char *data = wacom->data; |
182 | char *data = wacom->data; | ||
183 | struct input_dev *input = wacom->input; | 182 | struct input_dev *input = wacom->input; |
184 | int prox = data[1] & 0x20, pressure; | 183 | int prox = data[1] & 0x20; |
185 | 184 | ||
186 | dev_dbg(input->dev.parent, | 185 | dev_dbg(input->dev.parent, |
187 | "%s: received report #%d", __func__, data[0]); | 186 | "%s: received report #%d", __func__, data[0]); |
@@ -198,10 +197,7 @@ static int wacom_dtu_irq(struct wacom_wac *wacom) | |||
198 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); | 197 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
199 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | 198 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
200 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | 199 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
201 | pressure = ((data[7] & 0x01) << 8) | data[6]; | 200 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]); |
202 | if (pressure < 0) | ||
203 | pressure = features->pressure_max + pressure + 1; | ||
204 | input_report_abs(input, ABS_PRESSURE, pressure); | ||
205 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); | 201 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
206 | if (!prox) /* out-prox */ | 202 | if (!prox) /* out-prox */ |
207 | wacom->id[0] = 0; | 203 | wacom->id[0] = 0; |
@@ -906,7 +902,7 @@ static int int_dist(int x1, int y1, int x2, int y2) | |||
906 | static int wacom_24hdt_irq(struct wacom_wac *wacom) | 902 | static int wacom_24hdt_irq(struct wacom_wac *wacom) |
907 | { | 903 | { |
908 | struct input_dev *input = wacom->input; | 904 | struct input_dev *input = wacom->input; |
909 | char *data = wacom->data; | 905 | unsigned char *data = wacom->data; |
910 | int i; | 906 | int i; |
911 | int current_num_contacts = data[61]; | 907 | int current_num_contacts = data[61]; |
912 | int contacts_to_send = 0; | 908 | int contacts_to_send = 0; |
@@ -959,7 +955,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom) | |||
959 | static int wacom_mt_touch(struct wacom_wac *wacom) | 955 | static int wacom_mt_touch(struct wacom_wac *wacom) |
960 | { | 956 | { |
961 | struct input_dev *input = wacom->input; | 957 | struct input_dev *input = wacom->input; |
962 | char *data = wacom->data; | 958 | unsigned char *data = wacom->data; |
963 | int i; | 959 | int i; |
964 | int current_num_contacts = data[2]; | 960 | int current_num_contacts = data[2]; |
965 | int contacts_to_send = 0; | 961 | int contacts_to_send = 0; |
@@ -1038,7 +1034,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom) | |||
1038 | 1034 | ||
1039 | static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) | 1035 | static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) |
1040 | { | 1036 | { |
1041 | char *data = wacom->data; | 1037 | unsigned char *data = wacom->data; |
1042 | struct input_dev *input = wacom->input; | 1038 | struct input_dev *input = wacom->input; |
1043 | bool prox; | 1039 | bool prox; |
1044 | int x = 0, y = 0; | 1040 | int x = 0, y = 0; |
@@ -1074,10 +1070,8 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) | |||
1074 | 1070 | ||
1075 | static int wacom_tpc_pen(struct wacom_wac *wacom) | 1071 | static int wacom_tpc_pen(struct wacom_wac *wacom) |
1076 | { | 1072 | { |
1077 | struct wacom_features *features = &wacom->features; | 1073 | unsigned char *data = wacom->data; |
1078 | char *data = wacom->data; | ||
1079 | struct input_dev *input = wacom->input; | 1074 | struct input_dev *input = wacom->input; |
1080 | int pressure; | ||
1081 | bool prox = data[1] & 0x20; | 1075 | bool prox = data[1] & 0x20; |
1082 | 1076 | ||
1083 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ | 1077 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ |
@@ -1093,10 +1087,7 @@ static int wacom_tpc_pen(struct wacom_wac *wacom) | |||
1093 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); | 1087 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
1094 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | 1088 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
1095 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | 1089 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
1096 | pressure = ((data[7] & 0x01) << 8) | data[6]; | 1090 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x03) << 8) | data[6]); |
1097 | if (pressure < 0) | ||
1098 | pressure = features->pressure_max + pressure + 1; | ||
1099 | input_report_abs(input, ABS_PRESSURE, pressure); | ||
1100 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); | 1091 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
1101 | input_report_key(input, wacom->tool[0], prox); | 1092 | input_report_key(input, wacom->tool[0], prox); |
1102 | return 1; | 1093 | return 1; |
@@ -1107,7 +1098,7 @@ static int wacom_tpc_pen(struct wacom_wac *wacom) | |||
1107 | 1098 | ||
1108 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) | 1099 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) |
1109 | { | 1100 | { |
1110 | char *data = wacom->data; | 1101 | unsigned char *data = wacom->data; |
1111 | 1102 | ||
1112 | dev_dbg(wacom->input->dev.parent, | 1103 | dev_dbg(wacom->input->dev.parent, |
1113 | "%s: received report #%d\n", __func__, data[0]); | 1104 | "%s: received report #%d\n", __func__, data[0]); |
@@ -1838,7 +1829,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1838 | case DTU: | 1829 | case DTU: |
1839 | if (features->type == DTUS) { | 1830 | if (features->type == DTUS) { |
1840 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); | 1831 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); |
1841 | for (i = 0; i < 3; i++) | 1832 | for (i = 0; i < 4; i++) |
1842 | __set_bit(BTN_0 + i, input_dev->keybit); | 1833 | __set_bit(BTN_0 + i, input_dev->keybit); |
1843 | } | 1834 | } |
1844 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); | 1835 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 45a06e495ed2..7f8aa981500d 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -425,7 +425,7 @@ static int ads7845_read12_ser(struct device *dev, unsigned command) | |||
425 | name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \ | 425 | name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \ |
426 | { \ | 426 | { \ |
427 | struct ads7846 *ts = dev_get_drvdata(dev); \ | 427 | struct ads7846 *ts = dev_get_drvdata(dev); \ |
428 | ssize_t v = ads7846_read12_ser(dev, \ | 428 | ssize_t v = ads7846_read12_ser(&ts->spi->dev, \ |
429 | READ_12BIT_SER(var)); \ | 429 | READ_12BIT_SER(var)); \ |
430 | if (v < 0) \ | 430 | if (v < 0) \ |
431 | return v; \ | 431 | return v; \ |
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c index ded3b3574209..6d38be3d970c 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c | |||
@@ -38,66 +38,24 @@ struct pbias_reg_info { | |||
38 | struct pbias_regulator_data { | 38 | struct pbias_regulator_data { |
39 | struct regulator_desc desc; | 39 | struct regulator_desc desc; |
40 | void __iomem *pbias_addr; | 40 | void __iomem *pbias_addr; |
41 | unsigned int pbias_reg; | ||
42 | struct regulator_dev *dev; | 41 | struct regulator_dev *dev; |
43 | struct regmap *syscon; | 42 | struct regmap *syscon; |
44 | const struct pbias_reg_info *info; | 43 | const struct pbias_reg_info *info; |
45 | int voltage; | 44 | int voltage; |
46 | }; | 45 | }; |
47 | 46 | ||
48 | static int pbias_regulator_set_voltage(struct regulator_dev *dev, | 47 | static const unsigned int pbias_volt_table[] = { |
49 | int min_uV, int max_uV, unsigned *selector) | 48 | 1800000, |
50 | { | 49 | 3000000 |
51 | struct pbias_regulator_data *data = rdev_get_drvdata(dev); | 50 | }; |
52 | const struct pbias_reg_info *info = data->info; | ||
53 | int ret, vmode; | ||
54 | |||
55 | if (min_uV <= 1800000) | ||
56 | vmode = 0; | ||
57 | else if (min_uV > 1800000) | ||
58 | vmode = info->vmode; | ||
59 | |||
60 | ret = regmap_update_bits(data->syscon, data->pbias_reg, | ||
61 | info->vmode, vmode); | ||
62 | |||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | static int pbias_regulator_get_voltage(struct regulator_dev *rdev) | ||
67 | { | ||
68 | struct pbias_regulator_data *data = rdev_get_drvdata(rdev); | ||
69 | const struct pbias_reg_info *info = data->info; | ||
70 | int value, voltage; | ||
71 | |||
72 | regmap_read(data->syscon, data->pbias_reg, &value); | ||
73 | value &= info->vmode; | ||
74 | |||
75 | voltage = value ? 3000000 : 1800000; | ||
76 | |||
77 | return voltage; | ||
78 | } | ||
79 | 51 | ||
80 | static int pbias_regulator_enable(struct regulator_dev *rdev) | 52 | static int pbias_regulator_enable(struct regulator_dev *rdev) |
81 | { | 53 | { |
82 | struct pbias_regulator_data *data = rdev_get_drvdata(rdev); | 54 | struct pbias_regulator_data *data = rdev_get_drvdata(rdev); |
83 | const struct pbias_reg_info *info = data->info; | 55 | const struct pbias_reg_info *info = data->info; |
84 | int ret; | ||
85 | |||
86 | ret = regmap_update_bits(data->syscon, data->pbias_reg, | ||
87 | info->enable_mask, info->enable); | ||
88 | |||
89 | return ret; | ||
90 | } | ||
91 | |||
92 | static int pbias_regulator_disable(struct regulator_dev *rdev) | ||
93 | { | ||
94 | struct pbias_regulator_data *data = rdev_get_drvdata(rdev); | ||
95 | const struct pbias_reg_info *info = data->info; | ||
96 | int ret; | ||
97 | 56 | ||
98 | ret = regmap_update_bits(data->syscon, data->pbias_reg, | 57 | return regmap_update_bits(data->syscon, rdev->desc->enable_reg, |
99 | info->enable_mask, 0); | 58 | info->enable_mask, info->enable); |
100 | return ret; | ||
101 | } | 59 | } |
102 | 60 | ||
103 | static int pbias_regulator_is_enable(struct regulator_dev *rdev) | 61 | static int pbias_regulator_is_enable(struct regulator_dev *rdev) |
@@ -106,17 +64,18 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev) | |||
106 | const struct pbias_reg_info *info = data->info; | 64 | const struct pbias_reg_info *info = data->info; |
107 | int value; | 65 | int value; |
108 | 66 | ||
109 | regmap_read(data->syscon, data->pbias_reg, &value); | 67 | regmap_read(data->syscon, rdev->desc->enable_reg, &value); |
110 | 68 | ||
111 | return (value & info->enable_mask) == info->enable_mask; | 69 | return (value & info->enable_mask) == info->enable; |
112 | } | 70 | } |
113 | 71 | ||
114 | static struct regulator_ops pbias_regulator_voltage_ops = { | 72 | static struct regulator_ops pbias_regulator_voltage_ops = { |
115 | .set_voltage = pbias_regulator_set_voltage, | 73 | .list_voltage = regulator_list_voltage_table, |
116 | .get_voltage = pbias_regulator_get_voltage, | 74 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
117 | .enable = pbias_regulator_enable, | 75 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
118 | .disable = pbias_regulator_disable, | 76 | .enable = pbias_regulator_enable, |
119 | .is_enabled = pbias_regulator_is_enable, | 77 | .disable = regulator_disable_regmap, |
78 | .is_enabled = pbias_regulator_is_enable, | ||
120 | }; | 79 | }; |
121 | 80 | ||
122 | static const struct pbias_reg_info pbias_mmc_omap2430 = { | 81 | static const struct pbias_reg_info pbias_mmc_omap2430 = { |
@@ -192,6 +151,7 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
192 | if (IS_ERR(syscon)) | 151 | if (IS_ERR(syscon)) |
193 | return PTR_ERR(syscon); | 152 | return PTR_ERR(syscon); |
194 | 153 | ||
154 | cfg.regmap = syscon; | ||
195 | cfg.dev = &pdev->dev; | 155 | cfg.dev = &pdev->dev; |
196 | 156 | ||
197 | for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { | 157 | for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { |
@@ -207,15 +167,19 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
207 | if (!res) | 167 | if (!res) |
208 | return -EINVAL; | 168 | return -EINVAL; |
209 | 169 | ||
210 | drvdata[data_idx].pbias_reg = res->start; | ||
211 | drvdata[data_idx].syscon = syscon; | 170 | drvdata[data_idx].syscon = syscon; |
212 | drvdata[data_idx].info = info; | 171 | drvdata[data_idx].info = info; |
213 | drvdata[data_idx].desc.name = info->name; | 172 | drvdata[data_idx].desc.name = info->name; |
214 | drvdata[data_idx].desc.owner = THIS_MODULE; | 173 | drvdata[data_idx].desc.owner = THIS_MODULE; |
215 | drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; | 174 | drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; |
216 | drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; | 175 | drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; |
176 | drvdata[data_idx].desc.volt_table = pbias_volt_table; | ||
217 | drvdata[data_idx].desc.n_voltages = 2; | 177 | drvdata[data_idx].desc.n_voltages = 2; |
218 | drvdata[data_idx].desc.enable_time = info->enable_time; | 178 | drvdata[data_idx].desc.enable_time = info->enable_time; |
179 | drvdata[data_idx].desc.vsel_reg = res->start; | ||
180 | drvdata[data_idx].desc.vsel_mask = info->vmode; | ||
181 | drvdata[data_idx].desc.enable_reg = res->start; | ||
182 | drvdata[data_idx].desc.enable_mask = info->enable_mask; | ||
219 | 183 | ||
220 | cfg.init_data = pbias_matches[idx].init_data; | 184 | cfg.init_data = pbias_matches[idx].init_data; |
221 | cfg.driver_data = &drvdata[data_idx]; | 185 | cfg.driver_data = &drvdata[data_idx]; |
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 8005f9869481..079e6b1b0cdb 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c | |||
@@ -1115,8 +1115,11 @@ static int atmel_spi_one_transfer(struct spi_master *master, | |||
1115 | atmel_spi_next_xfer_pio(master, xfer); | 1115 | atmel_spi_next_xfer_pio(master, xfer); |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | /* interrupts are disabled, so free the lock for schedule */ | ||
1119 | atmel_spi_unlock(as); | ||
1118 | ret = wait_for_completion_timeout(&as->xfer_completion, | 1120 | ret = wait_for_completion_timeout(&as->xfer_completion, |
1119 | SPI_DMA_TIMEOUT); | 1121 | SPI_DMA_TIMEOUT); |
1122 | atmel_spi_lock(as); | ||
1120 | if (WARN_ON(ret == 0)) { | 1123 | if (WARN_ON(ret == 0)) { |
1121 | dev_err(&spi->dev, | 1124 | dev_err(&spi->dev, |
1122 | "spi trasfer timeout, err %d\n", ret); | 1125 | "spi trasfer timeout, err %d\n", ret); |
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c index 55e57c3eb9bd..ebf720b88a2a 100644 --- a/drivers/spi/spi-bfin5xx.c +++ b/drivers/spi/spi-bfin5xx.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/device.h> | 14 | #include <linux/device.h> |
15 | #include <linux/gpio.h> | ||
15 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
16 | #include <linux/io.h> | 17 | #include <linux/io.h> |
17 | #include <linux/ioport.h> | 18 | #include <linux/ioport.h> |
diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c index 9009456bdf4d..c8e795ef2e13 100644 --- a/drivers/spi/spi-sh-hspi.c +++ b/drivers/spi/spi-sh-hspi.c | |||
@@ -244,9 +244,9 @@ static int hspi_probe(struct platform_device *pdev) | |||
244 | return -ENOMEM; | 244 | return -ENOMEM; |
245 | } | 245 | } |
246 | 246 | ||
247 | clk = clk_get(NULL, "shyway_clk"); | 247 | clk = clk_get(&pdev->dev, NULL); |
248 | if (IS_ERR(clk)) { | 248 | if (IS_ERR(clk)) { |
249 | dev_err(&pdev->dev, "shyway_clk is required\n"); | 249 | dev_err(&pdev->dev, "couldn't get clock\n"); |
250 | ret = -EINVAL; | 250 | ret = -EINVAL; |
251 | goto error0; | 251 | goto error0; |
252 | } | 252 | } |
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index 1a77ad52812f..67d8909dcf39 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c | |||
@@ -287,8 +287,8 @@ static irqreturn_t spi_sirfsoc_irq(int irq, void *dev_id) | |||
287 | sspi->left_rx_word) | 287 | sspi->left_rx_word) |
288 | sspi->rx_word(sspi); | 288 | sspi->rx_word(sspi); |
289 | 289 | ||
290 | if (spi_stat & (SIRFSOC_SPI_FIFO_EMPTY | 290 | if (spi_stat & (SIRFSOC_SPI_TXFIFO_EMPTY | |
291 | | SIRFSOC_SPI_TXFIFO_THD_REACH)) | 291 | SIRFSOC_SPI_TXFIFO_THD_REACH)) |
292 | while (!((readl(sspi->base + SIRFSOC_SPI_TXFIFO_STATUS) | 292 | while (!((readl(sspi->base + SIRFSOC_SPI_TXFIFO_STATUS) |
293 | & SIRFSOC_SPI_FIFO_FULL)) && | 293 | & SIRFSOC_SPI_FIFO_FULL)) && |
294 | sspi->left_tx_word) | 294 | sspi->left_tx_word) |
@@ -470,7 +470,16 @@ static void spi_sirfsoc_chipselect(struct spi_device *spi, int value) | |||
470 | writel(regval, sspi->base + SIRFSOC_SPI_CTRL); | 470 | writel(regval, sspi->base + SIRFSOC_SPI_CTRL); |
471 | } else { | 471 | } else { |
472 | int gpio = sspi->chipselect[spi->chip_select]; | 472 | int gpio = sspi->chipselect[spi->chip_select]; |
473 | gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1); | 473 | switch (value) { |
474 | case BITBANG_CS_ACTIVE: | ||
475 | gpio_direction_output(gpio, | ||
476 | spi->mode & SPI_CS_HIGH ? 1 : 0); | ||
477 | break; | ||
478 | case BITBANG_CS_INACTIVE: | ||
479 | gpio_direction_output(gpio, | ||
480 | spi->mode & SPI_CS_HIGH ? 0 : 1); | ||
481 | break; | ||
482 | } | ||
474 | } | 483 | } |
475 | } | 484 | } |
476 | 485 | ||
@@ -559,6 +568,11 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
559 | regval &= ~SIRFSOC_SPI_CMD_MODE; | 568 | regval &= ~SIRFSOC_SPI_CMD_MODE; |
560 | sspi->tx_by_cmd = false; | 569 | sspi->tx_by_cmd = false; |
561 | } | 570 | } |
571 | /* | ||
572 | * set spi controller in RISC chipselect mode, we are controlling CS by | ||
573 | * software BITBANG_CS_ACTIVE and BITBANG_CS_INACTIVE. | ||
574 | */ | ||
575 | regval |= SIRFSOC_SPI_CS_IO_MODE; | ||
562 | writel(regval, sspi->base + SIRFSOC_SPI_CTRL); | 576 | writel(regval, sspi->base + SIRFSOC_SPI_CTRL); |
563 | 577 | ||
564 | if (IS_DMA_VALID(t)) { | 578 | if (IS_DMA_VALID(t)) { |
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 39da1c2efa50..88a6df4cbe6d 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -1221,9 +1221,6 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1221 | if (!S_ISREG(inode->i_mode)) | 1221 | if (!S_ISREG(inode->i_mode)) |
1222 | return -EOPNOTSUPP; | 1222 | return -EOPNOTSUPP; |
1223 | 1223 | ||
1224 | if (IS_SWAPFILE(inode)) | ||
1225 | return -ETXTBSY; | ||
1226 | |||
1227 | mutex_lock(&inode->i_mutex); | 1224 | mutex_lock(&inode->i_mutex); |
1228 | 1225 | ||
1229 | if (ceph_snap(inode) != CEPH_NOSNAP) { | 1226 | if (ceph_snap(inode) != CEPH_NOSNAP) { |
diff --git a/fs/compat.c b/fs/compat.c index ca926ad0430c..66d3d3c6b4b2 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -457,9 +457,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, | |||
457 | case F_GETLK64: | 457 | case F_GETLK64: |
458 | case F_SETLK64: | 458 | case F_SETLK64: |
459 | case F_SETLKW64: | 459 | case F_SETLKW64: |
460 | case F_GETLKP: | 460 | case F_OFD_GETLK: |
461 | case F_SETLKP: | 461 | case F_OFD_SETLK: |
462 | case F_SETLKPW: | 462 | case F_OFD_SETLKW: |
463 | ret = get_compat_flock64(&f, compat_ptr(arg)); | 463 | ret = get_compat_flock64(&f, compat_ptr(arg)); |
464 | if (ret != 0) | 464 | if (ret != 0) |
465 | break; | 465 | break; |
@@ -468,7 +468,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, | |||
468 | conv_cmd = convert_fcntl_cmd(cmd); | 468 | conv_cmd = convert_fcntl_cmd(cmd); |
469 | ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f); | 469 | ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f); |
470 | set_fs(old_fs); | 470 | set_fs(old_fs); |
471 | if ((conv_cmd == F_GETLK || conv_cmd == F_GETLKP) && ret == 0) { | 471 | if ((conv_cmd == F_GETLK || conv_cmd == F_OFD_GETLK) && ret == 0) { |
472 | /* need to return lock information - see above for commentary */ | 472 | /* need to return lock information - see above for commentary */ |
473 | if (f.l_start > COMPAT_LOFF_T_MAX) | 473 | if (f.l_start > COMPAT_LOFF_T_MAX) |
474 | ret = -EOVERFLOW; | 474 | ret = -EOVERFLOW; |
@@ -493,9 +493,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, | |||
493 | case F_GETLK64: | 493 | case F_GETLK64: |
494 | case F_SETLK64: | 494 | case F_SETLK64: |
495 | case F_SETLKW64: | 495 | case F_SETLKW64: |
496 | case F_GETLKP: | 496 | case F_OFD_GETLK: |
497 | case F_SETLKP: | 497 | case F_OFD_SETLK: |
498 | case F_SETLKPW: | 498 | case F_OFD_SETLKW: |
499 | return -EINVAL; | 499 | return -EINVAL; |
500 | } | 500 | } |
501 | return compat_sys_fcntl64(fd, cmd, arg); | 501 | return compat_sys_fcntl64(fd, cmd, arg); |
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 6ea7b1436bbc..5c56785007e0 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -667,7 +667,7 @@ ext4_fsblk_t ext4_count_free_clusters(struct super_block *sb) | |||
667 | continue; | 667 | continue; |
668 | 668 | ||
669 | x = ext4_count_free(bitmap_bh->b_data, | 669 | x = ext4_count_free(bitmap_bh->b_data, |
670 | EXT4_BLOCKS_PER_GROUP(sb) / 8); | 670 | EXT4_CLUSTERS_PER_GROUP(sb) / 8); |
671 | printk(KERN_DEBUG "group %u: stored = %d, counted = %u\n", | 671 | printk(KERN_DEBUG "group %u: stored = %d, counted = %u\n", |
672 | i, ext4_free_group_clusters(sb, gdp), x); | 672 | i, ext4_free_group_clusters(sb, gdp), x); |
673 | bitmap_count += x; | 673 | bitmap_count += x; |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index f1c65dc7cc0a..66946aa62127 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -2466,23 +2466,6 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize) | |||
2466 | up_write(&EXT4_I(inode)->i_data_sem); | 2466 | up_write(&EXT4_I(inode)->i_data_sem); |
2467 | } | 2467 | } |
2468 | 2468 | ||
2469 | /* | ||
2470 | * Update i_disksize after writeback has been started. Races with truncate | ||
2471 | * are avoided by checking i_size under i_data_sem. | ||
2472 | */ | ||
2473 | static inline void ext4_wb_update_i_disksize(struct inode *inode, loff_t newsize) | ||
2474 | { | ||
2475 | loff_t i_size; | ||
2476 | |||
2477 | down_write(&EXT4_I(inode)->i_data_sem); | ||
2478 | i_size = i_size_read(inode); | ||
2479 | if (newsize > i_size) | ||
2480 | newsize = i_size; | ||
2481 | if (newsize > EXT4_I(inode)->i_disksize) | ||
2482 | EXT4_I(inode)->i_disksize = newsize; | ||
2483 | up_write(&EXT4_I(inode)->i_data_sem); | ||
2484 | } | ||
2485 | |||
2486 | struct ext4_group_info { | 2469 | struct ext4_group_info { |
2487 | unsigned long bb_state; | 2470 | unsigned long bb_state; |
2488 | struct rb_root bb_free_root; | 2471 | struct rb_root bb_free_root; |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 82df3ce9874a..01b0c208f625 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -3313,6 +3313,11 @@ static int ext4_split_extent(handle_t *handle, | |||
3313 | return PTR_ERR(path); | 3313 | return PTR_ERR(path); |
3314 | depth = ext_depth(inode); | 3314 | depth = ext_depth(inode); |
3315 | ex = path[depth].p_ext; | 3315 | ex = path[depth].p_ext; |
3316 | if (!ex) { | ||
3317 | EXT4_ERROR_INODE(inode, "unexpected hole at %lu", | ||
3318 | (unsigned long) map->m_lblk); | ||
3319 | return -EIO; | ||
3320 | } | ||
3316 | uninitialized = ext4_ext_is_uninitialized(ex); | 3321 | uninitialized = ext4_ext_is_uninitialized(ex); |
3317 | split_flag1 = 0; | 3322 | split_flag1 = 0; |
3318 | 3323 | ||
@@ -3694,6 +3699,12 @@ static int ext4_convert_initialized_extents(handle_t *handle, | |||
3694 | } | 3699 | } |
3695 | depth = ext_depth(inode); | 3700 | depth = ext_depth(inode); |
3696 | ex = path[depth].p_ext; | 3701 | ex = path[depth].p_ext; |
3702 | if (!ex) { | ||
3703 | EXT4_ERROR_INODE(inode, "unexpected hole at %lu", | ||
3704 | (unsigned long) map->m_lblk); | ||
3705 | err = -EIO; | ||
3706 | goto out; | ||
3707 | } | ||
3697 | } | 3708 | } |
3698 | 3709 | ||
3699 | err = ext4_ext_get_access(handle, inode, path + depth); | 3710 | err = ext4_ext_get_access(handle, inode, path + depth); |
@@ -4730,6 +4741,9 @@ static long ext4_zero_range(struct file *file, loff_t offset, | |||
4730 | 4741 | ||
4731 | trace_ext4_zero_range(inode, offset, len, mode); | 4742 | trace_ext4_zero_range(inode, offset, len, mode); |
4732 | 4743 | ||
4744 | if (!S_ISREG(inode->i_mode)) | ||
4745 | return -EINVAL; | ||
4746 | |||
4733 | /* | 4747 | /* |
4734 | * Write out all dirty pages to avoid race conditions | 4748 | * Write out all dirty pages to avoid race conditions |
4735 | * Then release them. | 4749 | * Then release them. |
@@ -4878,9 +4892,6 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
4878 | if (mode & FALLOC_FL_PUNCH_HOLE) | 4892 | if (mode & FALLOC_FL_PUNCH_HOLE) |
4879 | return ext4_punch_hole(inode, offset, len); | 4893 | return ext4_punch_hole(inode, offset, len); |
4880 | 4894 | ||
4881 | if (mode & FALLOC_FL_COLLAPSE_RANGE) | ||
4882 | return ext4_collapse_range(inode, offset, len); | ||
4883 | |||
4884 | ret = ext4_convert_inline_data(inode); | 4895 | ret = ext4_convert_inline_data(inode); |
4885 | if (ret) | 4896 | if (ret) |
4886 | return ret; | 4897 | return ret; |
@@ -4892,6 +4903,9 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
4892 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | 4903 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) |
4893 | return -EOPNOTSUPP; | 4904 | return -EOPNOTSUPP; |
4894 | 4905 | ||
4906 | if (mode & FALLOC_FL_COLLAPSE_RANGE) | ||
4907 | return ext4_collapse_range(inode, offset, len); | ||
4908 | |||
4895 | if (mode & FALLOC_FL_ZERO_RANGE) | 4909 | if (mode & FALLOC_FL_ZERO_RANGE) |
4896 | return ext4_zero_range(file, offset, len, mode); | 4910 | return ext4_zero_range(file, offset, len, mode); |
4897 | 4911 | ||
@@ -5229,18 +5243,19 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, | |||
5229 | if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) | 5243 | if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) |
5230 | update = 1; | 5244 | update = 1; |
5231 | 5245 | ||
5232 | *start = ex_last->ee_block + | 5246 | *start = le32_to_cpu(ex_last->ee_block) + |
5233 | ext4_ext_get_actual_len(ex_last); | 5247 | ext4_ext_get_actual_len(ex_last); |
5234 | 5248 | ||
5235 | while (ex_start <= ex_last) { | 5249 | while (ex_start <= ex_last) { |
5236 | ex_start->ee_block -= shift; | 5250 | le32_add_cpu(&ex_start->ee_block, -shift); |
5237 | if (ex_start > | 5251 | /* Try to merge to the left. */ |
5238 | EXT_FIRST_EXTENT(path[depth].p_hdr)) { | 5252 | if ((ex_start > |
5239 | if (ext4_ext_try_to_merge_right(inode, | 5253 | EXT_FIRST_EXTENT(path[depth].p_hdr)) && |
5240 | path, ex_start - 1)) | 5254 | ext4_ext_try_to_merge_right(inode, |
5241 | ex_last--; | 5255 | path, ex_start - 1)) |
5242 | } | 5256 | ex_last--; |
5243 | ex_start++; | 5257 | else |
5258 | ex_start++; | ||
5244 | } | 5259 | } |
5245 | err = ext4_ext_dirty(handle, inode, path + depth); | 5260 | err = ext4_ext_dirty(handle, inode, path + depth); |
5246 | if (err) | 5261 | if (err) |
@@ -5255,7 +5270,7 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, | |||
5255 | if (err) | 5270 | if (err) |
5256 | goto out; | 5271 | goto out; |
5257 | 5272 | ||
5258 | path[depth].p_idx->ei_block -= shift; | 5273 | le32_add_cpu(&path[depth].p_idx->ei_block, -shift); |
5259 | err = ext4_ext_dirty(handle, inode, path + depth); | 5274 | err = ext4_ext_dirty(handle, inode, path + depth); |
5260 | if (err) | 5275 | if (err) |
5261 | goto out; | 5276 | goto out; |
@@ -5300,7 +5315,8 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, | |||
5300 | return ret; | 5315 | return ret; |
5301 | } | 5316 | } |
5302 | 5317 | ||
5303 | stop_block = extent->ee_block + ext4_ext_get_actual_len(extent); | 5318 | stop_block = le32_to_cpu(extent->ee_block) + |
5319 | ext4_ext_get_actual_len(extent); | ||
5304 | ext4_ext_drop_refs(path); | 5320 | ext4_ext_drop_refs(path); |
5305 | kfree(path); | 5321 | kfree(path); |
5306 | 5322 | ||
@@ -5313,10 +5329,18 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, | |||
5313 | * enough to accomodate the shift. | 5329 | * enough to accomodate the shift. |
5314 | */ | 5330 | */ |
5315 | path = ext4_ext_find_extent(inode, start - 1, NULL, 0); | 5331 | path = ext4_ext_find_extent(inode, start - 1, NULL, 0); |
5332 | if (IS_ERR(path)) | ||
5333 | return PTR_ERR(path); | ||
5316 | depth = path->p_depth; | 5334 | depth = path->p_depth; |
5317 | extent = path[depth].p_ext; | 5335 | extent = path[depth].p_ext; |
5318 | ex_start = extent->ee_block; | 5336 | if (extent) { |
5319 | ex_end = extent->ee_block + ext4_ext_get_actual_len(extent); | 5337 | ex_start = le32_to_cpu(extent->ee_block); |
5338 | ex_end = le32_to_cpu(extent->ee_block) + | ||
5339 | ext4_ext_get_actual_len(extent); | ||
5340 | } else { | ||
5341 | ex_start = 0; | ||
5342 | ex_end = 0; | ||
5343 | } | ||
5320 | ext4_ext_drop_refs(path); | 5344 | ext4_ext_drop_refs(path); |
5321 | kfree(path); | 5345 | kfree(path); |
5322 | 5346 | ||
@@ -5331,7 +5355,13 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle, | |||
5331 | return PTR_ERR(path); | 5355 | return PTR_ERR(path); |
5332 | depth = path->p_depth; | 5356 | depth = path->p_depth; |
5333 | extent = path[depth].p_ext; | 5357 | extent = path[depth].p_ext; |
5334 | current_block = extent->ee_block; | 5358 | if (!extent) { |
5359 | EXT4_ERROR_INODE(inode, "unexpected hole at %lu", | ||
5360 | (unsigned long) start); | ||
5361 | return -EIO; | ||
5362 | } | ||
5363 | |||
5364 | current_block = le32_to_cpu(extent->ee_block); | ||
5335 | if (start > current_block) { | 5365 | if (start > current_block) { |
5336 | /* Hole, move to the next extent */ | 5366 | /* Hole, move to the next extent */ |
5337 | ret = mext_next_extent(inode, path, &extent); | 5367 | ret = mext_next_extent(inode, path, &extent); |
@@ -5365,17 +5395,18 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) | |||
5365 | ext4_lblk_t punch_start, punch_stop; | 5395 | ext4_lblk_t punch_start, punch_stop; |
5366 | handle_t *handle; | 5396 | handle_t *handle; |
5367 | unsigned int credits; | 5397 | unsigned int credits; |
5368 | loff_t new_size; | 5398 | loff_t new_size, ioffset; |
5369 | int ret; | 5399 | int ret; |
5370 | 5400 | ||
5371 | BUG_ON(offset + len > i_size_read(inode)); | ||
5372 | |||
5373 | /* Collapse range works only on fs block size aligned offsets. */ | 5401 | /* Collapse range works only on fs block size aligned offsets. */ |
5374 | if (offset & (EXT4_BLOCK_SIZE(sb) - 1) || | 5402 | if (offset & (EXT4_BLOCK_SIZE(sb) - 1) || |
5375 | len & (EXT4_BLOCK_SIZE(sb) - 1)) | 5403 | len & (EXT4_BLOCK_SIZE(sb) - 1)) |
5376 | return -EINVAL; | 5404 | return -EINVAL; |
5377 | 5405 | ||
5378 | if (!S_ISREG(inode->i_mode)) | 5406 | if (!S_ISREG(inode->i_mode)) |
5407 | return -EINVAL; | ||
5408 | |||
5409 | if (EXT4_SB(inode->i_sb)->s_cluster_ratio > 1) | ||
5379 | return -EOPNOTSUPP; | 5410 | return -EOPNOTSUPP; |
5380 | 5411 | ||
5381 | trace_ext4_collapse_range(inode, offset, len); | 5412 | trace_ext4_collapse_range(inode, offset, len); |
@@ -5383,22 +5414,34 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) | |||
5383 | punch_start = offset >> EXT4_BLOCK_SIZE_BITS(sb); | 5414 | punch_start = offset >> EXT4_BLOCK_SIZE_BITS(sb); |
5384 | punch_stop = (offset + len) >> EXT4_BLOCK_SIZE_BITS(sb); | 5415 | punch_stop = (offset + len) >> EXT4_BLOCK_SIZE_BITS(sb); |
5385 | 5416 | ||
5417 | /* Call ext4_force_commit to flush all data in case of data=journal. */ | ||
5418 | if (ext4_should_journal_data(inode)) { | ||
5419 | ret = ext4_force_commit(inode->i_sb); | ||
5420 | if (ret) | ||
5421 | return ret; | ||
5422 | } | ||
5423 | |||
5424 | /* | ||
5425 | * Need to round down offset to be aligned with page size boundary | ||
5426 | * for page size > block size. | ||
5427 | */ | ||
5428 | ioffset = round_down(offset, PAGE_SIZE); | ||
5429 | |||
5386 | /* Write out all dirty pages */ | 5430 | /* Write out all dirty pages */ |
5387 | ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1); | 5431 | ret = filemap_write_and_wait_range(inode->i_mapping, ioffset, |
5432 | LLONG_MAX); | ||
5388 | if (ret) | 5433 | if (ret) |
5389 | return ret; | 5434 | return ret; |
5390 | 5435 | ||
5391 | /* Take mutex lock */ | 5436 | /* Take mutex lock */ |
5392 | mutex_lock(&inode->i_mutex); | 5437 | mutex_lock(&inode->i_mutex); |
5393 | 5438 | ||
5394 | /* It's not possible punch hole on append only file */ | 5439 | /* |
5395 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) { | 5440 | * There is no need to overlap collapse range with EOF, in which case |
5396 | ret = -EPERM; | 5441 | * it is effectively a truncate operation |
5397 | goto out_mutex; | 5442 | */ |
5398 | } | 5443 | if (offset + len >= i_size_read(inode)) { |
5399 | 5444 | ret = -EINVAL; | |
5400 | if (IS_SWAPFILE(inode)) { | ||
5401 | ret = -ETXTBSY; | ||
5402 | goto out_mutex; | 5445 | goto out_mutex; |
5403 | } | 5446 | } |
5404 | 5447 | ||
@@ -5408,7 +5451,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) | |||
5408 | goto out_mutex; | 5451 | goto out_mutex; |
5409 | } | 5452 | } |
5410 | 5453 | ||
5411 | truncate_pagecache_range(inode, offset, -1); | 5454 | truncate_pagecache(inode, ioffset); |
5412 | 5455 | ||
5413 | /* Wait for existing dio to complete */ | 5456 | /* Wait for existing dio to complete */ |
5414 | ext4_inode_block_unlocked_dio(inode); | 5457 | ext4_inode_block_unlocked_dio(inode); |
@@ -5425,7 +5468,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) | |||
5425 | ext4_discard_preallocations(inode); | 5468 | ext4_discard_preallocations(inode); |
5426 | 5469 | ||
5427 | ret = ext4_es_remove_extent(inode, punch_start, | 5470 | ret = ext4_es_remove_extent(inode, punch_start, |
5428 | EXT_MAX_BLOCKS - punch_start - 1); | 5471 | EXT_MAX_BLOCKS - punch_start); |
5429 | if (ret) { | 5472 | if (ret) { |
5430 | up_write(&EXT4_I(inode)->i_data_sem); | 5473 | up_write(&EXT4_I(inode)->i_data_sem); |
5431 | goto out_stop; | 5474 | goto out_stop; |
@@ -5436,6 +5479,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) | |||
5436 | up_write(&EXT4_I(inode)->i_data_sem); | 5479 | up_write(&EXT4_I(inode)->i_data_sem); |
5437 | goto out_stop; | 5480 | goto out_stop; |
5438 | } | 5481 | } |
5482 | ext4_discard_preallocations(inode); | ||
5439 | 5483 | ||
5440 | ret = ext4_ext_shift_extents(inode, handle, punch_stop, | 5484 | ret = ext4_ext_shift_extents(inode, handle, punch_stop, |
5441 | punch_stop - punch_start); | 5485 | punch_stop - punch_start); |
@@ -5445,10 +5489,9 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) | |||
5445 | } | 5489 | } |
5446 | 5490 | ||
5447 | new_size = i_size_read(inode) - len; | 5491 | new_size = i_size_read(inode) - len; |
5448 | truncate_setsize(inode, new_size); | 5492 | i_size_write(inode, new_size); |
5449 | EXT4_I(inode)->i_disksize = new_size; | 5493 | EXT4_I(inode)->i_disksize = new_size; |
5450 | 5494 | ||
5451 | ext4_discard_preallocations(inode); | ||
5452 | up_write(&EXT4_I(inode)->i_data_sem); | 5495 | up_write(&EXT4_I(inode)->i_data_sem); |
5453 | if (IS_SYNC(inode)) | 5496 | if (IS_SYNC(inode)) |
5454 | ext4_handle_sync(handle); | 5497 | ext4_handle_sync(handle); |
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 0a014a7194b2..0ebc21204b51 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c | |||
@@ -810,7 +810,7 @@ retry: | |||
810 | 810 | ||
811 | newes.es_lblk = end + 1; | 811 | newes.es_lblk = end + 1; |
812 | newes.es_len = len2; | 812 | newes.es_len = len2; |
813 | block = 0x7FDEADBEEF; | 813 | block = 0x7FDEADBEEFULL; |
814 | if (ext4_es_is_written(&orig_es) || | 814 | if (ext4_es_is_written(&orig_es) || |
815 | ext4_es_is_unwritten(&orig_es)) | 815 | ext4_es_is_unwritten(&orig_es)) |
816 | block = ext4_es_pblock(&orig_es) + | 816 | block = ext4_es_pblock(&orig_es) + |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index ca7502d89fde..063fc1538355 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -82,7 +82,7 @@ ext4_unaligned_aio(struct inode *inode, const struct iovec *iov, | |||
82 | size_t count = iov_length(iov, nr_segs); | 82 | size_t count = iov_length(iov, nr_segs); |
83 | loff_t final_size = pos + count; | 83 | loff_t final_size = pos + count; |
84 | 84 | ||
85 | if (pos >= inode->i_size) | 85 | if (pos >= i_size_read(inode)) |
86 | return 0; | 86 | return 0; |
87 | 87 | ||
88 | if ((pos & blockmask) || (final_size & blockmask)) | 88 | if ((pos & blockmask) || (final_size & blockmask)) |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 5b0d2c7d5408..d7b7462a0e13 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -522,6 +522,10 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, | |||
522 | if (unlikely(map->m_len > INT_MAX)) | 522 | if (unlikely(map->m_len > INT_MAX)) |
523 | map->m_len = INT_MAX; | 523 | map->m_len = INT_MAX; |
524 | 524 | ||
525 | /* We can handle the block number less than EXT_MAX_BLOCKS */ | ||
526 | if (unlikely(map->m_lblk >= EXT_MAX_BLOCKS)) | ||
527 | return -EIO; | ||
528 | |||
525 | /* Lookup extent status tree firstly */ | 529 | /* Lookup extent status tree firstly */ |
526 | if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { | 530 | if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { |
527 | ext4_es_lru_add(inode); | 531 | ext4_es_lru_add(inode); |
@@ -2243,13 +2247,23 @@ static int mpage_map_and_submit_extent(handle_t *handle, | |||
2243 | return err; | 2247 | return err; |
2244 | } while (map->m_len); | 2248 | } while (map->m_len); |
2245 | 2249 | ||
2246 | /* Update on-disk size after IO is submitted */ | 2250 | /* |
2251 | * Update on-disk size after IO is submitted. Races with | ||
2252 | * truncate are avoided by checking i_size under i_data_sem. | ||
2253 | */ | ||
2247 | disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT; | 2254 | disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT; |
2248 | if (disksize > EXT4_I(inode)->i_disksize) { | 2255 | if (disksize > EXT4_I(inode)->i_disksize) { |
2249 | int err2; | 2256 | int err2; |
2250 | 2257 | loff_t i_size; | |
2251 | ext4_wb_update_i_disksize(inode, disksize); | 2258 | |
2259 | down_write(&EXT4_I(inode)->i_data_sem); | ||
2260 | i_size = i_size_read(inode); | ||
2261 | if (disksize > i_size) | ||
2262 | disksize = i_size; | ||
2263 | if (disksize > EXT4_I(inode)->i_disksize) | ||
2264 | EXT4_I(inode)->i_disksize = disksize; | ||
2252 | err2 = ext4_mark_inode_dirty(handle, inode); | 2265 | err2 = ext4_mark_inode_dirty(handle, inode); |
2266 | up_write(&EXT4_I(inode)->i_data_sem); | ||
2253 | if (err2) | 2267 | if (err2) |
2254 | ext4_error(inode->i_sb, | 2268 | ext4_error(inode->i_sb, |
2255 | "Failed to mark inode %lu dirty", | 2269 | "Failed to mark inode %lu dirty", |
@@ -3527,15 +3541,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) | |||
3527 | } | 3541 | } |
3528 | 3542 | ||
3529 | mutex_lock(&inode->i_mutex); | 3543 | mutex_lock(&inode->i_mutex); |
3530 | /* It's not possible punch hole on append only file */ | ||
3531 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) { | ||
3532 | ret = -EPERM; | ||
3533 | goto out_mutex; | ||
3534 | } | ||
3535 | if (IS_SWAPFILE(inode)) { | ||
3536 | ret = -ETXTBSY; | ||
3537 | goto out_mutex; | ||
3538 | } | ||
3539 | 3544 | ||
3540 | /* No need to punch hole beyond i_size */ | 3545 | /* No need to punch hole beyond i_size */ |
3541 | if (offset >= inode->i_size) | 3546 | if (offset >= inode->i_size) |
@@ -3616,7 +3621,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) | |||
3616 | ret = ext4_free_hole_blocks(handle, inode, first_block, | 3621 | ret = ext4_free_hole_blocks(handle, inode, first_block, |
3617 | stop_block); | 3622 | stop_block); |
3618 | 3623 | ||
3619 | ext4_discard_preallocations(inode); | ||
3620 | up_write(&EXT4_I(inode)->i_data_sem); | 3624 | up_write(&EXT4_I(inode)->i_data_sem); |
3621 | if (IS_SYNC(inode)) | 3625 | if (IS_SYNC(inode)) |
3622 | ext4_handle_sync(handle); | 3626 | ext4_handle_sync(handle); |
@@ -4423,21 +4427,20 @@ out_brelse: | |||
4423 | * | 4427 | * |
4424 | * We are called from a few places: | 4428 | * We are called from a few places: |
4425 | * | 4429 | * |
4426 | * - Within generic_file_write() for O_SYNC files. | 4430 | * - Within generic_file_aio_write() -> generic_write_sync() for O_SYNC files. |
4427 | * Here, there will be no transaction running. We wait for any running | 4431 | * Here, there will be no transaction running. We wait for any running |
4428 | * transaction to commit. | 4432 | * transaction to commit. |
4429 | * | 4433 | * |
4430 | * - Within sys_sync(), kupdate and such. | 4434 | * - Within flush work (sys_sync(), kupdate and such). |
4431 | * We wait on commit, if tol to. | 4435 | * We wait on commit, if told to. |
4432 | * | 4436 | * |
4433 | * - Within prune_icache() (PF_MEMALLOC == true) | 4437 | * - Within iput_final() -> write_inode_now() |
4434 | * Here we simply return. We can't afford to block kswapd on the | 4438 | * We wait on commit, if told to. |
4435 | * journal commit. | ||
4436 | * | 4439 | * |
4437 | * In all cases it is actually safe for us to return without doing anything, | 4440 | * In all cases it is actually safe for us to return without doing anything, |
4438 | * because the inode has been copied into a raw inode buffer in | 4441 | * because the inode has been copied into a raw inode buffer in |
4439 | * ext4_mark_inode_dirty(). This is a correctness thing for O_SYNC and for | 4442 | * ext4_mark_inode_dirty(). This is a correctness thing for WB_SYNC_ALL |
4440 | * knfsd. | 4443 | * writeback. |
4441 | * | 4444 | * |
4442 | * Note that we are absolutely dependent upon all inode dirtiers doing the | 4445 | * Note that we are absolutely dependent upon all inode dirtiers doing the |
4443 | * right thing: they *must* call mark_inode_dirty() after dirtying info in | 4446 | * right thing: they *must* call mark_inode_dirty() after dirtying info in |
@@ -4449,15 +4452,15 @@ out_brelse: | |||
4449 | * stuff(); | 4452 | * stuff(); |
4450 | * inode->i_size = expr; | 4453 | * inode->i_size = expr; |
4451 | * | 4454 | * |
4452 | * is in error because a kswapd-driven write_inode() could occur while | 4455 | * is in error because write_inode() could occur while `stuff()' is running, |
4453 | * `stuff()' is running, and the new i_size will be lost. Plus the inode | 4456 | * and the new i_size will be lost. Plus the inode will no longer be on the |
4454 | * will no longer be on the superblock's dirty inode list. | 4457 | * superblock's dirty inode list. |
4455 | */ | 4458 | */ |
4456 | int ext4_write_inode(struct inode *inode, struct writeback_control *wbc) | 4459 | int ext4_write_inode(struct inode *inode, struct writeback_control *wbc) |
4457 | { | 4460 | { |
4458 | int err; | 4461 | int err; |
4459 | 4462 | ||
4460 | if (current->flags & PF_MEMALLOC) | 4463 | if (WARN_ON_ONCE(current->flags & PF_MEMALLOC)) |
4461 | return 0; | 4464 | return 0; |
4462 | 4465 | ||
4463 | if (EXT4_SB(inode->i_sb)->s_journal) { | 4466 | if (EXT4_SB(inode->i_sb)->s_journal) { |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index a888cac76e9c..c8238a26818c 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -989,7 +989,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb, | |||
989 | poff = block % blocks_per_page; | 989 | poff = block % blocks_per_page; |
990 | page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); | 990 | page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); |
991 | if (!page) | 991 | if (!page) |
992 | return -EIO; | 992 | return -ENOMEM; |
993 | BUG_ON(page->mapping != inode->i_mapping); | 993 | BUG_ON(page->mapping != inode->i_mapping); |
994 | e4b->bd_bitmap_page = page; | 994 | e4b->bd_bitmap_page = page; |
995 | e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize); | 995 | e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize); |
@@ -1003,7 +1003,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb, | |||
1003 | pnum = block / blocks_per_page; | 1003 | pnum = block / blocks_per_page; |
1004 | page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); | 1004 | page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); |
1005 | if (!page) | 1005 | if (!page) |
1006 | return -EIO; | 1006 | return -ENOMEM; |
1007 | BUG_ON(page->mapping != inode->i_mapping); | 1007 | BUG_ON(page->mapping != inode->i_mapping); |
1008 | e4b->bd_buddy_page = page; | 1008 | e4b->bd_buddy_page = page; |
1009 | return 0; | 1009 | return 0; |
@@ -1168,7 +1168,11 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, | |||
1168 | unlock_page(page); | 1168 | unlock_page(page); |
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | if (page == NULL || !PageUptodate(page)) { | 1171 | if (page == NULL) { |
1172 | ret = -ENOMEM; | ||
1173 | goto err; | ||
1174 | } | ||
1175 | if (!PageUptodate(page)) { | ||
1172 | ret = -EIO; | 1176 | ret = -EIO; |
1173 | goto err; | 1177 | goto err; |
1174 | } | 1178 | } |
@@ -1197,7 +1201,11 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, | |||
1197 | unlock_page(page); | 1201 | unlock_page(page); |
1198 | } | 1202 | } |
1199 | } | 1203 | } |
1200 | if (page == NULL || !PageUptodate(page)) { | 1204 | if (page == NULL) { |
1205 | ret = -ENOMEM; | ||
1206 | goto err; | ||
1207 | } | ||
1208 | if (!PageUptodate(page)) { | ||
1201 | ret = -EIO; | 1209 | ret = -EIO; |
1202 | goto err; | 1210 | goto err; |
1203 | } | 1211 | } |
@@ -5008,6 +5016,8 @@ error_return: | |||
5008 | */ | 5016 | */ |
5009 | static int ext4_trim_extent(struct super_block *sb, int start, int count, | 5017 | static int ext4_trim_extent(struct super_block *sb, int start, int count, |
5010 | ext4_group_t group, struct ext4_buddy *e4b) | 5018 | ext4_group_t group, struct ext4_buddy *e4b) |
5019 | __releases(bitlock) | ||
5020 | __acquires(bitlock) | ||
5011 | { | 5021 | { |
5012 | struct ext4_free_extent ex; | 5022 | struct ext4_free_extent ex; |
5013 | int ret = 0; | 5023 | int ret = 0; |
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index ab95508e3d40..c18d95b50540 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c | |||
@@ -308,13 +308,14 @@ static void ext4_end_bio(struct bio *bio, int error) | |||
308 | if (error) { | 308 | if (error) { |
309 | struct inode *inode = io_end->inode; | 309 | struct inode *inode = io_end->inode; |
310 | 310 | ||
311 | ext4_warning(inode->i_sb, "I/O error writing to inode %lu " | 311 | ext4_warning(inode->i_sb, "I/O error %d writing to inode %lu " |
312 | "(offset %llu size %ld starting block %llu)", | 312 | "(offset %llu size %ld starting block %llu)", |
313 | inode->i_ino, | 313 | error, inode->i_ino, |
314 | (unsigned long long) io_end->offset, | 314 | (unsigned long long) io_end->offset, |
315 | (long) io_end->size, | 315 | (long) io_end->size, |
316 | (unsigned long long) | 316 | (unsigned long long) |
317 | bi_sector >> (inode->i_blkbits - 9)); | 317 | bi_sector >> (inode->i_blkbits - 9)); |
318 | mapping_set_error(inode->i_mapping, error); | ||
318 | } | 319 | } |
319 | 320 | ||
320 | if (io_end->flag & EXT4_IO_END_UNWRITTEN) { | 321 | if (io_end->flag & EXT4_IO_END_UNWRITTEN) { |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index f3c667091618..6f9e6fadac04 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -3869,19 +3869,38 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3869 | goto failed_mount2; | 3869 | goto failed_mount2; |
3870 | } | 3870 | } |
3871 | } | 3871 | } |
3872 | |||
3873 | /* | ||
3874 | * set up enough so that it can read an inode, | ||
3875 | * and create new inode for buddy allocator | ||
3876 | */ | ||
3877 | sbi->s_gdb_count = db_count; | ||
3878 | if (!test_opt(sb, NOLOAD) && | ||
3879 | EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) | ||
3880 | sb->s_op = &ext4_sops; | ||
3881 | else | ||
3882 | sb->s_op = &ext4_nojournal_sops; | ||
3883 | |||
3884 | ext4_ext_init(sb); | ||
3885 | err = ext4_mb_init(sb); | ||
3886 | if (err) { | ||
3887 | ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", | ||
3888 | err); | ||
3889 | goto failed_mount2; | ||
3890 | } | ||
3891 | |||
3872 | if (!ext4_check_descriptors(sb, &first_not_zeroed)) { | 3892 | if (!ext4_check_descriptors(sb, &first_not_zeroed)) { |
3873 | ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); | 3893 | ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); |
3874 | goto failed_mount2; | 3894 | goto failed_mount2a; |
3875 | } | 3895 | } |
3876 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) | 3896 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) |
3877 | if (!ext4_fill_flex_info(sb)) { | 3897 | if (!ext4_fill_flex_info(sb)) { |
3878 | ext4_msg(sb, KERN_ERR, | 3898 | ext4_msg(sb, KERN_ERR, |
3879 | "unable to initialize " | 3899 | "unable to initialize " |
3880 | "flex_bg meta info!"); | 3900 | "flex_bg meta info!"); |
3881 | goto failed_mount2; | 3901 | goto failed_mount2a; |
3882 | } | 3902 | } |
3883 | 3903 | ||
3884 | sbi->s_gdb_count = db_count; | ||
3885 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); | 3904 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); |
3886 | spin_lock_init(&sbi->s_next_gen_lock); | 3905 | spin_lock_init(&sbi->s_next_gen_lock); |
3887 | 3906 | ||
@@ -3916,14 +3935,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3916 | sbi->s_stripe = ext4_get_stripe_size(sbi); | 3935 | sbi->s_stripe = ext4_get_stripe_size(sbi); |
3917 | sbi->s_extent_max_zeroout_kb = 32; | 3936 | sbi->s_extent_max_zeroout_kb = 32; |
3918 | 3937 | ||
3919 | /* | ||
3920 | * set up enough so that it can read an inode | ||
3921 | */ | ||
3922 | if (!test_opt(sb, NOLOAD) && | ||
3923 | EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) | ||
3924 | sb->s_op = &ext4_sops; | ||
3925 | else | ||
3926 | sb->s_op = &ext4_nojournal_sops; | ||
3927 | sb->s_export_op = &ext4_export_ops; | 3938 | sb->s_export_op = &ext4_export_ops; |
3928 | sb->s_xattr = ext4_xattr_handlers; | 3939 | sb->s_xattr = ext4_xattr_handlers; |
3929 | #ifdef CONFIG_QUOTA | 3940 | #ifdef CONFIG_QUOTA |
@@ -4113,21 +4124,13 @@ no_journal: | |||
4113 | if (err) { | 4124 | if (err) { |
4114 | ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " | 4125 | ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " |
4115 | "reserved pool", ext4_calculate_resv_clusters(sb)); | 4126 | "reserved pool", ext4_calculate_resv_clusters(sb)); |
4116 | goto failed_mount4a; | 4127 | goto failed_mount5; |
4117 | } | 4128 | } |
4118 | 4129 | ||
4119 | err = ext4_setup_system_zone(sb); | 4130 | err = ext4_setup_system_zone(sb); |
4120 | if (err) { | 4131 | if (err) { |
4121 | ext4_msg(sb, KERN_ERR, "failed to initialize system " | 4132 | ext4_msg(sb, KERN_ERR, "failed to initialize system " |
4122 | "zone (%d)", err); | 4133 | "zone (%d)", err); |
4123 | goto failed_mount4a; | ||
4124 | } | ||
4125 | |||
4126 | ext4_ext_init(sb); | ||
4127 | err = ext4_mb_init(sb); | ||
4128 | if (err) { | ||
4129 | ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", | ||
4130 | err); | ||
4131 | goto failed_mount5; | 4134 | goto failed_mount5; |
4132 | } | 4135 | } |
4133 | 4136 | ||
@@ -4204,11 +4207,8 @@ failed_mount8: | |||
4204 | failed_mount7: | 4207 | failed_mount7: |
4205 | ext4_unregister_li_request(sb); | 4208 | ext4_unregister_li_request(sb); |
4206 | failed_mount6: | 4209 | failed_mount6: |
4207 | ext4_mb_release(sb); | ||
4208 | failed_mount5: | ||
4209 | ext4_ext_release(sb); | ||
4210 | ext4_release_system_zone(sb); | 4210 | ext4_release_system_zone(sb); |
4211 | failed_mount4a: | 4211 | failed_mount5: |
4212 | dput(sb->s_root); | 4212 | dput(sb->s_root); |
4213 | sb->s_root = NULL; | 4213 | sb->s_root = NULL; |
4214 | failed_mount4: | 4214 | failed_mount4: |
@@ -4232,11 +4232,14 @@ failed_mount3: | |||
4232 | percpu_counter_destroy(&sbi->s_extent_cache_cnt); | 4232 | percpu_counter_destroy(&sbi->s_extent_cache_cnt); |
4233 | if (sbi->s_mmp_tsk) | 4233 | if (sbi->s_mmp_tsk) |
4234 | kthread_stop(sbi->s_mmp_tsk); | 4234 | kthread_stop(sbi->s_mmp_tsk); |
4235 | failed_mount2a: | ||
4236 | ext4_mb_release(sb); | ||
4235 | failed_mount2: | 4237 | failed_mount2: |
4236 | for (i = 0; i < db_count; i++) | 4238 | for (i = 0; i < db_count; i++) |
4237 | brelse(sbi->s_group_desc[i]); | 4239 | brelse(sbi->s_group_desc[i]); |
4238 | ext4_kvfree(sbi->s_group_desc); | 4240 | ext4_kvfree(sbi->s_group_desc); |
4239 | failed_mount: | 4241 | failed_mount: |
4242 | ext4_ext_release(sb); | ||
4240 | if (sbi->s_chksum_driver) | 4243 | if (sbi->s_chksum_driver) |
4241 | crypto_free_shash(sbi->s_chksum_driver); | 4244 | crypto_free_shash(sbi->s_chksum_driver); |
4242 | if (sbi->s_proc) { | 4245 | if (sbi->s_proc) { |
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 1f5cf5880718..4eec399ec807 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -520,8 +520,8 @@ static void ext4_xattr_update_super_block(handle_t *handle, | |||
520 | } | 520 | } |
521 | 521 | ||
522 | /* | 522 | /* |
523 | * Release the xattr block BH: If the reference count is > 1, decrement | 523 | * Release the xattr block BH: If the reference count is > 1, decrement it; |
524 | * it; otherwise free the block. | 524 | * otherwise free the block. |
525 | */ | 525 | */ |
526 | static void | 526 | static void |
527 | ext4_xattr_release_block(handle_t *handle, struct inode *inode, | 527 | ext4_xattr_release_block(handle_t *handle, struct inode *inode, |
@@ -542,16 +542,31 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, | |||
542 | if (ce) | 542 | if (ce) |
543 | mb_cache_entry_free(ce); | 543 | mb_cache_entry_free(ce); |
544 | get_bh(bh); | 544 | get_bh(bh); |
545 | unlock_buffer(bh); | ||
545 | ext4_free_blocks(handle, inode, bh, 0, 1, | 546 | ext4_free_blocks(handle, inode, bh, 0, 1, |
546 | EXT4_FREE_BLOCKS_METADATA | | 547 | EXT4_FREE_BLOCKS_METADATA | |
547 | EXT4_FREE_BLOCKS_FORGET); | 548 | EXT4_FREE_BLOCKS_FORGET); |
548 | unlock_buffer(bh); | ||
549 | } else { | 549 | } else { |
550 | le32_add_cpu(&BHDR(bh)->h_refcount, -1); | 550 | le32_add_cpu(&BHDR(bh)->h_refcount, -1); |
551 | if (ce) | 551 | if (ce) |
552 | mb_cache_entry_release(ce); | 552 | mb_cache_entry_release(ce); |
553 | /* | ||
554 | * Beware of this ugliness: Releasing of xattr block references | ||
555 | * from different inodes can race and so we have to protect | ||
556 | * from a race where someone else frees the block (and releases | ||
557 | * its journal_head) before we are done dirtying the buffer. In | ||
558 | * nojournal mode this race is harmless and we actually cannot | ||
559 | * call ext4_handle_dirty_xattr_block() with locked buffer as | ||
560 | * that function can call sync_dirty_buffer() so for that case | ||
561 | * we handle the dirtying after unlocking the buffer. | ||
562 | */ | ||
563 | if (ext4_handle_valid(handle)) | ||
564 | error = ext4_handle_dirty_xattr_block(handle, inode, | ||
565 | bh); | ||
553 | unlock_buffer(bh); | 566 | unlock_buffer(bh); |
554 | error = ext4_handle_dirty_xattr_block(handle, inode, bh); | 567 | if (!ext4_handle_valid(handle)) |
568 | error = ext4_handle_dirty_xattr_block(handle, inode, | ||
569 | bh); | ||
555 | if (IS_SYNC(inode)) | 570 | if (IS_SYNC(inode)) |
556 | ext4_handle_sync(handle); | 571 | ext4_handle_sync(handle); |
557 | dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1)); | 572 | dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1)); |
diff --git a/fs/fcntl.c b/fs/fcntl.c index 9ead1596399a..72c82f69b01b 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -274,15 +274,15 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, | |||
274 | break; | 274 | break; |
275 | #if BITS_PER_LONG != 32 | 275 | #if BITS_PER_LONG != 32 |
276 | /* 32-bit arches must use fcntl64() */ | 276 | /* 32-bit arches must use fcntl64() */ |
277 | case F_GETLKP: | 277 | case F_OFD_GETLK: |
278 | #endif | 278 | #endif |
279 | case F_GETLK: | 279 | case F_GETLK: |
280 | err = fcntl_getlk(filp, cmd, (struct flock __user *) arg); | 280 | err = fcntl_getlk(filp, cmd, (struct flock __user *) arg); |
281 | break; | 281 | break; |
282 | #if BITS_PER_LONG != 32 | 282 | #if BITS_PER_LONG != 32 |
283 | /* 32-bit arches must use fcntl64() */ | 283 | /* 32-bit arches must use fcntl64() */ |
284 | case F_SETLKP: | 284 | case F_OFD_SETLK: |
285 | case F_SETLKPW: | 285 | case F_OFD_SETLKW: |
286 | #endif | 286 | #endif |
287 | /* Fallthrough */ | 287 | /* Fallthrough */ |
288 | case F_SETLK: | 288 | case F_SETLK: |
@@ -399,13 +399,13 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, | |||
399 | 399 | ||
400 | switch (cmd) { | 400 | switch (cmd) { |
401 | case F_GETLK64: | 401 | case F_GETLK64: |
402 | case F_GETLKP: | 402 | case F_OFD_GETLK: |
403 | err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg); | 403 | err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg); |
404 | break; | 404 | break; |
405 | case F_SETLK64: | 405 | case F_SETLK64: |
406 | case F_SETLKW64: | 406 | case F_SETLKW64: |
407 | case F_SETLKP: | 407 | case F_OFD_SETLK: |
408 | case F_SETLKPW: | 408 | case F_OFD_SETLKW: |
409 | err = fcntl_setlk64(fd, f.file, cmd, | 409 | err = fcntl_setlk64(fd, f.file, cmd, |
410 | (struct flock64 __user *) arg); | 410 | (struct flock64 __user *) arg); |
411 | break; | 411 | break; |
diff --git a/fs/locks.c b/fs/locks.c index 13fc7a6d380a..e663aeac579e 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -135,7 +135,7 @@ | |||
135 | #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) | 135 | #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) |
136 | #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) | 136 | #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) |
137 | #define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG)) | 137 | #define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG)) |
138 | #define IS_FILE_PVT(fl) (fl->fl_flags & FL_FILE_PVT) | 138 | #define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) |
139 | 139 | ||
140 | static bool lease_breaking(struct file_lock *fl) | 140 | static bool lease_breaking(struct file_lock *fl) |
141 | { | 141 | { |
@@ -564,7 +564,7 @@ static void __locks_insert_block(struct file_lock *blocker, | |||
564 | BUG_ON(!list_empty(&waiter->fl_block)); | 564 | BUG_ON(!list_empty(&waiter->fl_block)); |
565 | waiter->fl_next = blocker; | 565 | waiter->fl_next = blocker; |
566 | list_add_tail(&waiter->fl_block, &blocker->fl_block); | 566 | list_add_tail(&waiter->fl_block, &blocker->fl_block); |
567 | if (IS_POSIX(blocker) && !IS_FILE_PVT(blocker)) | 567 | if (IS_POSIX(blocker) && !IS_OFDLCK(blocker)) |
568 | locks_insert_global_blocked(waiter); | 568 | locks_insert_global_blocked(waiter); |
569 | } | 569 | } |
570 | 570 | ||
@@ -759,12 +759,12 @@ EXPORT_SYMBOL(posix_test_lock); | |||
759 | * of tasks (such as posix threads) sharing the same open file table. | 759 | * of tasks (such as posix threads) sharing the same open file table. |
760 | * To handle those cases, we just bail out after a few iterations. | 760 | * To handle those cases, we just bail out after a few iterations. |
761 | * | 761 | * |
762 | * For FL_FILE_PVT locks, the owner is the filp, not the files_struct. | 762 | * For FL_OFDLCK locks, the owner is the filp, not the files_struct. |
763 | * Because the owner is not even nominally tied to a thread of | 763 | * Because the owner is not even nominally tied to a thread of |
764 | * execution, the deadlock detection below can't reasonably work well. Just | 764 | * execution, the deadlock detection below can't reasonably work well. Just |
765 | * skip it for those. | 765 | * skip it for those. |
766 | * | 766 | * |
767 | * In principle, we could do a more limited deadlock detection on FL_FILE_PVT | 767 | * In principle, we could do a more limited deadlock detection on FL_OFDLCK |
768 | * locks that just checks for the case where two tasks are attempting to | 768 | * locks that just checks for the case where two tasks are attempting to |
769 | * upgrade from read to write locks on the same inode. | 769 | * upgrade from read to write locks on the same inode. |
770 | */ | 770 | */ |
@@ -791,9 +791,9 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, | |||
791 | 791 | ||
792 | /* | 792 | /* |
793 | * This deadlock detector can't reasonably detect deadlocks with | 793 | * This deadlock detector can't reasonably detect deadlocks with |
794 | * FL_FILE_PVT locks, since they aren't owned by a process, per-se. | 794 | * FL_OFDLCK locks, since they aren't owned by a process, per-se. |
795 | */ | 795 | */ |
796 | if (IS_FILE_PVT(caller_fl)) | 796 | if (IS_OFDLCK(caller_fl)) |
797 | return 0; | 797 | return 0; |
798 | 798 | ||
799 | while ((block_fl = what_owner_is_waiting_for(block_fl))) { | 799 | while ((block_fl = what_owner_is_waiting_for(block_fl))) { |
@@ -1391,11 +1391,10 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) | |||
1391 | 1391 | ||
1392 | restart: | 1392 | restart: |
1393 | break_time = flock->fl_break_time; | 1393 | break_time = flock->fl_break_time; |
1394 | if (break_time != 0) { | 1394 | if (break_time != 0) |
1395 | break_time -= jiffies; | 1395 | break_time -= jiffies; |
1396 | if (break_time == 0) | 1396 | if (break_time == 0) |
1397 | break_time++; | 1397 | break_time++; |
1398 | } | ||
1399 | locks_insert_block(flock, new_fl); | 1398 | locks_insert_block(flock, new_fl); |
1400 | spin_unlock(&inode->i_lock); | 1399 | spin_unlock(&inode->i_lock); |
1401 | error = wait_event_interruptible_timeout(new_fl->fl_wait, | 1400 | error = wait_event_interruptible_timeout(new_fl->fl_wait, |
@@ -1891,7 +1890,7 @@ EXPORT_SYMBOL_GPL(vfs_test_lock); | |||
1891 | 1890 | ||
1892 | static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) | 1891 | static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) |
1893 | { | 1892 | { |
1894 | flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid; | 1893 | flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; |
1895 | #if BITS_PER_LONG == 32 | 1894 | #if BITS_PER_LONG == 32 |
1896 | /* | 1895 | /* |
1897 | * Make sure we can represent the posix lock via | 1896 | * Make sure we can represent the posix lock via |
@@ -1913,7 +1912,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) | |||
1913 | #if BITS_PER_LONG == 32 | 1912 | #if BITS_PER_LONG == 32 |
1914 | static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) | 1913 | static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) |
1915 | { | 1914 | { |
1916 | flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid; | 1915 | flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid; |
1917 | flock->l_start = fl->fl_start; | 1916 | flock->l_start = fl->fl_start; |
1918 | flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : | 1917 | flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : |
1919 | fl->fl_end - fl->fl_start + 1; | 1918 | fl->fl_end - fl->fl_start + 1; |
@@ -1942,13 +1941,13 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l) | |||
1942 | if (error) | 1941 | if (error) |
1943 | goto out; | 1942 | goto out; |
1944 | 1943 | ||
1945 | if (cmd == F_GETLKP) { | 1944 | if (cmd == F_OFD_GETLK) { |
1946 | error = -EINVAL; | 1945 | error = -EINVAL; |
1947 | if (flock.l_pid != 0) | 1946 | if (flock.l_pid != 0) |
1948 | goto out; | 1947 | goto out; |
1949 | 1948 | ||
1950 | cmd = F_GETLK; | 1949 | cmd = F_GETLK; |
1951 | file_lock.fl_flags |= FL_FILE_PVT; | 1950 | file_lock.fl_flags |= FL_OFDLCK; |
1952 | file_lock.fl_owner = (fl_owner_t)filp; | 1951 | file_lock.fl_owner = (fl_owner_t)filp; |
1953 | } | 1952 | } |
1954 | 1953 | ||
@@ -2074,25 +2073,25 @@ again: | |||
2074 | 2073 | ||
2075 | /* | 2074 | /* |
2076 | * If the cmd is requesting file-private locks, then set the | 2075 | * If the cmd is requesting file-private locks, then set the |
2077 | * FL_FILE_PVT flag and override the owner. | 2076 | * FL_OFDLCK flag and override the owner. |
2078 | */ | 2077 | */ |
2079 | switch (cmd) { | 2078 | switch (cmd) { |
2080 | case F_SETLKP: | 2079 | case F_OFD_SETLK: |
2081 | error = -EINVAL; | 2080 | error = -EINVAL; |
2082 | if (flock.l_pid != 0) | 2081 | if (flock.l_pid != 0) |
2083 | goto out; | 2082 | goto out; |
2084 | 2083 | ||
2085 | cmd = F_SETLK; | 2084 | cmd = F_SETLK; |
2086 | file_lock->fl_flags |= FL_FILE_PVT; | 2085 | file_lock->fl_flags |= FL_OFDLCK; |
2087 | file_lock->fl_owner = (fl_owner_t)filp; | 2086 | file_lock->fl_owner = (fl_owner_t)filp; |
2088 | break; | 2087 | break; |
2089 | case F_SETLKPW: | 2088 | case F_OFD_SETLKW: |
2090 | error = -EINVAL; | 2089 | error = -EINVAL; |
2091 | if (flock.l_pid != 0) | 2090 | if (flock.l_pid != 0) |
2092 | goto out; | 2091 | goto out; |
2093 | 2092 | ||
2094 | cmd = F_SETLKW; | 2093 | cmd = F_SETLKW; |
2095 | file_lock->fl_flags |= FL_FILE_PVT; | 2094 | file_lock->fl_flags |= FL_OFDLCK; |
2096 | file_lock->fl_owner = (fl_owner_t)filp; | 2095 | file_lock->fl_owner = (fl_owner_t)filp; |
2097 | /* Fallthrough */ | 2096 | /* Fallthrough */ |
2098 | case F_SETLKW: | 2097 | case F_SETLKW: |
@@ -2144,13 +2143,13 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l) | |||
2144 | if (error) | 2143 | if (error) |
2145 | goto out; | 2144 | goto out; |
2146 | 2145 | ||
2147 | if (cmd == F_GETLKP) { | 2146 | if (cmd == F_OFD_GETLK) { |
2148 | error = -EINVAL; | 2147 | error = -EINVAL; |
2149 | if (flock.l_pid != 0) | 2148 | if (flock.l_pid != 0) |
2150 | goto out; | 2149 | goto out; |
2151 | 2150 | ||
2152 | cmd = F_GETLK64; | 2151 | cmd = F_GETLK64; |
2153 | file_lock.fl_flags |= FL_FILE_PVT; | 2152 | file_lock.fl_flags |= FL_OFDLCK; |
2154 | file_lock.fl_owner = (fl_owner_t)filp; | 2153 | file_lock.fl_owner = (fl_owner_t)filp; |
2155 | } | 2154 | } |
2156 | 2155 | ||
@@ -2209,25 +2208,25 @@ again: | |||
2209 | 2208 | ||
2210 | /* | 2209 | /* |
2211 | * If the cmd is requesting file-private locks, then set the | 2210 | * If the cmd is requesting file-private locks, then set the |
2212 | * FL_FILE_PVT flag and override the owner. | 2211 | * FL_OFDLCK flag and override the owner. |
2213 | */ | 2212 | */ |
2214 | switch (cmd) { | 2213 | switch (cmd) { |
2215 | case F_SETLKP: | 2214 | case F_OFD_SETLK: |
2216 | error = -EINVAL; | 2215 | error = -EINVAL; |
2217 | if (flock.l_pid != 0) | 2216 | if (flock.l_pid != 0) |
2218 | goto out; | 2217 | goto out; |
2219 | 2218 | ||
2220 | cmd = F_SETLK64; | 2219 | cmd = F_SETLK64; |
2221 | file_lock->fl_flags |= FL_FILE_PVT; | 2220 | file_lock->fl_flags |= FL_OFDLCK; |
2222 | file_lock->fl_owner = (fl_owner_t)filp; | 2221 | file_lock->fl_owner = (fl_owner_t)filp; |
2223 | break; | 2222 | break; |
2224 | case F_SETLKPW: | 2223 | case F_OFD_SETLKW: |
2225 | error = -EINVAL; | 2224 | error = -EINVAL; |
2226 | if (flock.l_pid != 0) | 2225 | if (flock.l_pid != 0) |
2227 | goto out; | 2226 | goto out; |
2228 | 2227 | ||
2229 | cmd = F_SETLKW64; | 2228 | cmd = F_SETLKW64; |
2230 | file_lock->fl_flags |= FL_FILE_PVT; | 2229 | file_lock->fl_flags |= FL_OFDLCK; |
2231 | file_lock->fl_owner = (fl_owner_t)filp; | 2230 | file_lock->fl_owner = (fl_owner_t)filp; |
2232 | /* Fallthrough */ | 2231 | /* Fallthrough */ |
2233 | case F_SETLKW64: | 2232 | case F_SETLKW64: |
@@ -2413,8 +2412,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, | |||
2413 | if (IS_POSIX(fl)) { | 2412 | if (IS_POSIX(fl)) { |
2414 | if (fl->fl_flags & FL_ACCESS) | 2413 | if (fl->fl_flags & FL_ACCESS) |
2415 | seq_printf(f, "ACCESS"); | 2414 | seq_printf(f, "ACCESS"); |
2416 | else if (IS_FILE_PVT(fl)) | 2415 | else if (IS_OFDLCK(fl)) |
2417 | seq_printf(f, "FLPVT "); | 2416 | seq_printf(f, "OFDLCK"); |
2418 | else | 2417 | else |
2419 | seq_printf(f, "POSIX "); | 2418 | seq_printf(f, "POSIX "); |
2420 | 2419 | ||
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 39c8ef875f91..2c73cae9899d 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
@@ -654,9 +654,11 @@ static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args) | |||
654 | 654 | ||
655 | static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) | 655 | static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) |
656 | { | 656 | { |
657 | int maxtime = max_cb_time(clp->net); | ||
657 | struct rpc_timeout timeparms = { | 658 | struct rpc_timeout timeparms = { |
658 | .to_initval = max_cb_time(clp->net), | 659 | .to_initval = maxtime, |
659 | .to_retries = 0, | 660 | .to_retries = 0, |
661 | .to_maxval = maxtime, | ||
660 | }; | 662 | }; |
661 | struct rpc_create_args args = { | 663 | struct rpc_create_args args = { |
662 | .net = clp->net, | 664 | .net = clp->net, |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2723c1badd01..18881f34737a 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -3627,14 +3627,6 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) | |||
3627 | /* nfsd4_check_resp_size guarantees enough room for error status */ | 3627 | /* nfsd4_check_resp_size guarantees enough room for error status */ |
3628 | if (!op->status) | 3628 | if (!op->status) |
3629 | op->status = nfsd4_check_resp_size(resp, 0); | 3629 | op->status = nfsd4_check_resp_size(resp, 0); |
3630 | if (op->status == nfserr_resource && nfsd4_has_session(&resp->cstate)) { | ||
3631 | struct nfsd4_slot *slot = resp->cstate.slot; | ||
3632 | |||
3633 | if (slot->sl_flags & NFSD4_SLOT_CACHETHIS) | ||
3634 | op->status = nfserr_rep_too_big_to_cache; | ||
3635 | else | ||
3636 | op->status = nfserr_rep_too_big; | ||
3637 | } | ||
3638 | if (so) { | 3630 | if (so) { |
3639 | so->so_replay.rp_status = op->status; | 3631 | so->so_replay.rp_status = op->status; |
3640 | so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1); | 3632 | so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1); |
@@ -254,17 +254,22 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
254 | return -EBADF; | 254 | return -EBADF; |
255 | 255 | ||
256 | /* | 256 | /* |
257 | * It's not possible to punch hole or perform collapse range | 257 | * We can only allow pure fallocate on append only files |
258 | * on append only file | ||
259 | */ | 258 | */ |
260 | if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE) | 259 | if ((mode & ~FALLOC_FL_KEEP_SIZE) && IS_APPEND(inode)) |
261 | && IS_APPEND(inode)) | ||
262 | return -EPERM; | 260 | return -EPERM; |
263 | 261 | ||
264 | if (IS_IMMUTABLE(inode)) | 262 | if (IS_IMMUTABLE(inode)) |
265 | return -EPERM; | 263 | return -EPERM; |
266 | 264 | ||
267 | /* | 265 | /* |
266 | * We can not allow to do any fallocate operation on an active | ||
267 | * swapfile | ||
268 | */ | ||
269 | if (IS_SWAPFILE(inode)) | ||
270 | ret = -ETXTBSY; | ||
271 | |||
272 | /* | ||
268 | * Revalidate the write permissions, in case security policy has | 273 | * Revalidate the write permissions, in case security policy has |
269 | * changed since the files were opened. | 274 | * changed since the files were opened. |
270 | */ | 275 | */ |
@@ -286,14 +291,6 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
286 | if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) | 291 | if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) |
287 | return -EFBIG; | 292 | return -EFBIG; |
288 | 293 | ||
289 | /* | ||
290 | * There is no need to overlap collapse range with EOF, in which case | ||
291 | * it is effectively a truncate operation | ||
292 | */ | ||
293 | if ((mode & FALLOC_FL_COLLAPSE_RANGE) && | ||
294 | (offset + len >= i_size_read(inode))) | ||
295 | return -EINVAL; | ||
296 | |||
297 | if (!file->f_op->fallocate) | 294 | if (!file->f_op->fallocate) |
298 | return -EOPNOTSUPP; | 295 | return -EOPNOTSUPP; |
299 | 296 | ||
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 82afdcb33183..951a2321ee01 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -841,7 +841,15 @@ xfs_file_fallocate( | |||
841 | goto out_unlock; | 841 | goto out_unlock; |
842 | } | 842 | } |
843 | 843 | ||
844 | ASSERT(offset + len < i_size_read(inode)); | 844 | /* |
845 | * There is no need to overlap collapse range with EOF, | ||
846 | * in which case it is effectively a truncate operation | ||
847 | */ | ||
848 | if (offset + len >= i_size_read(inode)) { | ||
849 | error = -EINVAL; | ||
850 | goto out_unlock; | ||
851 | } | ||
852 | |||
845 | new_size = i_size_read(inode) - len; | 853 | new_size = i_size_read(inode) - len; |
846 | 854 | ||
847 | error = xfs_collapse_file_space(ip, offset, len); | 855 | error = xfs_collapse_file_space(ip, offset, len); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 7a9c5bca2b76..878031227c57 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -815,7 +815,7 @@ static inline struct file *get_file(struct file *f) | |||
815 | #define FL_SLEEP 128 /* A blocking lock */ | 815 | #define FL_SLEEP 128 /* A blocking lock */ |
816 | #define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */ | 816 | #define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */ |
817 | #define FL_UNLOCK_PENDING 512 /* Lease is being broken */ | 817 | #define FL_UNLOCK_PENDING 512 /* Lease is being broken */ |
818 | #define FL_FILE_PVT 1024 /* lock is private to the file */ | 818 | #define FL_OFDLCK 1024 /* lock is "owned" by struct file */ |
819 | 819 | ||
820 | /* | 820 | /* |
821 | * Special return value from posix_lock_file() and vfs_lock_file() for | 821 | * Special return value from posix_lock_file() and vfs_lock_file() for |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 1de36be64df4..5ab4e3a76721 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -822,6 +822,7 @@ struct ata_port { | |||
822 | unsigned long qc_allocated; | 822 | unsigned long qc_allocated; |
823 | unsigned int qc_active; | 823 | unsigned int qc_active; |
824 | int nr_active_links; /* #links with active qcs */ | 824 | int nr_active_links; /* #links with active qcs */ |
825 | unsigned int last_tag; /* track next tag hw expects */ | ||
825 | 826 | ||
826 | struct ata_link link; /* host default link */ | 827 | struct ata_link link; /* host default link */ |
827 | struct ata_link *slave_link; /* see ata_slave_link_init() */ | 828 | struct ata_link *slave_link; /* see ata_slave_link_init() */ |
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index e530681bea70..1a4a8c157b31 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h | |||
@@ -258,14 +258,14 @@ regulator_get_exclusive(struct device *dev, const char *id) | |||
258 | static inline struct regulator *__must_check | 258 | static inline struct regulator *__must_check |
259 | regulator_get_optional(struct device *dev, const char *id) | 259 | regulator_get_optional(struct device *dev, const char *id) |
260 | { | 260 | { |
261 | return NULL; | 261 | return ERR_PTR(-ENODEV); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | static inline struct regulator *__must_check | 265 | static inline struct regulator *__must_check |
266 | devm_regulator_get_optional(struct device *dev, const char *id) | 266 | devm_regulator_get_optional(struct device *dev, const char *id) |
267 | { | 267 | { |
268 | return NULL; | 268 | return ERR_PTR(-ENODEV); |
269 | } | 269 | } |
270 | 270 | ||
271 | static inline void regulator_put(struct regulator *regulator) | 271 | static inline void regulator_put(struct regulator *regulator) |
diff --git a/include/linux/serio.h b/include/linux/serio.h index 36aac733840a..9f779c7a2da4 100644 --- a/include/linux/serio.h +++ b/include/linux/serio.h | |||
@@ -23,6 +23,7 @@ struct serio { | |||
23 | 23 | ||
24 | char name[32]; | 24 | char name[32]; |
25 | char phys[32]; | 25 | char phys[32]; |
26 | char firmware_id[128]; | ||
26 | 27 | ||
27 | bool manual_bind; | 28 | bool manual_bind; |
28 | 29 | ||
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index 010ea89eeb0e..6a1a0245474f 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h | |||
@@ -16,15 +16,6 @@ struct mpage_da_data; | |||
16 | struct ext4_map_blocks; | 16 | struct ext4_map_blocks; |
17 | struct extent_status; | 17 | struct extent_status; |
18 | 18 | ||
19 | /* shim until we merge in the xfs_collapse_range branch */ | ||
20 | #ifndef FALLOC_FL_COLLAPSE_RANGE | ||
21 | #define FALLOC_FL_COLLAPSE_RANGE 0x08 | ||
22 | #endif | ||
23 | |||
24 | #ifndef FALLOC_FL_ZERO_RANGE | ||
25 | #define FALLOC_FL_ZERO_RANGE 0x10 | ||
26 | #endif | ||
27 | |||
28 | #define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode)) | 19 | #define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode)) |
29 | 20 | ||
30 | #define show_mballoc_flags(flags) __print_flags(flags, "|", \ | 21 | #define show_mballoc_flags(flags) __print_flags(flags, "|", \ |
diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h index a9b13f8b3595..7543b3e51331 100644 --- a/include/uapi/asm-generic/fcntl.h +++ b/include/uapi/asm-generic/fcntl.h | |||
@@ -133,20 +133,20 @@ | |||
133 | #endif | 133 | #endif |
134 | 134 | ||
135 | /* | 135 | /* |
136 | * fd "private" POSIX locks. | 136 | * Open File Description Locks |
137 | * | 137 | * |
138 | * Usually POSIX locks held by a process are released on *any* close and are | 138 | * Usually record locks held by a process are released on *any* close and are |
139 | * not inherited across a fork(). | 139 | * not inherited across a fork(). |
140 | * | 140 | * |
141 | * These cmd values will set locks that conflict with normal POSIX locks, but | 141 | * These cmd values will set locks that conflict with process-associated |
142 | * are "owned" by the opened file, not the process. This means that they are | 142 | * record locks, but are "owned" by the open file description, not the |
143 | * inherited across fork() like BSD (flock) locks, and they are only released | 143 | * process. This means that they are inherited across fork() like BSD (flock) |
144 | * automatically when the last reference to the the open file against which | 144 | * locks, and they are only released automatically when the last reference to |
145 | * they were acquired is put. | 145 | * the the open file against which they were acquired is put. |
146 | */ | 146 | */ |
147 | #define F_GETLKP 36 | 147 | #define F_OFD_GETLK 36 |
148 | #define F_SETLKP 37 | 148 | #define F_OFD_SETLK 37 |
149 | #define F_SETLKPW 38 | 149 | #define F_OFD_SETLKW 38 |
150 | 150 | ||
151 | #define F_OWNER_TID 0 | 151 | #define F_OWNER_TID 0 |
152 | #define F_OWNER_PID 1 | 152 | #define F_OWNER_PID 1 |
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index bd24470d24a2..f4849525519c 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h | |||
@@ -164,6 +164,7 @@ struct input_keymap_entry { | |||
164 | #define INPUT_PROP_DIRECT 0x01 /* direct input devices */ | 164 | #define INPUT_PROP_DIRECT 0x01 /* direct input devices */ |
165 | #define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */ | 165 | #define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */ |
166 | #define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */ | 166 | #define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */ |
167 | #define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ | ||
167 | 168 | ||
168 | #define INPUT_PROP_MAX 0x1f | 169 | #define INPUT_PROP_MAX 0x1f |
169 | #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) | 170 | #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) |
diff --git a/mm/memory.c b/mm/memory.c index d0f0bef3be48..93e332d5ed77 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -1955,12 +1955,17 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, | |||
1955 | unsigned long address, unsigned int fault_flags) | 1955 | unsigned long address, unsigned int fault_flags) |
1956 | { | 1956 | { |
1957 | struct vm_area_struct *vma; | 1957 | struct vm_area_struct *vma; |
1958 | vm_flags_t vm_flags; | ||
1958 | int ret; | 1959 | int ret; |
1959 | 1960 | ||
1960 | vma = find_extend_vma(mm, address); | 1961 | vma = find_extend_vma(mm, address); |
1961 | if (!vma || address < vma->vm_start) | 1962 | if (!vma || address < vma->vm_start) |
1962 | return -EFAULT; | 1963 | return -EFAULT; |
1963 | 1964 | ||
1965 | vm_flags = (fault_flags & FAULT_FLAG_WRITE) ? VM_WRITE : VM_READ; | ||
1966 | if (!(vm_flags & vma->vm_flags)) | ||
1967 | return -EFAULT; | ||
1968 | |||
1964 | ret = handle_mm_fault(mm, vma, address, fault_flags); | 1969 | ret = handle_mm_fault(mm, vma, address, fault_flags); |
1965 | if (ret & VM_FAULT_ERROR) { | 1970 | if (ret & VM_FAULT_ERROR) { |
1966 | if (ret & VM_FAULT_OOM) | 1971 | if (ret & VM_FAULT_OOM) |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index b4beb77967b1..2c7341dbc5d6 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -3317,9 +3317,9 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, | |||
3317 | case F_GETLK: | 3317 | case F_GETLK: |
3318 | case F_SETLK: | 3318 | case F_SETLK: |
3319 | case F_SETLKW: | 3319 | case F_SETLKW: |
3320 | case F_GETLKP: | 3320 | case F_OFD_GETLK: |
3321 | case F_SETLKP: | 3321 | case F_OFD_SETLK: |
3322 | case F_SETLKPW: | 3322 | case F_OFD_SETLKW: |
3323 | #if BITS_PER_LONG == 32 | 3323 | #if BITS_PER_LONG == 32 |
3324 | case F_GETLK64: | 3324 | case F_GETLK64: |
3325 | case F_SETLK64: | 3325 | case F_SETLK64: |