diff options
92 files changed, 1027 insertions, 556 deletions
@@ -51,6 +51,7 @@ Greg Kroah-Hartman <gregkh@suse.de> | |||
51 | Greg Kroah-Hartman <greg@kroah.com> | 51 | Greg Kroah-Hartman <greg@kroah.com> |
52 | Henk Vergonet <Henk.Vergonet@gmail.com> | 52 | Henk Vergonet <Henk.Vergonet@gmail.com> |
53 | Henrik Kretzschmar <henne@nachtwindheim.de> | 53 | Henrik Kretzschmar <henne@nachtwindheim.de> |
54 | Henrik Rydberg <rydberg@bitmath.org> | ||
54 | Herbert Xu <herbert@gondor.apana.org.au> | 55 | Herbert Xu <herbert@gondor.apana.org.au> |
55 | Jacob Shin <Jacob.Shin@amd.com> | 56 | Jacob Shin <Jacob.Shin@amd.com> |
56 | James Bottomley <jejb@mulgrave.(none)> | 57 | James Bottomley <jejb@mulgrave.(none)> |
diff --git a/MAINTAINERS b/MAINTAINERS index ddb9ac8d32b3..3589d67437f8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -724,15 +724,15 @@ F: include/uapi/linux/apm_bios.h | |||
724 | F: drivers/char/apm-emulation.c | 724 | F: drivers/char/apm-emulation.c |
725 | 725 | ||
726 | APPLE BCM5974 MULTITOUCH DRIVER | 726 | APPLE BCM5974 MULTITOUCH DRIVER |
727 | M: Henrik Rydberg <rydberg@euromail.se> | 727 | M: Henrik Rydberg <rydberg@bitmath.org> |
728 | L: linux-input@vger.kernel.org | 728 | L: linux-input@vger.kernel.org |
729 | S: Maintained | 729 | S: Odd fixes |
730 | F: drivers/input/mouse/bcm5974.c | 730 | F: drivers/input/mouse/bcm5974.c |
731 | 731 | ||
732 | APPLE SMC DRIVER | 732 | APPLE SMC DRIVER |
733 | M: Henrik Rydberg <rydberg@euromail.se> | 733 | M: Henrik Rydberg <rydberg@bitmath.org> |
734 | L: lm-sensors@lm-sensors.org | 734 | L: lm-sensors@lm-sensors.org |
735 | S: Maintained | 735 | S: Odd fixes |
736 | F: drivers/hwmon/applesmc.c | 736 | F: drivers/hwmon/applesmc.c |
737 | 737 | ||
738 | APPLETALK NETWORK LAYER | 738 | APPLETALK NETWORK LAYER |
@@ -2259,6 +2259,7 @@ F: drivers/gpio/gpio-bt8xx.c | |||
2259 | BTRFS FILE SYSTEM | 2259 | BTRFS FILE SYSTEM |
2260 | M: Chris Mason <clm@fb.com> | 2260 | M: Chris Mason <clm@fb.com> |
2261 | M: Josef Bacik <jbacik@fb.com> | 2261 | M: Josef Bacik <jbacik@fb.com> |
2262 | M: David Sterba <dsterba@suse.cz> | ||
2262 | L: linux-btrfs@vger.kernel.org | 2263 | L: linux-btrfs@vger.kernel.org |
2263 | W: http://btrfs.wiki.kernel.org/ | 2264 | W: http://btrfs.wiki.kernel.org/ |
2264 | Q: http://patchwork.kernel.org/project/linux-btrfs/list/ | 2265 | Q: http://patchwork.kernel.org/project/linux-btrfs/list/ |
@@ -4940,10 +4941,10 @@ F: include/uapi/linux/input.h | |||
4940 | F: include/linux/input/ | 4941 | F: include/linux/input/ |
4941 | 4942 | ||
4942 | INPUT MULTITOUCH (MT) PROTOCOL | 4943 | INPUT MULTITOUCH (MT) PROTOCOL |
4943 | M: Henrik Rydberg <rydberg@euromail.se> | 4944 | M: Henrik Rydberg <rydberg@bitmath.org> |
4944 | L: linux-input@vger.kernel.org | 4945 | L: linux-input@vger.kernel.org |
4945 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rydberg/input-mt.git | 4946 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rydberg/input-mt.git |
4946 | S: Maintained | 4947 | S: Odd fixes |
4947 | F: Documentation/input/multi-touch-protocol.txt | 4948 | F: Documentation/input/multi-touch-protocol.txt |
4948 | F: drivers/input/input-mt.c | 4949 | F: drivers/input/input-mt.c |
4949 | K: \b(ABS|SYN)_MT_ | 4950 | K: \b(ABS|SYN)_MT_ |
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index b1fa4e614718..fbe0ca31a99c 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <asm/barrier.h> | 22 | #include <asm/barrier.h> |
23 | 23 | ||
24 | #include <linux/bug.h> | ||
24 | #include <linux/init.h> | 25 | #include <linux/init.h> |
25 | #include <linux/types.h> | 26 | #include <linux/types.h> |
26 | 27 | ||
diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h index ace70682499b..8e797b2fcc01 100644 --- a/arch/arm64/include/asm/cpu.h +++ b/arch/arm64/include/asm/cpu.h | |||
@@ -39,6 +39,7 @@ struct cpuinfo_arm64 { | |||
39 | u64 reg_id_aa64pfr0; | 39 | u64 reg_id_aa64pfr0; |
40 | u64 reg_id_aa64pfr1; | 40 | u64 reg_id_aa64pfr1; |
41 | 41 | ||
42 | u32 reg_id_dfr0; | ||
42 | u32 reg_id_isar0; | 43 | u32 reg_id_isar0; |
43 | u32 reg_id_isar1; | 44 | u32 reg_id_isar1; |
44 | u32 reg_id_isar2; | 45 | u32 reg_id_isar2; |
@@ -51,6 +52,10 @@ struct cpuinfo_arm64 { | |||
51 | u32 reg_id_mmfr3; | 52 | u32 reg_id_mmfr3; |
52 | u32 reg_id_pfr0; | 53 | u32 reg_id_pfr0; |
53 | u32 reg_id_pfr1; | 54 | u32 reg_id_pfr1; |
55 | |||
56 | u32 reg_mvfr0; | ||
57 | u32 reg_mvfr1; | ||
58 | u32 reg_mvfr2; | ||
54 | }; | 59 | }; |
55 | 60 | ||
56 | DECLARE_PER_CPU(struct cpuinfo_arm64, cpu_data); | 61 | DECLARE_PER_CPU(struct cpuinfo_arm64, cpu_data); |
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 286b1bec547c..f9be30ea1cbd 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include <asm/fpsimd.h> | 32 | #include <asm/fpsimd.h> |
33 | #include <asm/hw_breakpoint.h> | 33 | #include <asm/hw_breakpoint.h> |
34 | #include <asm/pgtable-hwdef.h> | ||
34 | #include <asm/ptrace.h> | 35 | #include <asm/ptrace.h> |
35 | #include <asm/types.h> | 36 | #include <asm/types.h> |
36 | 37 | ||
@@ -123,9 +124,6 @@ struct task_struct; | |||
123 | /* Free all resources held by a thread. */ | 124 | /* Free all resources held by a thread. */ |
124 | extern void release_thread(struct task_struct *); | 125 | extern void release_thread(struct task_struct *); |
125 | 126 | ||
126 | /* Prepare to copy thread state - unlazy all lazy status */ | ||
127 | #define prepare_to_copy(tsk) do { } while (0) | ||
128 | |||
129 | unsigned long get_wchan(struct task_struct *p); | 127 | unsigned long get_wchan(struct task_struct *p); |
130 | 128 | ||
131 | #define cpu_relax() barrier() | 129 | #define cpu_relax() barrier() |
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index 49c9aefd24a5..b780c6c76eec 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h | |||
@@ -44,7 +44,7 @@ | |||
44 | #define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2) | 44 | #define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2) |
45 | #define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5) | 45 | #define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5) |
46 | 46 | ||
47 | #define __NR_compat_syscalls 386 | 47 | #define __NR_compat_syscalls 387 |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #define __ARCH_WANT_SYS_CLONE | 50 | #define __ARCH_WANT_SYS_CLONE |
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 57b641747534..07d435cf2eea 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c | |||
@@ -147,6 +147,7 @@ static void cpuinfo_sanity_check(struct cpuinfo_arm64 *cur) | |||
147 | * If we have AArch32, we care about 32-bit features for compat. These | 147 | * If we have AArch32, we care about 32-bit features for compat. These |
148 | * registers should be RES0 otherwise. | 148 | * registers should be RES0 otherwise. |
149 | */ | 149 | */ |
150 | diff |= CHECK(id_dfr0, boot, cur, cpu); | ||
150 | diff |= CHECK(id_isar0, boot, cur, cpu); | 151 | diff |= CHECK(id_isar0, boot, cur, cpu); |
151 | diff |= CHECK(id_isar1, boot, cur, cpu); | 152 | diff |= CHECK(id_isar1, boot, cur, cpu); |
152 | diff |= CHECK(id_isar2, boot, cur, cpu); | 153 | diff |= CHECK(id_isar2, boot, cur, cpu); |
@@ -165,6 +166,10 @@ static void cpuinfo_sanity_check(struct cpuinfo_arm64 *cur) | |||
165 | diff |= CHECK(id_pfr0, boot, cur, cpu); | 166 | diff |= CHECK(id_pfr0, boot, cur, cpu); |
166 | diff |= CHECK(id_pfr1, boot, cur, cpu); | 167 | diff |= CHECK(id_pfr1, boot, cur, cpu); |
167 | 168 | ||
169 | diff |= CHECK(mvfr0, boot, cur, cpu); | ||
170 | diff |= CHECK(mvfr1, boot, cur, cpu); | ||
171 | diff |= CHECK(mvfr2, boot, cur, cpu); | ||
172 | |||
168 | /* | 173 | /* |
169 | * Mismatched CPU features are a recipe for disaster. Don't even | 174 | * Mismatched CPU features are a recipe for disaster. Don't even |
170 | * pretend to support them. | 175 | * pretend to support them. |
@@ -189,6 +194,7 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info) | |||
189 | info->reg_id_aa64pfr0 = read_cpuid(ID_AA64PFR0_EL1); | 194 | info->reg_id_aa64pfr0 = read_cpuid(ID_AA64PFR0_EL1); |
190 | info->reg_id_aa64pfr1 = read_cpuid(ID_AA64PFR1_EL1); | 195 | info->reg_id_aa64pfr1 = read_cpuid(ID_AA64PFR1_EL1); |
191 | 196 | ||
197 | info->reg_id_dfr0 = read_cpuid(ID_DFR0_EL1); | ||
192 | info->reg_id_isar0 = read_cpuid(ID_ISAR0_EL1); | 198 | info->reg_id_isar0 = read_cpuid(ID_ISAR0_EL1); |
193 | info->reg_id_isar1 = read_cpuid(ID_ISAR1_EL1); | 199 | info->reg_id_isar1 = read_cpuid(ID_ISAR1_EL1); |
194 | info->reg_id_isar2 = read_cpuid(ID_ISAR2_EL1); | 200 | info->reg_id_isar2 = read_cpuid(ID_ISAR2_EL1); |
@@ -202,6 +208,10 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info) | |||
202 | info->reg_id_pfr0 = read_cpuid(ID_PFR0_EL1); | 208 | info->reg_id_pfr0 = read_cpuid(ID_PFR0_EL1); |
203 | info->reg_id_pfr1 = read_cpuid(ID_PFR1_EL1); | 209 | info->reg_id_pfr1 = read_cpuid(ID_PFR1_EL1); |
204 | 210 | ||
211 | info->reg_mvfr0 = read_cpuid(MVFR0_EL1); | ||
212 | info->reg_mvfr1 = read_cpuid(MVFR1_EL1); | ||
213 | info->reg_mvfr2 = read_cpuid(MVFR2_EL1); | ||
214 | |||
205 | cpuinfo_detect_icache_policy(info); | 215 | cpuinfo_detect_icache_policy(info); |
206 | 216 | ||
207 | check_local_cpu_errata(); | 217 | check_local_cpu_errata(); |
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 6fac253bc783..2bb4347d0edf 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c | |||
@@ -326,6 +326,7 @@ void __init efi_idmap_init(void) | |||
326 | 326 | ||
327 | /* boot time idmap_pg_dir is incomplete, so fill in missing parts */ | 327 | /* boot time idmap_pg_dir is incomplete, so fill in missing parts */ |
328 | efi_setup_idmap(); | 328 | efi_setup_idmap(); |
329 | early_memunmap(memmap.map, memmap.map_end - memmap.map); | ||
329 | } | 330 | } |
330 | 331 | ||
331 | static int __init remap_region(efi_memory_desc_t *md, void **new) | 332 | static int __init remap_region(efi_memory_desc_t *md, void **new) |
@@ -380,7 +381,6 @@ static int __init arm64_enter_virtual_mode(void) | |||
380 | } | 381 | } |
381 | 382 | ||
382 | mapsize = memmap.map_end - memmap.map; | 383 | mapsize = memmap.map_end - memmap.map; |
383 | early_memunmap(memmap.map, mapsize); | ||
384 | 384 | ||
385 | if (efi_runtime_disabled()) { | 385 | if (efi_runtime_disabled()) { |
386 | pr_info("EFI runtime services will be disabled.\n"); | 386 | pr_info("EFI runtime services will be disabled.\n"); |
diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index fd027b101de5..9b6f71db2709 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/mm.h> | 25 | #include <linux/mm.h> |
26 | #include <linux/moduleloader.h> | 26 | #include <linux/moduleloader.h> |
27 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
28 | #include <asm/alternative.h> | ||
28 | #include <asm/insn.h> | 29 | #include <asm/insn.h> |
29 | #include <asm/sections.h> | 30 | #include <asm/sections.h> |
30 | 31 | ||
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index b80991166754..20fe2932ad0c 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c | |||
@@ -402,6 +402,7 @@ void __init setup_arch(char **cmdline_p) | |||
402 | request_standard_resources(); | 402 | request_standard_resources(); |
403 | 403 | ||
404 | efi_idmap_init(); | 404 | efi_idmap_init(); |
405 | early_ioremap_reset(); | ||
405 | 406 | ||
406 | unflatten_device_tree(); | 407 | unflatten_device_tree(); |
407 | 408 | ||
diff --git a/arch/arm64/kernel/smp_spin_table.c b/arch/arm64/kernel/smp_spin_table.c index 4f93c67e63de..14944e5b28da 100644 --- a/arch/arm64/kernel/smp_spin_table.c +++ b/arch/arm64/kernel/smp_spin_table.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <asm/cacheflush.h> | 25 | #include <asm/cacheflush.h> |
26 | #include <asm/cpu_ops.h> | 26 | #include <asm/cpu_ops.h> |
27 | #include <asm/cputype.h> | 27 | #include <asm/cputype.h> |
28 | #include <asm/io.h> | ||
28 | #include <asm/smp_plat.h> | 29 | #include <asm/smp_plat.h> |
29 | 30 | ||
30 | extern void secondary_holding_pen(void); | 31 | extern void secondary_holding_pen(void); |
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c index 6f4bac969bf7..23eada79439c 100644 --- a/arch/blackfin/mach-bf533/boards/stamp.c +++ b/arch/blackfin/mach-bf533/boards/stamp.c | |||
@@ -7,6 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/device.h> | 9 | #include <linux/device.h> |
10 | #include <linux/delay.h> | ||
10 | #include <linux/platform_device.h> | 11 | #include <linux/platform_device.h> |
11 | #include <linux/mtd/mtd.h> | 12 | #include <linux/mtd/mtd.h> |
12 | #include <linux/mtd/partitions.h> | 13 | #include <linux/mtd/partitions.h> |
diff --git a/drivers/Makefile b/drivers/Makefile index 67d2334dc41e..527a6da8d539 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -50,7 +50,10 @@ obj-$(CONFIG_RESET_CONTROLLER) += reset/ | |||
50 | obj-y += tty/ | 50 | obj-y += tty/ |
51 | obj-y += char/ | 51 | obj-y += char/ |
52 | 52 | ||
53 | # gpu/ comes after char for AGP vs DRM startup | 53 | # iommu/ comes before gpu as gpu are using iommu controllers |
54 | obj-$(CONFIG_IOMMU_SUPPORT) += iommu/ | ||
55 | |||
56 | # gpu/ comes after char for AGP vs DRM startup and after iommu | ||
54 | obj-y += gpu/ | 57 | obj-y += gpu/ |
55 | 58 | ||
56 | obj-$(CONFIG_CONNECTOR) += connector/ | 59 | obj-$(CONFIG_CONNECTOR) += connector/ |
@@ -141,7 +144,6 @@ obj-y += clk/ | |||
141 | 144 | ||
142 | obj-$(CONFIG_MAILBOX) += mailbox/ | 145 | obj-$(CONFIG_MAILBOX) += mailbox/ |
143 | obj-$(CONFIG_HWSPINLOCK) += hwspinlock/ | 146 | obj-$(CONFIG_HWSPINLOCK) += hwspinlock/ |
144 | obj-$(CONFIG_IOMMU_SUPPORT) += iommu/ | ||
145 | obj-$(CONFIG_REMOTEPROC) += remoteproc/ | 147 | obj-$(CONFIG_REMOTEPROC) += remoteproc/ |
146 | obj-$(CONFIG_RPMSG) += rpmsg/ | 148 | obj-$(CONFIG_RPMSG) += rpmsg/ |
147 | 149 | ||
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 66e40398b3d3..e620807418ea 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile | |||
@@ -37,6 +37,7 @@ obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o | |||
37 | obj-$(CONFIG_DRM_TTM) += ttm/ | 37 | obj-$(CONFIG_DRM_TTM) += ttm/ |
38 | obj-$(CONFIG_DRM_TDFX) += tdfx/ | 38 | obj-$(CONFIG_DRM_TDFX) += tdfx/ |
39 | obj-$(CONFIG_DRM_R128) += r128/ | 39 | obj-$(CONFIG_DRM_R128) += r128/ |
40 | obj-$(CONFIG_HSA_AMD) += amd/amdkfd/ | ||
40 | obj-$(CONFIG_DRM_RADEON)+= radeon/ | 41 | obj-$(CONFIG_DRM_RADEON)+= radeon/ |
41 | obj-$(CONFIG_DRM_MGA) += mga/ | 42 | obj-$(CONFIG_DRM_MGA) += mga/ |
42 | obj-$(CONFIG_DRM_I810) += i810/ | 43 | obj-$(CONFIG_DRM_I810) += i810/ |
@@ -67,4 +68,3 @@ obj-$(CONFIG_DRM_IMX) += imx/ | |||
67 | obj-y += i2c/ | 68 | obj-y += i2c/ |
68 | obj-y += panel/ | 69 | obj-y += panel/ |
69 | obj-y += bridge/ | 70 | obj-y += bridge/ |
70 | obj-$(CONFIG_HSA_AMD) += amd/amdkfd/ | ||
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 7d4974b83af7..fcfdf23e1913 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <uapi/linux/kfd_ioctl.h> | 31 | #include <uapi/linux/kfd_ioctl.h> |
32 | #include <linux/time.h> | 32 | #include <linux/time.h> |
33 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
34 | #include <linux/uaccess.h> | ||
35 | #include <uapi/asm-generic/mman-common.h> | 34 | #include <uapi/asm-generic/mman-common.h> |
36 | #include <asm/processor.h> | 35 | #include <asm/processor.h> |
37 | #include "kfd_priv.h" | 36 | #include "kfd_priv.h" |
@@ -127,17 +126,14 @@ static int kfd_open(struct inode *inode, struct file *filep) | |||
127 | return 0; | 126 | return 0; |
128 | } | 127 | } |
129 | 128 | ||
130 | static long kfd_ioctl_get_version(struct file *filep, struct kfd_process *p, | 129 | static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p, |
131 | void __user *arg) | 130 | void *data) |
132 | { | 131 | { |
133 | struct kfd_ioctl_get_version_args args; | 132 | struct kfd_ioctl_get_version_args *args = data; |
134 | int err = 0; | 133 | int err = 0; |
135 | 134 | ||
136 | args.major_version = KFD_IOCTL_MAJOR_VERSION; | 135 | args->major_version = KFD_IOCTL_MAJOR_VERSION; |
137 | args.minor_version = KFD_IOCTL_MINOR_VERSION; | 136 | args->minor_version = KFD_IOCTL_MINOR_VERSION; |
138 | |||
139 | if (copy_to_user(arg, &args, sizeof(args))) | ||
140 | err = -EFAULT; | ||
141 | 137 | ||
142 | return err; | 138 | return err; |
143 | } | 139 | } |
@@ -221,10 +217,10 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties, | |||
221 | return 0; | 217 | return 0; |
222 | } | 218 | } |
223 | 219 | ||
224 | static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, | 220 | static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, |
225 | void __user *arg) | 221 | void *data) |
226 | { | 222 | { |
227 | struct kfd_ioctl_create_queue_args args; | 223 | struct kfd_ioctl_create_queue_args *args = data; |
228 | struct kfd_dev *dev; | 224 | struct kfd_dev *dev; |
229 | int err = 0; | 225 | int err = 0; |
230 | unsigned int queue_id; | 226 | unsigned int queue_id; |
@@ -233,16 +229,13 @@ static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, | |||
233 | 229 | ||
234 | memset(&q_properties, 0, sizeof(struct queue_properties)); | 230 | memset(&q_properties, 0, sizeof(struct queue_properties)); |
235 | 231 | ||
236 | if (copy_from_user(&args, arg, sizeof(args))) | ||
237 | return -EFAULT; | ||
238 | |||
239 | pr_debug("kfd: creating queue ioctl\n"); | 232 | pr_debug("kfd: creating queue ioctl\n"); |
240 | 233 | ||
241 | err = set_queue_properties_from_user(&q_properties, &args); | 234 | err = set_queue_properties_from_user(&q_properties, args); |
242 | if (err) | 235 | if (err) |
243 | return err; | 236 | return err; |
244 | 237 | ||
245 | dev = kfd_device_by_id(args.gpu_id); | 238 | dev = kfd_device_by_id(args->gpu_id); |
246 | if (dev == NULL) | 239 | if (dev == NULL) |
247 | return -EINVAL; | 240 | return -EINVAL; |
248 | 241 | ||
@@ -250,7 +243,7 @@ static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, | |||
250 | 243 | ||
251 | pdd = kfd_bind_process_to_device(dev, p); | 244 | pdd = kfd_bind_process_to_device(dev, p); |
252 | if (IS_ERR(pdd)) { | 245 | if (IS_ERR(pdd)) { |
253 | err = PTR_ERR(pdd); | 246 | err = -ESRCH; |
254 | goto err_bind_process; | 247 | goto err_bind_process; |
255 | } | 248 | } |
256 | 249 | ||
@@ -263,33 +256,26 @@ static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, | |||
263 | if (err != 0) | 256 | if (err != 0) |
264 | goto err_create_queue; | 257 | goto err_create_queue; |
265 | 258 | ||
266 | args.queue_id = queue_id; | 259 | args->queue_id = queue_id; |
267 | 260 | ||
268 | /* Return gpu_id as doorbell offset for mmap usage */ | 261 | /* Return gpu_id as doorbell offset for mmap usage */ |
269 | args.doorbell_offset = args.gpu_id << PAGE_SHIFT; | 262 | args->doorbell_offset = args->gpu_id << PAGE_SHIFT; |
270 | |||
271 | if (copy_to_user(arg, &args, sizeof(args))) { | ||
272 | err = -EFAULT; | ||
273 | goto err_copy_args_out; | ||
274 | } | ||
275 | 263 | ||
276 | mutex_unlock(&p->mutex); | 264 | mutex_unlock(&p->mutex); |
277 | 265 | ||
278 | pr_debug("kfd: queue id %d was created successfully\n", args.queue_id); | 266 | pr_debug("kfd: queue id %d was created successfully\n", args->queue_id); |
279 | 267 | ||
280 | pr_debug("ring buffer address == 0x%016llX\n", | 268 | pr_debug("ring buffer address == 0x%016llX\n", |
281 | args.ring_base_address); | 269 | args->ring_base_address); |
282 | 270 | ||
283 | pr_debug("read ptr address == 0x%016llX\n", | 271 | pr_debug("read ptr address == 0x%016llX\n", |
284 | args.read_pointer_address); | 272 | args->read_pointer_address); |
285 | 273 | ||
286 | pr_debug("write ptr address == 0x%016llX\n", | 274 | pr_debug("write ptr address == 0x%016llX\n", |
287 | args.write_pointer_address); | 275 | args->write_pointer_address); |
288 | 276 | ||
289 | return 0; | 277 | return 0; |
290 | 278 | ||
291 | err_copy_args_out: | ||
292 | pqm_destroy_queue(&p->pqm, queue_id); | ||
293 | err_create_queue: | 279 | err_create_queue: |
294 | err_bind_process: | 280 | err_bind_process: |
295 | mutex_unlock(&p->mutex); | 281 | mutex_unlock(&p->mutex); |
@@ -297,99 +283,90 @@ err_bind_process: | |||
297 | } | 283 | } |
298 | 284 | ||
299 | static int kfd_ioctl_destroy_queue(struct file *filp, struct kfd_process *p, | 285 | static int kfd_ioctl_destroy_queue(struct file *filp, struct kfd_process *p, |
300 | void __user *arg) | 286 | void *data) |
301 | { | 287 | { |
302 | int retval; | 288 | int retval; |
303 | struct kfd_ioctl_destroy_queue_args args; | 289 | struct kfd_ioctl_destroy_queue_args *args = data; |
304 | |||
305 | if (copy_from_user(&args, arg, sizeof(args))) | ||
306 | return -EFAULT; | ||
307 | 290 | ||
308 | pr_debug("kfd: destroying queue id %d for PASID %d\n", | 291 | pr_debug("kfd: destroying queue id %d for PASID %d\n", |
309 | args.queue_id, | 292 | args->queue_id, |
310 | p->pasid); | 293 | p->pasid); |
311 | 294 | ||
312 | mutex_lock(&p->mutex); | 295 | mutex_lock(&p->mutex); |
313 | 296 | ||
314 | retval = pqm_destroy_queue(&p->pqm, args.queue_id); | 297 | retval = pqm_destroy_queue(&p->pqm, args->queue_id); |
315 | 298 | ||
316 | mutex_unlock(&p->mutex); | 299 | mutex_unlock(&p->mutex); |
317 | return retval; | 300 | return retval; |
318 | } | 301 | } |
319 | 302 | ||
320 | static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p, | 303 | static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p, |
321 | void __user *arg) | 304 | void *data) |
322 | { | 305 | { |
323 | int retval; | 306 | int retval; |
324 | struct kfd_ioctl_update_queue_args args; | 307 | struct kfd_ioctl_update_queue_args *args = data; |
325 | struct queue_properties properties; | 308 | struct queue_properties properties; |
326 | 309 | ||
327 | if (copy_from_user(&args, arg, sizeof(args))) | 310 | if (args->queue_percentage > KFD_MAX_QUEUE_PERCENTAGE) { |
328 | return -EFAULT; | ||
329 | |||
330 | if (args.queue_percentage > KFD_MAX_QUEUE_PERCENTAGE) { | ||
331 | pr_err("kfd: queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n"); | 311 | pr_err("kfd: queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n"); |
332 | return -EINVAL; | 312 | return -EINVAL; |
333 | } | 313 | } |
334 | 314 | ||
335 | if (args.queue_priority > KFD_MAX_QUEUE_PRIORITY) { | 315 | if (args->queue_priority > KFD_MAX_QUEUE_PRIORITY) { |
336 | pr_err("kfd: queue priority must be between 0 to KFD_MAX_QUEUE_PRIORITY\n"); | 316 | pr_err("kfd: queue priority must be between 0 to KFD_MAX_QUEUE_PRIORITY\n"); |
337 | return -EINVAL; | 317 | return -EINVAL; |
338 | } | 318 | } |
339 | 319 | ||
340 | if ((args.ring_base_address) && | 320 | if ((args->ring_base_address) && |
341 | (!access_ok(VERIFY_WRITE, | 321 | (!access_ok(VERIFY_WRITE, |
342 | (const void __user *) args.ring_base_address, | 322 | (const void __user *) args->ring_base_address, |
343 | sizeof(uint64_t)))) { | 323 | sizeof(uint64_t)))) { |
344 | pr_err("kfd: can't access ring base address\n"); | 324 | pr_err("kfd: can't access ring base address\n"); |
345 | return -EFAULT; | 325 | return -EFAULT; |
346 | } | 326 | } |
347 | 327 | ||
348 | if (!is_power_of_2(args.ring_size) && (args.ring_size != 0)) { | 328 | if (!is_power_of_2(args->ring_size) && (args->ring_size != 0)) { |
349 | pr_err("kfd: ring size must be a power of 2 or 0\n"); | 329 | pr_err("kfd: ring size must be a power of 2 or 0\n"); |
350 | return -EINVAL; | 330 | return -EINVAL; |
351 | } | 331 | } |
352 | 332 | ||
353 | properties.queue_address = args.ring_base_address; | 333 | properties.queue_address = args->ring_base_address; |
354 | properties.queue_size = args.ring_size; | 334 | properties.queue_size = args->ring_size; |
355 | properties.queue_percent = args.queue_percentage; | 335 | properties.queue_percent = args->queue_percentage; |
356 | properties.priority = args.queue_priority; | 336 | properties.priority = args->queue_priority; |
357 | 337 | ||
358 | pr_debug("kfd: updating queue id %d for PASID %d\n", | 338 | pr_debug("kfd: updating queue id %d for PASID %d\n", |
359 | args.queue_id, p->pasid); | 339 | args->queue_id, p->pasid); |
360 | 340 | ||
361 | mutex_lock(&p->mutex); | 341 | mutex_lock(&p->mutex); |
362 | 342 | ||
363 | retval = pqm_update_queue(&p->pqm, args.queue_id, &properties); | 343 | retval = pqm_update_queue(&p->pqm, args->queue_id, &properties); |
364 | 344 | ||
365 | mutex_unlock(&p->mutex); | 345 | mutex_unlock(&p->mutex); |
366 | 346 | ||
367 | return retval; | 347 | return retval; |
368 | } | 348 | } |
369 | 349 | ||
370 | static long kfd_ioctl_set_memory_policy(struct file *filep, | 350 | static int kfd_ioctl_set_memory_policy(struct file *filep, |
371 | struct kfd_process *p, void __user *arg) | 351 | struct kfd_process *p, void *data) |
372 | { | 352 | { |
373 | struct kfd_ioctl_set_memory_policy_args args; | 353 | struct kfd_ioctl_set_memory_policy_args *args = data; |
374 | struct kfd_dev *dev; | 354 | struct kfd_dev *dev; |
375 | int err = 0; | 355 | int err = 0; |
376 | struct kfd_process_device *pdd; | 356 | struct kfd_process_device *pdd; |
377 | enum cache_policy default_policy, alternate_policy; | 357 | enum cache_policy default_policy, alternate_policy; |
378 | 358 | ||
379 | if (copy_from_user(&args, arg, sizeof(args))) | 359 | if (args->default_policy != KFD_IOC_CACHE_POLICY_COHERENT |
380 | return -EFAULT; | 360 | && args->default_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { |
381 | |||
382 | if (args.default_policy != KFD_IOC_CACHE_POLICY_COHERENT | ||
383 | && args.default_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { | ||
384 | return -EINVAL; | 361 | return -EINVAL; |
385 | } | 362 | } |
386 | 363 | ||
387 | if (args.alternate_policy != KFD_IOC_CACHE_POLICY_COHERENT | 364 | if (args->alternate_policy != KFD_IOC_CACHE_POLICY_COHERENT |
388 | && args.alternate_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { | 365 | && args->alternate_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { |
389 | return -EINVAL; | 366 | return -EINVAL; |
390 | } | 367 | } |
391 | 368 | ||
392 | dev = kfd_device_by_id(args.gpu_id); | 369 | dev = kfd_device_by_id(args->gpu_id); |
393 | if (dev == NULL) | 370 | if (dev == NULL) |
394 | return -EINVAL; | 371 | return -EINVAL; |
395 | 372 | ||
@@ -397,23 +374,23 @@ static long kfd_ioctl_set_memory_policy(struct file *filep, | |||
397 | 374 | ||
398 | pdd = kfd_bind_process_to_device(dev, p); | 375 | pdd = kfd_bind_process_to_device(dev, p); |
399 | if (IS_ERR(pdd)) { | 376 | if (IS_ERR(pdd)) { |
400 | err = PTR_ERR(pdd); | 377 | err = -ESRCH; |
401 | goto out; | 378 | goto out; |
402 | } | 379 | } |
403 | 380 | ||
404 | default_policy = (args.default_policy == KFD_IOC_CACHE_POLICY_COHERENT) | 381 | default_policy = (args->default_policy == KFD_IOC_CACHE_POLICY_COHERENT) |
405 | ? cache_policy_coherent : cache_policy_noncoherent; | 382 | ? cache_policy_coherent : cache_policy_noncoherent; |
406 | 383 | ||
407 | alternate_policy = | 384 | alternate_policy = |
408 | (args.alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT) | 385 | (args->alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT) |
409 | ? cache_policy_coherent : cache_policy_noncoherent; | 386 | ? cache_policy_coherent : cache_policy_noncoherent; |
410 | 387 | ||
411 | if (!dev->dqm->set_cache_memory_policy(dev->dqm, | 388 | if (!dev->dqm->set_cache_memory_policy(dev->dqm, |
412 | &pdd->qpd, | 389 | &pdd->qpd, |
413 | default_policy, | 390 | default_policy, |
414 | alternate_policy, | 391 | alternate_policy, |
415 | (void __user *)args.alternate_aperture_base, | 392 | (void __user *)args->alternate_aperture_base, |
416 | args.alternate_aperture_size)) | 393 | args->alternate_aperture_size)) |
417 | err = -EINVAL; | 394 | err = -EINVAL; |
418 | 395 | ||
419 | out: | 396 | out: |
@@ -422,53 +399,44 @@ out: | |||
422 | return err; | 399 | return err; |
423 | } | 400 | } |
424 | 401 | ||
425 | static long kfd_ioctl_get_clock_counters(struct file *filep, | 402 | static int kfd_ioctl_get_clock_counters(struct file *filep, |
426 | struct kfd_process *p, void __user *arg) | 403 | struct kfd_process *p, void *data) |
427 | { | 404 | { |
428 | struct kfd_ioctl_get_clock_counters_args args; | 405 | struct kfd_ioctl_get_clock_counters_args *args = data; |
429 | struct kfd_dev *dev; | 406 | struct kfd_dev *dev; |
430 | struct timespec time; | 407 | struct timespec time; |
431 | 408 | ||
432 | if (copy_from_user(&args, arg, sizeof(args))) | 409 | dev = kfd_device_by_id(args->gpu_id); |
433 | return -EFAULT; | ||
434 | |||
435 | dev = kfd_device_by_id(args.gpu_id); | ||
436 | if (dev == NULL) | 410 | if (dev == NULL) |
437 | return -EINVAL; | 411 | return -EINVAL; |
438 | 412 | ||
439 | /* Reading GPU clock counter from KGD */ | 413 | /* Reading GPU clock counter from KGD */ |
440 | args.gpu_clock_counter = kfd2kgd->get_gpu_clock_counter(dev->kgd); | 414 | args->gpu_clock_counter = kfd2kgd->get_gpu_clock_counter(dev->kgd); |
441 | 415 | ||
442 | /* No access to rdtsc. Using raw monotonic time */ | 416 | /* No access to rdtsc. Using raw monotonic time */ |
443 | getrawmonotonic(&time); | 417 | getrawmonotonic(&time); |
444 | args.cpu_clock_counter = (uint64_t)timespec_to_ns(&time); | 418 | args->cpu_clock_counter = (uint64_t)timespec_to_ns(&time); |
445 | 419 | ||
446 | get_monotonic_boottime(&time); | 420 | get_monotonic_boottime(&time); |
447 | args.system_clock_counter = (uint64_t)timespec_to_ns(&time); | 421 | args->system_clock_counter = (uint64_t)timespec_to_ns(&time); |
448 | 422 | ||
449 | /* Since the counter is in nano-seconds we use 1GHz frequency */ | 423 | /* Since the counter is in nano-seconds we use 1GHz frequency */ |
450 | args.system_clock_freq = 1000000000; | 424 | args->system_clock_freq = 1000000000; |
451 | |||
452 | if (copy_to_user(arg, &args, sizeof(args))) | ||
453 | return -EFAULT; | ||
454 | 425 | ||
455 | return 0; | 426 | return 0; |
456 | } | 427 | } |
457 | 428 | ||
458 | 429 | ||
459 | static int kfd_ioctl_get_process_apertures(struct file *filp, | 430 | static int kfd_ioctl_get_process_apertures(struct file *filp, |
460 | struct kfd_process *p, void __user *arg) | 431 | struct kfd_process *p, void *data) |
461 | { | 432 | { |
462 | struct kfd_ioctl_get_process_apertures_args args; | 433 | struct kfd_ioctl_get_process_apertures_args *args = data; |
463 | struct kfd_process_device_apertures *pAperture; | 434 | struct kfd_process_device_apertures *pAperture; |
464 | struct kfd_process_device *pdd; | 435 | struct kfd_process_device *pdd; |
465 | 436 | ||
466 | dev_dbg(kfd_device, "get apertures for PASID %d", p->pasid); | 437 | dev_dbg(kfd_device, "get apertures for PASID %d", p->pasid); |
467 | 438 | ||
468 | if (copy_from_user(&args, arg, sizeof(args))) | 439 | args->num_of_nodes = 0; |
469 | return -EFAULT; | ||
470 | |||
471 | args.num_of_nodes = 0; | ||
472 | 440 | ||
473 | mutex_lock(&p->mutex); | 441 | mutex_lock(&p->mutex); |
474 | 442 | ||
@@ -477,7 +445,8 @@ static int kfd_ioctl_get_process_apertures(struct file *filp, | |||
477 | /* Run over all pdd of the process */ | 445 | /* Run over all pdd of the process */ |
478 | pdd = kfd_get_first_process_device_data(p); | 446 | pdd = kfd_get_first_process_device_data(p); |
479 | do { | 447 | do { |
480 | pAperture = &args.process_apertures[args.num_of_nodes]; | 448 | pAperture = |
449 | &args->process_apertures[args->num_of_nodes]; | ||
481 | pAperture->gpu_id = pdd->dev->id; | 450 | pAperture->gpu_id = pdd->dev->id; |
482 | pAperture->lds_base = pdd->lds_base; | 451 | pAperture->lds_base = pdd->lds_base; |
483 | pAperture->lds_limit = pdd->lds_limit; | 452 | pAperture->lds_limit = pdd->lds_limit; |
@@ -487,7 +456,7 @@ static int kfd_ioctl_get_process_apertures(struct file *filp, | |||
487 | pAperture->scratch_limit = pdd->scratch_limit; | 456 | pAperture->scratch_limit = pdd->scratch_limit; |
488 | 457 | ||
489 | dev_dbg(kfd_device, | 458 | dev_dbg(kfd_device, |
490 | "node id %u\n", args.num_of_nodes); | 459 | "node id %u\n", args->num_of_nodes); |
491 | dev_dbg(kfd_device, | 460 | dev_dbg(kfd_device, |
492 | "gpu id %u\n", pdd->dev->id); | 461 | "gpu id %u\n", pdd->dev->id); |
493 | dev_dbg(kfd_device, | 462 | dev_dbg(kfd_device, |
@@ -503,80 +472,131 @@ static int kfd_ioctl_get_process_apertures(struct file *filp, | |||
503 | dev_dbg(kfd_device, | 472 | dev_dbg(kfd_device, |
504 | "scratch_limit %llX\n", pdd->scratch_limit); | 473 | "scratch_limit %llX\n", pdd->scratch_limit); |
505 | 474 | ||
506 | args.num_of_nodes++; | 475 | args->num_of_nodes++; |
507 | } while ((pdd = kfd_get_next_process_device_data(p, pdd)) != NULL && | 476 | } while ((pdd = kfd_get_next_process_device_data(p, pdd)) != NULL && |
508 | (args.num_of_nodes < NUM_OF_SUPPORTED_GPUS)); | 477 | (args->num_of_nodes < NUM_OF_SUPPORTED_GPUS)); |
509 | } | 478 | } |
510 | 479 | ||
511 | mutex_unlock(&p->mutex); | 480 | mutex_unlock(&p->mutex); |
512 | 481 | ||
513 | if (copy_to_user(arg, &args, sizeof(args))) | ||
514 | return -EFAULT; | ||
515 | |||
516 | return 0; | 482 | return 0; |
517 | } | 483 | } |
518 | 484 | ||
485 | #define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \ | ||
486 | [_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0, .name = #ioctl} | ||
487 | |||
488 | /** Ioctl table */ | ||
489 | static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = { | ||
490 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_VERSION, | ||
491 | kfd_ioctl_get_version, 0), | ||
492 | |||
493 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_CREATE_QUEUE, | ||
494 | kfd_ioctl_create_queue, 0), | ||
495 | |||
496 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_DESTROY_QUEUE, | ||
497 | kfd_ioctl_destroy_queue, 0), | ||
498 | |||
499 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_MEMORY_POLICY, | ||
500 | kfd_ioctl_set_memory_policy, 0), | ||
501 | |||
502 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_CLOCK_COUNTERS, | ||
503 | kfd_ioctl_get_clock_counters, 0), | ||
504 | |||
505 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_PROCESS_APERTURES, | ||
506 | kfd_ioctl_get_process_apertures, 0), | ||
507 | |||
508 | AMDKFD_IOCTL_DEF(AMDKFD_IOC_UPDATE_QUEUE, | ||
509 | kfd_ioctl_update_queue, 0), | ||
510 | }; | ||
511 | |||
512 | #define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls) | ||
513 | |||
519 | static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) | 514 | static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) |
520 | { | 515 | { |
521 | struct kfd_process *process; | 516 | struct kfd_process *process; |
522 | long err = -EINVAL; | 517 | amdkfd_ioctl_t *func; |
518 | const struct amdkfd_ioctl_desc *ioctl = NULL; | ||
519 | unsigned int nr = _IOC_NR(cmd); | ||
520 | char stack_kdata[128]; | ||
521 | char *kdata = NULL; | ||
522 | unsigned int usize, asize; | ||
523 | int retcode = -EINVAL; | ||
523 | 524 | ||
524 | dev_dbg(kfd_device, | 525 | if (nr >= AMDKFD_CORE_IOCTL_COUNT) |
525 | "ioctl cmd 0x%x (#%d), arg 0x%lx\n", | 526 | goto err_i1; |
526 | cmd, _IOC_NR(cmd), arg); | 527 | |
528 | if ((nr >= AMDKFD_COMMAND_START) && (nr < AMDKFD_COMMAND_END)) { | ||
529 | u32 amdkfd_size; | ||
530 | |||
531 | ioctl = &amdkfd_ioctls[nr]; | ||
532 | |||
533 | amdkfd_size = _IOC_SIZE(ioctl->cmd); | ||
534 | usize = asize = _IOC_SIZE(cmd); | ||
535 | if (amdkfd_size > asize) | ||
536 | asize = amdkfd_size; | ||
537 | |||
538 | cmd = ioctl->cmd; | ||
539 | } else | ||
540 | goto err_i1; | ||
541 | |||
542 | dev_dbg(kfd_device, "ioctl cmd 0x%x (#%d), arg 0x%lx\n", cmd, nr, arg); | ||
527 | 543 | ||
528 | process = kfd_get_process(current); | 544 | process = kfd_get_process(current); |
529 | if (IS_ERR(process)) | 545 | if (IS_ERR(process)) { |
530 | return PTR_ERR(process); | 546 | dev_dbg(kfd_device, "no process\n"); |
547 | goto err_i1; | ||
548 | } | ||
531 | 549 | ||
532 | switch (cmd) { | 550 | /* Do not trust userspace, use our own definition */ |
533 | case KFD_IOC_GET_VERSION: | 551 | func = ioctl->func; |
534 | err = kfd_ioctl_get_version(filep, process, (void __user *)arg); | 552 | |
535 | break; | 553 | if (unlikely(!func)) { |
536 | case KFD_IOC_CREATE_QUEUE: | 554 | dev_dbg(kfd_device, "no function\n"); |
537 | err = kfd_ioctl_create_queue(filep, process, | 555 | retcode = -EINVAL; |
538 | (void __user *)arg); | 556 | goto err_i1; |
539 | break; | ||
540 | |||
541 | case KFD_IOC_DESTROY_QUEUE: | ||
542 | err = kfd_ioctl_destroy_queue(filep, process, | ||
543 | (void __user *)arg); | ||
544 | break; | ||
545 | |||
546 | case KFD_IOC_SET_MEMORY_POLICY: | ||
547 | err = kfd_ioctl_set_memory_policy(filep, process, | ||
548 | (void __user *)arg); | ||
549 | break; | ||
550 | |||
551 | case KFD_IOC_GET_CLOCK_COUNTERS: | ||
552 | err = kfd_ioctl_get_clock_counters(filep, process, | ||
553 | (void __user *)arg); | ||
554 | break; | ||
555 | |||
556 | case KFD_IOC_GET_PROCESS_APERTURES: | ||
557 | err = kfd_ioctl_get_process_apertures(filep, process, | ||
558 | (void __user *)arg); | ||
559 | break; | ||
560 | |||
561 | case KFD_IOC_UPDATE_QUEUE: | ||
562 | err = kfd_ioctl_update_queue(filep, process, | ||
563 | (void __user *)arg); | ||
564 | break; | ||
565 | |||
566 | default: | ||
567 | dev_err(kfd_device, | ||
568 | "unknown ioctl cmd 0x%x, arg 0x%lx)\n", | ||
569 | cmd, arg); | ||
570 | err = -EINVAL; | ||
571 | break; | ||
572 | } | 557 | } |
573 | 558 | ||
574 | if (err < 0) | 559 | if (cmd & (IOC_IN | IOC_OUT)) { |
575 | dev_err(kfd_device, | 560 | if (asize <= sizeof(stack_kdata)) { |
576 | "ioctl error %ld for ioctl cmd 0x%x (#%d)\n", | 561 | kdata = stack_kdata; |
577 | err, cmd, _IOC_NR(cmd)); | 562 | } else { |
563 | kdata = kmalloc(asize, GFP_KERNEL); | ||
564 | if (!kdata) { | ||
565 | retcode = -ENOMEM; | ||
566 | goto err_i1; | ||
567 | } | ||
568 | } | ||
569 | if (asize > usize) | ||
570 | memset(kdata + usize, 0, asize - usize); | ||
571 | } | ||
578 | 572 | ||
579 | return err; | 573 | if (cmd & IOC_IN) { |
574 | if (copy_from_user(kdata, (void __user *)arg, usize) != 0) { | ||
575 | retcode = -EFAULT; | ||
576 | goto err_i1; | ||
577 | } | ||
578 | } else if (cmd & IOC_OUT) { | ||
579 | memset(kdata, 0, usize); | ||
580 | } | ||
581 | |||
582 | retcode = func(filep, process, kdata); | ||
583 | |||
584 | if (cmd & IOC_OUT) | ||
585 | if (copy_to_user((void __user *)arg, kdata, usize) != 0) | ||
586 | retcode = -EFAULT; | ||
587 | |||
588 | err_i1: | ||
589 | if (!ioctl) | ||
590 | dev_dbg(kfd_device, "invalid ioctl: pid=%d, cmd=0x%02x, nr=0x%02x\n", | ||
591 | task_pid_nr(current), cmd, nr); | ||
592 | |||
593 | if (kdata != stack_kdata) | ||
594 | kfree(kdata); | ||
595 | |||
596 | if (retcode) | ||
597 | dev_dbg(kfd_device, "ret = %d\n", retcode); | ||
598 | |||
599 | return retcode; | ||
580 | } | 600 | } |
581 | 601 | ||
582 | static int kfd_mmap(struct file *filp, struct vm_area_struct *vma) | 602 | static int kfd_mmap(struct file *filp, struct vm_area_struct *vma) |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 924e90c072e5..9c8961d22360 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | |||
@@ -161,6 +161,9 @@ static void deallocate_vmid(struct device_queue_manager *dqm, | |||
161 | { | 161 | { |
162 | int bit = qpd->vmid - KFD_VMID_START_OFFSET; | 162 | int bit = qpd->vmid - KFD_VMID_START_OFFSET; |
163 | 163 | ||
164 | /* Release the vmid mapping */ | ||
165 | set_pasid_vmid_mapping(dqm, 0, qpd->vmid); | ||
166 | |||
164 | set_bit(bit, (unsigned long *)&dqm->vmid_bitmap); | 167 | set_bit(bit, (unsigned long *)&dqm->vmid_bitmap); |
165 | qpd->vmid = 0; | 168 | qpd->vmid = 0; |
166 | q->properties.vmid = 0; | 169 | q->properties.vmid = 0; |
@@ -272,6 +275,18 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm, | |||
272 | return retval; | 275 | return retval; |
273 | } | 276 | } |
274 | 277 | ||
278 | pr_debug("kfd: loading mqd to hqd on pipe (%d) queue (%d)\n", | ||
279 | q->pipe, | ||
280 | q->queue); | ||
281 | |||
282 | retval = mqd->load_mqd(mqd, q->mqd, q->pipe, | ||
283 | q->queue, q->properties.write_ptr); | ||
284 | if (retval != 0) { | ||
285 | deallocate_hqd(dqm, q); | ||
286 | mqd->uninit_mqd(mqd, q->mqd, q->mqd_mem_obj); | ||
287 | return retval; | ||
288 | } | ||
289 | |||
275 | return 0; | 290 | return 0; |
276 | } | 291 | } |
277 | 292 | ||
@@ -320,6 +335,7 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q) | |||
320 | { | 335 | { |
321 | int retval; | 336 | int retval; |
322 | struct mqd_manager *mqd; | 337 | struct mqd_manager *mqd; |
338 | bool prev_active = false; | ||
323 | 339 | ||
324 | BUG_ON(!dqm || !q || !q->mqd); | 340 | BUG_ON(!dqm || !q || !q->mqd); |
325 | 341 | ||
@@ -330,10 +346,18 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q) | |||
330 | return -ENOMEM; | 346 | return -ENOMEM; |
331 | } | 347 | } |
332 | 348 | ||
333 | retval = mqd->update_mqd(mqd, q->mqd, &q->properties); | ||
334 | if (q->properties.is_active == true) | 349 | if (q->properties.is_active == true) |
350 | prev_active = true; | ||
351 | |||
352 | /* | ||
353 | * | ||
354 | * check active state vs. the previous state | ||
355 | * and modify counter accordingly | ||
356 | */ | ||
357 | retval = mqd->update_mqd(mqd, q->mqd, &q->properties); | ||
358 | if ((q->properties.is_active == true) && (prev_active == false)) | ||
335 | dqm->queue_count++; | 359 | dqm->queue_count++; |
336 | else | 360 | else if ((q->properties.is_active == false) && (prev_active == true)) |
337 | dqm->queue_count--; | 361 | dqm->queue_count--; |
338 | 362 | ||
339 | if (sched_policy != KFD_SCHED_POLICY_NO_HWS) | 363 | if (sched_policy != KFD_SCHED_POLICY_NO_HWS) |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c index adc31474e786..4c3828cf45bf 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | |||
@@ -184,7 +184,7 @@ static bool is_occupied(struct mqd_manager *mm, void *mqd, | |||
184 | uint32_t queue_id) | 184 | uint32_t queue_id) |
185 | { | 185 | { |
186 | 186 | ||
187 | return kfd2kgd->hqd_is_occupies(mm->dev->kgd, queue_address, | 187 | return kfd2kgd->hqd_is_occupied(mm->dev->kgd, queue_address, |
188 | pipe_id, queue_id); | 188 | pipe_id, queue_id); |
189 | 189 | ||
190 | } | 190 | } |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c b/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c index 71699ad97d74..4c25ef504f79 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c | |||
@@ -32,7 +32,7 @@ int kfd_pasid_init(void) | |||
32 | { | 32 | { |
33 | pasid_limit = max_num_of_processes; | 33 | pasid_limit = max_num_of_processes; |
34 | 34 | ||
35 | pasid_bitmap = kzalloc(BITS_TO_LONGS(pasid_limit), GFP_KERNEL); | 35 | pasid_bitmap = kcalloc(BITS_TO_LONGS(pasid_limit), sizeof(long), GFP_KERNEL); |
36 | if (!pasid_bitmap) | 36 | if (!pasid_bitmap) |
37 | return -ENOMEM; | 37 | return -ENOMEM; |
38 | 38 | ||
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index f9fb81e3bb09..a5edb29507e3 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h | |||
@@ -463,6 +463,24 @@ struct kfd_process { | |||
463 | bool is_32bit_user_mode; | 463 | bool is_32bit_user_mode; |
464 | }; | 464 | }; |
465 | 465 | ||
466 | /** | ||
467 | * Ioctl function type. | ||
468 | * | ||
469 | * \param filep pointer to file structure. | ||
470 | * \param p amdkfd process pointer. | ||
471 | * \param data pointer to arg that was copied from user. | ||
472 | */ | ||
473 | typedef int amdkfd_ioctl_t(struct file *filep, struct kfd_process *p, | ||
474 | void *data); | ||
475 | |||
476 | struct amdkfd_ioctl_desc { | ||
477 | unsigned int cmd; | ||
478 | int flags; | ||
479 | amdkfd_ioctl_t *func; | ||
480 | unsigned int cmd_drv; | ||
481 | const char *name; | ||
482 | }; | ||
483 | |||
466 | void kfd_process_create_wq(void); | 484 | void kfd_process_create_wq(void); |
467 | void kfd_process_destroy_wq(void); | 485 | void kfd_process_destroy_wq(void); |
468 | struct kfd_process *kfd_create_process(const struct task_struct *); | 486 | struct kfd_process *kfd_create_process(const struct task_struct *); |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c index b11792d7e70e..cca1708fd811 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c | |||
@@ -921,7 +921,7 @@ static int kfd_build_sysfs_node_tree(void) | |||
921 | uint32_t i = 0; | 921 | uint32_t i = 0; |
922 | 922 | ||
923 | list_for_each_entry(dev, &topology_device_list, list) { | 923 | list_for_each_entry(dev, &topology_device_list, list) { |
924 | ret = kfd_build_sysfs_node_entry(dev, 0); | 924 | ret = kfd_build_sysfs_node_entry(dev, i); |
925 | if (ret < 0) | 925 | if (ret < 0) |
926 | return ret; | 926 | return ret; |
927 | i++; | 927 | i++; |
diff --git a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h index 47b551970a14..96a512208fad 100644 --- a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h +++ b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h | |||
@@ -183,7 +183,7 @@ struct kfd2kgd_calls { | |||
183 | int (*hqd_load)(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, | 183 | int (*hqd_load)(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, |
184 | uint32_t queue_id, uint32_t __user *wptr); | 184 | uint32_t queue_id, uint32_t __user *wptr); |
185 | 185 | ||
186 | bool (*hqd_is_occupies)(struct kgd_dev *kgd, uint64_t queue_address, | 186 | bool (*hqd_is_occupied)(struct kgd_dev *kgd, uint64_t queue_address, |
187 | uint32_t pipe_id, uint32_t queue_id); | 187 | uint32_t pipe_id, uint32_t queue_id); |
188 | 188 | ||
189 | int (*hqd_destroy)(struct kgd_dev *kgd, uint32_t reset_type, | 189 | int (*hqd_destroy)(struct kgd_dev *kgd, uint32_t reset_type, |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 70d0f0f06f1a..e9f891c432f8 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -1756,8 +1756,6 @@ struct drm_i915_private { | |||
1756 | */ | 1756 | */ |
1757 | struct workqueue_struct *dp_wq; | 1757 | struct workqueue_struct *dp_wq; |
1758 | 1758 | ||
1759 | uint32_t bios_vgacntr; | ||
1760 | |||
1761 | /* Abstract the submission mechanism (legacy ringbuffer or execlists) away */ | 1759 | /* Abstract the submission mechanism (legacy ringbuffer or execlists) away */ |
1762 | struct { | 1760 | struct { |
1763 | int (*do_execbuf)(struct drm_device *dev, struct drm_file *file, | 1761 | int (*do_execbuf)(struct drm_device *dev, struct drm_file *file, |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 52adcb680be3..c11603b4cf1d 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -1048,6 +1048,7 @@ int | |||
1048 | i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, | 1048 | i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, |
1049 | struct drm_file *file) | 1049 | struct drm_file *file) |
1050 | { | 1050 | { |
1051 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1051 | struct drm_i915_gem_pwrite *args = data; | 1052 | struct drm_i915_gem_pwrite *args = data; |
1052 | struct drm_i915_gem_object *obj; | 1053 | struct drm_i915_gem_object *obj; |
1053 | int ret; | 1054 | int ret; |
@@ -1067,9 +1068,11 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, | |||
1067 | return -EFAULT; | 1068 | return -EFAULT; |
1068 | } | 1069 | } |
1069 | 1070 | ||
1071 | intel_runtime_pm_get(dev_priv); | ||
1072 | |||
1070 | ret = i915_mutex_lock_interruptible(dev); | 1073 | ret = i915_mutex_lock_interruptible(dev); |
1071 | if (ret) | 1074 | if (ret) |
1072 | return ret; | 1075 | goto put_rpm; |
1073 | 1076 | ||
1074 | obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle)); | 1077 | obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle)); |
1075 | if (&obj->base == NULL) { | 1078 | if (&obj->base == NULL) { |
@@ -1121,6 +1124,9 @@ out: | |||
1121 | drm_gem_object_unreference(&obj->base); | 1124 | drm_gem_object_unreference(&obj->base); |
1122 | unlock: | 1125 | unlock: |
1123 | mutex_unlock(&dev->struct_mutex); | 1126 | mutex_unlock(&dev->struct_mutex); |
1127 | put_rpm: | ||
1128 | intel_runtime_pm_put(dev_priv); | ||
1129 | |||
1124 | return ret; | 1130 | return ret; |
1125 | } | 1131 | } |
1126 | 1132 | ||
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 996c2931c499..d0d3dfbe6d2a 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c | |||
@@ -3725,8 +3725,6 @@ static bool i8xx_handle_vblank(struct drm_device *dev, | |||
3725 | if ((iir & flip_pending) == 0) | 3725 | if ((iir & flip_pending) == 0) |
3726 | goto check_page_flip; | 3726 | goto check_page_flip; |
3727 | 3727 | ||
3728 | intel_prepare_page_flip(dev, plane); | ||
3729 | |||
3730 | /* We detect FlipDone by looking for the change in PendingFlip from '1' | 3728 | /* We detect FlipDone by looking for the change in PendingFlip from '1' |
3731 | * to '0' on the following vblank, i.e. IIR has the Pendingflip | 3729 | * to '0' on the following vblank, i.e. IIR has the Pendingflip |
3732 | * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence | 3730 | * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence |
@@ -3736,6 +3734,7 @@ static bool i8xx_handle_vblank(struct drm_device *dev, | |||
3736 | if (I915_READ16(ISR) & flip_pending) | 3734 | if (I915_READ16(ISR) & flip_pending) |
3737 | goto check_page_flip; | 3735 | goto check_page_flip; |
3738 | 3736 | ||
3737 | intel_prepare_page_flip(dev, plane); | ||
3739 | intel_finish_page_flip(dev, pipe); | 3738 | intel_finish_page_flip(dev, pipe); |
3740 | return true; | 3739 | return true; |
3741 | 3740 | ||
@@ -3907,8 +3906,6 @@ static bool i915_handle_vblank(struct drm_device *dev, | |||
3907 | if ((iir & flip_pending) == 0) | 3906 | if ((iir & flip_pending) == 0) |
3908 | goto check_page_flip; | 3907 | goto check_page_flip; |
3909 | 3908 | ||
3910 | intel_prepare_page_flip(dev, plane); | ||
3911 | |||
3912 | /* We detect FlipDone by looking for the change in PendingFlip from '1' | 3909 | /* We detect FlipDone by looking for the change in PendingFlip from '1' |
3913 | * to '0' on the following vblank, i.e. IIR has the Pendingflip | 3910 | * to '0' on the following vblank, i.e. IIR has the Pendingflip |
3914 | * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence | 3911 | * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence |
@@ -3918,6 +3915,7 @@ static bool i915_handle_vblank(struct drm_device *dev, | |||
3918 | if (I915_READ(ISR) & flip_pending) | 3915 | if (I915_READ(ISR) & flip_pending) |
3919 | goto check_page_flip; | 3916 | goto check_page_flip; |
3920 | 3917 | ||
3918 | intel_prepare_page_flip(dev, plane); | ||
3921 | intel_finish_page_flip(dev, pipe); | 3919 | intel_finish_page_flip(dev, pipe); |
3922 | return true; | 3920 | return true; |
3923 | 3921 | ||
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index fb3e3d429191..e2af1383b179 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -13057,11 +13057,7 @@ static void i915_disable_vga(struct drm_device *dev) | |||
13057 | vga_put(dev->pdev, VGA_RSRC_LEGACY_IO); | 13057 | vga_put(dev->pdev, VGA_RSRC_LEGACY_IO); |
13058 | udelay(300); | 13058 | udelay(300); |
13059 | 13059 | ||
13060 | /* | 13060 | I915_WRITE(vga_reg, VGA_DISP_DISABLE); |
13061 | * Fujitsu-Siemens Lifebook S6010 (830) has problems resuming | ||
13062 | * from S3 without preserving (some of?) the other bits. | ||
13063 | */ | ||
13064 | I915_WRITE(vga_reg, dev_priv->bios_vgacntr | VGA_DISP_DISABLE); | ||
13065 | POSTING_READ(vga_reg); | 13061 | POSTING_READ(vga_reg); |
13066 | } | 13062 | } |
13067 | 13063 | ||
@@ -13146,8 +13142,6 @@ void intel_modeset_init(struct drm_device *dev) | |||
13146 | 13142 | ||
13147 | intel_shared_dpll_init(dev); | 13143 | intel_shared_dpll_init(dev); |
13148 | 13144 | ||
13149 | /* save the BIOS value before clobbering it */ | ||
13150 | dev_priv->bios_vgacntr = I915_READ(i915_vgacntrl_reg(dev)); | ||
13151 | /* Just disable it once at startup */ | 13145 | /* Just disable it once at startup */ |
13152 | i915_disable_vga(dev); | 13146 | i915_disable_vga(dev); |
13153 | intel_setup_outputs(dev); | 13147 | intel_setup_outputs(dev); |
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c index f5a78d53e297..ac6da7102fbb 100644 --- a/drivers/gpu/drm/i915/intel_runtime_pm.c +++ b/drivers/gpu/drm/i915/intel_runtime_pm.c | |||
@@ -615,29 +615,6 @@ static void chv_pipe_power_well_disable(struct drm_i915_private *dev_priv, | |||
615 | vlv_power_sequencer_reset(dev_priv); | 615 | vlv_power_sequencer_reset(dev_priv); |
616 | } | 616 | } |
617 | 617 | ||
618 | static void check_power_well_state(struct drm_i915_private *dev_priv, | ||
619 | struct i915_power_well *power_well) | ||
620 | { | ||
621 | bool enabled = power_well->ops->is_enabled(dev_priv, power_well); | ||
622 | |||
623 | if (power_well->always_on || !i915.disable_power_well) { | ||
624 | if (!enabled) | ||
625 | goto mismatch; | ||
626 | |||
627 | return; | ||
628 | } | ||
629 | |||
630 | if (enabled != (power_well->count > 0)) | ||
631 | goto mismatch; | ||
632 | |||
633 | return; | ||
634 | |||
635 | mismatch: | ||
636 | WARN(1, "state mismatch for '%s' (always_on %d hw state %d use-count %d disable_power_well %d\n", | ||
637 | power_well->name, power_well->always_on, enabled, | ||
638 | power_well->count, i915.disable_power_well); | ||
639 | } | ||
640 | |||
641 | /** | 618 | /** |
642 | * intel_display_power_get - grab a power domain reference | 619 | * intel_display_power_get - grab a power domain reference |
643 | * @dev_priv: i915 device instance | 620 | * @dev_priv: i915 device instance |
@@ -669,8 +646,6 @@ void intel_display_power_get(struct drm_i915_private *dev_priv, | |||
669 | power_well->ops->enable(dev_priv, power_well); | 646 | power_well->ops->enable(dev_priv, power_well); |
670 | power_well->hw_enabled = true; | 647 | power_well->hw_enabled = true; |
671 | } | 648 | } |
672 | |||
673 | check_power_well_state(dev_priv, power_well); | ||
674 | } | 649 | } |
675 | 650 | ||
676 | power_domains->domain_use_count[domain]++; | 651 | power_domains->domain_use_count[domain]++; |
@@ -709,8 +684,6 @@ void intel_display_power_put(struct drm_i915_private *dev_priv, | |||
709 | power_well->hw_enabled = false; | 684 | power_well->hw_enabled = false; |
710 | power_well->ops->disable(dev_priv, power_well); | 685 | power_well->ops->disable(dev_priv, power_well); |
711 | } | 686 | } |
712 | |||
713 | check_power_well_state(dev_priv, power_well); | ||
714 | } | 687 | } |
715 | 688 | ||
716 | mutex_unlock(&power_domains->lock); | 689 | mutex_unlock(&power_domains->lock); |
diff --git a/drivers/gpu/drm/nouveau/core/core/event.c b/drivers/gpu/drm/nouveau/core/core/event.c index ff2b434b3db4..760947e380c9 100644 --- a/drivers/gpu/drm/nouveau/core/core/event.c +++ b/drivers/gpu/drm/nouveau/core/core/event.c | |||
@@ -26,7 +26,7 @@ | |||
26 | void | 26 | void |
27 | nvkm_event_put(struct nvkm_event *event, u32 types, int index) | 27 | nvkm_event_put(struct nvkm_event *event, u32 types, int index) |
28 | { | 28 | { |
29 | BUG_ON(!spin_is_locked(&event->refs_lock)); | 29 | assert_spin_locked(&event->refs_lock); |
30 | while (types) { | 30 | while (types) { |
31 | int type = __ffs(types); types &= ~(1 << type); | 31 | int type = __ffs(types); types &= ~(1 << type); |
32 | if (--event->refs[index * event->types_nr + type] == 0) { | 32 | if (--event->refs[index * event->types_nr + type] == 0) { |
@@ -39,7 +39,7 @@ nvkm_event_put(struct nvkm_event *event, u32 types, int index) | |||
39 | void | 39 | void |
40 | nvkm_event_get(struct nvkm_event *event, u32 types, int index) | 40 | nvkm_event_get(struct nvkm_event *event, u32 types, int index) |
41 | { | 41 | { |
42 | BUG_ON(!spin_is_locked(&event->refs_lock)); | 42 | assert_spin_locked(&event->refs_lock); |
43 | while (types) { | 43 | while (types) { |
44 | int type = __ffs(types); types &= ~(1 << type); | 44 | int type = __ffs(types); types &= ~(1 << type); |
45 | if (++event->refs[index * event->types_nr + type] == 1) { | 45 | if (++event->refs[index * event->types_nr + type] == 1) { |
diff --git a/drivers/gpu/drm/nouveau/core/core/notify.c b/drivers/gpu/drm/nouveau/core/core/notify.c index d1bcde55e9d7..839a32577680 100644 --- a/drivers/gpu/drm/nouveau/core/core/notify.c +++ b/drivers/gpu/drm/nouveau/core/core/notify.c | |||
@@ -98,7 +98,7 @@ nvkm_notify_send(struct nvkm_notify *notify, void *data, u32 size) | |||
98 | struct nvkm_event *event = notify->event; | 98 | struct nvkm_event *event = notify->event; |
99 | unsigned long flags; | 99 | unsigned long flags; |
100 | 100 | ||
101 | BUG_ON(!spin_is_locked(&event->list_lock)); | 101 | assert_spin_locked(&event->list_lock); |
102 | BUG_ON(size != notify->size); | 102 | BUG_ON(size != notify->size); |
103 | 103 | ||
104 | spin_lock_irqsave(&event->refs_lock, flags); | 104 | spin_lock_irqsave(&event->refs_lock, flags); |
diff --git a/drivers/gpu/drm/nouveau/core/engine/device/nve0.c b/drivers/gpu/drm/nouveau/core/engine/device/nve0.c index 674da1f095b2..732922690653 100644 --- a/drivers/gpu/drm/nouveau/core/engine/device/nve0.c +++ b/drivers/gpu/drm/nouveau/core/engine/device/nve0.c | |||
@@ -249,6 +249,39 @@ nve0_identify(struct nouveau_device *device) | |||
249 | device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass; | 249 | device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass; |
250 | device->oclass[NVDEV_ENGINE_PERFMON] = &nvf0_perfmon_oclass; | 250 | device->oclass[NVDEV_ENGINE_PERFMON] = &nvf0_perfmon_oclass; |
251 | break; | 251 | break; |
252 | case 0x106: | ||
253 | device->cname = "GK208B"; | ||
254 | device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; | ||
255 | device->oclass[NVDEV_SUBDEV_GPIO ] = nve0_gpio_oclass; | ||
256 | device->oclass[NVDEV_SUBDEV_I2C ] = nve0_i2c_oclass; | ||
257 | device->oclass[NVDEV_SUBDEV_FUSE ] = &gf100_fuse_oclass; | ||
258 | device->oclass[NVDEV_SUBDEV_CLOCK ] = &nve0_clock_oclass; | ||
259 | device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass; | ||
260 | device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; | ||
261 | device->oclass[NVDEV_SUBDEV_DEVINIT] = nvc0_devinit_oclass; | ||
262 | device->oclass[NVDEV_SUBDEV_MC ] = gk20a_mc_oclass; | ||
263 | device->oclass[NVDEV_SUBDEV_BUS ] = nvc0_bus_oclass; | ||
264 | device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; | ||
265 | device->oclass[NVDEV_SUBDEV_FB ] = nve0_fb_oclass; | ||
266 | device->oclass[NVDEV_SUBDEV_LTC ] = gk104_ltc_oclass; | ||
267 | device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass; | ||
268 | device->oclass[NVDEV_SUBDEV_INSTMEM] = nv50_instmem_oclass; | ||
269 | device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass; | ||
270 | device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass; | ||
271 | device->oclass[NVDEV_SUBDEV_PWR ] = nv108_pwr_oclass; | ||
272 | device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass; | ||
273 | device->oclass[NVDEV_ENGINE_DMAOBJ ] = nvd0_dmaeng_oclass; | ||
274 | device->oclass[NVDEV_ENGINE_FIFO ] = nv108_fifo_oclass; | ||
275 | device->oclass[NVDEV_ENGINE_SW ] = nvc0_software_oclass; | ||
276 | device->oclass[NVDEV_ENGINE_GR ] = nv108_graph_oclass; | ||
277 | device->oclass[NVDEV_ENGINE_DISP ] = nvf0_disp_oclass; | ||
278 | device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass; | ||
279 | device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass; | ||
280 | device->oclass[NVDEV_ENGINE_COPY2 ] = &nve0_copy2_oclass; | ||
281 | device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass; | ||
282 | device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass; | ||
283 | device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass; | ||
284 | break; | ||
252 | case 0x108: | 285 | case 0x108: |
253 | device->cname = "GK208"; | 286 | device->cname = "GK208"; |
254 | device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; | 287 | device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c b/drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c index 5e58bba0dd5c..a7a890fad1e5 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c | |||
@@ -44,8 +44,10 @@ static void | |||
44 | pramin_fini(void *data) | 44 | pramin_fini(void *data) |
45 | { | 45 | { |
46 | struct priv *priv = data; | 46 | struct priv *priv = data; |
47 | nv_wr32(priv->bios, 0x001700, priv->bar0); | 47 | if (priv) { |
48 | kfree(priv); | 48 | nv_wr32(priv->bios, 0x001700, priv->bar0); |
49 | kfree(priv); | ||
50 | } | ||
49 | } | 51 | } |
50 | 52 | ||
51 | static void * | 53 | static void * |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c index 00f2ca7e44a5..033a8e999497 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c +++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c | |||
@@ -24,34 +24,71 @@ | |||
24 | 24 | ||
25 | #include "nv50.h" | 25 | #include "nv50.h" |
26 | 26 | ||
27 | struct nvaa_ram_priv { | ||
28 | struct nouveau_ram base; | ||
29 | u64 poller_base; | ||
30 | }; | ||
31 | |||
27 | static int | 32 | static int |
28 | nvaa_ram_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | 33 | nvaa_ram_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
29 | struct nouveau_oclass *oclass, void *data, u32 datasize, | 34 | struct nouveau_oclass *oclass, void *data, u32 datasize, |
30 | struct nouveau_object **pobject) | 35 | struct nouveau_object **pobject) |
31 | { | 36 | { |
32 | const u32 rsvd_head = ( 256 * 1024) >> 12; /* vga memory */ | 37 | u32 rsvd_head = ( 256 * 1024); /* vga memory */ |
33 | const u32 rsvd_tail = (1024 * 1024) >> 12; /* vbios etc */ | 38 | u32 rsvd_tail = (1024 * 1024); /* vbios etc */ |
34 | struct nouveau_fb *pfb = nouveau_fb(parent); | 39 | struct nouveau_fb *pfb = nouveau_fb(parent); |
35 | struct nouveau_ram *ram; | 40 | struct nvaa_ram_priv *priv; |
36 | int ret; | 41 | int ret; |
37 | 42 | ||
38 | ret = nouveau_ram_create(parent, engine, oclass, &ram); | 43 | ret = nouveau_ram_create(parent, engine, oclass, &priv); |
39 | *pobject = nv_object(ram); | 44 | *pobject = nv_object(priv); |
40 | if (ret) | 45 | if (ret) |
41 | return ret; | 46 | return ret; |
42 | 47 | ||
43 | ram->size = nv_rd32(pfb, 0x10020c); | 48 | priv->base.type = NV_MEM_TYPE_STOLEN; |
44 | ram->size = (ram->size & 0xffffff00) | ((ram->size & 0x000000ff) << 32); | 49 | priv->base.stolen = (u64)nv_rd32(pfb, 0x100e10) << 12; |
50 | priv->base.size = (u64)nv_rd32(pfb, 0x100e14) << 12; | ||
45 | 51 | ||
46 | ret = nouveau_mm_init(&pfb->vram, rsvd_head, (ram->size >> 12) - | 52 | rsvd_tail += 0x1000; |
47 | (rsvd_head + rsvd_tail), 1); | 53 | priv->poller_base = priv->base.size - rsvd_tail; |
54 | |||
55 | ret = nouveau_mm_init(&pfb->vram, rsvd_head >> 12, | ||
56 | (priv->base.size - (rsvd_head + rsvd_tail)) >> 12, | ||
57 | 1); | ||
48 | if (ret) | 58 | if (ret) |
49 | return ret; | 59 | return ret; |
50 | 60 | ||
51 | ram->type = NV_MEM_TYPE_STOLEN; | 61 | priv->base.get = nv50_ram_get; |
52 | ram->stolen = (u64)nv_rd32(pfb, 0x100e10) << 12; | 62 | priv->base.put = nv50_ram_put; |
53 | ram->get = nv50_ram_get; | 63 | return 0; |
54 | ram->put = nv50_ram_put; | 64 | } |
65 | |||
66 | static int | ||
67 | nvaa_ram_init(struct nouveau_object *object) | ||
68 | { | ||
69 | struct nouveau_fb *pfb = nouveau_fb(object); | ||
70 | struct nvaa_ram_priv *priv = (void *)object; | ||
71 | int ret; | ||
72 | u64 dniso, hostnb, flush; | ||
73 | |||
74 | ret = nouveau_ram_init(&priv->base); | ||
75 | if (ret) | ||
76 | return ret; | ||
77 | |||
78 | dniso = ((priv->base.size - (priv->poller_base + 0x00)) >> 5) - 1; | ||
79 | hostnb = ((priv->base.size - (priv->poller_base + 0x20)) >> 5) - 1; | ||
80 | flush = ((priv->base.size - (priv->poller_base + 0x40)) >> 5) - 1; | ||
81 | |||
82 | /* Enable NISO poller for various clients and set their associated | ||
83 | * read address, only for MCP77/78 and MCP79/7A. (fd#25701) | ||
84 | */ | ||
85 | nv_wr32(pfb, 0x100c18, dniso); | ||
86 | nv_mask(pfb, 0x100c14, 0x00000000, 0x00000001); | ||
87 | nv_wr32(pfb, 0x100c1c, hostnb); | ||
88 | nv_mask(pfb, 0x100c14, 0x00000000, 0x00000002); | ||
89 | nv_wr32(pfb, 0x100c24, flush); | ||
90 | nv_mask(pfb, 0x100c14, 0x00000000, 0x00010000); | ||
91 | |||
55 | return 0; | 92 | return 0; |
56 | } | 93 | } |
57 | 94 | ||
@@ -60,7 +97,7 @@ nvaa_ram_oclass = { | |||
60 | .ofuncs = &(struct nouveau_ofuncs) { | 97 | .ofuncs = &(struct nouveau_ofuncs) { |
61 | .ctor = nvaa_ram_ctor, | 98 | .ctor = nvaa_ram_ctor, |
62 | .dtor = _nouveau_ram_dtor, | 99 | .dtor = _nouveau_ram_dtor, |
63 | .init = _nouveau_ram_init, | 100 | .init = nvaa_ram_init, |
64 | .fini = _nouveau_ram_fini, | 101 | .fini = _nouveau_ram_fini, |
65 | }, | 102 | }, |
66 | }; | 103 | }; |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c index a75c35ccf25c..165401c4045c 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c +++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c | |||
@@ -24,13 +24,6 @@ | |||
24 | 24 | ||
25 | #include "nv04.h" | 25 | #include "nv04.h" |
26 | 26 | ||
27 | static void | ||
28 | nv4c_mc_msi_rearm(struct nouveau_mc *pmc) | ||
29 | { | ||
30 | struct nv04_mc_priv *priv = (void *)pmc; | ||
31 | nv_wr08(priv, 0x088050, 0xff); | ||
32 | } | ||
33 | |||
34 | struct nouveau_oclass * | 27 | struct nouveau_oclass * |
35 | nv4c_mc_oclass = &(struct nouveau_mc_oclass) { | 28 | nv4c_mc_oclass = &(struct nouveau_mc_oclass) { |
36 | .base.handle = NV_SUBDEV(MC, 0x4c), | 29 | .base.handle = NV_SUBDEV(MC, 0x4c), |
@@ -41,5 +34,4 @@ nv4c_mc_oclass = &(struct nouveau_mc_oclass) { | |||
41 | .fini = _nouveau_mc_fini, | 34 | .fini = _nouveau_mc_fini, |
42 | }, | 35 | }, |
43 | .intr = nv04_mc_intr, | 36 | .intr = nv04_mc_intr, |
44 | .msi_rearm = nv4c_mc_msi_rearm, | ||
45 | }.base; | 37 | }.base; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 21ec561edc99..bba2960d3dfb 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
@@ -1572,8 +1572,10 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) | |||
1572 | * so use the DMA API for them. | 1572 | * so use the DMA API for them. |
1573 | */ | 1573 | */ |
1574 | if (!nv_device_is_cpu_coherent(device) && | 1574 | if (!nv_device_is_cpu_coherent(device) && |
1575 | ttm->caching_state == tt_uncached) | 1575 | ttm->caching_state == tt_uncached) { |
1576 | ttm_dma_unpopulate(ttm_dma, dev->dev); | 1576 | ttm_dma_unpopulate(ttm_dma, dev->dev); |
1577 | return; | ||
1578 | } | ||
1577 | 1579 | ||
1578 | #if __OS_HAS_AGP | 1580 | #if __OS_HAS_AGP |
1579 | if (drm->agp.stat == ENABLED) { | 1581 | if (drm->agp.stat == ENABLED) { |
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 42c34babc2e5..bf0f9e21d714 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c | |||
@@ -36,7 +36,14 @@ void | |||
36 | nouveau_gem_object_del(struct drm_gem_object *gem) | 36 | nouveau_gem_object_del(struct drm_gem_object *gem) |
37 | { | 37 | { |
38 | struct nouveau_bo *nvbo = nouveau_gem_object(gem); | 38 | struct nouveau_bo *nvbo = nouveau_gem_object(gem); |
39 | struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); | ||
39 | struct ttm_buffer_object *bo = &nvbo->bo; | 40 | struct ttm_buffer_object *bo = &nvbo->bo; |
41 | struct device *dev = drm->dev->dev; | ||
42 | int ret; | ||
43 | |||
44 | ret = pm_runtime_get_sync(dev); | ||
45 | if (WARN_ON(ret < 0 && ret != -EACCES)) | ||
46 | return; | ||
40 | 47 | ||
41 | if (gem->import_attach) | 48 | if (gem->import_attach) |
42 | drm_prime_gem_destroy(gem, nvbo->bo.sg); | 49 | drm_prime_gem_destroy(gem, nvbo->bo.sg); |
@@ -46,6 +53,9 @@ nouveau_gem_object_del(struct drm_gem_object *gem) | |||
46 | /* reset filp so nouveau_bo_del_ttm() can test for it */ | 53 | /* reset filp so nouveau_bo_del_ttm() can test for it */ |
47 | gem->filp = NULL; | 54 | gem->filp = NULL; |
48 | ttm_bo_unref(&bo); | 55 | ttm_bo_unref(&bo); |
56 | |||
57 | pm_runtime_mark_last_busy(dev); | ||
58 | pm_runtime_put_autosuspend(dev); | ||
49 | } | 59 | } |
50 | 60 | ||
51 | int | 61 | int |
@@ -53,7 +63,9 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv) | |||
53 | { | 63 | { |
54 | struct nouveau_cli *cli = nouveau_cli(file_priv); | 64 | struct nouveau_cli *cli = nouveau_cli(file_priv); |
55 | struct nouveau_bo *nvbo = nouveau_gem_object(gem); | 65 | struct nouveau_bo *nvbo = nouveau_gem_object(gem); |
66 | struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); | ||
56 | struct nouveau_vma *vma; | 67 | struct nouveau_vma *vma; |
68 | struct device *dev = drm->dev->dev; | ||
57 | int ret; | 69 | int ret; |
58 | 70 | ||
59 | if (!cli->vm) | 71 | if (!cli->vm) |
@@ -71,11 +83,16 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv) | |||
71 | goto out; | 83 | goto out; |
72 | } | 84 | } |
73 | 85 | ||
86 | ret = pm_runtime_get_sync(dev); | ||
87 | if (ret < 0 && ret != -EACCES) | ||
88 | goto out; | ||
89 | |||
74 | ret = nouveau_bo_vma_add(nvbo, cli->vm, vma); | 90 | ret = nouveau_bo_vma_add(nvbo, cli->vm, vma); |
75 | if (ret) { | 91 | if (ret) |
76 | kfree(vma); | 92 | kfree(vma); |
77 | goto out; | 93 | |
78 | } | 94 | pm_runtime_mark_last_busy(dev); |
95 | pm_runtime_put_autosuspend(dev); | ||
79 | } else { | 96 | } else { |
80 | vma->refcount++; | 97 | vma->refcount++; |
81 | } | 98 | } |
@@ -129,6 +146,8 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv) | |||
129 | { | 146 | { |
130 | struct nouveau_cli *cli = nouveau_cli(file_priv); | 147 | struct nouveau_cli *cli = nouveau_cli(file_priv); |
131 | struct nouveau_bo *nvbo = nouveau_gem_object(gem); | 148 | struct nouveau_bo *nvbo = nouveau_gem_object(gem); |
149 | struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev); | ||
150 | struct device *dev = drm->dev->dev; | ||
132 | struct nouveau_vma *vma; | 151 | struct nouveau_vma *vma; |
133 | int ret; | 152 | int ret; |
134 | 153 | ||
@@ -141,8 +160,14 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv) | |||
141 | 160 | ||
142 | vma = nouveau_bo_vma_find(nvbo, cli->vm); | 161 | vma = nouveau_bo_vma_find(nvbo, cli->vm); |
143 | if (vma) { | 162 | if (vma) { |
144 | if (--vma->refcount == 0) | 163 | if (--vma->refcount == 0) { |
145 | nouveau_gem_object_unmap(nvbo, vma); | 164 | ret = pm_runtime_get_sync(dev); |
165 | if (!WARN_ON(ret < 0 && ret != -EACCES)) { | ||
166 | nouveau_gem_object_unmap(nvbo, vma); | ||
167 | pm_runtime_mark_last_busy(dev); | ||
168 | pm_runtime_put_autosuspend(dev); | ||
169 | } | ||
170 | } | ||
146 | } | 171 | } |
147 | ttm_bo_unreserve(&nvbo->bo); | 172 | ttm_bo_unreserve(&nvbo->bo); |
148 | } | 173 | } |
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index d59ec491dbb9..ed644a4f6f57 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c | |||
@@ -1851,10 +1851,9 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc) | |||
1851 | return pll; | 1851 | return pll; |
1852 | } | 1852 | } |
1853 | /* otherwise, pick one of the plls */ | 1853 | /* otherwise, pick one of the plls */ |
1854 | if ((rdev->family == CHIP_KAVERI) || | 1854 | if ((rdev->family == CHIP_KABINI) || |
1855 | (rdev->family == CHIP_KABINI) || | ||
1856 | (rdev->family == CHIP_MULLINS)) { | 1855 | (rdev->family == CHIP_MULLINS)) { |
1857 | /* KB/KV/ML has PPLL1 and PPLL2 */ | 1856 | /* KB/ML has PPLL1 and PPLL2 */ |
1858 | pll_in_use = radeon_get_pll_use_mask(crtc); | 1857 | pll_in_use = radeon_get_pll_use_mask(crtc); |
1859 | if (!(pll_in_use & (1 << ATOM_PPLL2))) | 1858 | if (!(pll_in_use & (1 << ATOM_PPLL2))) |
1860 | return ATOM_PPLL2; | 1859 | return ATOM_PPLL2; |
@@ -1863,7 +1862,7 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc) | |||
1863 | DRM_ERROR("unable to allocate a PPLL\n"); | 1862 | DRM_ERROR("unable to allocate a PPLL\n"); |
1864 | return ATOM_PPLL_INVALID; | 1863 | return ATOM_PPLL_INVALID; |
1865 | } else { | 1864 | } else { |
1866 | /* CI has PPLL0, PPLL1, and PPLL2 */ | 1865 | /* CI/KV has PPLL0, PPLL1, and PPLL2 */ |
1867 | pll_in_use = radeon_get_pll_use_mask(crtc); | 1866 | pll_in_use = radeon_get_pll_use_mask(crtc); |
1868 | if (!(pll_in_use & (1 << ATOM_PPLL2))) | 1867 | if (!(pll_in_use & (1 << ATOM_PPLL2))) |
1869 | return ATOM_PPLL2; | 1868 | return ATOM_PPLL2; |
@@ -2155,6 +2154,7 @@ static void atombios_crtc_disable(struct drm_crtc *crtc) | |||
2155 | case ATOM_PPLL0: | 2154 | case ATOM_PPLL0: |
2156 | /* disable the ppll */ | 2155 | /* disable the ppll */ |
2157 | if ((rdev->family == CHIP_ARUBA) || | 2156 | if ((rdev->family == CHIP_ARUBA) || |
2157 | (rdev->family == CHIP_KAVERI) || | ||
2158 | (rdev->family == CHIP_BONAIRE) || | 2158 | (rdev->family == CHIP_BONAIRE) || |
2159 | (rdev->family == CHIP_HAWAII)) | 2159 | (rdev->family == CHIP_HAWAII)) |
2160 | atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id, | 2160 | atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id, |
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c index 11ba9d21b89b..db42a670f995 100644 --- a/drivers/gpu/drm/radeon/atombios_dp.c +++ b/drivers/gpu/drm/radeon/atombios_dp.c | |||
@@ -492,6 +492,10 @@ int radeon_dp_mode_valid_helper(struct drm_connector *connector, | |||
492 | struct radeon_connector_atom_dig *dig_connector; | 492 | struct radeon_connector_atom_dig *dig_connector; |
493 | int dp_clock; | 493 | int dp_clock; |
494 | 494 | ||
495 | if ((mode->clock > 340000) && | ||
496 | (!radeon_connector_is_dp12_capable(connector))) | ||
497 | return MODE_CLOCK_HIGH; | ||
498 | |||
495 | if (!radeon_connector->con_priv) | 499 | if (!radeon_connector->con_priv) |
496 | return MODE_CLOCK_HIGH; | 500 | return MODE_CLOCK_HIGH; |
497 | dig_connector = radeon_connector->con_priv; | 501 | dig_connector = radeon_connector->con_priv; |
diff --git a/drivers/gpu/drm/radeon/cikd.h b/drivers/gpu/drm/radeon/cikd.h index ba85986febea..03003f8a6de6 100644 --- a/drivers/gpu/drm/radeon/cikd.h +++ b/drivers/gpu/drm/radeon/cikd.h | |||
@@ -2156,4 +2156,6 @@ | |||
2156 | #define ATC_VM_APERTURE1_HIGH_ADDR 0x330Cu | 2156 | #define ATC_VM_APERTURE1_HIGH_ADDR 0x330Cu |
2157 | #define ATC_VM_APERTURE1_LOW_ADDR 0x3304u | 2157 | #define ATC_VM_APERTURE1_LOW_ADDR 0x3304u |
2158 | 2158 | ||
2159 | #define IH_VMID_0_LUT 0x3D40u | ||
2160 | |||
2159 | #endif | 2161 | #endif |
diff --git a/drivers/gpu/drm/radeon/dce3_1_afmt.c b/drivers/gpu/drm/radeon/dce3_1_afmt.c index 2fe8cfc966d9..bafdf92a5732 100644 --- a/drivers/gpu/drm/radeon/dce3_1_afmt.c +++ b/drivers/gpu/drm/radeon/dce3_1_afmt.c | |||
@@ -103,7 +103,7 @@ static void dce3_2_afmt_write_sad_regs(struct drm_encoder *encoder) | |||
103 | } | 103 | } |
104 | 104 | ||
105 | sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); | 105 | sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); |
106 | if (sad_count < 0) { | 106 | if (sad_count <= 0) { |
107 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); | 107 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); |
108 | return; | 108 | return; |
109 | } | 109 | } |
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c index 9b42001295ba..e3e9c10cfba9 100644 --- a/drivers/gpu/drm/radeon/kv_dpm.c +++ b/drivers/gpu/drm/radeon/kv_dpm.c | |||
@@ -2745,13 +2745,11 @@ int kv_dpm_init(struct radeon_device *rdev) | |||
2745 | pi->enable_auto_thermal_throttling = true; | 2745 | pi->enable_auto_thermal_throttling = true; |
2746 | pi->disable_nb_ps3_in_battery = false; | 2746 | pi->disable_nb_ps3_in_battery = false; |
2747 | if (radeon_bapm == -1) { | 2747 | if (radeon_bapm == -1) { |
2748 | /* There are stability issues reported on with | 2748 | /* only enable bapm on KB, ML by default */ |
2749 | * bapm enabled on an asrock system. | 2749 | if (rdev->family == CHIP_KABINI || rdev->family == CHIP_MULLINS) |
2750 | */ | ||
2751 | if (rdev->pdev->subsystem_vendor == 0x1849) | ||
2752 | pi->bapm_enable = false; | ||
2753 | else | ||
2754 | pi->bapm_enable = true; | 2750 | pi->bapm_enable = true; |
2751 | else | ||
2752 | pi->bapm_enable = false; | ||
2755 | } else if (radeon_bapm == 0) { | 2753 | } else if (radeon_bapm == 0) { |
2756 | pi->bapm_enable = false; | 2754 | pi->bapm_enable = false; |
2757 | } else { | 2755 | } else { |
diff --git a/drivers/gpu/drm/radeon/radeon_kfd.c b/drivers/gpu/drm/radeon/radeon_kfd.c index 242fd8b1b221..8bf87f1203cc 100644 --- a/drivers/gpu/drm/radeon/radeon_kfd.c +++ b/drivers/gpu/drm/radeon/radeon_kfd.c | |||
@@ -72,7 +72,7 @@ static int kgd_init_pipeline(struct kgd_dev *kgd, uint32_t pipe_id, | |||
72 | static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, | 72 | static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, |
73 | uint32_t queue_id, uint32_t __user *wptr); | 73 | uint32_t queue_id, uint32_t __user *wptr); |
74 | 74 | ||
75 | static bool kgd_hqd_is_occupies(struct kgd_dev *kgd, uint64_t queue_address, | 75 | static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address, |
76 | uint32_t pipe_id, uint32_t queue_id); | 76 | uint32_t pipe_id, uint32_t queue_id); |
77 | 77 | ||
78 | static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, | 78 | static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, |
@@ -92,7 +92,7 @@ static const struct kfd2kgd_calls kfd2kgd = { | |||
92 | .init_memory = kgd_init_memory, | 92 | .init_memory = kgd_init_memory, |
93 | .init_pipeline = kgd_init_pipeline, | 93 | .init_pipeline = kgd_init_pipeline, |
94 | .hqd_load = kgd_hqd_load, | 94 | .hqd_load = kgd_hqd_load, |
95 | .hqd_is_occupies = kgd_hqd_is_occupies, | 95 | .hqd_is_occupied = kgd_hqd_is_occupied, |
96 | .hqd_destroy = kgd_hqd_destroy, | 96 | .hqd_destroy = kgd_hqd_destroy, |
97 | .get_fw_version = get_fw_version | 97 | .get_fw_version = get_fw_version |
98 | }; | 98 | }; |
@@ -101,6 +101,7 @@ static const struct kgd2kfd_calls *kgd2kfd; | |||
101 | 101 | ||
102 | bool radeon_kfd_init(void) | 102 | bool radeon_kfd_init(void) |
103 | { | 103 | { |
104 | #if defined(CONFIG_HSA_AMD_MODULE) | ||
104 | bool (*kgd2kfd_init_p)(unsigned, const struct kfd2kgd_calls*, | 105 | bool (*kgd2kfd_init_p)(unsigned, const struct kfd2kgd_calls*, |
105 | const struct kgd2kfd_calls**); | 106 | const struct kgd2kfd_calls**); |
106 | 107 | ||
@@ -117,6 +118,17 @@ bool radeon_kfd_init(void) | |||
117 | } | 118 | } |
118 | 119 | ||
119 | return true; | 120 | return true; |
121 | #elif defined(CONFIG_HSA_AMD) | ||
122 | if (!kgd2kfd_init(KFD_INTERFACE_VERSION, &kfd2kgd, &kgd2kfd)) { | ||
123 | kgd2kfd = NULL; | ||
124 | |||
125 | return false; | ||
126 | } | ||
127 | |||
128 | return true; | ||
129 | #else | ||
130 | return false; | ||
131 | #endif | ||
120 | } | 132 | } |
121 | 133 | ||
122 | void radeon_kfd_fini(void) | 134 | void radeon_kfd_fini(void) |
@@ -378,6 +390,10 @@ static int kgd_set_pasid_vmid_mapping(struct kgd_dev *kgd, unsigned int pasid, | |||
378 | cpu_relax(); | 390 | cpu_relax(); |
379 | write_register(kgd, ATC_VMID_PASID_MAPPING_UPDATE_STATUS, 1U << vmid); | 391 | write_register(kgd, ATC_VMID_PASID_MAPPING_UPDATE_STATUS, 1U << vmid); |
380 | 392 | ||
393 | /* Mapping vmid to pasid also for IH block */ | ||
394 | write_register(kgd, IH_VMID_0_LUT + vmid * sizeof(uint32_t), | ||
395 | pasid_mapping); | ||
396 | |||
381 | return 0; | 397 | return 0; |
382 | } | 398 | } |
383 | 399 | ||
@@ -517,7 +533,7 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, | |||
517 | return 0; | 533 | return 0; |
518 | } | 534 | } |
519 | 535 | ||
520 | static bool kgd_hqd_is_occupies(struct kgd_dev *kgd, uint64_t queue_address, | 536 | static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address, |
521 | uint32_t pipe_id, uint32_t queue_id) | 537 | uint32_t pipe_id, uint32_t queue_id) |
522 | { | 538 | { |
523 | uint32_t act; | 539 | uint32_t act; |
@@ -556,6 +572,7 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, | |||
556 | if (timeout == 0) { | 572 | if (timeout == 0) { |
557 | pr_err("kfd: cp queue preemption time out (%dms)\n", | 573 | pr_err("kfd: cp queue preemption time out (%dms)\n", |
558 | temp); | 574 | temp); |
575 | release_queue(kgd); | ||
559 | return -ETIME; | 576 | return -ETIME; |
560 | } | 577 | } |
561 | msleep(20); | 578 | msleep(20); |
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c index 535403e0c8a2..15aee723db77 100644 --- a/drivers/gpu/drm/radeon/radeon_state.c +++ b/drivers/gpu/drm/radeon/radeon_state.c | |||
@@ -1703,7 +1703,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev, | |||
1703 | u32 format; | 1703 | u32 format; |
1704 | u32 *buffer; | 1704 | u32 *buffer; |
1705 | const u8 __user *data; | 1705 | const u8 __user *data; |
1706 | int size, dwords, tex_width, blit_width, spitch; | 1706 | unsigned int size, dwords, tex_width, blit_width, spitch; |
1707 | u32 height; | 1707 | u32 height; |
1708 | int i; | 1708 | int i; |
1709 | u32 texpitch, microtile; | 1709 | u32 texpitch, microtile; |
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 230b6f887cd8..dfdc26970022 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -27,7 +27,8 @@ if HID | |||
27 | 27 | ||
28 | config HID_BATTERY_STRENGTH | 28 | config HID_BATTERY_STRENGTH |
29 | bool "Battery level reporting for HID devices" | 29 | bool "Battery level reporting for HID devices" |
30 | depends on HID && POWER_SUPPLY && HID = POWER_SUPPLY | 30 | depends on HID |
31 | select POWER_SUPPLY | ||
31 | default n | 32 | default n |
32 | ---help--- | 33 | ---help--- |
33 | This option adds support of reporting battery strength (for HID devices | 34 | This option adds support of reporting battery strength (for HID devices |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index c3d0ac1a0988..8b638792cb43 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1805,6 +1805,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1805 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, | 1805 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, |
1806 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, | 1806 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, |
1807 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, | 1807 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, |
1808 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2) }, | ||
1808 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) }, | 1809 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) }, |
1809 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, | 1810 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, |
1810 | { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, | 1811 | { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 7460f3402298..9243359c1821 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -526,6 +526,7 @@ | |||
526 | #define USB_DEVICE_ID_KYE_GPEN_560 0x5003 | 526 | #define USB_DEVICE_ID_KYE_GPEN_560 0x5003 |
527 | #define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010 | 527 | #define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010 |
528 | #define USB_DEVICE_ID_KYE_MOUSEPEN_I608X 0x5011 | 528 | #define USB_DEVICE_ID_KYE_MOUSEPEN_I608X 0x5011 |
529 | #define USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2 0x501a | ||
529 | #define USB_DEVICE_ID_KYE_EASYPEN_M610X 0x5013 | 530 | #define USB_DEVICE_ID_KYE_EASYPEN_M610X 0x5013 |
530 | 531 | ||
531 | #define USB_VENDOR_ID_LABTEC 0x1020 | 532 | #define USB_VENDOR_ID_LABTEC 0x1020 |
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index e0a0f06ac5ef..9505605b6e22 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -312,6 +312,9 @@ static const struct hid_device_id hid_battery_quirks[] = { | |||
312 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), | 312 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), |
313 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, | 313 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, |
314 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, | 314 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, |
315 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO), | ||
316 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, | ||
317 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, | ||
315 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), | 318 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), |
316 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, | 319 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, |
317 | {} | 320 | {} |
diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c index b92bf01a1ae8..158fcf577fae 100644 --- a/drivers/hid/hid-kye.c +++ b/drivers/hid/hid-kye.c | |||
@@ -323,6 +323,7 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
323 | } | 323 | } |
324 | break; | 324 | break; |
325 | case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: | 325 | case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: |
326 | case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2: | ||
326 | if (*rsize == MOUSEPEN_I608X_RDESC_ORIG_SIZE) { | 327 | if (*rsize == MOUSEPEN_I608X_RDESC_ORIG_SIZE) { |
327 | rdesc = mousepen_i608x_rdesc_fixed; | 328 | rdesc = mousepen_i608x_rdesc_fixed; |
328 | *rsize = sizeof(mousepen_i608x_rdesc_fixed); | 329 | *rsize = sizeof(mousepen_i608x_rdesc_fixed); |
@@ -415,6 +416,7 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
415 | switch (id->product) { | 416 | switch (id->product) { |
416 | case USB_DEVICE_ID_KYE_EASYPEN_I405X: | 417 | case USB_DEVICE_ID_KYE_EASYPEN_I405X: |
417 | case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: | 418 | case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: |
419 | case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2: | ||
418 | case USB_DEVICE_ID_KYE_EASYPEN_M610X: | 420 | case USB_DEVICE_ID_KYE_EASYPEN_M610X: |
419 | ret = kye_tablet_enable(hdev); | 421 | ret = kye_tablet_enable(hdev); |
420 | if (ret) { | 422 | if (ret) { |
@@ -446,6 +448,8 @@ static const struct hid_device_id kye_devices[] = { | |||
446 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, | 448 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, |
447 | USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, | 449 | USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, |
448 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, | 450 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, |
451 | USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2) }, | ||
452 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, | ||
449 | USB_DEVICE_ID_KYE_EASYPEN_M610X) }, | 453 | USB_DEVICE_ID_KYE_EASYPEN_M610X) }, |
450 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, | 454 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, |
451 | USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, | 455 | USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, |
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c index c917ab61aafa..5bc6d80d5be7 100644 --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c | |||
@@ -962,10 +962,24 @@ static int logi_dj_raw_event(struct hid_device *hdev, | |||
962 | 962 | ||
963 | switch (data[0]) { | 963 | switch (data[0]) { |
964 | case REPORT_ID_DJ_SHORT: | 964 | case REPORT_ID_DJ_SHORT: |
965 | if (size != DJREPORT_SHORT_LENGTH) { | ||
966 | dev_err(&hdev->dev, "DJ report of bad size (%d)", size); | ||
967 | return false; | ||
968 | } | ||
965 | return logi_dj_dj_event(hdev, report, data, size); | 969 | return logi_dj_dj_event(hdev, report, data, size); |
966 | case REPORT_ID_HIDPP_SHORT: | 970 | case REPORT_ID_HIDPP_SHORT: |
967 | /* intentional fallthrough */ | 971 | if (size != HIDPP_REPORT_SHORT_LENGTH) { |
972 | dev_err(&hdev->dev, | ||
973 | "Short HID++ report of bad size (%d)", size); | ||
974 | return false; | ||
975 | } | ||
976 | return logi_dj_hidpp_event(hdev, report, data, size); | ||
968 | case REPORT_ID_HIDPP_LONG: | 977 | case REPORT_ID_HIDPP_LONG: |
978 | if (size != HIDPP_REPORT_LONG_LENGTH) { | ||
979 | dev_err(&hdev->dev, | ||
980 | "Long HID++ report of bad size (%d)", size); | ||
981 | return false; | ||
982 | } | ||
969 | return logi_dj_hidpp_event(hdev, report, data, size); | 983 | return logi_dj_hidpp_event(hdev, report, data, size); |
970 | } | 984 | } |
971 | 985 | ||
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 2f420c0b6609..a93cefe0e522 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c | |||
@@ -282,6 +282,33 @@ static inline bool hidpp_report_is_connect_event(struct hidpp_report *report) | |||
282 | (report->rap.sub_id == 0x41); | 282 | (report->rap.sub_id == 0x41); |
283 | } | 283 | } |
284 | 284 | ||
285 | /** | ||
286 | * hidpp_prefix_name() prefixes the current given name with "Logitech ". | ||
287 | */ | ||
288 | static void hidpp_prefix_name(char **name, int name_length) | ||
289 | { | ||
290 | #define PREFIX_LENGTH 9 /* "Logitech " */ | ||
291 | |||
292 | int new_length; | ||
293 | char *new_name; | ||
294 | |||
295 | if (name_length > PREFIX_LENGTH && | ||
296 | strncmp(*name, "Logitech ", PREFIX_LENGTH) == 0) | ||
297 | /* The prefix has is already in the name */ | ||
298 | return; | ||
299 | |||
300 | new_length = PREFIX_LENGTH + name_length; | ||
301 | new_name = kzalloc(new_length, GFP_KERNEL); | ||
302 | if (!new_name) | ||
303 | return; | ||
304 | |||
305 | snprintf(new_name, new_length, "Logitech %s", *name); | ||
306 | |||
307 | kfree(*name); | ||
308 | |||
309 | *name = new_name; | ||
310 | } | ||
311 | |||
285 | /* -------------------------------------------------------------------------- */ | 312 | /* -------------------------------------------------------------------------- */ |
286 | /* HIDP++ 1.0 commands */ | 313 | /* HIDP++ 1.0 commands */ |
287 | /* -------------------------------------------------------------------------- */ | 314 | /* -------------------------------------------------------------------------- */ |
@@ -321,6 +348,10 @@ static char *hidpp_get_unifying_name(struct hidpp_device *hidpp_dev) | |||
321 | return NULL; | 348 | return NULL; |
322 | 349 | ||
323 | memcpy(name, &response.rap.params[2], len); | 350 | memcpy(name, &response.rap.params[2], len); |
351 | |||
352 | /* include the terminating '\0' */ | ||
353 | hidpp_prefix_name(&name, len + 1); | ||
354 | |||
324 | return name; | 355 | return name; |
325 | } | 356 | } |
326 | 357 | ||
@@ -498,6 +529,9 @@ static char *hidpp_get_device_name(struct hidpp_device *hidpp) | |||
498 | index += ret; | 529 | index += ret; |
499 | } | 530 | } |
500 | 531 | ||
532 | /* include the terminating '\0' */ | ||
533 | hidpp_prefix_name(&name, __name_length + 1); | ||
534 | |||
501 | return name; | 535 | return name; |
502 | } | 536 | } |
503 | 537 | ||
@@ -794,18 +828,25 @@ static int wtp_raw_event(struct hid_device *hdev, u8 *data, int size) | |||
794 | 828 | ||
795 | switch (data[0]) { | 829 | switch (data[0]) { |
796 | case 0x02: | 830 | case 0x02: |
831 | if (size < 2) { | ||
832 | hid_err(hdev, "Received HID report of bad size (%d)", | ||
833 | size); | ||
834 | return 1; | ||
835 | } | ||
797 | if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { | 836 | if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { |
798 | input_event(wd->input, EV_KEY, BTN_LEFT, | 837 | input_event(wd->input, EV_KEY, BTN_LEFT, |
799 | !!(data[1] & 0x01)); | 838 | !!(data[1] & 0x01)); |
800 | input_event(wd->input, EV_KEY, BTN_RIGHT, | 839 | input_event(wd->input, EV_KEY, BTN_RIGHT, |
801 | !!(data[1] & 0x02)); | 840 | !!(data[1] & 0x02)); |
802 | input_sync(wd->input); | 841 | input_sync(wd->input); |
842 | return 0; | ||
803 | } else { | 843 | } else { |
804 | if (size < 21) | 844 | if (size < 21) |
805 | return 1; | 845 | return 1; |
806 | return wtp_mouse_raw_xy_event(hidpp, &data[7]); | 846 | return wtp_mouse_raw_xy_event(hidpp, &data[7]); |
807 | } | 847 | } |
808 | case REPORT_ID_HIDPP_LONG: | 848 | case REPORT_ID_HIDPP_LONG: |
849 | /* size is already checked in hidpp_raw_event. */ | ||
809 | if ((report->fap.feature_index != wd->mt_feature_index) || | 850 | if ((report->fap.feature_index != wd->mt_feature_index) || |
810 | (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY)) | 851 | (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY)) |
811 | return 1; | 852 | return 1; |
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 1a07e07d99a0..47d7e74231e5 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c | |||
@@ -35,6 +35,8 @@ static struct class *pyra_class; | |||
35 | static void profile_activated(struct pyra_device *pyra, | 35 | static void profile_activated(struct pyra_device *pyra, |
36 | unsigned int new_profile) | 36 | unsigned int new_profile) |
37 | { | 37 | { |
38 | if (new_profile >= ARRAY_SIZE(pyra->profile_settings)) | ||
39 | return; | ||
38 | pyra->actual_profile = new_profile; | 40 | pyra->actual_profile = new_profile; |
39 | pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi; | 41 | pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi; |
40 | } | 42 | } |
@@ -257,9 +259,11 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp, | |||
257 | if (off != 0 || count != PYRA_SIZE_SETTINGS) | 259 | if (off != 0 || count != PYRA_SIZE_SETTINGS) |
258 | return -EINVAL; | 260 | return -EINVAL; |
259 | 261 | ||
260 | mutex_lock(&pyra->pyra_lock); | ||
261 | |||
262 | settings = (struct pyra_settings const *)buf; | 262 | settings = (struct pyra_settings const *)buf; |
263 | if (settings->startup_profile >= ARRAY_SIZE(pyra->profile_settings)) | ||
264 | return -EINVAL; | ||
265 | |||
266 | mutex_lock(&pyra->pyra_lock); | ||
263 | 267 | ||
264 | retval = pyra_set_settings(usb_dev, settings); | 268 | retval = pyra_set_settings(usb_dev, settings); |
265 | if (retval) { | 269 | if (retval) { |
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index d32037cbf9db..d43e967e7533 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c | |||
@@ -706,12 +706,7 @@ static int i2c_hid_start(struct hid_device *hid) | |||
706 | 706 | ||
707 | static void i2c_hid_stop(struct hid_device *hid) | 707 | static void i2c_hid_stop(struct hid_device *hid) |
708 | { | 708 | { |
709 | struct i2c_client *client = hid->driver_data; | ||
710 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
711 | |||
712 | hid->claimed = 0; | 709 | hid->claimed = 0; |
713 | |||
714 | i2c_hid_free_buffers(ihid); | ||
715 | } | 710 | } |
716 | 711 | ||
717 | static int i2c_hid_open(struct hid_device *hid) | 712 | static int i2c_hid_open(struct hid_device *hid) |
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index dc89be90b35e..b27b3d33ebab 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -124,6 +124,7 @@ static const struct hid_blacklist { | |||
124 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT }, | 124 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT }, |
125 | { USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD, HID_QUIRK_NO_INIT_REPORTS }, | 125 | { USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD, HID_QUIRK_NO_INIT_REPORTS }, |
126 | { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X, HID_QUIRK_MULTI_INPUT }, | 126 | { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X, HID_QUIRK_MULTI_INPUT }, |
127 | { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2, HID_QUIRK_MULTI_INPUT }, | ||
127 | { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X, HID_QUIRK_MULTI_INPUT }, | 128 | { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X, HID_QUIRK_MULTI_INPUT }, |
128 | { USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_DUOSENSE, HID_QUIRK_NO_INIT_REPORTS }, | 129 | { USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_DUOSENSE, HID_QUIRK_NO_INIT_REPORTS }, |
129 | { USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD, HID_QUIRK_NO_INIT_REPORTS }, | 130 | { USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD, HID_QUIRK_NO_INIT_REPORTS }, |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 12ca291c1380..cce1cbc1a927 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -734,7 +734,9 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) | |||
734 | * Return target busy if we've received a non-zero retry_delay_timer | 734 | * Return target busy if we've received a non-zero retry_delay_timer |
735 | * in a FCP_RSP. | 735 | * in a FCP_RSP. |
736 | */ | 736 | */ |
737 | if (time_after(jiffies, fcport->retry_delay_timestamp)) | 737 | if (fcport->retry_delay_timestamp == 0) { |
738 | /* retry delay not set */ | ||
739 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) | ||
738 | fcport->retry_delay_timestamp = 0; | 740 | fcport->retry_delay_timestamp = 0; |
739 | else | 741 | else |
740 | goto qc24_target_busy; | 742 | goto qc24_target_busy; |
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 255201f22126..7cc0122a18ce 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c | |||
@@ -840,13 +840,11 @@ static const struct vfio_device_ops vfio_pci_ops = { | |||
840 | 840 | ||
841 | static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 841 | static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
842 | { | 842 | { |
843 | u8 type; | ||
844 | struct vfio_pci_device *vdev; | 843 | struct vfio_pci_device *vdev; |
845 | struct iommu_group *group; | 844 | struct iommu_group *group; |
846 | int ret; | 845 | int ret; |
847 | 846 | ||
848 | pci_read_config_byte(pdev, PCI_HEADER_TYPE, &type); | 847 | if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL) |
849 | if ((type & PCI_HEADER_TYPE) != PCI_HEADER_TYPE_NORMAL) | ||
850 | return -EINVAL; | 848 | return -EINVAL; |
851 | 849 | ||
852 | group = iommu_group_get(&pdev->dev); | 850 | group = iommu_group_get(&pdev->dev); |
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 2d3e32ebfd15..8729cf68d2fe 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -1552,7 +1552,6 @@ int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb, | |||
1552 | { | 1552 | { |
1553 | int ret; | 1553 | int ret; |
1554 | int type; | 1554 | int type; |
1555 | struct btrfs_tree_block_info *info; | ||
1556 | struct btrfs_extent_inline_ref *eiref; | 1555 | struct btrfs_extent_inline_ref *eiref; |
1557 | 1556 | ||
1558 | if (*ptr == (unsigned long)-1) | 1557 | if (*ptr == (unsigned long)-1) |
@@ -1573,9 +1572,17 @@ int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb, | |||
1573 | } | 1572 | } |
1574 | 1573 | ||
1575 | /* we can treat both ref types equally here */ | 1574 | /* we can treat both ref types equally here */ |
1576 | info = (struct btrfs_tree_block_info *)(ei + 1); | ||
1577 | *out_root = btrfs_extent_inline_ref_offset(eb, eiref); | 1575 | *out_root = btrfs_extent_inline_ref_offset(eb, eiref); |
1578 | *out_level = btrfs_tree_block_level(eb, info); | 1576 | |
1577 | if (key->type == BTRFS_EXTENT_ITEM_KEY) { | ||
1578 | struct btrfs_tree_block_info *info; | ||
1579 | |||
1580 | info = (struct btrfs_tree_block_info *)(ei + 1); | ||
1581 | *out_level = btrfs_tree_block_level(eb, info); | ||
1582 | } else { | ||
1583 | ASSERT(key->type == BTRFS_METADATA_ITEM_KEY); | ||
1584 | *out_level = (u8)key->offset; | ||
1585 | } | ||
1579 | 1586 | ||
1580 | if (ret == 1) | 1587 | if (ret == 1) |
1581 | *ptr = (unsigned long)-1; | 1588 | *ptr = (unsigned long)-1; |
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 054577bddaf2..de4e70fb3cbb 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c | |||
@@ -1857,6 +1857,14 @@ int btrfs_delayed_delete_inode_ref(struct inode *inode) | |||
1857 | { | 1857 | { |
1858 | struct btrfs_delayed_node *delayed_node; | 1858 | struct btrfs_delayed_node *delayed_node; |
1859 | 1859 | ||
1860 | /* | ||
1861 | * we don't do delayed inode updates during log recovery because it | ||
1862 | * leads to enospc problems. This means we also can't do | ||
1863 | * delayed inode refs | ||
1864 | */ | ||
1865 | if (BTRFS_I(inode)->root->fs_info->log_root_recovering) | ||
1866 | return -EAGAIN; | ||
1867 | |||
1860 | delayed_node = btrfs_get_or_create_delayed_node(inode); | 1868 | delayed_node = btrfs_get_or_create_delayed_node(inode); |
1861 | if (IS_ERR(delayed_node)) | 1869 | if (IS_ERR(delayed_node)) |
1862 | return PTR_ERR(delayed_node); | 1870 | return PTR_ERR(delayed_node); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a80b97100d90..15116585e714 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3139,9 +3139,11 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans, | |||
3139 | struct extent_buffer *leaf; | 3139 | struct extent_buffer *leaf; |
3140 | 3140 | ||
3141 | ret = btrfs_search_slot(trans, extent_root, &cache->key, path, 0, 1); | 3141 | ret = btrfs_search_slot(trans, extent_root, &cache->key, path, 0, 1); |
3142 | if (ret < 0) | 3142 | if (ret) { |
3143 | if (ret > 0) | ||
3144 | ret = -ENOENT; | ||
3143 | goto fail; | 3145 | goto fail; |
3144 | BUG_ON(ret); /* Corruption */ | 3146 | } |
3145 | 3147 | ||
3146 | leaf = path->nodes[0]; | 3148 | leaf = path->nodes[0]; |
3147 | bi = btrfs_item_ptr_offset(leaf, path->slots[0]); | 3149 | bi = btrfs_item_ptr_offset(leaf, path->slots[0]); |
@@ -3149,11 +3151,9 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans, | |||
3149 | btrfs_mark_buffer_dirty(leaf); | 3151 | btrfs_mark_buffer_dirty(leaf); |
3150 | btrfs_release_path(path); | 3152 | btrfs_release_path(path); |
3151 | fail: | 3153 | fail: |
3152 | if (ret) { | 3154 | if (ret) |
3153 | btrfs_abort_transaction(trans, root, ret); | 3155 | btrfs_abort_transaction(trans, root, ret); |
3154 | return ret; | 3156 | return ret; |
3155 | } | ||
3156 | return 0; | ||
3157 | 3157 | ||
3158 | } | 3158 | } |
3159 | 3159 | ||
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e687bb0dc73a..8bf326affb94 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6255,8 +6255,10 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
6255 | 6255 | ||
6256 | out_fail: | 6256 | out_fail: |
6257 | btrfs_end_transaction(trans, root); | 6257 | btrfs_end_transaction(trans, root); |
6258 | if (drop_on_err) | 6258 | if (drop_on_err) { |
6259 | inode_dec_link_count(inode); | ||
6259 | iput(inode); | 6260 | iput(inode); |
6261 | } | ||
6260 | btrfs_balance_delayed_items(root); | 6262 | btrfs_balance_delayed_items(root); |
6261 | btrfs_btree_balance_dirty(root); | 6263 | btrfs_btree_balance_dirty(root); |
6262 | return err; | 6264 | return err; |
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index f2bb13a23f86..9e1569ffbf6e 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c | |||
@@ -2607,9 +2607,9 @@ static int scrub_extent_for_parity(struct scrub_parity *sparity, | |||
2607 | ret = scrub_pages_for_parity(sparity, logical, l, physical, dev, | 2607 | ret = scrub_pages_for_parity(sparity, logical, l, physical, dev, |
2608 | flags, gen, mirror_num, | 2608 | flags, gen, mirror_num, |
2609 | have_csum ? csum : NULL); | 2609 | have_csum ? csum : NULL); |
2610 | skip: | ||
2611 | if (ret) | 2610 | if (ret) |
2612 | return ret; | 2611 | return ret; |
2612 | skip: | ||
2613 | len -= l; | 2613 | len -= l; |
2614 | logical += l; | 2614 | logical += l; |
2615 | physical += l; | 2615 | physical += l; |
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index f5013d92a7e6..c81c0e004588 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c | |||
@@ -1416,7 +1416,7 @@ void ceph_fill_inline_data(struct inode *inode, struct page *locked_page, | |||
1416 | } | 1416 | } |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | dout("fill_inline_data %p %llx.%llx len %lu locked_page %p\n", | 1419 | dout("fill_inline_data %p %llx.%llx len %zu locked_page %p\n", |
1420 | inode, ceph_vinop(inode), len, locked_page); | 1420 | inode, ceph_vinop(inode), len, locked_page); |
1421 | 1421 | ||
1422 | if (len > 0) { | 1422 | if (len > 0) { |
diff --git a/fs/fcntl.c b/fs/fcntl.c index 99d440a4a6ba..ee85cd4e136a 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -740,14 +740,15 @@ static int __init fcntl_init(void) | |||
740 | * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY | 740 | * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY |
741 | * is defined as O_NONBLOCK on some platforms and not on others. | 741 | * is defined as O_NONBLOCK on some platforms and not on others. |
742 | */ | 742 | */ |
743 | BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32( | 743 | BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32( |
744 | O_RDONLY | O_WRONLY | O_RDWR | | 744 | O_RDONLY | O_WRONLY | O_RDWR | |
745 | O_CREAT | O_EXCL | O_NOCTTY | | 745 | O_CREAT | O_EXCL | O_NOCTTY | |
746 | O_TRUNC | O_APPEND | /* O_NONBLOCK | */ | 746 | O_TRUNC | O_APPEND | /* O_NONBLOCK | */ |
747 | __O_SYNC | O_DSYNC | FASYNC | | 747 | __O_SYNC | O_DSYNC | FASYNC | |
748 | O_DIRECT | O_LARGEFILE | O_DIRECTORY | | 748 | O_DIRECT | O_LARGEFILE | O_DIRECTORY | |
749 | O_NOFOLLOW | O_NOATIME | O_CLOEXEC | | 749 | O_NOFOLLOW | O_NOATIME | O_CLOEXEC | |
750 | __FMODE_EXEC | O_PATH | __O_TMPFILE | 750 | __FMODE_EXEC | O_PATH | __O_TMPFILE | |
751 | __FMODE_NONOTIFY | ||
751 | )); | 752 | )); |
752 | 753 | ||
753 | fasync_cache = kmem_cache_create("fasync_cache", | 754 | fasync_cache = kmem_cache_create("fasync_cache", |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 3550a9c87616..c06a1ba80d73 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -3897,11 +3897,11 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh, | |||
3897 | status = nfs4_setlease(dp); | 3897 | status = nfs4_setlease(dp); |
3898 | goto out; | 3898 | goto out; |
3899 | } | 3899 | } |
3900 | atomic_inc(&fp->fi_delegees); | ||
3901 | if (fp->fi_had_conflict) { | 3900 | if (fp->fi_had_conflict) { |
3902 | status = -EAGAIN; | 3901 | status = -EAGAIN; |
3903 | goto out_unlock; | 3902 | goto out_unlock; |
3904 | } | 3903 | } |
3904 | atomic_inc(&fp->fi_delegees); | ||
3905 | hash_delegation_locked(dp, fp); | 3905 | hash_delegation_locked(dp, fp); |
3906 | status = 0; | 3906 | status = 0; |
3907 | out_unlock: | 3907 | out_unlock: |
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 79b5af5e6a7b..cecd875653e4 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c | |||
@@ -2023,11 +2023,8 @@ leave: | |||
2023 | dlm_lockres_drop_inflight_ref(dlm, res); | 2023 | dlm_lockres_drop_inflight_ref(dlm, res); |
2024 | spin_unlock(&res->spinlock); | 2024 | spin_unlock(&res->spinlock); |
2025 | 2025 | ||
2026 | if (ret < 0) { | 2026 | if (ret < 0) |
2027 | mlog_errno(ret); | 2027 | mlog_errno(ret); |
2028 | if (newlock) | ||
2029 | dlm_lock_put(newlock); | ||
2030 | } | ||
2031 | 2028 | ||
2032 | return ret; | 2029 | return ret; |
2033 | } | 2030 | } |
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index b931e04e3388..914c121ec890 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -94,6 +94,14 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | |||
94 | struct inode *inode, | 94 | struct inode *inode, |
95 | const char *symname); | 95 | const char *symname); |
96 | 96 | ||
97 | static int ocfs2_double_lock(struct ocfs2_super *osb, | ||
98 | struct buffer_head **bh1, | ||
99 | struct inode *inode1, | ||
100 | struct buffer_head **bh2, | ||
101 | struct inode *inode2, | ||
102 | int rename); | ||
103 | |||
104 | static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2); | ||
97 | /* An orphan dir name is an 8 byte value, printed as a hex string */ | 105 | /* An orphan dir name is an 8 byte value, printed as a hex string */ |
98 | #define OCFS2_ORPHAN_NAMELEN ((int)(2 * sizeof(u64))) | 106 | #define OCFS2_ORPHAN_NAMELEN ((int)(2 * sizeof(u64))) |
99 | 107 | ||
@@ -678,8 +686,10 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
678 | { | 686 | { |
679 | handle_t *handle; | 687 | handle_t *handle; |
680 | struct inode *inode = old_dentry->d_inode; | 688 | struct inode *inode = old_dentry->d_inode; |
689 | struct inode *old_dir = old_dentry->d_parent->d_inode; | ||
681 | int err; | 690 | int err; |
682 | struct buffer_head *fe_bh = NULL; | 691 | struct buffer_head *fe_bh = NULL; |
692 | struct buffer_head *old_dir_bh = NULL; | ||
683 | struct buffer_head *parent_fe_bh = NULL; | 693 | struct buffer_head *parent_fe_bh = NULL; |
684 | struct ocfs2_dinode *fe = NULL; | 694 | struct ocfs2_dinode *fe = NULL; |
685 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); | 695 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); |
@@ -696,19 +706,33 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
696 | 706 | ||
697 | dquot_initialize(dir); | 707 | dquot_initialize(dir); |
698 | 708 | ||
699 | err = ocfs2_inode_lock_nested(dir, &parent_fe_bh, 1, OI_LS_PARENT); | 709 | err = ocfs2_double_lock(osb, &old_dir_bh, old_dir, |
710 | &parent_fe_bh, dir, 0); | ||
700 | if (err < 0) { | 711 | if (err < 0) { |
701 | if (err != -ENOENT) | 712 | if (err != -ENOENT) |
702 | mlog_errno(err); | 713 | mlog_errno(err); |
703 | return err; | 714 | return err; |
704 | } | 715 | } |
705 | 716 | ||
717 | /* make sure both dirs have bhs | ||
718 | * get an extra ref on old_dir_bh if old==new */ | ||
719 | if (!parent_fe_bh) { | ||
720 | if (old_dir_bh) { | ||
721 | parent_fe_bh = old_dir_bh; | ||
722 | get_bh(parent_fe_bh); | ||
723 | } else { | ||
724 | mlog(ML_ERROR, "%s: no old_dir_bh!\n", osb->uuid_str); | ||
725 | err = -EIO; | ||
726 | goto out; | ||
727 | } | ||
728 | } | ||
729 | |||
706 | if (!dir->i_nlink) { | 730 | if (!dir->i_nlink) { |
707 | err = -ENOENT; | 731 | err = -ENOENT; |
708 | goto out; | 732 | goto out; |
709 | } | 733 | } |
710 | 734 | ||
711 | err = ocfs2_lookup_ino_from_name(dir, old_dentry->d_name.name, | 735 | err = ocfs2_lookup_ino_from_name(old_dir, old_dentry->d_name.name, |
712 | old_dentry->d_name.len, &old_de_ino); | 736 | old_dentry->d_name.len, &old_de_ino); |
713 | if (err) { | 737 | if (err) { |
714 | err = -ENOENT; | 738 | err = -ENOENT; |
@@ -801,10 +825,11 @@ out_unlock_inode: | |||
801 | ocfs2_inode_unlock(inode, 1); | 825 | ocfs2_inode_unlock(inode, 1); |
802 | 826 | ||
803 | out: | 827 | out: |
804 | ocfs2_inode_unlock(dir, 1); | 828 | ocfs2_double_unlock(old_dir, dir); |
805 | 829 | ||
806 | brelse(fe_bh); | 830 | brelse(fe_bh); |
807 | brelse(parent_fe_bh); | 831 | brelse(parent_fe_bh); |
832 | brelse(old_dir_bh); | ||
808 | 833 | ||
809 | ocfs2_free_dir_lookup_result(&lookup); | 834 | ocfs2_free_dir_lookup_result(&lookup); |
810 | 835 | ||
@@ -1072,14 +1097,15 @@ static int ocfs2_check_if_ancestor(struct ocfs2_super *osb, | |||
1072 | } | 1097 | } |
1073 | 1098 | ||
1074 | /* | 1099 | /* |
1075 | * The only place this should be used is rename! | 1100 | * The only place this should be used is rename and link! |
1076 | * if they have the same id, then the 1st one is the only one locked. | 1101 | * if they have the same id, then the 1st one is the only one locked. |
1077 | */ | 1102 | */ |
1078 | static int ocfs2_double_lock(struct ocfs2_super *osb, | 1103 | static int ocfs2_double_lock(struct ocfs2_super *osb, |
1079 | struct buffer_head **bh1, | 1104 | struct buffer_head **bh1, |
1080 | struct inode *inode1, | 1105 | struct inode *inode1, |
1081 | struct buffer_head **bh2, | 1106 | struct buffer_head **bh2, |
1082 | struct inode *inode2) | 1107 | struct inode *inode2, |
1108 | int rename) | ||
1083 | { | 1109 | { |
1084 | int status; | 1110 | int status; |
1085 | int inode1_is_ancestor, inode2_is_ancestor; | 1111 | int inode1_is_ancestor, inode2_is_ancestor; |
@@ -1127,7 +1153,7 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
1127 | } | 1153 | } |
1128 | /* lock id2 */ | 1154 | /* lock id2 */ |
1129 | status = ocfs2_inode_lock_nested(inode2, bh2, 1, | 1155 | status = ocfs2_inode_lock_nested(inode2, bh2, 1, |
1130 | OI_LS_RENAME1); | 1156 | rename == 1 ? OI_LS_RENAME1 : OI_LS_PARENT); |
1131 | if (status < 0) { | 1157 | if (status < 0) { |
1132 | if (status != -ENOENT) | 1158 | if (status != -ENOENT) |
1133 | mlog_errno(status); | 1159 | mlog_errno(status); |
@@ -1136,7 +1162,8 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
1136 | } | 1162 | } |
1137 | 1163 | ||
1138 | /* lock id1 */ | 1164 | /* lock id1 */ |
1139 | status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_RENAME2); | 1165 | status = ocfs2_inode_lock_nested(inode1, bh1, 1, |
1166 | rename == 1 ? OI_LS_RENAME2 : OI_LS_PARENT); | ||
1140 | if (status < 0) { | 1167 | if (status < 0) { |
1141 | /* | 1168 | /* |
1142 | * An error return must mean that no cluster locks | 1169 | * An error return must mean that no cluster locks |
@@ -1252,7 +1279,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1252 | 1279 | ||
1253 | /* if old and new are the same, this'll just do one lock. */ | 1280 | /* if old and new are the same, this'll just do one lock. */ |
1254 | status = ocfs2_double_lock(osb, &old_dir_bh, old_dir, | 1281 | status = ocfs2_double_lock(osb, &old_dir_bh, old_dir, |
1255 | &new_dir_bh, new_dir); | 1282 | &new_dir_bh, new_dir, 1); |
1256 | if (status < 0) { | 1283 | if (status < 0) { |
1257 | mlog_errno(status); | 1284 | mlog_errno(status); |
1258 | goto bail; | 1285 | goto bail; |
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index 5d86416d35f2..61b19c46bdb3 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h | |||
@@ -87,8 +87,8 @@ struct ceph_osd_req_op { | |||
87 | struct ceph_osd_data osd_data; | 87 | struct ceph_osd_data osd_data; |
88 | } extent; | 88 | } extent; |
89 | struct { | 89 | struct { |
90 | __le32 name_len; | 90 | u32 name_len; |
91 | __le32 value_len; | 91 | u32 value_len; |
92 | __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */ | 92 | __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */ |
93 | __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */ | 93 | __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */ |
94 | struct ceph_osd_data osd_data; | 94 | struct ceph_osd_data osd_data; |
diff --git a/include/linux/fs.h b/include/linux/fs.h index f90c0282c114..42efe13077b6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -135,7 +135,7 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset, | |||
135 | #define FMODE_CAN_WRITE ((__force fmode_t)0x40000) | 135 | #define FMODE_CAN_WRITE ((__force fmode_t)0x40000) |
136 | 136 | ||
137 | /* File was opened by fanotify and shouldn't generate fanotify events */ | 137 | /* File was opened by fanotify and shouldn't generate fanotify events */ |
138 | #define FMODE_NONOTIFY ((__force fmode_t)0x1000000) | 138 | #define FMODE_NONOTIFY ((__force fmode_t)0x4000000) |
139 | 139 | ||
140 | /* | 140 | /* |
141 | * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector | 141 | * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector |
diff --git a/include/linux/kdb.h b/include/linux/kdb.h index 290db1269c4c..75ae2e2631fc 100644 --- a/include/linux/kdb.h +++ b/include/linux/kdb.h | |||
@@ -13,11 +13,54 @@ | |||
13 | * Copyright (C) 2009 Jason Wessel <jason.wessel@windriver.com> | 13 | * Copyright (C) 2009 Jason Wessel <jason.wessel@windriver.com> |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /* Shifted versions of the command enable bits are be used if the command | ||
17 | * has no arguments (see kdb_check_flags). This allows commands, such as | ||
18 | * go, to have different permissions depending upon whether it is called | ||
19 | * with an argument. | ||
20 | */ | ||
21 | #define KDB_ENABLE_NO_ARGS_SHIFT 10 | ||
22 | |||
16 | typedef enum { | 23 | typedef enum { |
17 | KDB_REPEAT_NONE = 0, /* Do not repeat this command */ | 24 | KDB_ENABLE_ALL = (1 << 0), /* Enable everything */ |
18 | KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */ | 25 | KDB_ENABLE_MEM_READ = (1 << 1), |
19 | KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */ | 26 | KDB_ENABLE_MEM_WRITE = (1 << 2), |
20 | } kdb_repeat_t; | 27 | KDB_ENABLE_REG_READ = (1 << 3), |
28 | KDB_ENABLE_REG_WRITE = (1 << 4), | ||
29 | KDB_ENABLE_INSPECT = (1 << 5), | ||
30 | KDB_ENABLE_FLOW_CTRL = (1 << 6), | ||
31 | KDB_ENABLE_SIGNAL = (1 << 7), | ||
32 | KDB_ENABLE_REBOOT = (1 << 8), | ||
33 | /* User exposed values stop here, all remaining flags are | ||
34 | * exclusively used to describe a commands behaviour. | ||
35 | */ | ||
36 | |||
37 | KDB_ENABLE_ALWAYS_SAFE = (1 << 9), | ||
38 | KDB_ENABLE_MASK = (1 << KDB_ENABLE_NO_ARGS_SHIFT) - 1, | ||
39 | |||
40 | KDB_ENABLE_ALL_NO_ARGS = KDB_ENABLE_ALL << KDB_ENABLE_NO_ARGS_SHIFT, | ||
41 | KDB_ENABLE_MEM_READ_NO_ARGS = KDB_ENABLE_MEM_READ | ||
42 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
43 | KDB_ENABLE_MEM_WRITE_NO_ARGS = KDB_ENABLE_MEM_WRITE | ||
44 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
45 | KDB_ENABLE_REG_READ_NO_ARGS = KDB_ENABLE_REG_READ | ||
46 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
47 | KDB_ENABLE_REG_WRITE_NO_ARGS = KDB_ENABLE_REG_WRITE | ||
48 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
49 | KDB_ENABLE_INSPECT_NO_ARGS = KDB_ENABLE_INSPECT | ||
50 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
51 | KDB_ENABLE_FLOW_CTRL_NO_ARGS = KDB_ENABLE_FLOW_CTRL | ||
52 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
53 | KDB_ENABLE_SIGNAL_NO_ARGS = KDB_ENABLE_SIGNAL | ||
54 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
55 | KDB_ENABLE_REBOOT_NO_ARGS = KDB_ENABLE_REBOOT | ||
56 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
57 | KDB_ENABLE_ALWAYS_SAFE_NO_ARGS = KDB_ENABLE_ALWAYS_SAFE | ||
58 | << KDB_ENABLE_NO_ARGS_SHIFT, | ||
59 | KDB_ENABLE_MASK_NO_ARGS = KDB_ENABLE_MASK << KDB_ENABLE_NO_ARGS_SHIFT, | ||
60 | |||
61 | KDB_REPEAT_NO_ARGS = 0x40000000, /* Repeat the command w/o arguments */ | ||
62 | KDB_REPEAT_WITH_ARGS = 0x80000000, /* Repeat the command with args */ | ||
63 | } kdb_cmdflags_t; | ||
21 | 64 | ||
22 | typedef int (*kdb_func_t)(int, const char **); | 65 | typedef int (*kdb_func_t)(int, const char **); |
23 | 66 | ||
@@ -62,6 +105,7 @@ extern atomic_t kdb_event; | |||
62 | #define KDB_BADLENGTH (-19) | 105 | #define KDB_BADLENGTH (-19) |
63 | #define KDB_NOBP (-20) | 106 | #define KDB_NOBP (-20) |
64 | #define KDB_BADADDR (-21) | 107 | #define KDB_BADADDR (-21) |
108 | #define KDB_NOPERM (-22) | ||
65 | 109 | ||
66 | /* | 110 | /* |
67 | * kdb_diemsg | 111 | * kdb_diemsg |
@@ -146,17 +190,17 @@ static inline const char *kdb_walk_kallsyms(loff_t *pos) | |||
146 | 190 | ||
147 | /* Dynamic kdb shell command registration */ | 191 | /* Dynamic kdb shell command registration */ |
148 | extern int kdb_register(char *, kdb_func_t, char *, char *, short); | 192 | extern int kdb_register(char *, kdb_func_t, char *, char *, short); |
149 | extern int kdb_register_repeat(char *, kdb_func_t, char *, char *, | 193 | extern int kdb_register_flags(char *, kdb_func_t, char *, char *, |
150 | short, kdb_repeat_t); | 194 | short, kdb_cmdflags_t); |
151 | extern int kdb_unregister(char *); | 195 | extern int kdb_unregister(char *); |
152 | #else /* ! CONFIG_KGDB_KDB */ | 196 | #else /* ! CONFIG_KGDB_KDB */ |
153 | static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; } | 197 | static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; } |
154 | static inline void kdb_init(int level) {} | 198 | static inline void kdb_init(int level) {} |
155 | static inline int kdb_register(char *cmd, kdb_func_t func, char *usage, | 199 | static inline int kdb_register(char *cmd, kdb_func_t func, char *usage, |
156 | char *help, short minlen) { return 0; } | 200 | char *help, short minlen) { return 0; } |
157 | static inline int kdb_register_repeat(char *cmd, kdb_func_t func, char *usage, | 201 | static inline int kdb_register_flags(char *cmd, kdb_func_t func, char *usage, |
158 | char *help, short minlen, | 202 | char *help, short minlen, |
159 | kdb_repeat_t repeat) { return 0; } | 203 | kdb_cmdflags_t flags) { return 0; } |
160 | static inline int kdb_unregister(char *cmd) { return 0; } | 204 | static inline int kdb_unregister(char *cmd) { return 0; } |
161 | #endif /* CONFIG_KGDB_KDB */ | 205 | #endif /* CONFIG_KGDB_KDB */ |
162 | enum { | 206 | enum { |
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index c0c2bce6b0b7..d9d7e7e56352 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h | |||
@@ -37,6 +37,16 @@ struct anon_vma { | |||
37 | atomic_t refcount; | 37 | atomic_t refcount; |
38 | 38 | ||
39 | /* | 39 | /* |
40 | * Count of child anon_vmas and VMAs which points to this anon_vma. | ||
41 | * | ||
42 | * This counter is used for making decision about reusing anon_vma | ||
43 | * instead of forking new one. See comments in function anon_vma_clone. | ||
44 | */ | ||
45 | unsigned degree; | ||
46 | |||
47 | struct anon_vma *parent; /* Parent of this anon_vma */ | ||
48 | |||
49 | /* | ||
40 | * NOTE: the LSB of the rb_root.rb_node is set by | 50 | * NOTE: the LSB of the rb_root.rb_node is set by |
41 | * mm_take_all_locks() _after_ taking the above lock. So the | 51 | * mm_take_all_locks() _after_ taking the above lock. So the |
42 | * rb_root must only be read/written after taking the above lock | 52 | * rb_root must only be read/written after taking the above lock |
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index a219be961c0a..00048339c23e 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
@@ -177,7 +177,6 @@ int write_cache_pages(struct address_space *mapping, | |||
177 | struct writeback_control *wbc, writepage_t writepage, | 177 | struct writeback_control *wbc, writepage_t writepage, |
178 | void *data); | 178 | void *data); |
179 | int do_writepages(struct address_space *mapping, struct writeback_control *wbc); | 179 | int do_writepages(struct address_space *mapping, struct writeback_control *wbc); |
180 | void set_page_dirty_balance(struct page *page); | ||
181 | void writeback_set_ratelimit(void); | 180 | void writeback_set_ratelimit(void); |
182 | void tag_pages_for_writeback(struct address_space *mapping, | 181 | void tag_pages_for_writeback(struct address_space *mapping, |
183 | pgoff_t start, pgoff_t end); | 182 | pgoff_t start, pgoff_t end); |
diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h index 7543b3e51331..e063effe0cc1 100644 --- a/include/uapi/asm-generic/fcntl.h +++ b/include/uapi/asm-generic/fcntl.h | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | /* | 6 | /* |
7 | * FMODE_EXEC is 0x20 | 7 | * FMODE_EXEC is 0x20 |
8 | * FMODE_NONOTIFY is 0x1000000 | 8 | * FMODE_NONOTIFY is 0x4000000 |
9 | * These cannot be used by userspace O_* until internal and external open | 9 | * These cannot be used by userspace O_* until internal and external open |
10 | * flags are split. | 10 | * flags are split. |
11 | * -Eric Paris | 11 | * -Eric Paris |
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h index 7acef41fc209..af94f31e33ac 100644 --- a/include/uapi/linux/kfd_ioctl.h +++ b/include/uapi/linux/kfd_ioctl.h | |||
@@ -128,27 +128,34 @@ struct kfd_ioctl_get_process_apertures_args { | |||
128 | uint32_t pad; | 128 | uint32_t pad; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | #define KFD_IOC_MAGIC 'K' | 131 | #define AMDKFD_IOCTL_BASE 'K' |
132 | #define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr) | ||
133 | #define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type) | ||
134 | #define AMDKFD_IOW(nr, type) _IOW(AMDKFD_IOCTL_BASE, nr, type) | ||
135 | #define AMDKFD_IOWR(nr, type) _IOWR(AMDKFD_IOCTL_BASE, nr, type) | ||
132 | 136 | ||
133 | #define KFD_IOC_GET_VERSION \ | 137 | #define AMDKFD_IOC_GET_VERSION \ |
134 | _IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args) | 138 | AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args) |
135 | 139 | ||
136 | #define KFD_IOC_CREATE_QUEUE \ | 140 | #define AMDKFD_IOC_CREATE_QUEUE \ |
137 | _IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args) | 141 | AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args) |
138 | 142 | ||
139 | #define KFD_IOC_DESTROY_QUEUE \ | 143 | #define AMDKFD_IOC_DESTROY_QUEUE \ |
140 | _IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args) | 144 | AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args) |
141 | 145 | ||
142 | #define KFD_IOC_SET_MEMORY_POLICY \ | 146 | #define AMDKFD_IOC_SET_MEMORY_POLICY \ |
143 | _IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args) | 147 | AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args) |
144 | 148 | ||
145 | #define KFD_IOC_GET_CLOCK_COUNTERS \ | 149 | #define AMDKFD_IOC_GET_CLOCK_COUNTERS \ |
146 | _IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args) | 150 | AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args) |
147 | 151 | ||
148 | #define KFD_IOC_GET_PROCESS_APERTURES \ | 152 | #define AMDKFD_IOC_GET_PROCESS_APERTURES \ |
149 | _IOR(KFD_IOC_MAGIC, 6, struct kfd_ioctl_get_process_apertures_args) | 153 | AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args) |
150 | 154 | ||
151 | #define KFD_IOC_UPDATE_QUEUE \ | 155 | #define AMDKFD_IOC_UPDATE_QUEUE \ |
152 | _IOW(KFD_IOC_MAGIC, 7, struct kfd_ioctl_update_queue_args) | 156 | AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args) |
157 | |||
158 | #define AMDKFD_COMMAND_START 0x01 | ||
159 | #define AMDKFD_COMMAND_END 0x08 | ||
153 | 160 | ||
154 | #endif | 161 | #endif |
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 1adf62b39b96..07ce18ca71e0 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c | |||
@@ -27,6 +27,9 @@ | |||
27 | * version 2. This program is licensed "as is" without any warranty of any | 27 | * version 2. This program is licensed "as is" without any warranty of any |
28 | * kind, whether express or implied. | 28 | * kind, whether express or implied. |
29 | */ | 29 | */ |
30 | |||
31 | #define pr_fmt(fmt) "KGDB: " fmt | ||
32 | |||
30 | #include <linux/pid_namespace.h> | 33 | #include <linux/pid_namespace.h> |
31 | #include <linux/clocksource.h> | 34 | #include <linux/clocksource.h> |
32 | #include <linux/serial_core.h> | 35 | #include <linux/serial_core.h> |
@@ -196,8 +199,8 @@ int __weak kgdb_validate_break_address(unsigned long addr) | |||
196 | return err; | 199 | return err; |
197 | err = kgdb_arch_remove_breakpoint(&tmp); | 200 | err = kgdb_arch_remove_breakpoint(&tmp); |
198 | if (err) | 201 | if (err) |
199 | printk(KERN_ERR "KGDB: Critical breakpoint error, kernel " | 202 | pr_err("Critical breakpoint error, kernel memory destroyed at: %lx\n", |
200 | "memory destroyed at: %lx", addr); | 203 | addr); |
201 | return err; | 204 | return err; |
202 | } | 205 | } |
203 | 206 | ||
@@ -256,8 +259,8 @@ int dbg_activate_sw_breakpoints(void) | |||
256 | error = kgdb_arch_set_breakpoint(&kgdb_break[i]); | 259 | error = kgdb_arch_set_breakpoint(&kgdb_break[i]); |
257 | if (error) { | 260 | if (error) { |
258 | ret = error; | 261 | ret = error; |
259 | printk(KERN_INFO "KGDB: BP install failed: %lx", | 262 | pr_info("BP install failed: %lx\n", |
260 | kgdb_break[i].bpt_addr); | 263 | kgdb_break[i].bpt_addr); |
261 | continue; | 264 | continue; |
262 | } | 265 | } |
263 | 266 | ||
@@ -319,8 +322,8 @@ int dbg_deactivate_sw_breakpoints(void) | |||
319 | continue; | 322 | continue; |
320 | error = kgdb_arch_remove_breakpoint(&kgdb_break[i]); | 323 | error = kgdb_arch_remove_breakpoint(&kgdb_break[i]); |
321 | if (error) { | 324 | if (error) { |
322 | printk(KERN_INFO "KGDB: BP remove failed: %lx\n", | 325 | pr_info("BP remove failed: %lx\n", |
323 | kgdb_break[i].bpt_addr); | 326 | kgdb_break[i].bpt_addr); |
324 | ret = error; | 327 | ret = error; |
325 | } | 328 | } |
326 | 329 | ||
@@ -367,7 +370,7 @@ int dbg_remove_all_break(void) | |||
367 | goto setundefined; | 370 | goto setundefined; |
368 | error = kgdb_arch_remove_breakpoint(&kgdb_break[i]); | 371 | error = kgdb_arch_remove_breakpoint(&kgdb_break[i]); |
369 | if (error) | 372 | if (error) |
370 | printk(KERN_ERR "KGDB: breakpoint remove failed: %lx\n", | 373 | pr_err("breakpoint remove failed: %lx\n", |
371 | kgdb_break[i].bpt_addr); | 374 | kgdb_break[i].bpt_addr); |
372 | setundefined: | 375 | setundefined: |
373 | kgdb_break[i].state = BP_UNDEFINED; | 376 | kgdb_break[i].state = BP_UNDEFINED; |
@@ -400,9 +403,9 @@ static int kgdb_io_ready(int print_wait) | |||
400 | if (print_wait) { | 403 | if (print_wait) { |
401 | #ifdef CONFIG_KGDB_KDB | 404 | #ifdef CONFIG_KGDB_KDB |
402 | if (!dbg_kdb_mode) | 405 | if (!dbg_kdb_mode) |
403 | printk(KERN_CRIT "KGDB: waiting... or $3#33 for KDB\n"); | 406 | pr_crit("waiting... or $3#33 for KDB\n"); |
404 | #else | 407 | #else |
405 | printk(KERN_CRIT "KGDB: Waiting for remote debugger\n"); | 408 | pr_crit("Waiting for remote debugger\n"); |
406 | #endif | 409 | #endif |
407 | } | 410 | } |
408 | return 1; | 411 | return 1; |
@@ -430,8 +433,7 @@ static int kgdb_reenter_check(struct kgdb_state *ks) | |||
430 | exception_level = 0; | 433 | exception_level = 0; |
431 | kgdb_skipexception(ks->ex_vector, ks->linux_regs); | 434 | kgdb_skipexception(ks->ex_vector, ks->linux_regs); |
432 | dbg_activate_sw_breakpoints(); | 435 | dbg_activate_sw_breakpoints(); |
433 | printk(KERN_CRIT "KGDB: re-enter error: breakpoint removed %lx\n", | 436 | pr_crit("re-enter error: breakpoint removed %lx\n", addr); |
434 | addr); | ||
435 | WARN_ON_ONCE(1); | 437 | WARN_ON_ONCE(1); |
436 | 438 | ||
437 | return 1; | 439 | return 1; |
@@ -444,7 +446,7 @@ static int kgdb_reenter_check(struct kgdb_state *ks) | |||
444 | panic("Recursive entry to debugger"); | 446 | panic("Recursive entry to debugger"); |
445 | } | 447 | } |
446 | 448 | ||
447 | printk(KERN_CRIT "KGDB: re-enter exception: ALL breakpoints killed\n"); | 449 | pr_crit("re-enter exception: ALL breakpoints killed\n"); |
448 | #ifdef CONFIG_KGDB_KDB | 450 | #ifdef CONFIG_KGDB_KDB |
449 | /* Allow kdb to debug itself one level */ | 451 | /* Allow kdb to debug itself one level */ |
450 | return 0; | 452 | return 0; |
@@ -471,6 +473,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs, | |||
471 | int cpu; | 473 | int cpu; |
472 | int trace_on = 0; | 474 | int trace_on = 0; |
473 | int online_cpus = num_online_cpus(); | 475 | int online_cpus = num_online_cpus(); |
476 | u64 time_left; | ||
474 | 477 | ||
475 | kgdb_info[ks->cpu].enter_kgdb++; | 478 | kgdb_info[ks->cpu].enter_kgdb++; |
476 | kgdb_info[ks->cpu].exception_state |= exception_state; | 479 | kgdb_info[ks->cpu].exception_state |= exception_state; |
@@ -595,9 +598,13 @@ return_normal: | |||
595 | /* | 598 | /* |
596 | * Wait for the other CPUs to be notified and be waiting for us: | 599 | * Wait for the other CPUs to be notified and be waiting for us: |
597 | */ | 600 | */ |
598 | while (kgdb_do_roundup && (atomic_read(&masters_in_kgdb) + | 601 | time_left = loops_per_jiffy * HZ; |
599 | atomic_read(&slaves_in_kgdb)) != online_cpus) | 602 | while (kgdb_do_roundup && --time_left && |
603 | (atomic_read(&masters_in_kgdb) + atomic_read(&slaves_in_kgdb)) != | ||
604 | online_cpus) | ||
600 | cpu_relax(); | 605 | cpu_relax(); |
606 | if (!time_left) | ||
607 | pr_crit("KGDB: Timed out waiting for secondary CPUs.\n"); | ||
601 | 608 | ||
602 | /* | 609 | /* |
603 | * At this point the primary processor is completely | 610 | * At this point the primary processor is completely |
@@ -795,15 +802,15 @@ static struct console kgdbcons = { | |||
795 | static void sysrq_handle_dbg(int key) | 802 | static void sysrq_handle_dbg(int key) |
796 | { | 803 | { |
797 | if (!dbg_io_ops) { | 804 | if (!dbg_io_ops) { |
798 | printk(KERN_CRIT "ERROR: No KGDB I/O module available\n"); | 805 | pr_crit("ERROR: No KGDB I/O module available\n"); |
799 | return; | 806 | return; |
800 | } | 807 | } |
801 | if (!kgdb_connected) { | 808 | if (!kgdb_connected) { |
802 | #ifdef CONFIG_KGDB_KDB | 809 | #ifdef CONFIG_KGDB_KDB |
803 | if (!dbg_kdb_mode) | 810 | if (!dbg_kdb_mode) |
804 | printk(KERN_CRIT "KGDB or $3#33 for KDB\n"); | 811 | pr_crit("KGDB or $3#33 for KDB\n"); |
805 | #else | 812 | #else |
806 | printk(KERN_CRIT "Entering KGDB\n"); | 813 | pr_crit("Entering KGDB\n"); |
807 | #endif | 814 | #endif |
808 | } | 815 | } |
809 | 816 | ||
@@ -945,7 +952,7 @@ static void kgdb_initial_breakpoint(void) | |||
945 | { | 952 | { |
946 | kgdb_break_asap = 0; | 953 | kgdb_break_asap = 0; |
947 | 954 | ||
948 | printk(KERN_CRIT "kgdb: Waiting for connection from remote gdb...\n"); | 955 | pr_crit("Waiting for connection from remote gdb...\n"); |
949 | kgdb_breakpoint(); | 956 | kgdb_breakpoint(); |
950 | } | 957 | } |
951 | 958 | ||
@@ -964,8 +971,7 @@ int kgdb_register_io_module(struct kgdb_io *new_dbg_io_ops) | |||
964 | if (dbg_io_ops) { | 971 | if (dbg_io_ops) { |
965 | spin_unlock(&kgdb_registration_lock); | 972 | spin_unlock(&kgdb_registration_lock); |
966 | 973 | ||
967 | printk(KERN_ERR "kgdb: Another I/O driver is already " | 974 | pr_err("Another I/O driver is already registered with KGDB\n"); |
968 | "registered with KGDB.\n"); | ||
969 | return -EBUSY; | 975 | return -EBUSY; |
970 | } | 976 | } |
971 | 977 | ||
@@ -981,8 +987,7 @@ int kgdb_register_io_module(struct kgdb_io *new_dbg_io_ops) | |||
981 | 987 | ||
982 | spin_unlock(&kgdb_registration_lock); | 988 | spin_unlock(&kgdb_registration_lock); |
983 | 989 | ||
984 | printk(KERN_INFO "kgdb: Registered I/O driver %s.\n", | 990 | pr_info("Registered I/O driver %s\n", new_dbg_io_ops->name); |
985 | new_dbg_io_ops->name); | ||
986 | 991 | ||
987 | /* Arm KGDB now. */ | 992 | /* Arm KGDB now. */ |
988 | kgdb_register_callbacks(); | 993 | kgdb_register_callbacks(); |
@@ -1017,8 +1022,7 @@ void kgdb_unregister_io_module(struct kgdb_io *old_dbg_io_ops) | |||
1017 | 1022 | ||
1018 | spin_unlock(&kgdb_registration_lock); | 1023 | spin_unlock(&kgdb_registration_lock); |
1019 | 1024 | ||
1020 | printk(KERN_INFO | 1025 | pr_info("Unregistered I/O driver %s, debugger disabled\n", |
1021 | "kgdb: Unregistered I/O driver %s, debugger disabled.\n", | ||
1022 | old_dbg_io_ops->name); | 1026 | old_dbg_io_ops->name); |
1023 | } | 1027 | } |
1024 | EXPORT_SYMBOL_GPL(kgdb_unregister_io_module); | 1028 | EXPORT_SYMBOL_GPL(kgdb_unregister_io_module); |
diff --git a/kernel/debug/kdb/kdb_bp.c b/kernel/debug/kdb/kdb_bp.c index b20d544f20c2..e1dbf4a2c69e 100644 --- a/kernel/debug/kdb/kdb_bp.c +++ b/kernel/debug/kdb/kdb_bp.c | |||
@@ -531,22 +531,29 @@ void __init kdb_initbptab(void) | |||
531 | for (i = 0, bp = kdb_breakpoints; i < KDB_MAXBPT; i++, bp++) | 531 | for (i = 0, bp = kdb_breakpoints; i < KDB_MAXBPT; i++, bp++) |
532 | bp->bp_free = 1; | 532 | bp->bp_free = 1; |
533 | 533 | ||
534 | kdb_register_repeat("bp", kdb_bp, "[<vaddr>]", | 534 | kdb_register_flags("bp", kdb_bp, "[<vaddr>]", |
535 | "Set/Display breakpoints", 0, KDB_REPEAT_NO_ARGS); | 535 | "Set/Display breakpoints", 0, |
536 | kdb_register_repeat("bl", kdb_bp, "[<vaddr>]", | 536 | KDB_ENABLE_FLOW_CTRL | KDB_REPEAT_NO_ARGS); |
537 | "Display breakpoints", 0, KDB_REPEAT_NO_ARGS); | 537 | kdb_register_flags("bl", kdb_bp, "[<vaddr>]", |
538 | "Display breakpoints", 0, | ||
539 | KDB_ENABLE_FLOW_CTRL | KDB_REPEAT_NO_ARGS); | ||
538 | if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) | 540 | if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) |
539 | kdb_register_repeat("bph", kdb_bp, "[<vaddr>]", | 541 | kdb_register_flags("bph", kdb_bp, "[<vaddr>]", |
540 | "[datar [length]|dataw [length]] Set hw brk", 0, KDB_REPEAT_NO_ARGS); | 542 | "[datar [length]|dataw [length]] Set hw brk", 0, |
541 | kdb_register_repeat("bc", kdb_bc, "<bpnum>", | 543 | KDB_ENABLE_FLOW_CTRL | KDB_REPEAT_NO_ARGS); |
542 | "Clear Breakpoint", 0, KDB_REPEAT_NONE); | 544 | kdb_register_flags("bc", kdb_bc, "<bpnum>", |
543 | kdb_register_repeat("be", kdb_bc, "<bpnum>", | 545 | "Clear Breakpoint", 0, |
544 | "Enable Breakpoint", 0, KDB_REPEAT_NONE); | 546 | KDB_ENABLE_FLOW_CTRL); |
545 | kdb_register_repeat("bd", kdb_bc, "<bpnum>", | 547 | kdb_register_flags("be", kdb_bc, "<bpnum>", |
546 | "Disable Breakpoint", 0, KDB_REPEAT_NONE); | 548 | "Enable Breakpoint", 0, |
547 | 549 | KDB_ENABLE_FLOW_CTRL); | |
548 | kdb_register_repeat("ss", kdb_ss, "", | 550 | kdb_register_flags("bd", kdb_bc, "<bpnum>", |
549 | "Single Step", 1, KDB_REPEAT_NO_ARGS); | 551 | "Disable Breakpoint", 0, |
552 | KDB_ENABLE_FLOW_CTRL); | ||
553 | |||
554 | kdb_register_flags("ss", kdb_ss, "", | ||
555 | "Single Step", 1, | ||
556 | KDB_ENABLE_FLOW_CTRL | KDB_REPEAT_NO_ARGS); | ||
550 | /* | 557 | /* |
551 | * Architecture dependent initialization. | 558 | * Architecture dependent initialization. |
552 | */ | 559 | */ |
diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c index 8859ca34dcfe..15e1a7af5dd0 100644 --- a/kernel/debug/kdb/kdb_debugger.c +++ b/kernel/debug/kdb/kdb_debugger.c | |||
@@ -129,6 +129,10 @@ int kdb_stub(struct kgdb_state *ks) | |||
129 | ks->pass_exception = 1; | 129 | ks->pass_exception = 1; |
130 | KDB_FLAG_SET(CATASTROPHIC); | 130 | KDB_FLAG_SET(CATASTROPHIC); |
131 | } | 131 | } |
132 | /* set CATASTROPHIC if the system contains unresponsive processors */ | ||
133 | for_each_online_cpu(i) | ||
134 | if (!kgdb_info[i].enter_kgdb) | ||
135 | KDB_FLAG_SET(CATASTROPHIC); | ||
132 | if (KDB_STATE(SSBPT) && reason == KDB_REASON_SSTEP) { | 136 | if (KDB_STATE(SSBPT) && reason == KDB_REASON_SSTEP) { |
133 | KDB_STATE_CLEAR(SSBPT); | 137 | KDB_STATE_CLEAR(SSBPT); |
134 | KDB_STATE_CLEAR(DOING_SS); | 138 | KDB_STATE_CLEAR(DOING_SS); |
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 379650b984f8..f191bddf64b8 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c | |||
@@ -12,6 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/ctype.h> | 14 | #include <linux/ctype.h> |
15 | #include <linux/types.h> | ||
15 | #include <linux/string.h> | 16 | #include <linux/string.h> |
16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
17 | #include <linux/kmsg_dump.h> | 18 | #include <linux/kmsg_dump.h> |
@@ -23,6 +24,7 @@ | |||
23 | #include <linux/vmalloc.h> | 24 | #include <linux/vmalloc.h> |
24 | #include <linux/atomic.h> | 25 | #include <linux/atomic.h> |
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/moduleparam.h> | ||
26 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
27 | #include <linux/init.h> | 29 | #include <linux/init.h> |
28 | #include <linux/kallsyms.h> | 30 | #include <linux/kallsyms.h> |
@@ -42,6 +44,12 @@ | |||
42 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
43 | #include "kdb_private.h" | 45 | #include "kdb_private.h" |
44 | 46 | ||
47 | #undef MODULE_PARAM_PREFIX | ||
48 | #define MODULE_PARAM_PREFIX "kdb." | ||
49 | |||
50 | static int kdb_cmd_enabled = CONFIG_KDB_DEFAULT_ENABLE; | ||
51 | module_param_named(cmd_enable, kdb_cmd_enabled, int, 0600); | ||
52 | |||
45 | #define GREP_LEN 256 | 53 | #define GREP_LEN 256 |
46 | char kdb_grep_string[GREP_LEN]; | 54 | char kdb_grep_string[GREP_LEN]; |
47 | int kdb_grepping_flag; | 55 | int kdb_grepping_flag; |
@@ -121,6 +129,7 @@ static kdbmsg_t kdbmsgs[] = { | |||
121 | KDBMSG(BADLENGTH, "Invalid length field"), | 129 | KDBMSG(BADLENGTH, "Invalid length field"), |
122 | KDBMSG(NOBP, "No Breakpoint exists"), | 130 | KDBMSG(NOBP, "No Breakpoint exists"), |
123 | KDBMSG(BADADDR, "Invalid address"), | 131 | KDBMSG(BADADDR, "Invalid address"), |
132 | KDBMSG(NOPERM, "Permission denied"), | ||
124 | }; | 133 | }; |
125 | #undef KDBMSG | 134 | #undef KDBMSG |
126 | 135 | ||
@@ -188,6 +197,26 @@ struct task_struct *kdb_curr_task(int cpu) | |||
188 | } | 197 | } |
189 | 198 | ||
190 | /* | 199 | /* |
200 | * Check whether the flags of the current command and the permissions | ||
201 | * of the kdb console has allow a command to be run. | ||
202 | */ | ||
203 | static inline bool kdb_check_flags(kdb_cmdflags_t flags, int permissions, | ||
204 | bool no_args) | ||
205 | { | ||
206 | /* permissions comes from userspace so needs massaging slightly */ | ||
207 | permissions &= KDB_ENABLE_MASK; | ||
208 | permissions |= KDB_ENABLE_ALWAYS_SAFE; | ||
209 | |||
210 | /* some commands change group when launched with no arguments */ | ||
211 | if (no_args) | ||
212 | permissions |= permissions << KDB_ENABLE_NO_ARGS_SHIFT; | ||
213 | |||
214 | flags |= KDB_ENABLE_ALL; | ||
215 | |||
216 | return permissions & flags; | ||
217 | } | ||
218 | |||
219 | /* | ||
191 | * kdbgetenv - This function will return the character string value of | 220 | * kdbgetenv - This function will return the character string value of |
192 | * an environment variable. | 221 | * an environment variable. |
193 | * Parameters: | 222 | * Parameters: |
@@ -476,6 +505,15 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg, | |||
476 | kdb_symtab_t symtab; | 505 | kdb_symtab_t symtab; |
477 | 506 | ||
478 | /* | 507 | /* |
508 | * If the enable flags prohibit both arbitrary memory access | ||
509 | * and flow control then there are no reasonable grounds to | ||
510 | * provide symbol lookup. | ||
511 | */ | ||
512 | if (!kdb_check_flags(KDB_ENABLE_MEM_READ | KDB_ENABLE_FLOW_CTRL, | ||
513 | kdb_cmd_enabled, false)) | ||
514 | return KDB_NOPERM; | ||
515 | |||
516 | /* | ||
479 | * Process arguments which follow the following syntax: | 517 | * Process arguments which follow the following syntax: |
480 | * | 518 | * |
481 | * symbol | numeric-address [+/- numeric-offset] | 519 | * symbol | numeric-address [+/- numeric-offset] |
@@ -641,8 +679,13 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0) | |||
641 | if (!s->count) | 679 | if (!s->count) |
642 | s->usable = 0; | 680 | s->usable = 0; |
643 | if (s->usable) | 681 | if (s->usable) |
644 | kdb_register(s->name, kdb_exec_defcmd, | 682 | /* macros are always safe because when executed each |
645 | s->usage, s->help, 0); | 683 | * internal command re-enters kdb_parse() and is |
684 | * safety checked individually. | ||
685 | */ | ||
686 | kdb_register_flags(s->name, kdb_exec_defcmd, s->usage, | ||
687 | s->help, 0, | ||
688 | KDB_ENABLE_ALWAYS_SAFE); | ||
646 | return 0; | 689 | return 0; |
647 | } | 690 | } |
648 | if (!s->usable) | 691 | if (!s->usable) |
@@ -1003,25 +1046,22 @@ int kdb_parse(const char *cmdstr) | |||
1003 | 1046 | ||
1004 | if (i < kdb_max_commands) { | 1047 | if (i < kdb_max_commands) { |
1005 | int result; | 1048 | int result; |
1049 | |||
1050 | if (!kdb_check_flags(tp->cmd_flags, kdb_cmd_enabled, argc <= 1)) | ||
1051 | return KDB_NOPERM; | ||
1052 | |||
1006 | KDB_STATE_SET(CMD); | 1053 | KDB_STATE_SET(CMD); |
1007 | result = (*tp->cmd_func)(argc-1, (const char **)argv); | 1054 | result = (*tp->cmd_func)(argc-1, (const char **)argv); |
1008 | if (result && ignore_errors && result > KDB_CMD_GO) | 1055 | if (result && ignore_errors && result > KDB_CMD_GO) |
1009 | result = 0; | 1056 | result = 0; |
1010 | KDB_STATE_CLEAR(CMD); | 1057 | KDB_STATE_CLEAR(CMD); |
1011 | switch (tp->cmd_repeat) { | 1058 | |
1012 | case KDB_REPEAT_NONE: | 1059 | if (tp->cmd_flags & KDB_REPEAT_WITH_ARGS) |
1013 | argc = 0; | 1060 | return result; |
1014 | if (argv[0]) | 1061 | |
1015 | *(argv[0]) = '\0'; | 1062 | argc = tp->cmd_flags & KDB_REPEAT_NO_ARGS ? 1 : 0; |
1016 | break; | 1063 | if (argv[argc]) |
1017 | case KDB_REPEAT_NO_ARGS: | 1064 | *(argv[argc]) = '\0'; |
1018 | argc = 1; | ||
1019 | if (argv[1]) | ||
1020 | *(argv[1]) = '\0'; | ||
1021 | break; | ||
1022 | case KDB_REPEAT_WITH_ARGS: | ||
1023 | break; | ||
1024 | } | ||
1025 | return result; | 1065 | return result; |
1026 | } | 1066 | } |
1027 | 1067 | ||
@@ -1921,10 +1961,14 @@ static int kdb_rm(int argc, const char **argv) | |||
1921 | */ | 1961 | */ |
1922 | static int kdb_sr(int argc, const char **argv) | 1962 | static int kdb_sr(int argc, const char **argv) |
1923 | { | 1963 | { |
1964 | bool check_mask = | ||
1965 | !kdb_check_flags(KDB_ENABLE_ALL, kdb_cmd_enabled, false); | ||
1966 | |||
1924 | if (argc != 1) | 1967 | if (argc != 1) |
1925 | return KDB_ARGCOUNT; | 1968 | return KDB_ARGCOUNT; |
1969 | |||
1926 | kdb_trap_printk++; | 1970 | kdb_trap_printk++; |
1927 | __handle_sysrq(*argv[1], false); | 1971 | __handle_sysrq(*argv[1], check_mask); |
1928 | kdb_trap_printk--; | 1972 | kdb_trap_printk--; |
1929 | 1973 | ||
1930 | return 0; | 1974 | return 0; |
@@ -2157,6 +2201,8 @@ static void kdb_cpu_status(void) | |||
2157 | for (start_cpu = -1, i = 0; i < NR_CPUS; i++) { | 2201 | for (start_cpu = -1, i = 0; i < NR_CPUS; i++) { |
2158 | if (!cpu_online(i)) { | 2202 | if (!cpu_online(i)) { |
2159 | state = 'F'; /* cpu is offline */ | 2203 | state = 'F'; /* cpu is offline */ |
2204 | } else if (!kgdb_info[i].enter_kgdb) { | ||
2205 | state = 'D'; /* cpu is online but unresponsive */ | ||
2160 | } else { | 2206 | } else { |
2161 | state = ' '; /* cpu is responding to kdb */ | 2207 | state = ' '; /* cpu is responding to kdb */ |
2162 | if (kdb_task_state_char(KDB_TSK(i)) == 'I') | 2208 | if (kdb_task_state_char(KDB_TSK(i)) == 'I') |
@@ -2210,7 +2256,7 @@ static int kdb_cpu(int argc, const char **argv) | |||
2210 | /* | 2256 | /* |
2211 | * Validate cpunum | 2257 | * Validate cpunum |
2212 | */ | 2258 | */ |
2213 | if ((cpunum > NR_CPUS) || !cpu_online(cpunum)) | 2259 | if ((cpunum > NR_CPUS) || !kgdb_info[cpunum].enter_kgdb) |
2214 | return KDB_BADCPUNUM; | 2260 | return KDB_BADCPUNUM; |
2215 | 2261 | ||
2216 | dbg_switch_cpu = cpunum; | 2262 | dbg_switch_cpu = cpunum; |
@@ -2375,6 +2421,8 @@ static int kdb_help(int argc, const char **argv) | |||
2375 | return 0; | 2421 | return 0; |
2376 | if (!kt->cmd_name) | 2422 | if (!kt->cmd_name) |
2377 | continue; | 2423 | continue; |
2424 | if (!kdb_check_flags(kt->cmd_flags, kdb_cmd_enabled, true)) | ||
2425 | continue; | ||
2378 | if (strlen(kt->cmd_usage) > 20) | 2426 | if (strlen(kt->cmd_usage) > 20) |
2379 | space = "\n "; | 2427 | space = "\n "; |
2380 | kdb_printf("%-15.15s %-20s%s%s\n", kt->cmd_name, | 2428 | kdb_printf("%-15.15s %-20s%s%s\n", kt->cmd_name, |
@@ -2629,7 +2677,7 @@ static int kdb_grep_help(int argc, const char **argv) | |||
2629 | } | 2677 | } |
2630 | 2678 | ||
2631 | /* | 2679 | /* |
2632 | * kdb_register_repeat - This function is used to register a kernel | 2680 | * kdb_register_flags - This function is used to register a kernel |
2633 | * debugger command. | 2681 | * debugger command. |
2634 | * Inputs: | 2682 | * Inputs: |
2635 | * cmd Command name | 2683 | * cmd Command name |
@@ -2641,12 +2689,12 @@ static int kdb_grep_help(int argc, const char **argv) | |||
2641 | * zero for success, one if a duplicate command. | 2689 | * zero for success, one if a duplicate command. |
2642 | */ | 2690 | */ |
2643 | #define kdb_command_extend 50 /* arbitrary */ | 2691 | #define kdb_command_extend 50 /* arbitrary */ |
2644 | int kdb_register_repeat(char *cmd, | 2692 | int kdb_register_flags(char *cmd, |
2645 | kdb_func_t func, | 2693 | kdb_func_t func, |
2646 | char *usage, | 2694 | char *usage, |
2647 | char *help, | 2695 | char *help, |
2648 | short minlen, | 2696 | short minlen, |
2649 | kdb_repeat_t repeat) | 2697 | kdb_cmdflags_t flags) |
2650 | { | 2698 | { |
2651 | int i; | 2699 | int i; |
2652 | kdbtab_t *kp; | 2700 | kdbtab_t *kp; |
@@ -2694,19 +2742,18 @@ int kdb_register_repeat(char *cmd, | |||
2694 | kp->cmd_func = func; | 2742 | kp->cmd_func = func; |
2695 | kp->cmd_usage = usage; | 2743 | kp->cmd_usage = usage; |
2696 | kp->cmd_help = help; | 2744 | kp->cmd_help = help; |
2697 | kp->cmd_flags = 0; | ||
2698 | kp->cmd_minlen = minlen; | 2745 | kp->cmd_minlen = minlen; |
2699 | kp->cmd_repeat = repeat; | 2746 | kp->cmd_flags = flags; |
2700 | 2747 | ||
2701 | return 0; | 2748 | return 0; |
2702 | } | 2749 | } |
2703 | EXPORT_SYMBOL_GPL(kdb_register_repeat); | 2750 | EXPORT_SYMBOL_GPL(kdb_register_flags); |
2704 | 2751 | ||
2705 | 2752 | ||
2706 | /* | 2753 | /* |
2707 | * kdb_register - Compatibility register function for commands that do | 2754 | * kdb_register - Compatibility register function for commands that do |
2708 | * not need to specify a repeat state. Equivalent to | 2755 | * not need to specify a repeat state. Equivalent to |
2709 | * kdb_register_repeat with KDB_REPEAT_NONE. | 2756 | * kdb_register_flags with flags set to 0. |
2710 | * Inputs: | 2757 | * Inputs: |
2711 | * cmd Command name | 2758 | * cmd Command name |
2712 | * func Function to execute the command | 2759 | * func Function to execute the command |
@@ -2721,8 +2768,7 @@ int kdb_register(char *cmd, | |||
2721 | char *help, | 2768 | char *help, |
2722 | short minlen) | 2769 | short minlen) |
2723 | { | 2770 | { |
2724 | return kdb_register_repeat(cmd, func, usage, help, minlen, | 2771 | return kdb_register_flags(cmd, func, usage, help, minlen, 0); |
2725 | KDB_REPEAT_NONE); | ||
2726 | } | 2772 | } |
2727 | EXPORT_SYMBOL_GPL(kdb_register); | 2773 | EXPORT_SYMBOL_GPL(kdb_register); |
2728 | 2774 | ||
@@ -2764,80 +2810,109 @@ static void __init kdb_inittab(void) | |||
2764 | for_each_kdbcmd(kp, i) | 2810 | for_each_kdbcmd(kp, i) |
2765 | kp->cmd_name = NULL; | 2811 | kp->cmd_name = NULL; |
2766 | 2812 | ||
2767 | kdb_register_repeat("md", kdb_md, "<vaddr>", | 2813 | kdb_register_flags("md", kdb_md, "<vaddr>", |
2768 | "Display Memory Contents, also mdWcN, e.g. md8c1", 1, | 2814 | "Display Memory Contents, also mdWcN, e.g. md8c1", 1, |
2769 | KDB_REPEAT_NO_ARGS); | 2815 | KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS); |
2770 | kdb_register_repeat("mdr", kdb_md, "<vaddr> <bytes>", | 2816 | kdb_register_flags("mdr", kdb_md, "<vaddr> <bytes>", |
2771 | "Display Raw Memory", 0, KDB_REPEAT_NO_ARGS); | 2817 | "Display Raw Memory", 0, |
2772 | kdb_register_repeat("mdp", kdb_md, "<paddr> <bytes>", | 2818 | KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS); |
2773 | "Display Physical Memory", 0, KDB_REPEAT_NO_ARGS); | 2819 | kdb_register_flags("mdp", kdb_md, "<paddr> <bytes>", |
2774 | kdb_register_repeat("mds", kdb_md, "<vaddr>", | 2820 | "Display Physical Memory", 0, |
2775 | "Display Memory Symbolically", 0, KDB_REPEAT_NO_ARGS); | 2821 | KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS); |
2776 | kdb_register_repeat("mm", kdb_mm, "<vaddr> <contents>", | 2822 | kdb_register_flags("mds", kdb_md, "<vaddr>", |
2777 | "Modify Memory Contents", 0, KDB_REPEAT_NO_ARGS); | 2823 | "Display Memory Symbolically", 0, |
2778 | kdb_register_repeat("go", kdb_go, "[<vaddr>]", | 2824 | KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS); |
2779 | "Continue Execution", 1, KDB_REPEAT_NONE); | 2825 | kdb_register_flags("mm", kdb_mm, "<vaddr> <contents>", |
2780 | kdb_register_repeat("rd", kdb_rd, "", | 2826 | "Modify Memory Contents", 0, |
2781 | "Display Registers", 0, KDB_REPEAT_NONE); | 2827 | KDB_ENABLE_MEM_WRITE | KDB_REPEAT_NO_ARGS); |
2782 | kdb_register_repeat("rm", kdb_rm, "<reg> <contents>", | 2828 | kdb_register_flags("go", kdb_go, "[<vaddr>]", |
2783 | "Modify Registers", 0, KDB_REPEAT_NONE); | 2829 | "Continue Execution", 1, |
2784 | kdb_register_repeat("ef", kdb_ef, "<vaddr>", | 2830 | KDB_ENABLE_REG_WRITE | KDB_ENABLE_ALWAYS_SAFE_NO_ARGS); |
2785 | "Display exception frame", 0, KDB_REPEAT_NONE); | 2831 | kdb_register_flags("rd", kdb_rd, "", |
2786 | kdb_register_repeat("bt", kdb_bt, "[<vaddr>]", | 2832 | "Display Registers", 0, |
2787 | "Stack traceback", 1, KDB_REPEAT_NONE); | 2833 | KDB_ENABLE_REG_READ); |
2788 | kdb_register_repeat("btp", kdb_bt, "<pid>", | 2834 | kdb_register_flags("rm", kdb_rm, "<reg> <contents>", |
2789 | "Display stack for process <pid>", 0, KDB_REPEAT_NONE); | 2835 | "Modify Registers", 0, |
2790 | kdb_register_repeat("bta", kdb_bt, "[D|R|S|T|C|Z|E|U|I|M|A]", | 2836 | KDB_ENABLE_REG_WRITE); |
2791 | "Backtrace all processes matching state flag", 0, KDB_REPEAT_NONE); | 2837 | kdb_register_flags("ef", kdb_ef, "<vaddr>", |
2792 | kdb_register_repeat("btc", kdb_bt, "", | 2838 | "Display exception frame", 0, |
2793 | "Backtrace current process on each cpu", 0, KDB_REPEAT_NONE); | 2839 | KDB_ENABLE_MEM_READ); |
2794 | kdb_register_repeat("btt", kdb_bt, "<vaddr>", | 2840 | kdb_register_flags("bt", kdb_bt, "[<vaddr>]", |
2841 | "Stack traceback", 1, | ||
2842 | KDB_ENABLE_MEM_READ | KDB_ENABLE_INSPECT_NO_ARGS); | ||
2843 | kdb_register_flags("btp", kdb_bt, "<pid>", | ||
2844 | "Display stack for process <pid>", 0, | ||
2845 | KDB_ENABLE_INSPECT); | ||
2846 | kdb_register_flags("bta", kdb_bt, "[D|R|S|T|C|Z|E|U|I|M|A]", | ||
2847 | "Backtrace all processes matching state flag", 0, | ||
2848 | KDB_ENABLE_INSPECT); | ||
2849 | kdb_register_flags("btc", kdb_bt, "", | ||
2850 | "Backtrace current process on each cpu", 0, | ||
2851 | KDB_ENABLE_INSPECT); | ||
2852 | kdb_register_flags("btt", kdb_bt, "<vaddr>", | ||
2795 | "Backtrace process given its struct task address", 0, | 2853 | "Backtrace process given its struct task address", 0, |
2796 | KDB_REPEAT_NONE); | 2854 | KDB_ENABLE_MEM_READ | KDB_ENABLE_INSPECT_NO_ARGS); |
2797 | kdb_register_repeat("env", kdb_env, "", | 2855 | kdb_register_flags("env", kdb_env, "", |
2798 | "Show environment variables", 0, KDB_REPEAT_NONE); | 2856 | "Show environment variables", 0, |
2799 | kdb_register_repeat("set", kdb_set, "", | 2857 | KDB_ENABLE_ALWAYS_SAFE); |
2800 | "Set environment variables", 0, KDB_REPEAT_NONE); | 2858 | kdb_register_flags("set", kdb_set, "", |
2801 | kdb_register_repeat("help", kdb_help, "", | 2859 | "Set environment variables", 0, |
2802 | "Display Help Message", 1, KDB_REPEAT_NONE); | 2860 | KDB_ENABLE_ALWAYS_SAFE); |
2803 | kdb_register_repeat("?", kdb_help, "", | 2861 | kdb_register_flags("help", kdb_help, "", |
2804 | "Display Help Message", 0, KDB_REPEAT_NONE); | 2862 | "Display Help Message", 1, |
2805 | kdb_register_repeat("cpu", kdb_cpu, "<cpunum>", | 2863 | KDB_ENABLE_ALWAYS_SAFE); |
2806 | "Switch to new cpu", 0, KDB_REPEAT_NONE); | 2864 | kdb_register_flags("?", kdb_help, "", |
2807 | kdb_register_repeat("kgdb", kdb_kgdb, "", | 2865 | "Display Help Message", 0, |
2808 | "Enter kgdb mode", 0, KDB_REPEAT_NONE); | 2866 | KDB_ENABLE_ALWAYS_SAFE); |
2809 | kdb_register_repeat("ps", kdb_ps, "[<flags>|A]", | 2867 | kdb_register_flags("cpu", kdb_cpu, "<cpunum>", |
2810 | "Display active task list", 0, KDB_REPEAT_NONE); | 2868 | "Switch to new cpu", 0, |
2811 | kdb_register_repeat("pid", kdb_pid, "<pidnum>", | 2869 | KDB_ENABLE_ALWAYS_SAFE_NO_ARGS); |
2812 | "Switch to another task", 0, KDB_REPEAT_NONE); | 2870 | kdb_register_flags("kgdb", kdb_kgdb, "", |
2813 | kdb_register_repeat("reboot", kdb_reboot, "", | 2871 | "Enter kgdb mode", 0, 0); |
2814 | "Reboot the machine immediately", 0, KDB_REPEAT_NONE); | 2872 | kdb_register_flags("ps", kdb_ps, "[<flags>|A]", |
2873 | "Display active task list", 0, | ||
2874 | KDB_ENABLE_INSPECT); | ||
2875 | kdb_register_flags("pid", kdb_pid, "<pidnum>", | ||
2876 | "Switch to another task", 0, | ||
2877 | KDB_ENABLE_INSPECT); | ||
2878 | kdb_register_flags("reboot", kdb_reboot, "", | ||
2879 | "Reboot the machine immediately", 0, | ||
2880 | KDB_ENABLE_REBOOT); | ||
2815 | #if defined(CONFIG_MODULES) | 2881 | #if defined(CONFIG_MODULES) |
2816 | kdb_register_repeat("lsmod", kdb_lsmod, "", | 2882 | kdb_register_flags("lsmod", kdb_lsmod, "", |
2817 | "List loaded kernel modules", 0, KDB_REPEAT_NONE); | 2883 | "List loaded kernel modules", 0, |
2884 | KDB_ENABLE_INSPECT); | ||
2818 | #endif | 2885 | #endif |
2819 | #if defined(CONFIG_MAGIC_SYSRQ) | 2886 | #if defined(CONFIG_MAGIC_SYSRQ) |
2820 | kdb_register_repeat("sr", kdb_sr, "<key>", | 2887 | kdb_register_flags("sr", kdb_sr, "<key>", |
2821 | "Magic SysRq key", 0, KDB_REPEAT_NONE); | 2888 | "Magic SysRq key", 0, |
2889 | KDB_ENABLE_ALWAYS_SAFE); | ||
2822 | #endif | 2890 | #endif |
2823 | #if defined(CONFIG_PRINTK) | 2891 | #if defined(CONFIG_PRINTK) |
2824 | kdb_register_repeat("dmesg", kdb_dmesg, "[lines]", | 2892 | kdb_register_flags("dmesg", kdb_dmesg, "[lines]", |
2825 | "Display syslog buffer", 0, KDB_REPEAT_NONE); | 2893 | "Display syslog buffer", 0, |
2894 | KDB_ENABLE_ALWAYS_SAFE); | ||
2826 | #endif | 2895 | #endif |
2827 | if (arch_kgdb_ops.enable_nmi) { | 2896 | if (arch_kgdb_ops.enable_nmi) { |
2828 | kdb_register_repeat("disable_nmi", kdb_disable_nmi, "", | 2897 | kdb_register_flags("disable_nmi", kdb_disable_nmi, "", |
2829 | "Disable NMI entry to KDB", 0, KDB_REPEAT_NONE); | 2898 | "Disable NMI entry to KDB", 0, |
2830 | } | 2899 | KDB_ENABLE_ALWAYS_SAFE); |
2831 | kdb_register_repeat("defcmd", kdb_defcmd, "name \"usage\" \"help\"", | 2900 | } |
2832 | "Define a set of commands, down to endefcmd", 0, KDB_REPEAT_NONE); | 2901 | kdb_register_flags("defcmd", kdb_defcmd, "name \"usage\" \"help\"", |
2833 | kdb_register_repeat("kill", kdb_kill, "<-signal> <pid>", | 2902 | "Define a set of commands, down to endefcmd", 0, |
2834 | "Send a signal to a process", 0, KDB_REPEAT_NONE); | 2903 | KDB_ENABLE_ALWAYS_SAFE); |
2835 | kdb_register_repeat("summary", kdb_summary, "", | 2904 | kdb_register_flags("kill", kdb_kill, "<-signal> <pid>", |
2836 | "Summarize the system", 4, KDB_REPEAT_NONE); | 2905 | "Send a signal to a process", 0, |
2837 | kdb_register_repeat("per_cpu", kdb_per_cpu, "<sym> [<bytes>] [<cpu>]", | 2906 | KDB_ENABLE_SIGNAL); |
2838 | "Display per_cpu variables", 3, KDB_REPEAT_NONE); | 2907 | kdb_register_flags("summary", kdb_summary, "", |
2839 | kdb_register_repeat("grephelp", kdb_grep_help, "", | 2908 | "Summarize the system", 4, |
2840 | "Display help on | grep", 0, KDB_REPEAT_NONE); | 2909 | KDB_ENABLE_ALWAYS_SAFE); |
2910 | kdb_register_flags("per_cpu", kdb_per_cpu, "<sym> [<bytes>] [<cpu>]", | ||
2911 | "Display per_cpu variables", 3, | ||
2912 | KDB_ENABLE_MEM_READ); | ||
2913 | kdb_register_flags("grephelp", kdb_grep_help, "", | ||
2914 | "Display help on | grep", 0, | ||
2915 | KDB_ENABLE_ALWAYS_SAFE); | ||
2841 | } | 2916 | } |
2842 | 2917 | ||
2843 | /* Execute any commands defined in kdb_cmds. */ | 2918 | /* Execute any commands defined in kdb_cmds. */ |
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h index 7afd3c8c41d5..eaacd1693954 100644 --- a/kernel/debug/kdb/kdb_private.h +++ b/kernel/debug/kdb/kdb_private.h | |||
@@ -172,10 +172,9 @@ typedef struct _kdbtab { | |||
172 | kdb_func_t cmd_func; /* Function to execute command */ | 172 | kdb_func_t cmd_func; /* Function to execute command */ |
173 | char *cmd_usage; /* Usage String for this command */ | 173 | char *cmd_usage; /* Usage String for this command */ |
174 | char *cmd_help; /* Help message for this command */ | 174 | char *cmd_help; /* Help message for this command */ |
175 | short cmd_flags; /* Parsing flags */ | ||
176 | short cmd_minlen; /* Minimum legal # command | 175 | short cmd_minlen; /* Minimum legal # command |
177 | * chars required */ | 176 | * chars required */ |
178 | kdb_repeat_t cmd_repeat; /* Does command auto repeat on enter? */ | 177 | kdb_cmdflags_t cmd_flags; /* Command behaviour flags */ |
179 | } kdbtab_t; | 178 | } kdbtab_t; |
180 | 179 | ||
181 | extern int kdb_bt(int, const char **); /* KDB display back trace */ | 180 | extern int kdb_bt(int, const char **); /* KDB display back trace */ |
diff --git a/kernel/exit.c b/kernel/exit.c index 1ea4369890a3..6806c55475ee 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -1287,9 +1287,15 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p) | |||
1287 | static int wait_consider_task(struct wait_opts *wo, int ptrace, | 1287 | static int wait_consider_task(struct wait_opts *wo, int ptrace, |
1288 | struct task_struct *p) | 1288 | struct task_struct *p) |
1289 | { | 1289 | { |
1290 | /* | ||
1291 | * We can race with wait_task_zombie() from another thread. | ||
1292 | * Ensure that EXIT_ZOMBIE -> EXIT_DEAD/EXIT_TRACE transition | ||
1293 | * can't confuse the checks below. | ||
1294 | */ | ||
1295 | int exit_state = ACCESS_ONCE(p->exit_state); | ||
1290 | int ret; | 1296 | int ret; |
1291 | 1297 | ||
1292 | if (unlikely(p->exit_state == EXIT_DEAD)) | 1298 | if (unlikely(exit_state == EXIT_DEAD)) |
1293 | return 0; | 1299 | return 0; |
1294 | 1300 | ||
1295 | ret = eligible_child(wo, p); | 1301 | ret = eligible_child(wo, p); |
@@ -1310,7 +1316,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace, | |||
1310 | return 0; | 1316 | return 0; |
1311 | } | 1317 | } |
1312 | 1318 | ||
1313 | if (unlikely(p->exit_state == EXIT_TRACE)) { | 1319 | if (unlikely(exit_state == EXIT_TRACE)) { |
1314 | /* | 1320 | /* |
1315 | * ptrace == 0 means we are the natural parent. In this case | 1321 | * ptrace == 0 means we are the natural parent. In this case |
1316 | * we should clear notask_error, debugger will notify us. | 1322 | * we should clear notask_error, debugger will notify us. |
@@ -1337,7 +1343,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace, | |||
1337 | } | 1343 | } |
1338 | 1344 | ||
1339 | /* slay zombie? */ | 1345 | /* slay zombie? */ |
1340 | if (p->exit_state == EXIT_ZOMBIE) { | 1346 | if (exit_state == EXIT_ZOMBIE) { |
1341 | /* we don't reap group leaders with subthreads */ | 1347 | /* we don't reap group leaders with subthreads */ |
1342 | if (!delay_group_leader(p)) { | 1348 | if (!delay_group_leader(p)) { |
1343 | /* | 1349 | /* |
diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c index b0b1c44e923a..3ccf5c2c1320 100644 --- a/kernel/trace/trace_kdb.c +++ b/kernel/trace/trace_kdb.c | |||
@@ -132,8 +132,8 @@ static int kdb_ftdump(int argc, const char **argv) | |||
132 | 132 | ||
133 | static __init int kdb_ftrace_register(void) | 133 | static __init int kdb_ftrace_register(void) |
134 | { | 134 | { |
135 | kdb_register_repeat("ftdump", kdb_ftdump, "[skip_#lines] [cpu]", | 135 | kdb_register_flags("ftdump", kdb_ftdump, "[skip_#lines] [cpu]", |
136 | "Dump ftrace log", 0, KDB_REPEAT_NONE); | 136 | "Dump ftrace log", 0, KDB_ENABLE_ALWAYS_SAFE); |
137 | return 0; | 137 | return 0; |
138 | } | 138 | } |
139 | 139 | ||
diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb index 358eb81fa28d..c635a107a7de 100644 --- a/lib/Kconfig.kgdb +++ b/lib/Kconfig.kgdb | |||
@@ -73,6 +73,31 @@ config KGDB_KDB | |||
73 | help | 73 | help |
74 | KDB frontend for kernel | 74 | KDB frontend for kernel |
75 | 75 | ||
76 | config KDB_DEFAULT_ENABLE | ||
77 | hex "KDB: Select kdb command functions to be enabled by default" | ||
78 | depends on KGDB_KDB | ||
79 | default 0x1 | ||
80 | help | ||
81 | Specifiers which kdb commands are enabled by default. This may | ||
82 | be set to 1 or 0 to enable all commands or disable almost all | ||
83 | commands. | ||
84 | |||
85 | Alternatively the following bitmask applies: | ||
86 | |||
87 | 0x0002 - allow arbitrary reads from memory and symbol lookup | ||
88 | 0x0004 - allow arbitrary writes to memory | ||
89 | 0x0008 - allow current register state to be inspected | ||
90 | 0x0010 - allow current register state to be modified | ||
91 | 0x0020 - allow passive inspection (backtrace, process list, lsmod) | ||
92 | 0x0040 - allow flow control management (breakpoint, single step) | ||
93 | 0x0080 - enable signalling of processes | ||
94 | 0x0100 - allow machine to be rebooted | ||
95 | |||
96 | The config option merely sets the default at boot time. Both | ||
97 | issuing 'echo X > /sys/module/kdb/parameters/cmd_enable' or | ||
98 | setting with kdb.cmd_enable=X kernel command line option will | ||
99 | override the default settings. | ||
100 | |||
76 | config KDB_KEYBOARD | 101 | config KDB_KEYBOARD |
77 | bool "KGDB_KDB: keyboard as input device" | 102 | bool "KGDB_KDB: keyboard as input device" |
78 | depends on VT && KGDB_KDB | 103 | depends on VT && KGDB_KDB |
diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index 56badfc4810a..957d3da53ddd 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug | |||
@@ -14,7 +14,6 @@ config DEBUG_PAGEALLOC | |||
14 | depends on !KMEMCHECK | 14 | depends on !KMEMCHECK |
15 | select PAGE_EXTENSION | 15 | select PAGE_EXTENSION |
16 | select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC | 16 | select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC |
17 | select PAGE_GUARD if ARCH_SUPPORTS_DEBUG_PAGEALLOC | ||
18 | ---help--- | 17 | ---help--- |
19 | Unmap pages from the kernel linear mapping after free_pages(). | 18 | Unmap pages from the kernel linear mapping after free_pages(). |
20 | This results in a large slowdown, but helps to find certain types | 19 | This results in a large slowdown, but helps to find certain types |
@@ -27,13 +26,5 @@ config DEBUG_PAGEALLOC | |||
27 | that would result in incorrect warnings of memory corruption after | 26 | that would result in incorrect warnings of memory corruption after |
28 | a resume because free pages are not saved to the suspend image. | 27 | a resume because free pages are not saved to the suspend image. |
29 | 28 | ||
30 | config WANT_PAGE_DEBUG_FLAGS | ||
31 | bool | ||
32 | |||
33 | config PAGE_POISONING | 29 | config PAGE_POISONING |
34 | bool | 30 | bool |
35 | select WANT_PAGE_DEBUG_FLAGS | ||
36 | |||
37 | config PAGE_GUARD | ||
38 | bool | ||
39 | select WANT_PAGE_DEBUG_FLAGS | ||
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ef91e856c7e4..851924fa5170 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -3043,18 +3043,6 @@ static int mem_cgroup_move_swap_account(swp_entry_t entry, | |||
3043 | if (swap_cgroup_cmpxchg(entry, old_id, new_id) == old_id) { | 3043 | if (swap_cgroup_cmpxchg(entry, old_id, new_id) == old_id) { |
3044 | mem_cgroup_swap_statistics(from, false); | 3044 | mem_cgroup_swap_statistics(from, false); |
3045 | mem_cgroup_swap_statistics(to, true); | 3045 | mem_cgroup_swap_statistics(to, true); |
3046 | /* | ||
3047 | * This function is only called from task migration context now. | ||
3048 | * It postpones page_counter and refcount handling till the end | ||
3049 | * of task migration(mem_cgroup_clear_mc()) for performance | ||
3050 | * improvement. But we cannot postpone css_get(to) because if | ||
3051 | * the process that has been moved to @to does swap-in, the | ||
3052 | * refcount of @to might be decreased to 0. | ||
3053 | * | ||
3054 | * We are in attach() phase, so the cgroup is guaranteed to be | ||
3055 | * alive, so we can just call css_get(). | ||
3056 | */ | ||
3057 | css_get(&to->css); | ||
3058 | return 0; | 3046 | return 0; |
3059 | } | 3047 | } |
3060 | return -EINVAL; | 3048 | return -EINVAL; |
@@ -4679,6 +4667,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) | |||
4679 | if (parent_css == NULL) { | 4667 | if (parent_css == NULL) { |
4680 | root_mem_cgroup = memcg; | 4668 | root_mem_cgroup = memcg; |
4681 | page_counter_init(&memcg->memory, NULL); | 4669 | page_counter_init(&memcg->memory, NULL); |
4670 | memcg->soft_limit = PAGE_COUNTER_MAX; | ||
4682 | page_counter_init(&memcg->memsw, NULL); | 4671 | page_counter_init(&memcg->memsw, NULL); |
4683 | page_counter_init(&memcg->kmem, NULL); | 4672 | page_counter_init(&memcg->kmem, NULL); |
4684 | } | 4673 | } |
@@ -4724,6 +4713,7 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css) | |||
4724 | 4713 | ||
4725 | if (parent->use_hierarchy) { | 4714 | if (parent->use_hierarchy) { |
4726 | page_counter_init(&memcg->memory, &parent->memory); | 4715 | page_counter_init(&memcg->memory, &parent->memory); |
4716 | memcg->soft_limit = PAGE_COUNTER_MAX; | ||
4727 | page_counter_init(&memcg->memsw, &parent->memsw); | 4717 | page_counter_init(&memcg->memsw, &parent->memsw); |
4728 | page_counter_init(&memcg->kmem, &parent->kmem); | 4718 | page_counter_init(&memcg->kmem, &parent->kmem); |
4729 | 4719 | ||
@@ -4733,6 +4723,7 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css) | |||
4733 | */ | 4723 | */ |
4734 | } else { | 4724 | } else { |
4735 | page_counter_init(&memcg->memory, NULL); | 4725 | page_counter_init(&memcg->memory, NULL); |
4726 | memcg->soft_limit = PAGE_COUNTER_MAX; | ||
4736 | page_counter_init(&memcg->memsw, NULL); | 4727 | page_counter_init(&memcg->memsw, NULL); |
4737 | page_counter_init(&memcg->kmem, NULL); | 4728 | page_counter_init(&memcg->kmem, NULL); |
4738 | /* | 4729 | /* |
@@ -4807,7 +4798,7 @@ static void mem_cgroup_css_reset(struct cgroup_subsys_state *css) | |||
4807 | mem_cgroup_resize_limit(memcg, PAGE_COUNTER_MAX); | 4798 | mem_cgroup_resize_limit(memcg, PAGE_COUNTER_MAX); |
4808 | mem_cgroup_resize_memsw_limit(memcg, PAGE_COUNTER_MAX); | 4799 | mem_cgroup_resize_memsw_limit(memcg, PAGE_COUNTER_MAX); |
4809 | memcg_update_kmem_limit(memcg, PAGE_COUNTER_MAX); | 4800 | memcg_update_kmem_limit(memcg, PAGE_COUNTER_MAX); |
4810 | memcg->soft_limit = 0; | 4801 | memcg->soft_limit = PAGE_COUNTER_MAX; |
4811 | } | 4802 | } |
4812 | 4803 | ||
4813 | #ifdef CONFIG_MMU | 4804 | #ifdef CONFIG_MMU |
diff --git a/mm/memory.c b/mm/memory.c index d7e497e98f46..c6565f00fb38 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -2137,17 +2137,24 @@ reuse: | |||
2137 | if (!dirty_page) | 2137 | if (!dirty_page) |
2138 | return ret; | 2138 | return ret; |
2139 | 2139 | ||
2140 | /* | ||
2141 | * Yes, Virginia, this is actually required to prevent a race | ||
2142 | * with clear_page_dirty_for_io() from clearing the page dirty | ||
2143 | * bit after it clear all dirty ptes, but before a racing | ||
2144 | * do_wp_page installs a dirty pte. | ||
2145 | * | ||
2146 | * do_shared_fault is protected similarly. | ||
2147 | */ | ||
2148 | if (!page_mkwrite) { | 2140 | if (!page_mkwrite) { |
2149 | wait_on_page_locked(dirty_page); | 2141 | struct address_space *mapping; |
2150 | set_page_dirty_balance(dirty_page); | 2142 | int dirtied; |
2143 | |||
2144 | lock_page(dirty_page); | ||
2145 | dirtied = set_page_dirty(dirty_page); | ||
2146 | VM_BUG_ON_PAGE(PageAnon(dirty_page), dirty_page); | ||
2147 | mapping = dirty_page->mapping; | ||
2148 | unlock_page(dirty_page); | ||
2149 | |||
2150 | if (dirtied && mapping) { | ||
2151 | /* | ||
2152 | * Some device drivers do not set page.mapping | ||
2153 | * but still dirty their pages | ||
2154 | */ | ||
2155 | balance_dirty_pages_ratelimited(mapping); | ||
2156 | } | ||
2157 | |||
2151 | /* file_update_time outside page_lock */ | 2158 | /* file_update_time outside page_lock */ |
2152 | if (vma->vm_file) | 2159 | if (vma->vm_file) |
2153 | file_update_time(vma->vm_file); | 2160 | file_update_time(vma->vm_file); |
@@ -778,10 +778,12 @@ again: remove_next = 1 + (end > next->vm_end); | |||
778 | if (exporter && exporter->anon_vma && !importer->anon_vma) { | 778 | if (exporter && exporter->anon_vma && !importer->anon_vma) { |
779 | int error; | 779 | int error; |
780 | 780 | ||
781 | importer->anon_vma = exporter->anon_vma; | ||
781 | error = anon_vma_clone(importer, exporter); | 782 | error = anon_vma_clone(importer, exporter); |
782 | if (error) | 783 | if (error) { |
784 | importer->anon_vma = NULL; | ||
783 | return error; | 785 | return error; |
784 | importer->anon_vma = exporter->anon_vma; | 786 | } |
785 | } | 787 | } |
786 | } | 788 | } |
787 | 789 | ||
@@ -2099,14 +2101,17 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns | |||
2099 | { | 2101 | { |
2100 | struct mm_struct *mm = vma->vm_mm; | 2102 | struct mm_struct *mm = vma->vm_mm; |
2101 | struct rlimit *rlim = current->signal->rlim; | 2103 | struct rlimit *rlim = current->signal->rlim; |
2102 | unsigned long new_start; | 2104 | unsigned long new_start, actual_size; |
2103 | 2105 | ||
2104 | /* address space limit tests */ | 2106 | /* address space limit tests */ |
2105 | if (!may_expand_vm(mm, grow)) | 2107 | if (!may_expand_vm(mm, grow)) |
2106 | return -ENOMEM; | 2108 | return -ENOMEM; |
2107 | 2109 | ||
2108 | /* Stack limit test */ | 2110 | /* Stack limit test */ |
2109 | if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur)) | 2111 | actual_size = size; |
2112 | if (size && (vma->vm_flags & (VM_GROWSUP | VM_GROWSDOWN))) | ||
2113 | actual_size -= PAGE_SIZE; | ||
2114 | if (actual_size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur)) | ||
2110 | return -ENOMEM; | 2115 | return -ENOMEM; |
2111 | 2116 | ||
2112 | /* mlock limit tests */ | 2117 | /* mlock limit tests */ |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index d5d81f5384d1..6f4335238e33 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -1541,16 +1541,6 @@ pause: | |||
1541 | bdi_start_background_writeback(bdi); | 1541 | bdi_start_background_writeback(bdi); |
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | void set_page_dirty_balance(struct page *page) | ||
1545 | { | ||
1546 | if (set_page_dirty(page)) { | ||
1547 | struct address_space *mapping = page_mapping(page); | ||
1548 | |||
1549 | if (mapping) | ||
1550 | balance_dirty_pages_ratelimited(mapping); | ||
1551 | } | ||
1552 | } | ||
1553 | |||
1554 | static DEFINE_PER_CPU(int, bdp_ratelimits); | 1544 | static DEFINE_PER_CPU(int, bdp_ratelimits); |
1555 | 1545 | ||
1556 | /* | 1546 | /* |
@@ -2123,32 +2113,25 @@ EXPORT_SYMBOL(account_page_dirtied); | |||
2123 | * page dirty in that case, but not all the buffers. This is a "bottom-up" | 2113 | * page dirty in that case, but not all the buffers. This is a "bottom-up" |
2124 | * dirtying, whereas __set_page_dirty_buffers() is a "top-down" dirtying. | 2114 | * dirtying, whereas __set_page_dirty_buffers() is a "top-down" dirtying. |
2125 | * | 2115 | * |
2126 | * Most callers have locked the page, which pins the address_space in memory. | 2116 | * The caller must ensure this doesn't race with truncation. Most will simply |
2127 | * But zap_pte_range() does not lock the page, however in that case the | 2117 | * hold the page lock, but e.g. zap_pte_range() calls with the page mapped and |
2128 | * mapping is pinned by the vma's ->vm_file reference. | 2118 | * the pte lock held, which also locks out truncation. |
2129 | * | ||
2130 | * We take care to handle the case where the page was truncated from the | ||
2131 | * mapping by re-checking page_mapping() inside tree_lock. | ||
2132 | */ | 2119 | */ |
2133 | int __set_page_dirty_nobuffers(struct page *page) | 2120 | int __set_page_dirty_nobuffers(struct page *page) |
2134 | { | 2121 | { |
2135 | if (!TestSetPageDirty(page)) { | 2122 | if (!TestSetPageDirty(page)) { |
2136 | struct address_space *mapping = page_mapping(page); | 2123 | struct address_space *mapping = page_mapping(page); |
2137 | struct address_space *mapping2; | ||
2138 | unsigned long flags; | 2124 | unsigned long flags; |
2139 | 2125 | ||
2140 | if (!mapping) | 2126 | if (!mapping) |
2141 | return 1; | 2127 | return 1; |
2142 | 2128 | ||
2143 | spin_lock_irqsave(&mapping->tree_lock, flags); | 2129 | spin_lock_irqsave(&mapping->tree_lock, flags); |
2144 | mapping2 = page_mapping(page); | 2130 | BUG_ON(page_mapping(page) != mapping); |
2145 | if (mapping2) { /* Race with truncate? */ | 2131 | WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); |
2146 | BUG_ON(mapping2 != mapping); | 2132 | account_page_dirtied(page, mapping); |
2147 | WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); | 2133 | radix_tree_tag_set(&mapping->page_tree, page_index(page), |
2148 | account_page_dirtied(page, mapping); | 2134 | PAGECACHE_TAG_DIRTY); |
2149 | radix_tree_tag_set(&mapping->page_tree, | ||
2150 | page_index(page), PAGECACHE_TAG_DIRTY); | ||
2151 | } | ||
2152 | spin_unlock_irqrestore(&mapping->tree_lock, flags); | 2135 | spin_unlock_irqrestore(&mapping->tree_lock, flags); |
2153 | if (mapping->host) { | 2136 | if (mapping->host) { |
2154 | /* !PageAnon && !swapper_space */ | 2137 | /* !PageAnon && !swapper_space */ |
@@ -2305,12 +2288,10 @@ int clear_page_dirty_for_io(struct page *page) | |||
2305 | /* | 2288 | /* |
2306 | * We carefully synchronise fault handlers against | 2289 | * We carefully synchronise fault handlers against |
2307 | * installing a dirty pte and marking the page dirty | 2290 | * installing a dirty pte and marking the page dirty |
2308 | * at this point. We do this by having them hold the | 2291 | * at this point. We do this by having them hold the |
2309 | * page lock at some point after installing their | 2292 | * page lock while dirtying the page, and pages are |
2310 | * pte, but before marking the page dirty. | 2293 | * always locked coming in here, so we get the desired |
2311 | * Pages are always locked coming in here, so we get | 2294 | * exclusion. |
2312 | * the desired exclusion. See mm/memory.c:do_wp_page() | ||
2313 | * for more comments. | ||
2314 | */ | 2295 | */ |
2315 | if (TestClearPageDirty(page)) { | 2296 | if (TestClearPageDirty(page)) { |
2316 | dec_zone_page_state(page, NR_FILE_DIRTY); | 2297 | dec_zone_page_state(page, NR_FILE_DIRTY); |
@@ -72,6 +72,8 @@ static inline struct anon_vma *anon_vma_alloc(void) | |||
72 | anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL); | 72 | anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL); |
73 | if (anon_vma) { | 73 | if (anon_vma) { |
74 | atomic_set(&anon_vma->refcount, 1); | 74 | atomic_set(&anon_vma->refcount, 1); |
75 | anon_vma->degree = 1; /* Reference for first vma */ | ||
76 | anon_vma->parent = anon_vma; | ||
75 | /* | 77 | /* |
76 | * Initialise the anon_vma root to point to itself. If called | 78 | * Initialise the anon_vma root to point to itself. If called |
77 | * from fork, the root will be reset to the parents anon_vma. | 79 | * from fork, the root will be reset to the parents anon_vma. |
@@ -188,6 +190,8 @@ int anon_vma_prepare(struct vm_area_struct *vma) | |||
188 | if (likely(!vma->anon_vma)) { | 190 | if (likely(!vma->anon_vma)) { |
189 | vma->anon_vma = anon_vma; | 191 | vma->anon_vma = anon_vma; |
190 | anon_vma_chain_link(vma, avc, anon_vma); | 192 | anon_vma_chain_link(vma, avc, anon_vma); |
193 | /* vma reference or self-parent link for new root */ | ||
194 | anon_vma->degree++; | ||
191 | allocated = NULL; | 195 | allocated = NULL; |
192 | avc = NULL; | 196 | avc = NULL; |
193 | } | 197 | } |
@@ -236,6 +240,14 @@ static inline void unlock_anon_vma_root(struct anon_vma *root) | |||
236 | /* | 240 | /* |
237 | * Attach the anon_vmas from src to dst. | 241 | * Attach the anon_vmas from src to dst. |
238 | * Returns 0 on success, -ENOMEM on failure. | 242 | * Returns 0 on success, -ENOMEM on failure. |
243 | * | ||
244 | * If dst->anon_vma is NULL this function tries to find and reuse existing | ||
245 | * anon_vma which has no vmas and only one child anon_vma. This prevents | ||
246 | * degradation of anon_vma hierarchy to endless linear chain in case of | ||
247 | * constantly forking task. On the other hand, an anon_vma with more than one | ||
248 | * child isn't reused even if there was no alive vma, thus rmap walker has a | ||
249 | * good chance of avoiding scanning the whole hierarchy when it searches where | ||
250 | * page is mapped. | ||
239 | */ | 251 | */ |
240 | int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) | 252 | int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) |
241 | { | 253 | { |
@@ -256,7 +268,21 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) | |||
256 | anon_vma = pavc->anon_vma; | 268 | anon_vma = pavc->anon_vma; |
257 | root = lock_anon_vma_root(root, anon_vma); | 269 | root = lock_anon_vma_root(root, anon_vma); |
258 | anon_vma_chain_link(dst, avc, anon_vma); | 270 | anon_vma_chain_link(dst, avc, anon_vma); |
271 | |||
272 | /* | ||
273 | * Reuse existing anon_vma if its degree lower than two, | ||
274 | * that means it has no vma and only one anon_vma child. | ||
275 | * | ||
276 | * Do not chose parent anon_vma, otherwise first child | ||
277 | * will always reuse it. Root anon_vma is never reused: | ||
278 | * it has self-parent reference and at least one child. | ||
279 | */ | ||
280 | if (!dst->anon_vma && anon_vma != src->anon_vma && | ||
281 | anon_vma->degree < 2) | ||
282 | dst->anon_vma = anon_vma; | ||
259 | } | 283 | } |
284 | if (dst->anon_vma) | ||
285 | dst->anon_vma->degree++; | ||
260 | unlock_anon_vma_root(root); | 286 | unlock_anon_vma_root(root); |
261 | return 0; | 287 | return 0; |
262 | 288 | ||
@@ -280,6 +306,9 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) | |||
280 | if (!pvma->anon_vma) | 306 | if (!pvma->anon_vma) |
281 | return 0; | 307 | return 0; |
282 | 308 | ||
309 | /* Drop inherited anon_vma, we'll reuse existing or allocate new. */ | ||
310 | vma->anon_vma = NULL; | ||
311 | |||
283 | /* | 312 | /* |
284 | * First, attach the new VMA to the parent VMA's anon_vmas, | 313 | * First, attach the new VMA to the parent VMA's anon_vmas, |
285 | * so rmap can find non-COWed pages in child processes. | 314 | * so rmap can find non-COWed pages in child processes. |
@@ -288,6 +317,10 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) | |||
288 | if (error) | 317 | if (error) |
289 | return error; | 318 | return error; |
290 | 319 | ||
320 | /* An existing anon_vma has been reused, all done then. */ | ||
321 | if (vma->anon_vma) | ||
322 | return 0; | ||
323 | |||
291 | /* Then add our own anon_vma. */ | 324 | /* Then add our own anon_vma. */ |
292 | anon_vma = anon_vma_alloc(); | 325 | anon_vma = anon_vma_alloc(); |
293 | if (!anon_vma) | 326 | if (!anon_vma) |
@@ -301,6 +334,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) | |||
301 | * lock any of the anon_vmas in this anon_vma tree. | 334 | * lock any of the anon_vmas in this anon_vma tree. |
302 | */ | 335 | */ |
303 | anon_vma->root = pvma->anon_vma->root; | 336 | anon_vma->root = pvma->anon_vma->root; |
337 | anon_vma->parent = pvma->anon_vma; | ||
304 | /* | 338 | /* |
305 | * With refcounts, an anon_vma can stay around longer than the | 339 | * With refcounts, an anon_vma can stay around longer than the |
306 | * process it belongs to. The root anon_vma needs to be pinned until | 340 | * process it belongs to. The root anon_vma needs to be pinned until |
@@ -311,6 +345,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) | |||
311 | vma->anon_vma = anon_vma; | 345 | vma->anon_vma = anon_vma; |
312 | anon_vma_lock_write(anon_vma); | 346 | anon_vma_lock_write(anon_vma); |
313 | anon_vma_chain_link(vma, avc, anon_vma); | 347 | anon_vma_chain_link(vma, avc, anon_vma); |
348 | anon_vma->parent->degree++; | ||
314 | anon_vma_unlock_write(anon_vma); | 349 | anon_vma_unlock_write(anon_vma); |
315 | 350 | ||
316 | return 0; | 351 | return 0; |
@@ -341,12 +376,16 @@ void unlink_anon_vmas(struct vm_area_struct *vma) | |||
341 | * Leave empty anon_vmas on the list - we'll need | 376 | * Leave empty anon_vmas on the list - we'll need |
342 | * to free them outside the lock. | 377 | * to free them outside the lock. |
343 | */ | 378 | */ |
344 | if (RB_EMPTY_ROOT(&anon_vma->rb_root)) | 379 | if (RB_EMPTY_ROOT(&anon_vma->rb_root)) { |
380 | anon_vma->parent->degree--; | ||
345 | continue; | 381 | continue; |
382 | } | ||
346 | 383 | ||
347 | list_del(&avc->same_vma); | 384 | list_del(&avc->same_vma); |
348 | anon_vma_chain_free(avc); | 385 | anon_vma_chain_free(avc); |
349 | } | 386 | } |
387 | if (vma->anon_vma) | ||
388 | vma->anon_vma->degree--; | ||
350 | unlock_anon_vma_root(root); | 389 | unlock_anon_vma_root(root); |
351 | 390 | ||
352 | /* | 391 | /* |
@@ -357,6 +396,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma) | |||
357 | list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) { | 396 | list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) { |
358 | struct anon_vma *anon_vma = avc->anon_vma; | 397 | struct anon_vma *anon_vma = avc->anon_vma; |
359 | 398 | ||
399 | BUG_ON(anon_vma->degree); | ||
360 | put_anon_vma(anon_vma); | 400 | put_anon_vma(anon_vma); |
361 | 401 | ||
362 | list_del(&avc->same_vma); | 402 | list_del(&avc->same_vma); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index bd9a72bc4a1b..ab2505c3ef54 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -2921,18 +2921,20 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining, | |||
2921 | return false; | 2921 | return false; |
2922 | 2922 | ||
2923 | /* | 2923 | /* |
2924 | * There is a potential race between when kswapd checks its watermarks | 2924 | * The throttled processes are normally woken up in balance_pgdat() as |
2925 | * and a process gets throttled. There is also a potential race if | 2925 | * soon as pfmemalloc_watermark_ok() is true. But there is a potential |
2926 | * processes get throttled, kswapd wakes, a large process exits therby | 2926 | * race between when kswapd checks the watermarks and a process gets |
2927 | * balancing the zones that causes kswapd to miss a wakeup. If kswapd | 2927 | * throttled. There is also a potential race if processes get |
2928 | * is going to sleep, no process should be sleeping on pfmemalloc_wait | 2928 | * throttled, kswapd wakes, a large process exits thereby balancing the |
2929 | * so wake them now if necessary. If necessary, processes will wake | 2929 | * zones, which causes kswapd to exit balance_pgdat() before reaching |
2930 | * kswapd and get throttled again | 2930 | * the wake up checks. If kswapd is going to sleep, no process should |
2931 | * be sleeping on pfmemalloc_wait, so wake them now if necessary. If | ||
2932 | * the wake up is premature, processes will wake kswapd and get | ||
2933 | * throttled again. The difference from wake ups in balance_pgdat() is | ||
2934 | * that here we are under prepare_to_wait(). | ||
2931 | */ | 2935 | */ |
2932 | if (waitqueue_active(&pgdat->pfmemalloc_wait)) { | 2936 | if (waitqueue_active(&pgdat->pfmemalloc_wait)) |
2933 | wake_up(&pgdat->pfmemalloc_wait); | 2937 | wake_up_all(&pgdat->pfmemalloc_wait); |
2934 | return false; | ||
2935 | } | ||
2936 | 2938 | ||
2937 | return pgdat_balanced(pgdat, order, classzone_idx); | 2939 | return pgdat_balanced(pgdat, order, classzone_idx); |
2938 | } | 2940 | } |
diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c index 15845814a0f2..ba6eb17226da 100644 --- a/net/ceph/auth_x.c +++ b/net/ceph/auth_x.c | |||
@@ -676,7 +676,7 @@ static int calcu_signature(struct ceph_x_authorizer *au, | |||
676 | int ret; | 676 | int ret; |
677 | char tmp_enc[40]; | 677 | char tmp_enc[40]; |
678 | __le32 tmp[5] = { | 678 | __le32 tmp[5] = { |
679 | 16u, msg->hdr.crc, msg->footer.front_crc, | 679 | cpu_to_le32(16), msg->hdr.crc, msg->footer.front_crc, |
680 | msg->footer.middle_crc, msg->footer.data_crc, | 680 | msg->footer.middle_crc, msg->footer.data_crc, |
681 | }; | 681 | }; |
682 | ret = ceph_x_encrypt(&au->session_key, &tmp, sizeof(tmp), | 682 | ret = ceph_x_encrypt(&au->session_key, &tmp, sizeof(tmp), |
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c index a83062ceeec9..f2148e22b148 100644 --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c | |||
@@ -717,7 +717,7 @@ static int get_poolop_reply_buf(const char *src, size_t src_len, | |||
717 | if (src_len != sizeof(u32) + dst_len) | 717 | if (src_len != sizeof(u32) + dst_len) |
718 | return -EINVAL; | 718 | return -EINVAL; |
719 | 719 | ||
720 | buf_len = le32_to_cpu(*(u32 *)src); | 720 | buf_len = le32_to_cpu(*(__le32 *)src); |
721 | if (buf_len != dst_len) | 721 | if (buf_len != dst_len) |
722 | return -EINVAL; | 722 | return -EINVAL; |
723 | 723 | ||
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 1cb61242e55e..4439ac4c1b53 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c | |||
@@ -606,7 +606,7 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len) | |||
606 | struct kvec *head = buf->head; | 606 | struct kvec *head = buf->head; |
607 | struct kvec *tail = buf->tail; | 607 | struct kvec *tail = buf->tail; |
608 | int fraglen; | 608 | int fraglen; |
609 | int new, old; | 609 | int new; |
610 | 610 | ||
611 | if (len > buf->len) { | 611 | if (len > buf->len) { |
612 | WARN_ON_ONCE(1); | 612 | WARN_ON_ONCE(1); |
@@ -629,8 +629,8 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len) | |||
629 | buf->len -= fraglen; | 629 | buf->len -= fraglen; |
630 | 630 | ||
631 | new = buf->page_base + buf->page_len; | 631 | new = buf->page_base + buf->page_len; |
632 | old = new + fraglen; | 632 | |
633 | xdr->page_ptr -= (old >> PAGE_SHIFT) - (new >> PAGE_SHIFT); | 633 | xdr->page_ptr = buf->pages + (new >> PAGE_SHIFT); |
634 | 634 | ||
635 | if (buf->page_len) { | 635 | if (buf->page_len) { |
636 | xdr->p = page_address(*xdr->page_ptr); | 636 | xdr->p = page_address(*xdr->page_ptr); |
diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c index 255dabc6fc33..2a85e4209f0b 100644 --- a/sound/firewire/fireworks/fireworks_transaction.c +++ b/sound/firewire/fireworks/fireworks_transaction.c | |||
@@ -124,7 +124,7 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode) | |||
124 | spin_lock_irq(&efw->lock); | 124 | spin_lock_irq(&efw->lock); |
125 | 125 | ||
126 | t = (struct snd_efw_transaction *)data; | 126 | t = (struct snd_efw_transaction *)data; |
127 | length = min_t(size_t, t->length * sizeof(t->length), length); | 127 | length = min_t(size_t, be32_to_cpu(t->length) * sizeof(u32), length); |
128 | 128 | ||
129 | if (efw->push_ptr < efw->pull_ptr) | 129 | if (efw->push_ptr < efw->pull_ptr) |
130 | capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr); | 130 | capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr); |
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 5f13d2d18079..b422e406a9cb 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c | |||
@@ -3353,6 +3353,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = { | |||
3353 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, | 3353 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, |
3354 | { .id = 0x10de0070, .name = "GPU 70 HDMI/DP", .patch = patch_nvhdmi }, | 3354 | { .id = 0x10de0070, .name = "GPU 70 HDMI/DP", .patch = patch_nvhdmi }, |
3355 | { .id = 0x10de0071, .name = "GPU 71 HDMI/DP", .patch = patch_nvhdmi }, | 3355 | { .id = 0x10de0071, .name = "GPU 71 HDMI/DP", .patch = patch_nvhdmi }, |
3356 | { .id = 0x10de0072, .name = "GPU 72 HDMI/DP", .patch = patch_nvhdmi }, | ||
3356 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, | 3357 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, |
3357 | { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, | 3358 | { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, |
3358 | { .id = 0x11069f81, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, | 3359 | { .id = 0x11069f81, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, |
@@ -3413,6 +3414,7 @@ MODULE_ALIAS("snd-hda-codec-id:10de0060"); | |||
3413 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); | 3414 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); |
3414 | MODULE_ALIAS("snd-hda-codec-id:10de0070"); | 3415 | MODULE_ALIAS("snd-hda-codec-id:10de0070"); |
3415 | MODULE_ALIAS("snd-hda-codec-id:10de0071"); | 3416 | MODULE_ALIAS("snd-hda-codec-id:10de0071"); |
3417 | MODULE_ALIAS("snd-hda-codec-id:10de0072"); | ||
3416 | MODULE_ALIAS("snd-hda-codec-id:10de8001"); | 3418 | MODULE_ALIAS("snd-hda-codec-id:10de8001"); |
3417 | MODULE_ALIAS("snd-hda-codec-id:11069f80"); | 3419 | MODULE_ALIAS("snd-hda-codec-id:11069f80"); |
3418 | MODULE_ALIAS("snd-hda-codec-id:11069f81"); | 3420 | MODULE_ALIAS("snd-hda-codec-id:11069f81"); |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 4f6413e01c13..605d14003d25 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -568,9 +568,9 @@ static void stac_store_hints(struct hda_codec *codec) | |||
568 | spec->gpio_mask; | 568 | spec->gpio_mask; |
569 | } | 569 | } |
570 | if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir)) | 570 | if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir)) |
571 | spec->gpio_mask &= spec->gpio_mask; | ||
572 | if (get_int_hint(codec, "gpio_data", &spec->gpio_data)) | ||
573 | spec->gpio_dir &= spec->gpio_mask; | 571 | spec->gpio_dir &= spec->gpio_mask; |
572 | if (get_int_hint(codec, "gpio_data", &spec->gpio_data)) | ||
573 | spec->gpio_data &= spec->gpio_mask; | ||
574 | if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask)) | 574 | if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask)) |
575 | spec->eapd_mask &= spec->gpio_mask; | 575 | spec->eapd_mask &= spec->gpio_mask; |
576 | if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute)) | 576 | if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute)) |
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 272844746135..327f8642ca80 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c | |||
@@ -816,7 +816,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) | |||
816 | return -EINVAL; | 816 | return -EINVAL; |
817 | } | 817 | } |
818 | 818 | ||
819 | if (cdev->n_streams < 2) { | 819 | if (cdev->n_streams < 1) { |
820 | dev_err(dev, "bogus number of streams: %d\n", cdev->n_streams); | 820 | dev_err(dev, "bogus number of streams: %d\n", cdev->n_streams); |
821 | return -EINVAL; | 821 | return -EINVAL; |
822 | } | 822 | } |