aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/admin-guide/pm/cpufreq.rst2
-rw-r--r--Documentation/cpu-freq/cpufreq-stats.txt8
-rw-r--r--Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt65
-rw-r--r--MAINTAINERS1
-rw-r--r--arch/arm/include/asm/cputype.h1
-rw-r--r--arch/arm/include/asm/proc-fns.h61
-rw-r--r--arch/arm/kernel/bugs.c4
-rw-r--r--arch/arm/kernel/head-common.S6
-rw-r--r--arch/arm/kernel/setup.c40
-rw-r--r--arch/arm/kernel/smp.c31
-rw-r--r--arch/arm/mach-omap2/display.c111
-rw-r--r--arch/arm/mm/proc-v7-bugs.c17
-rw-r--r--arch/arm/vfp/vfpmodule.c2
-rw-r--r--arch/arm64/kernel/setup.c1
-rw-r--r--arch/parisc/include/asm/spinlock.h4
-rw-r--r--arch/parisc/kernel/syscall.S12
-rw-r--r--arch/powerpc/include/asm/io.h20
-rw-r--r--arch/powerpc/include/asm/ppc-opcode.h2
-rw-r--r--arch/powerpc/include/asm/ptrace.h1
-rw-r--r--arch/powerpc/kernel/setup_64.c2
-rw-r--r--arch/powerpc/kvm/trace.h8
-rw-r--r--arch/powerpc/kvm/trace_booke.h9
-rw-r--r--arch/powerpc/kvm/trace_hv.h9
-rw-r--r--arch/powerpc/kvm/trace_pr.h9
-rw-r--r--arch/powerpc/mm/numa.c2
-rw-r--r--arch/powerpc/mm/slb.c35
-rw-r--r--arch/powerpc/platforms/powernv/npu-dma.c64
-rw-r--r--arch/riscv/Makefile4
-rw-r--r--arch/riscv/configs/defconfig1
-rw-r--r--arch/riscv/include/asm/ptrace.h4
-rw-r--r--arch/riscv/kernel/module.c12
-rw-r--r--arch/riscv/lib/Makefile2
-rw-r--r--arch/xtensa/include/asm/processor.h6
-rw-r--r--arch/xtensa/kernel/head.S7
-rw-r--r--block/bio.c1
-rw-r--r--block/blk-core.c5
-rw-r--r--block/blk-lib.c4
-rw-r--r--block/bounce.c1
-rw-r--r--crypto/crypto_user_base.c18
-rw-r--r--crypto/crypto_user_stat.c21
-rw-r--r--crypto/simd.c5
-rw-r--r--drivers/acpi/Kconfig2
-rw-r--r--drivers/ata/libata-core.c2
-rw-r--r--drivers/block/floppy.c3
-rw-r--r--drivers/cpufreq/imx6q-cpufreq.c7
-rw-r--r--drivers/cpuidle/cpuidle-arm.c40
-rw-r--r--drivers/crypto/hisilicon/sec/sec_algs.c31
-rw-r--r--drivers/firmware/efi/arm-init.c4
-rw-r--r--drivers/firmware/efi/arm-runtime.c2
-rw-r--r--drivers/firmware/efi/efi.c35
-rw-r--r--drivers/firmware/efi/libstub/arm-stub.c3
-rw-r--r--drivers/firmware/efi/libstub/fdt.c4
-rw-r--r--drivers/firmware/efi/memmap.c3
-rw-r--r--drivers/firmware/efi/runtime-wrappers.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c18
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/vega10_ih.c2
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c32
-rw-r--r--drivers/gpu/drm/drm_dp_mst_topology.c3
-rw-r--r--drivers/gpu/drm/drm_fourcc.c2
-rw-r--r--drivers/gpu/drm/i915/intel_device_info.c2
-rw-r--r--drivers/gpu/drm/i915/intel_display.c45
-rw-r--r--drivers/gpu/drm/i915/intel_dp_mst.c8
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h2
-rw-r--r--drivers/gpu/drm/i915/intel_hotplug.c70
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c14
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c38
-rw-r--r--drivers/gpu/drm/i915/intel_runtime_pm.c16
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c93
-rw-r--r--drivers/gpu/drm/meson/meson_venc.c15
-rw-r--r--drivers/gpu/drm/omapdrm/dss/dsi.c22
-rw-r--r--drivers/gpu/drm/omapdrm/dss/dss.c11
-rw-r--r--drivers/gpu/drm/omapdrm/dss/hdmi4.c37
-rw-r--r--drivers/gpu/drm/omapdrm/dss/hdmi5.c27
-rw-r--r--drivers/gpu/drm/omapdrm/dss/venc.c7
-rw-r--r--drivers/gpu/drm/omapdrm/omap_crtc.c6
-rw-r--r--drivers/pci/pci-acpi.c5
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson-gxbb.c2
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson-gxl.c2
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson.c2
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson8.c2
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson8b.c2
-rw-r--r--drivers/rtc/hctosys.c4
-rw-r--r--drivers/rtc/rtc-cmos.c16
-rw-r--r--drivers/rtc/rtc-pcf2127.c3
-rw-r--r--drivers/scsi/Kconfig1
-rw-r--r--drivers/scsi/NCR5380.c2
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v1_hw.c2
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v2_hw.c2
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v3_hw.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c2
-rw-r--r--drivers/scsi/myrb.c3
-rw-r--r--drivers/scsi/myrs.c13
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c2
-rw-r--r--drivers/scsi/scsi_lib.c8
-rw-r--r--drivers/scsi/ufs/ufshcd.c7
-rw-r--r--drivers/target/target_core_transport.c4
-rw-r--r--fs/fuse/dev.c16
-rw-r--r--fs/fuse/file.c4
-rw-r--r--fs/gfs2/bmap.c54
-rw-r--r--fs/gfs2/rgrp.c3
-rw-r--r--fs/namespace.c6
-rw-r--r--fs/nfs/callback_proc.c4
-rw-r--r--fs/nfs/delegation.c11
-rw-r--r--fs/nfs/nfs4state.c10
-rw-r--r--fs/nfsd/nfs4proc.c3
-rw-r--r--fs/notify/fanotify/fanotify.c10
-rw-r--r--fs/notify/fsnotify.c7
-rw-r--r--include/linux/efi.h7
-rw-r--r--include/trace/events/kyber.h8
-rw-r--r--kernel/debug/kdb/kdb_bt.c4
-rw-r--r--kernel/debug/kdb/kdb_io.c15
-rw-r--r--kernel/debug/kdb/kdb_keyboard.c4
-rw-r--r--kernel/debug/kdb/kdb_main.c35
-rw-r--r--kernel/debug/kdb/kdb_private.h2
-rw-r--r--kernel/debug/kdb/kdb_support.c28
-rw-r--r--net/sunrpc/auth_generic.c8
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c61
-rw-r--r--net/sunrpc/xdr.c7
-rw-r--r--security/integrity/digsig_asymmetric.c1
-rw-r--r--security/selinux/hooks.c3
-rw-r--r--security/selinux/ss/mls.c10
-rw-r--r--tools/testing/selftests/powerpc/mm/wild_bctr.c21
125 files changed, 919 insertions, 748 deletions
diff --git a/Documentation/admin-guide/pm/cpufreq.rst b/Documentation/admin-guide/pm/cpufreq.rst
index 47153e64dfb5..7eca9026a9ed 100644
--- a/Documentation/admin-guide/pm/cpufreq.rst
+++ b/Documentation/admin-guide/pm/cpufreq.rst
@@ -150,7 +150,7 @@ data structures necessary to handle the given policy and, possibly, to add
150a governor ``sysfs`` interface to it. Next, the governor is started by 150a governor ``sysfs`` interface to it. Next, the governor is started by
151invoking its ``->start()`` callback. 151invoking its ``->start()`` callback.
152 152
153That callback it expected to register per-CPU utilization update callbacks for 153That callback is expected to register per-CPU utilization update callbacks for
154all of the online CPUs belonging to the given policy with the CPU scheduler. 154all of the online CPUs belonging to the given policy with the CPU scheduler.
155The utilization update callbacks will be invoked by the CPU scheduler on 155The utilization update callbacks will be invoked by the CPU scheduler on
156important events, like task enqueue and dequeue, on every iteration of the 156important events, like task enqueue and dequeue, on every iteration of the
diff --git a/Documentation/cpu-freq/cpufreq-stats.txt b/Documentation/cpu-freq/cpufreq-stats.txt
index a873855c811d..14378cecb172 100644
--- a/Documentation/cpu-freq/cpufreq-stats.txt
+++ b/Documentation/cpu-freq/cpufreq-stats.txt
@@ -86,9 +86,11 @@ transitions.
86This will give a fine grained information about all the CPU frequency 86This will give a fine grained information about all the CPU frequency
87transitions. The cat output here is a two dimensional matrix, where an entry 87transitions. The cat output here is a two dimensional matrix, where an entry
88<i,j> (row i, column j) represents the count of number of transitions from 88<i,j> (row i, column j) represents the count of number of transitions from
89Freq_i to Freq_j. Freq_i is in descending order with increasing rows and 89Freq_i to Freq_j. Freq_i rows and Freq_j columns follow the sorting order in
90Freq_j is in descending order with increasing columns. The output here also 90which the driver has provided the frequency table initially to the cpufreq core
91contains the actual freq values for each row and column for better readability. 91and so can be sorted (ascending or descending) or unsorted. The output here
92also contains the actual freq values for each row and column for better
93readability.
92 94
93If the transition table is bigger than PAGE_SIZE, reading this will 95If the transition table is bigger than PAGE_SIZE, reading this will
94return an -EFBIG error. 96return an -EFBIG error.
diff --git a/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt b/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt
deleted file mode 100644
index 2aa06ac0fac5..000000000000
--- a/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt
+++ /dev/null
@@ -1,65 +0,0 @@
1Generic ARM big LITTLE cpufreq driver's DT glue
2-----------------------------------------------
3
4This is DT specific glue layer for generic cpufreq driver for big LITTLE
5systems.
6
7Both required and optional properties listed below must be defined
8under node /cpus/cpu@x. Where x is the first cpu inside a cluster.
9
10FIXME: Cpus should boot in the order specified in DT and all cpus for a cluster
11must be present contiguously. Generic DT driver will check only node 'x' for
12cpu:x.
13
14Required properties:
15- operating-points: Refer to Documentation/devicetree/bindings/opp/opp.txt
16 for details
17
18Optional properties:
19- clock-latency: Specify the possible maximum transition latency for clock,
20 in unit of nanoseconds.
21
22Examples:
23
24cpus {
25 #address-cells = <1>;
26 #size-cells = <0>;
27
28 cpu@0 {
29 compatible = "arm,cortex-a15";
30 reg = <0>;
31 next-level-cache = <&L2>;
32 operating-points = <
33 /* kHz uV */
34 792000 1100000
35 396000 950000
36 198000 850000
37 >;
38 clock-latency = <61036>; /* two CLK32 periods */
39 };
40
41 cpu@1 {
42 compatible = "arm,cortex-a15";
43 reg = <1>;
44 next-level-cache = <&L2>;
45 };
46
47 cpu@100 {
48 compatible = "arm,cortex-a7";
49 reg = <100>;
50 next-level-cache = <&L2>;
51 operating-points = <
52 /* kHz uV */
53 792000 950000
54 396000 750000
55 198000 450000
56 >;
57 clock-latency = <61036>; /* two CLK32 periods */
58 };
59
60 cpu@101 {
61 compatible = "arm,cortex-a7";
62 reg = <101>;
63 next-level-cache = <&L2>;
64 };
65};
diff --git a/MAINTAINERS b/MAINTAINERS
index 0abecc528dac..6c3fbbb361f8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11745,6 +11745,7 @@ F: Documentation/devicetree/bindings/pinctrl/fsl,*
11745PIN CONTROLLER - INTEL 11745PIN CONTROLLER - INTEL
11746M: Mika Westerberg <mika.westerberg@linux.intel.com> 11746M: Mika Westerberg <mika.westerberg@linux.intel.com>
11747M: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 11747M: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
11748T: git git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/intel.git
11748S: Maintained 11749S: Maintained
11749F: drivers/pinctrl/intel/ 11750F: drivers/pinctrl/intel/
11750 11751
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index 0d289240b6ca..775cac3c02bb 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -111,6 +111,7 @@
111#include <linux/kernel.h> 111#include <linux/kernel.h>
112 112
113extern unsigned int processor_id; 113extern unsigned int processor_id;
114struct proc_info_list *lookup_processor(u32 midr);
114 115
115#ifdef CONFIG_CPU_CP15 116#ifdef CONFIG_CPU_CP15
116#define read_cpuid(reg) \ 117#define read_cpuid(reg) \
diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
index e25f4392e1b2..e1b6f280ab08 100644
--- a/arch/arm/include/asm/proc-fns.h
+++ b/arch/arm/include/asm/proc-fns.h
@@ -23,7 +23,7 @@ struct mm_struct;
23/* 23/*
24 * Don't change this structure - ASM code relies on it. 24 * Don't change this structure - ASM code relies on it.
25 */ 25 */
26extern struct processor { 26struct processor {
27 /* MISC 27 /* MISC
28 * get data abort address/flags 28 * get data abort address/flags
29 */ 29 */
@@ -79,9 +79,13 @@ extern struct processor {
79 unsigned int suspend_size; 79 unsigned int suspend_size;
80 void (*do_suspend)(void *); 80 void (*do_suspend)(void *);
81 void (*do_resume)(void *); 81 void (*do_resume)(void *);
82} processor; 82};
83 83
84#ifndef MULTI_CPU 84#ifndef MULTI_CPU
85static inline void init_proc_vtable(const struct processor *p)
86{
87}
88
85extern void cpu_proc_init(void); 89extern void cpu_proc_init(void);
86extern void cpu_proc_fin(void); 90extern void cpu_proc_fin(void);
87extern int cpu_do_idle(void); 91extern int cpu_do_idle(void);
@@ -98,17 +102,50 @@ extern void cpu_reset(unsigned long addr, bool hvc) __attribute__((noreturn));
98extern void cpu_do_suspend(void *); 102extern void cpu_do_suspend(void *);
99extern void cpu_do_resume(void *); 103extern void cpu_do_resume(void *);
100#else 104#else
101#define cpu_proc_init processor._proc_init
102#define cpu_proc_fin processor._proc_fin
103#define cpu_reset processor.reset
104#define cpu_do_idle processor._do_idle
105#define cpu_dcache_clean_area processor.dcache_clean_area
106#define cpu_set_pte_ext processor.set_pte_ext
107#define cpu_do_switch_mm processor.switch_mm
108 105
109/* These three are private to arch/arm/kernel/suspend.c */ 106extern struct processor processor;
110#define cpu_do_suspend processor.do_suspend 107#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR)
111#define cpu_do_resume processor.do_resume 108#include <linux/smp.h>
109/*
110 * This can't be a per-cpu variable because we need to access it before
111 * per-cpu has been initialised. We have a couple of functions that are
112 * called in a pre-emptible context, and so can't use smp_processor_id()
113 * there, hence PROC_TABLE(). We insist in init_proc_vtable() that the
114 * function pointers for these are identical across all CPUs.
115 */
116extern struct processor *cpu_vtable[];
117#define PROC_VTABLE(f) cpu_vtable[smp_processor_id()]->f
118#define PROC_TABLE(f) cpu_vtable[0]->f
119static inline void init_proc_vtable(const struct processor *p)
120{
121 unsigned int cpu = smp_processor_id();
122 *cpu_vtable[cpu] = *p;
123 WARN_ON_ONCE(cpu_vtable[cpu]->dcache_clean_area !=
124 cpu_vtable[0]->dcache_clean_area);
125 WARN_ON_ONCE(cpu_vtable[cpu]->set_pte_ext !=
126 cpu_vtable[0]->set_pte_ext);
127}
128#else
129#define PROC_VTABLE(f) processor.f
130#define PROC_TABLE(f) processor.f
131static inline void init_proc_vtable(const struct processor *p)
132{
133 processor = *p;
134}
135#endif
136
137#define cpu_proc_init PROC_VTABLE(_proc_init)
138#define cpu_check_bugs PROC_VTABLE(check_bugs)
139#define cpu_proc_fin PROC_VTABLE(_proc_fin)
140#define cpu_reset PROC_VTABLE(reset)
141#define cpu_do_idle PROC_VTABLE(_do_idle)
142#define cpu_dcache_clean_area PROC_TABLE(dcache_clean_area)
143#define cpu_set_pte_ext PROC_TABLE(set_pte_ext)
144#define cpu_do_switch_mm PROC_VTABLE(switch_mm)
145
146/* These two are private to arch/arm/kernel/suspend.c */
147#define cpu_do_suspend PROC_VTABLE(do_suspend)
148#define cpu_do_resume PROC_VTABLE(do_resume)
112#endif 149#endif
113 150
114extern void cpu_resume(void); 151extern void cpu_resume(void);
diff --git a/arch/arm/kernel/bugs.c b/arch/arm/kernel/bugs.c
index 7be511310191..d41d3598e5e5 100644
--- a/arch/arm/kernel/bugs.c
+++ b/arch/arm/kernel/bugs.c
@@ -6,8 +6,8 @@
6void check_other_bugs(void) 6void check_other_bugs(void)
7{ 7{
8#ifdef MULTI_CPU 8#ifdef MULTI_CPU
9 if (processor.check_bugs) 9 if (cpu_check_bugs)
10 processor.check_bugs(); 10 cpu_check_bugs();
11#endif 11#endif
12} 12}
13 13
diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S
index 6e0375e7db05..997b02302c31 100644
--- a/arch/arm/kernel/head-common.S
+++ b/arch/arm/kernel/head-common.S
@@ -145,6 +145,9 @@ __mmap_switched_data:
145#endif 145#endif
146 .size __mmap_switched_data, . - __mmap_switched_data 146 .size __mmap_switched_data, . - __mmap_switched_data
147 147
148 __FINIT
149 .text
150
148/* 151/*
149 * This provides a C-API version of __lookup_processor_type 152 * This provides a C-API version of __lookup_processor_type
150 */ 153 */
@@ -156,9 +159,6 @@ ENTRY(lookup_processor_type)
156 ldmfd sp!, {r4 - r6, r9, pc} 159 ldmfd sp!, {r4 - r6, r9, pc}
157ENDPROC(lookup_processor_type) 160ENDPROC(lookup_processor_type)
158 161
159 __FINIT
160 .text
161
162/* 162/*
163 * Read processor ID register (CP#15, CR0), and look up in the linker-built 163 * Read processor ID register (CP#15, CR0), and look up in the linker-built
164 * supported processor list. Note that we can't use the absolute addresses 164 * supported processor list. Note that we can't use the absolute addresses
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index ac7e08886863..375b13f7e780 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -114,6 +114,11 @@ EXPORT_SYMBOL(elf_hwcap2);
114 114
115#ifdef MULTI_CPU 115#ifdef MULTI_CPU
116struct processor processor __ro_after_init; 116struct processor processor __ro_after_init;
117#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR)
118struct processor *cpu_vtable[NR_CPUS] = {
119 [0] = &processor,
120};
121#endif
117#endif 122#endif
118#ifdef MULTI_TLB 123#ifdef MULTI_TLB
119struct cpu_tlb_fns cpu_tlb __ro_after_init; 124struct cpu_tlb_fns cpu_tlb __ro_after_init;
@@ -666,28 +671,33 @@ static void __init smp_build_mpidr_hash(void)
666} 671}
667#endif 672#endif
668 673
669static void __init setup_processor(void) 674/*
675 * locate processor in the list of supported processor types. The linker
676 * builds this table for us from the entries in arch/arm/mm/proc-*.S
677 */
678struct proc_info_list *lookup_processor(u32 midr)
670{ 679{
671 struct proc_info_list *list; 680 struct proc_info_list *list = lookup_processor_type(midr);
672 681
673 /*
674 * locate processor in the list of supported processor
675 * types. The linker builds this table for us from the
676 * entries in arch/arm/mm/proc-*.S
677 */
678 list = lookup_processor_type(read_cpuid_id());
679 if (!list) { 682 if (!list) {
680 pr_err("CPU configuration botched (ID %08x), unable to continue.\n", 683 pr_err("CPU%u: configuration botched (ID %08x), CPU halted\n",
681 read_cpuid_id()); 684 smp_processor_id(), midr);
682 while (1); 685 while (1)
686 /* can't use cpu_relax() here as it may require MMU setup */;
683 } 687 }
684 688
689 return list;
690}
691
692static void __init setup_processor(void)
693{
694 unsigned int midr = read_cpuid_id();
695 struct proc_info_list *list = lookup_processor(midr);
696
685 cpu_name = list->cpu_name; 697 cpu_name = list->cpu_name;
686 __cpu_architecture = __get_cpu_architecture(); 698 __cpu_architecture = __get_cpu_architecture();
687 699
688#ifdef MULTI_CPU 700 init_proc_vtable(list->proc);
689 processor = *list->proc;
690#endif
691#ifdef MULTI_TLB 701#ifdef MULTI_TLB
692 cpu_tlb = *list->tlb; 702 cpu_tlb = *list->tlb;
693#endif 703#endif
@@ -699,7 +709,7 @@ static void __init setup_processor(void)
699#endif 709#endif
700 710
701 pr_info("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n", 711 pr_info("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n",
702 cpu_name, read_cpuid_id(), read_cpuid_id() & 15, 712 list->cpu_name, midr, midr & 15,
703 proc_arch[cpu_architecture()], get_cr()); 713 proc_arch[cpu_architecture()], get_cr());
704 714
705 snprintf(init_utsname()->machine, __NEW_UTS_LEN + 1, "%s%c", 715 snprintf(init_utsname()->machine, __NEW_UTS_LEN + 1, "%s%c",
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 0978282d5fc2..12a6172263c0 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -42,6 +42,7 @@
42#include <asm/mmu_context.h> 42#include <asm/mmu_context.h>
43#include <asm/pgtable.h> 43#include <asm/pgtable.h>
44#include <asm/pgalloc.h> 44#include <asm/pgalloc.h>
45#include <asm/procinfo.h>
45#include <asm/processor.h> 46#include <asm/processor.h>
46#include <asm/sections.h> 47#include <asm/sections.h>
47#include <asm/tlbflush.h> 48#include <asm/tlbflush.h>
@@ -102,6 +103,30 @@ static unsigned long get_arch_pgd(pgd_t *pgd)
102#endif 103#endif
103} 104}
104 105
106#if defined(CONFIG_BIG_LITTLE) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR)
107static int secondary_biglittle_prepare(unsigned int cpu)
108{
109 if (!cpu_vtable[cpu])
110 cpu_vtable[cpu] = kzalloc(sizeof(*cpu_vtable[cpu]), GFP_KERNEL);
111
112 return cpu_vtable[cpu] ? 0 : -ENOMEM;
113}
114
115static void secondary_biglittle_init(void)
116{
117 init_proc_vtable(lookup_processor(read_cpuid_id())->proc);
118}
119#else
120static int secondary_biglittle_prepare(unsigned int cpu)
121{
122 return 0;
123}
124
125static void secondary_biglittle_init(void)
126{
127}
128#endif
129
105int __cpu_up(unsigned int cpu, struct task_struct *idle) 130int __cpu_up(unsigned int cpu, struct task_struct *idle)
106{ 131{
107 int ret; 132 int ret;
@@ -109,6 +134,10 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
109 if (!smp_ops.smp_boot_secondary) 134 if (!smp_ops.smp_boot_secondary)
110 return -ENOSYS; 135 return -ENOSYS;
111 136
137 ret = secondary_biglittle_prepare(cpu);
138 if (ret)
139 return ret;
140
112 /* 141 /*
113 * We need to tell the secondary core where to find 142 * We need to tell the secondary core where to find
114 * its stack and the page tables. 143 * its stack and the page tables.
@@ -359,6 +388,8 @@ asmlinkage void secondary_start_kernel(void)
359 struct mm_struct *mm = &init_mm; 388 struct mm_struct *mm = &init_mm;
360 unsigned int cpu; 389 unsigned int cpu;
361 390
391 secondary_biglittle_init();
392
362 /* 393 /*
363 * The identity mapping is uncached (strongly ordered), so 394 * The identity mapping is uncached (strongly ordered), so
364 * switch away from it before attempting any exclusive accesses. 395 * switch away from it before attempting any exclusive accesses.
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index 9500b6e27380..f86b72d1d59e 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -209,11 +209,61 @@ static int __init omapdss_init_fbdev(void)
209 209
210 return 0; 210 return 0;
211} 211}
212#else 212
213static inline int omapdss_init_fbdev(void) 213static const char * const omapdss_compat_names[] __initconst = {
214 "ti,omap2-dss",
215 "ti,omap3-dss",
216 "ti,omap4-dss",
217 "ti,omap5-dss",
218 "ti,dra7-dss",
219};
220
221static struct device_node * __init omapdss_find_dss_of_node(void)
214{ 222{
215 return 0; 223 struct device_node *node;
224 int i;
225
226 for (i = 0; i < ARRAY_SIZE(omapdss_compat_names); ++i) {
227 node = of_find_compatible_node(NULL, NULL,
228 omapdss_compat_names[i]);
229 if (node)
230 return node;
231 }
232
233 return NULL;
216} 234}
235
236static int __init omapdss_init_of(void)
237{
238 int r;
239 struct device_node *node;
240 struct platform_device *pdev;
241
242 /* only create dss helper devices if dss is enabled in the .dts */
243
244 node = omapdss_find_dss_of_node();
245 if (!node)
246 return 0;
247
248 if (!of_device_is_available(node))
249 return 0;
250
251 pdev = of_find_device_by_node(node);
252
253 if (!pdev) {
254 pr_err("Unable to find DSS platform device\n");
255 return -ENODEV;
256 }
257
258 r = of_platform_populate(node, NULL, NULL, &pdev->dev);
259 if (r) {
260 pr_err("Unable to populate DSS submodule devices\n");
261 return r;
262 }
263
264 return omapdss_init_fbdev();
265}
266omap_device_initcall(omapdss_init_of);
217#endif /* CONFIG_FB_OMAP2 */ 267#endif /* CONFIG_FB_OMAP2 */
218 268
219static void dispc_disable_outputs(void) 269static void dispc_disable_outputs(void)
@@ -361,58 +411,3 @@ int omap_dss_reset(struct omap_hwmod *oh)
361 411
362 return r; 412 return r;
363} 413}
364
365static const char * const omapdss_compat_names[] __initconst = {
366 "ti,omap2-dss",
367 "ti,omap3-dss",
368 "ti,omap4-dss",
369 "ti,omap5-dss",
370 "ti,dra7-dss",
371};
372
373static struct device_node * __init omapdss_find_dss_of_node(void)
374{
375 struct device_node *node;
376 int i;
377
378 for (i = 0; i < ARRAY_SIZE(omapdss_compat_names); ++i) {
379 node = of_find_compatible_node(NULL, NULL,
380 omapdss_compat_names[i]);
381 if (node)
382 return node;
383 }
384
385 return NULL;
386}
387
388static int __init omapdss_init_of(void)
389{
390 int r;
391 struct device_node *node;
392 struct platform_device *pdev;
393
394 /* only create dss helper devices if dss is enabled in the .dts */
395
396 node = omapdss_find_dss_of_node();
397 if (!node)
398 return 0;
399
400 if (!of_device_is_available(node))
401 return 0;
402
403 pdev = of_find_device_by_node(node);
404
405 if (!pdev) {
406 pr_err("Unable to find DSS platform device\n");
407 return -ENODEV;
408 }
409
410 r = of_platform_populate(node, NULL, NULL, &pdev->dev);
411 if (r) {
412 pr_err("Unable to populate DSS submodule devices\n");
413 return r;
414 }
415
416 return omapdss_init_fbdev();
417}
418omap_device_initcall(omapdss_init_of);
diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c
index 5544b82a2e7a..9a07916af8dd 100644
--- a/arch/arm/mm/proc-v7-bugs.c
+++ b/arch/arm/mm/proc-v7-bugs.c
@@ -52,8 +52,6 @@ static void cpu_v7_spectre_init(void)
52 case ARM_CPU_PART_CORTEX_A17: 52 case ARM_CPU_PART_CORTEX_A17:
53 case ARM_CPU_PART_CORTEX_A73: 53 case ARM_CPU_PART_CORTEX_A73:
54 case ARM_CPU_PART_CORTEX_A75: 54 case ARM_CPU_PART_CORTEX_A75:
55 if (processor.switch_mm != cpu_v7_bpiall_switch_mm)
56 goto bl_error;
57 per_cpu(harden_branch_predictor_fn, cpu) = 55 per_cpu(harden_branch_predictor_fn, cpu) =
58 harden_branch_predictor_bpiall; 56 harden_branch_predictor_bpiall;
59 spectre_v2_method = "BPIALL"; 57 spectre_v2_method = "BPIALL";
@@ -61,8 +59,6 @@ static void cpu_v7_spectre_init(void)
61 59
62 case ARM_CPU_PART_CORTEX_A15: 60 case ARM_CPU_PART_CORTEX_A15:
63 case ARM_CPU_PART_BRAHMA_B15: 61 case ARM_CPU_PART_BRAHMA_B15:
64 if (processor.switch_mm != cpu_v7_iciallu_switch_mm)
65 goto bl_error;
66 per_cpu(harden_branch_predictor_fn, cpu) = 62 per_cpu(harden_branch_predictor_fn, cpu) =
67 harden_branch_predictor_iciallu; 63 harden_branch_predictor_iciallu;
68 spectre_v2_method = "ICIALLU"; 64 spectre_v2_method = "ICIALLU";
@@ -88,11 +84,9 @@ static void cpu_v7_spectre_init(void)
88 ARM_SMCCC_ARCH_WORKAROUND_1, &res); 84 ARM_SMCCC_ARCH_WORKAROUND_1, &res);
89 if ((int)res.a0 != 0) 85 if ((int)res.a0 != 0)
90 break; 86 break;
91 if (processor.switch_mm != cpu_v7_hvc_switch_mm && cpu)
92 goto bl_error;
93 per_cpu(harden_branch_predictor_fn, cpu) = 87 per_cpu(harden_branch_predictor_fn, cpu) =
94 call_hvc_arch_workaround_1; 88 call_hvc_arch_workaround_1;
95 processor.switch_mm = cpu_v7_hvc_switch_mm; 89 cpu_do_switch_mm = cpu_v7_hvc_switch_mm;
96 spectre_v2_method = "hypervisor"; 90 spectre_v2_method = "hypervisor";
97 break; 91 break;
98 92
@@ -101,11 +95,9 @@ static void cpu_v7_spectre_init(void)
101 ARM_SMCCC_ARCH_WORKAROUND_1, &res); 95 ARM_SMCCC_ARCH_WORKAROUND_1, &res);
102 if ((int)res.a0 != 0) 96 if ((int)res.a0 != 0)
103 break; 97 break;
104 if (processor.switch_mm != cpu_v7_smc_switch_mm && cpu)
105 goto bl_error;
106 per_cpu(harden_branch_predictor_fn, cpu) = 98 per_cpu(harden_branch_predictor_fn, cpu) =
107 call_smc_arch_workaround_1; 99 call_smc_arch_workaround_1;
108 processor.switch_mm = cpu_v7_smc_switch_mm; 100 cpu_do_switch_mm = cpu_v7_smc_switch_mm;
109 spectre_v2_method = "firmware"; 101 spectre_v2_method = "firmware";
110 break; 102 break;
111 103
@@ -119,11 +111,6 @@ static void cpu_v7_spectre_init(void)
119 if (spectre_v2_method) 111 if (spectre_v2_method)
120 pr_info("CPU%u: Spectre v2: using %s workaround\n", 112 pr_info("CPU%u: Spectre v2: using %s workaround\n",
121 smp_processor_id(), spectre_v2_method); 113 smp_processor_id(), spectre_v2_method);
122 return;
123
124bl_error:
125 pr_err("CPU%u: Spectre v2: incorrect context switching function, system vulnerable\n",
126 cpu);
127} 114}
128#else 115#else
129static void cpu_v7_spectre_init(void) 116static void cpu_v7_spectre_init(void)
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index aff6e6eadc70..ee7b07938dd5 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -573,7 +573,7 @@ int vfp_preserve_user_clear_hwstate(struct user_vfp *ufp,
573 */ 573 */
574 ufp_exc->fpexc = hwstate->fpexc; 574 ufp_exc->fpexc = hwstate->fpexc;
575 ufp_exc->fpinst = hwstate->fpinst; 575 ufp_exc->fpinst = hwstate->fpinst;
576 ufp_exc->fpinst2 = ufp_exc->fpinst2; 576 ufp_exc->fpinst2 = hwstate->fpinst2;
577 577
578 /* Ensure that VFP is disabled. */ 578 /* Ensure that VFP is disabled. */
579 vfp_flush_hwstate(thread); 579 vfp_flush_hwstate(thread);
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 953e316521fc..f4fc1e0544b7 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
313 arm64_memblock_init(); 313 arm64_memblock_init();
314 314
315 paging_init(); 315 paging_init();
316 efi_apply_persistent_mem_reservations();
316 317
317 acpi_table_upgrade(); 318 acpi_table_upgrade();
318 319
diff --git a/arch/parisc/include/asm/spinlock.h b/arch/parisc/include/asm/spinlock.h
index 16aec9ba2580..8a63515f03bf 100644
--- a/arch/parisc/include/asm/spinlock.h
+++ b/arch/parisc/include/asm/spinlock.h
@@ -37,8 +37,8 @@ static inline void arch_spin_unlock(arch_spinlock_t *x)
37 volatile unsigned int *a; 37 volatile unsigned int *a;
38 38
39 a = __ldcw_align(x); 39 a = __ldcw_align(x);
40 /* Release with ordered store. */ 40 mb();
41 __asm__ __volatile__("stw,ma %0,0(%1)" : : "r"(1), "r"(a) : "memory"); 41 *a = 1;
42} 42}
43 43
44static inline int arch_spin_trylock(arch_spinlock_t *x) 44static inline int arch_spin_trylock(arch_spinlock_t *x)
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index 9505c317818d..a9bc90dc4ae7 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -640,7 +640,8 @@ cas_action:
640 sub,<> %r28, %r25, %r0 640 sub,<> %r28, %r25, %r0
6412: stw %r24, 0(%r26) 6412: stw %r24, 0(%r26)
642 /* Free lock */ 642 /* Free lock */
643 stw,ma %r20, 0(%sr2,%r20) 643 sync
644 stw %r20, 0(%sr2,%r20)
644#if ENABLE_LWS_DEBUG 645#if ENABLE_LWS_DEBUG
645 /* Clear thread register indicator */ 646 /* Clear thread register indicator */
646 stw %r0, 4(%sr2,%r20) 647 stw %r0, 4(%sr2,%r20)
@@ -654,7 +655,8 @@ cas_action:
6543: 6553:
655 /* Error occurred on load or store */ 656 /* Error occurred on load or store */
656 /* Free lock */ 657 /* Free lock */
657 stw,ma %r20, 0(%sr2,%r20) 658 sync
659 stw %r20, 0(%sr2,%r20)
658#if ENABLE_LWS_DEBUG 660#if ENABLE_LWS_DEBUG
659 stw %r0, 4(%sr2,%r20) 661 stw %r0, 4(%sr2,%r20)
660#endif 662#endif
@@ -855,7 +857,8 @@ cas2_action:
855 857
856cas2_end: 858cas2_end:
857 /* Free lock */ 859 /* Free lock */
858 stw,ma %r20, 0(%sr2,%r20) 860 sync
861 stw %r20, 0(%sr2,%r20)
859 /* Enable interrupts */ 862 /* Enable interrupts */
860 ssm PSW_SM_I, %r0 863 ssm PSW_SM_I, %r0
861 /* Return to userspace, set no error */ 864 /* Return to userspace, set no error */
@@ -865,7 +868,8 @@ cas2_end:
86522: 86822:
866 /* Error occurred on load or store */ 869 /* Error occurred on load or store */
867 /* Free lock */ 870 /* Free lock */
868 stw,ma %r20, 0(%sr2,%r20) 871 sync
872 stw %r20, 0(%sr2,%r20)
869 ssm PSW_SM_I, %r0 873 ssm PSW_SM_I, %r0
870 ldo 1(%r0),%r28 874 ldo 1(%r0),%r28
871 b lws_exit 875 b lws_exit
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 3ef40b703c4a..e746becd9d6f 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -268,19 +268,13 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
268 * their hooks, a bitfield is reserved for use by the platform near the 268 * their hooks, a bitfield is reserved for use by the platform near the
269 * top of MMIO addresses (not PIO, those have to cope the hard way). 269 * top of MMIO addresses (not PIO, those have to cope the hard way).
270 * 270 *
271 * This bit field is 12 bits and is at the top of the IO virtual 271 * The highest address in the kernel virtual space are:
272 * addresses PCI_IO_INDIRECT_TOKEN_MASK.
273 * 272 *
274 * The kernel virtual space is thus: 273 * d0003fffffffffff # with Hash MMU
274 * c00fffffffffffff # with Radix MMU
275 * 275 *
276 * 0xD000000000000000 : vmalloc 276 * The top 4 bits are reserved as the region ID on hash, leaving us 8 bits
277 * 0xD000080000000000 : PCI PHB IO space 277 * that can be used for the field.
278 * 0xD000080080000000 : ioremap
279 * 0xD0000fffffffffff : end of ioremap region
280 *
281 * Since the top 4 bits are reserved as the region ID, we use thus
282 * the next 12 bits and keep 4 bits available for the future if the
283 * virtual address space is ever to be extended.
284 * 278 *
285 * The direct IO mapping operations will then mask off those bits 279 * The direct IO mapping operations will then mask off those bits
286 * before doing the actual access, though that only happen when 280 * before doing the actual access, though that only happen when
@@ -292,8 +286,8 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
292 */ 286 */
293 287
294#ifdef CONFIG_PPC_INDIRECT_MMIO 288#ifdef CONFIG_PPC_INDIRECT_MMIO
295#define PCI_IO_IND_TOKEN_MASK 0x0fff000000000000ul 289#define PCI_IO_IND_TOKEN_SHIFT 52
296#define PCI_IO_IND_TOKEN_SHIFT 48 290#define PCI_IO_IND_TOKEN_MASK (0xfful << PCI_IO_IND_TOKEN_SHIFT)
297#define PCI_FIX_ADDR(addr) \ 291#define PCI_FIX_ADDR(addr) \
298 ((PCI_IO_ADDR)(((unsigned long)(addr)) & ~PCI_IO_IND_TOKEN_MASK)) 292 ((PCI_IO_ADDR)(((unsigned long)(addr)) & ~PCI_IO_IND_TOKEN_MASK))
299#define PCI_GET_ADDR_TOKEN(addr) \ 293#define PCI_GET_ADDR_TOKEN(addr) \
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 6093bc8f74e5..a6e9e314c707 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -493,6 +493,8 @@
493 __PPC_RS(t) | __PPC_RA0(a) | __PPC_RB(b)) 493 __PPC_RS(t) | __PPC_RA0(a) | __PPC_RB(b))
494#define PPC_SLBFEE_DOT(t, b) stringify_in_c(.long PPC_INST_SLBFEE | \ 494#define PPC_SLBFEE_DOT(t, b) stringify_in_c(.long PPC_INST_SLBFEE | \
495 __PPC_RT(t) | __PPC_RB(b)) 495 __PPC_RT(t) | __PPC_RB(b))
496#define __PPC_SLBFEE_DOT(t, b) stringify_in_c(.long PPC_INST_SLBFEE | \
497 ___PPC_RT(t) | ___PPC_RB(b))
496#define PPC_ICBT(c,a,b) stringify_in_c(.long PPC_INST_ICBT | \ 498#define PPC_ICBT(c,a,b) stringify_in_c(.long PPC_INST_ICBT | \
497 __PPC_CT(c) | __PPC_RA0(a) | __PPC_RB(b)) 499 __PPC_CT(c) | __PPC_RA0(a) | __PPC_RB(b))
498/* PASemi instructions */ 500/* PASemi instructions */
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index f73886a1a7f5..0b8a735b6d85 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -54,6 +54,7 @@ struct pt_regs
54 54
55#ifdef CONFIG_PPC64 55#ifdef CONFIG_PPC64
56 unsigned long ppr; 56 unsigned long ppr;
57 unsigned long __pad; /* Maintain 16 byte interrupt stack alignment */
57#endif 58#endif
58}; 59};
59#endif 60#endif
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 2a51e4cc8246..236c1151a3a7 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -636,6 +636,8 @@ static void *__init alloc_stack(unsigned long limit, int cpu)
636{ 636{
637 unsigned long pa; 637 unsigned long pa;
638 638
639 BUILD_BUG_ON(STACK_INT_FRAME_SIZE % 16);
640
639 pa = memblock_alloc_base_nid(THREAD_SIZE, THREAD_SIZE, limit, 641 pa = memblock_alloc_base_nid(THREAD_SIZE, THREAD_SIZE, limit,
640 early_cpu_to_node(cpu), MEMBLOCK_NONE); 642 early_cpu_to_node(cpu), MEMBLOCK_NONE);
641 if (!pa) { 643 if (!pa) {
diff --git a/arch/powerpc/kvm/trace.h b/arch/powerpc/kvm/trace.h
index 491b0f715d6b..ea1d7c808319 100644
--- a/arch/powerpc/kvm/trace.h
+++ b/arch/powerpc/kvm/trace.h
@@ -6,8 +6,6 @@
6 6
7#undef TRACE_SYSTEM 7#undef TRACE_SYSTEM
8#define TRACE_SYSTEM kvm 8#define TRACE_SYSTEM kvm
9#define TRACE_INCLUDE_PATH .
10#define TRACE_INCLUDE_FILE trace
11 9
12/* 10/*
13 * Tracepoint for guest mode entry. 11 * Tracepoint for guest mode entry.
@@ -120,4 +118,10 @@ TRACE_EVENT(kvm_check_requests,
120#endif /* _TRACE_KVM_H */ 118#endif /* _TRACE_KVM_H */
121 119
122/* This part must be outside protection */ 120/* This part must be outside protection */
121#undef TRACE_INCLUDE_PATH
122#undef TRACE_INCLUDE_FILE
123
124#define TRACE_INCLUDE_PATH .
125#define TRACE_INCLUDE_FILE trace
126
123#include <trace/define_trace.h> 127#include <trace/define_trace.h>
diff --git a/arch/powerpc/kvm/trace_booke.h b/arch/powerpc/kvm/trace_booke.h
index ac640e81fdc5..3837842986aa 100644
--- a/arch/powerpc/kvm/trace_booke.h
+++ b/arch/powerpc/kvm/trace_booke.h
@@ -6,8 +6,6 @@
6 6
7#undef TRACE_SYSTEM 7#undef TRACE_SYSTEM
8#define TRACE_SYSTEM kvm_booke 8#define TRACE_SYSTEM kvm_booke
9#define TRACE_INCLUDE_PATH .
10#define TRACE_INCLUDE_FILE trace_booke
11 9
12#define kvm_trace_symbol_exit \ 10#define kvm_trace_symbol_exit \
13 {0, "CRITICAL"}, \ 11 {0, "CRITICAL"}, \
@@ -218,4 +216,11 @@ TRACE_EVENT(kvm_booke_queue_irqprio,
218#endif 216#endif
219 217
220/* This part must be outside protection */ 218/* This part must be outside protection */
219
220#undef TRACE_INCLUDE_PATH
221#undef TRACE_INCLUDE_FILE
222
223#define TRACE_INCLUDE_PATH .
224#define TRACE_INCLUDE_FILE trace_booke
225
221#include <trace/define_trace.h> 226#include <trace/define_trace.h>
diff --git a/arch/powerpc/kvm/trace_hv.h b/arch/powerpc/kvm/trace_hv.h
index bcfe8a987f6a..8a1e3b0047f1 100644
--- a/arch/powerpc/kvm/trace_hv.h
+++ b/arch/powerpc/kvm/trace_hv.h
@@ -9,8 +9,6 @@
9 9
10#undef TRACE_SYSTEM 10#undef TRACE_SYSTEM
11#define TRACE_SYSTEM kvm_hv 11#define TRACE_SYSTEM kvm_hv
12#define TRACE_INCLUDE_PATH .
13#define TRACE_INCLUDE_FILE trace_hv
14 12
15#define kvm_trace_symbol_hcall \ 13#define kvm_trace_symbol_hcall \
16 {H_REMOVE, "H_REMOVE"}, \ 14 {H_REMOVE, "H_REMOVE"}, \
@@ -497,4 +495,11 @@ TRACE_EVENT(kvmppc_run_vcpu_exit,
497#endif /* _TRACE_KVM_HV_H */ 495#endif /* _TRACE_KVM_HV_H */
498 496
499/* This part must be outside protection */ 497/* This part must be outside protection */
498
499#undef TRACE_INCLUDE_PATH
500#undef TRACE_INCLUDE_FILE
501
502#define TRACE_INCLUDE_PATH .
503#define TRACE_INCLUDE_FILE trace_hv
504
500#include <trace/define_trace.h> 505#include <trace/define_trace.h>
diff --git a/arch/powerpc/kvm/trace_pr.h b/arch/powerpc/kvm/trace_pr.h
index 2f9a8829552b..46a46d328fbf 100644
--- a/arch/powerpc/kvm/trace_pr.h
+++ b/arch/powerpc/kvm/trace_pr.h
@@ -8,8 +8,6 @@
8 8
9#undef TRACE_SYSTEM 9#undef TRACE_SYSTEM
10#define TRACE_SYSTEM kvm_pr 10#define TRACE_SYSTEM kvm_pr
11#define TRACE_INCLUDE_PATH .
12#define TRACE_INCLUDE_FILE trace_pr
13 11
14TRACE_EVENT(kvm_book3s_reenter, 12TRACE_EVENT(kvm_book3s_reenter,
15 TP_PROTO(int r, struct kvm_vcpu *vcpu), 13 TP_PROTO(int r, struct kvm_vcpu *vcpu),
@@ -257,4 +255,11 @@ TRACE_EVENT(kvm_exit,
257#endif /* _TRACE_KVM_H */ 255#endif /* _TRACE_KVM_H */
258 256
259/* This part must be outside protection */ 257/* This part must be outside protection */
258
259#undef TRACE_INCLUDE_PATH
260#undef TRACE_INCLUDE_FILE
261
262#define TRACE_INCLUDE_PATH .
263#define TRACE_INCLUDE_FILE trace_pr
264
260#include <trace/define_trace.h> 265#include <trace/define_trace.h>
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 3a048e98a132..ce28ae5ca080 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1178,7 +1178,7 @@ static long vphn_get_associativity(unsigned long cpu,
1178 1178
1179 switch (rc) { 1179 switch (rc) {
1180 case H_FUNCTION: 1180 case H_FUNCTION:
1181 printk(KERN_INFO 1181 printk_once(KERN_INFO
1182 "VPHN is not supported. Disabling polling...\n"); 1182 "VPHN is not supported. Disabling polling...\n");
1183 stop_topology_update(); 1183 stop_topology_update();
1184 break; 1184 break;
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index c3fdf2969d9f..bc3914d54e26 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -19,6 +19,7 @@
19#include <asm/mmu.h> 19#include <asm/mmu.h>
20#include <asm/mmu_context.h> 20#include <asm/mmu_context.h>
21#include <asm/paca.h> 21#include <asm/paca.h>
22#include <asm/ppc-opcode.h>
22#include <asm/cputable.h> 23#include <asm/cputable.h>
23#include <asm/cacheflush.h> 24#include <asm/cacheflush.h>
24#include <asm/smp.h> 25#include <asm/smp.h>
@@ -58,27 +59,19 @@ static inline unsigned long mk_vsid_data(unsigned long ea, int ssize,
58 return __mk_vsid_data(get_kernel_vsid(ea, ssize), ssize, flags); 59 return __mk_vsid_data(get_kernel_vsid(ea, ssize), ssize, flags);
59} 60}
60 61
61static void assert_slb_exists(unsigned long ea) 62static void assert_slb_presence(bool present, unsigned long ea)
62{ 63{
63#ifdef CONFIG_DEBUG_VM 64#ifdef CONFIG_DEBUG_VM
64 unsigned long tmp; 65 unsigned long tmp;
65 66
66 WARN_ON_ONCE(mfmsr() & MSR_EE); 67 WARN_ON_ONCE(mfmsr() & MSR_EE);
67 68
68 asm volatile("slbfee. %0, %1" : "=r"(tmp) : "r"(ea) : "cr0"); 69 if (!cpu_has_feature(CPU_FTR_ARCH_206))
69 WARN_ON(tmp == 0); 70 return;
70#endif
71}
72
73static void assert_slb_notexists(unsigned long ea)
74{
75#ifdef CONFIG_DEBUG_VM
76 unsigned long tmp;
77 71
78 WARN_ON_ONCE(mfmsr() & MSR_EE); 72 asm volatile(__PPC_SLBFEE_DOT(%0, %1) : "=r"(tmp) : "r"(ea) : "cr0");
79 73
80 asm volatile("slbfee. %0, %1" : "=r"(tmp) : "r"(ea) : "cr0"); 74 WARN_ON(present == (tmp == 0));
81 WARN_ON(tmp != 0);
82#endif 75#endif
83} 76}
84 77
@@ -114,7 +107,7 @@ static inline void create_shadowed_slbe(unsigned long ea, int ssize,
114 */ 107 */
115 slb_shadow_update(ea, ssize, flags, index); 108 slb_shadow_update(ea, ssize, flags, index);
116 109
117 assert_slb_notexists(ea); 110 assert_slb_presence(false, ea);
118 asm volatile("slbmte %0,%1" : 111 asm volatile("slbmte %0,%1" :
119 : "r" (mk_vsid_data(ea, ssize, flags)), 112 : "r" (mk_vsid_data(ea, ssize, flags)),
120 "r" (mk_esid_data(ea, ssize, index)) 113 "r" (mk_esid_data(ea, ssize, index))
@@ -137,7 +130,7 @@ void __slb_restore_bolted_realmode(void)
137 "r" (be64_to_cpu(p->save_area[index].esid))); 130 "r" (be64_to_cpu(p->save_area[index].esid)));
138 } 131 }
139 132
140 assert_slb_exists(local_paca->kstack); 133 assert_slb_presence(true, local_paca->kstack);
141} 134}
142 135
143/* 136/*
@@ -185,7 +178,7 @@ void slb_flush_and_restore_bolted(void)
185 :: "r" (be64_to_cpu(p->save_area[KSTACK_INDEX].vsid)), 178 :: "r" (be64_to_cpu(p->save_area[KSTACK_INDEX].vsid)),
186 "r" (be64_to_cpu(p->save_area[KSTACK_INDEX].esid)) 179 "r" (be64_to_cpu(p->save_area[KSTACK_INDEX].esid))
187 : "memory"); 180 : "memory");
188 assert_slb_exists(get_paca()->kstack); 181 assert_slb_presence(true, get_paca()->kstack);
189 182
190 get_paca()->slb_cache_ptr = 0; 183 get_paca()->slb_cache_ptr = 0;
191 184
@@ -443,9 +436,9 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm)
443 ea = (unsigned long) 436 ea = (unsigned long)
444 get_paca()->slb_cache[i] << SID_SHIFT; 437 get_paca()->slb_cache[i] << SID_SHIFT;
445 /* 438 /*
446 * Could assert_slb_exists here, but hypervisor 439 * Could assert_slb_presence(true) here, but
447 * or machine check could have come in and 440 * hypervisor or machine check could have come
448 * removed the entry at this point. 441 * in and removed the entry at this point.
449 */ 442 */
450 443
451 slbie_data = ea; 444 slbie_data = ea;
@@ -676,7 +669,7 @@ static long slb_insert_entry(unsigned long ea, unsigned long context,
676 * User preloads should add isync afterwards in case the kernel 669 * User preloads should add isync afterwards in case the kernel
677 * accesses user memory before it returns to userspace with rfid. 670 * accesses user memory before it returns to userspace with rfid.
678 */ 671 */
679 assert_slb_notexists(ea); 672 assert_slb_presence(false, ea);
680 asm volatile("slbmte %0, %1" : : "r" (vsid_data), "r" (esid_data)); 673 asm volatile("slbmte %0, %1" : : "r" (vsid_data), "r" (esid_data));
681 674
682 barrier(); 675 barrier();
@@ -715,7 +708,7 @@ static long slb_allocate_kernel(unsigned long ea, unsigned long id)
715 return -EFAULT; 708 return -EFAULT;
716 709
717 if (ea < H_VMALLOC_END) 710 if (ea < H_VMALLOC_END)
718 flags = get_paca()->vmalloc_sllp; 711 flags = local_paca->vmalloc_sllp;
719 else 712 else
720 flags = SLB_VSID_KERNEL | mmu_psize_defs[mmu_io_psize].sllp; 713 flags = SLB_VSID_KERNEL | mmu_psize_defs[mmu_io_psize].sllp;
721 } else { 714 } else {
diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index 6f60e0931922..75b935252981 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -102,63 +102,6 @@ struct pci_dev *pnv_pci_get_npu_dev(struct pci_dev *gpdev, int index)
102} 102}
103EXPORT_SYMBOL(pnv_pci_get_npu_dev); 103EXPORT_SYMBOL(pnv_pci_get_npu_dev);
104 104
105#define NPU_DMA_OP_UNSUPPORTED() \
106 dev_err_once(dev, "%s operation unsupported for NVLink devices\n", \
107 __func__)
108
109static void *dma_npu_alloc(struct device *dev, size_t size,
110 dma_addr_t *dma_handle, gfp_t flag,
111 unsigned long attrs)
112{
113 NPU_DMA_OP_UNSUPPORTED();
114 return NULL;
115}
116
117static void dma_npu_free(struct device *dev, size_t size,
118 void *vaddr, dma_addr_t dma_handle,
119 unsigned long attrs)
120{
121 NPU_DMA_OP_UNSUPPORTED();
122}
123
124static dma_addr_t dma_npu_map_page(struct device *dev, struct page *page,
125 unsigned long offset, size_t size,
126 enum dma_data_direction direction,
127 unsigned long attrs)
128{
129 NPU_DMA_OP_UNSUPPORTED();
130 return 0;
131}
132
133static int dma_npu_map_sg(struct device *dev, struct scatterlist *sglist,
134 int nelems, enum dma_data_direction direction,
135 unsigned long attrs)
136{
137 NPU_DMA_OP_UNSUPPORTED();
138 return 0;
139}
140
141static int dma_npu_dma_supported(struct device *dev, u64 mask)
142{
143 NPU_DMA_OP_UNSUPPORTED();
144 return 0;
145}
146
147static u64 dma_npu_get_required_mask(struct device *dev)
148{
149 NPU_DMA_OP_UNSUPPORTED();
150 return 0;
151}
152
153static const struct dma_map_ops dma_npu_ops = {
154 .map_page = dma_npu_map_page,
155 .map_sg = dma_npu_map_sg,
156 .alloc = dma_npu_alloc,
157 .free = dma_npu_free,
158 .dma_supported = dma_npu_dma_supported,
159 .get_required_mask = dma_npu_get_required_mask,
160};
161
162/* 105/*
163 * Returns the PE assoicated with the PCI device of the given 106 * Returns the PE assoicated with the PCI device of the given
164 * NPU. Returns the linked pci device if pci_dev != NULL. 107 * NPU. Returns the linked pci device if pci_dev != NULL.
@@ -270,10 +213,11 @@ static void pnv_npu_dma_set_32(struct pnv_ioda_pe *npe)
270 rc = pnv_npu_set_window(npe, 0, gpe->table_group.tables[0]); 213 rc = pnv_npu_set_window(npe, 0, gpe->table_group.tables[0]);
271 214
272 /* 215 /*
273 * We don't initialise npu_pe->tce32_table as we always use 216 * NVLink devices use the same TCE table configuration as
274 * dma_npu_ops which are nops. 217 * their parent device so drivers shouldn't be doing DMA
218 * operations directly on these devices.
275 */ 219 */
276 set_dma_ops(&npe->pdev->dev, &dma_npu_ops); 220 set_dma_ops(&npe->pdev->dev, NULL);
277} 221}
278 222
279/* 223/*
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index d10146197533..4af153a182b0 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -77,4 +77,8 @@ core-y += arch/riscv/kernel/ arch/riscv/mm/
77 77
78libs-y += arch/riscv/lib/ 78libs-y += arch/riscv/lib/
79 79
80PHONY += vdso_install
81vdso_install:
82 $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
83
80all: vmlinux 84all: vmlinux
diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig
index 07fa9ea75fea..ef4f15df9adf 100644
--- a/arch/riscv/configs/defconfig
+++ b/arch/riscv/configs/defconfig
@@ -76,4 +76,5 @@ CONFIG_NFS_V4_1=y
76CONFIG_NFS_V4_2=y 76CONFIG_NFS_V4_2=y
77CONFIG_ROOT_NFS=y 77CONFIG_ROOT_NFS=y
78CONFIG_CRYPTO_USER_API_HASH=y 78CONFIG_CRYPTO_USER_API_HASH=y
79CONFIG_PRINTK_TIME=y
79# CONFIG_RCU_TRACE is not set 80# CONFIG_RCU_TRACE is not set
diff --git a/arch/riscv/include/asm/ptrace.h b/arch/riscv/include/asm/ptrace.h
index 2c5df945d43c..bbe1862e8f80 100644
--- a/arch/riscv/include/asm/ptrace.h
+++ b/arch/riscv/include/asm/ptrace.h
@@ -56,8 +56,8 @@ struct pt_regs {
56 unsigned long sstatus; 56 unsigned long sstatus;
57 unsigned long sbadaddr; 57 unsigned long sbadaddr;
58 unsigned long scause; 58 unsigned long scause;
59 /* a0 value before the syscall */ 59 /* a0 value before the syscall */
60 unsigned long orig_a0; 60 unsigned long orig_a0;
61}; 61};
62 62
63#ifdef CONFIG_64BIT 63#ifdef CONFIG_64BIT
diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index 3303ed2cd419..7dd308129b40 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -21,7 +21,7 @@ static int apply_r_riscv_32_rela(struct module *me, u32 *location, Elf_Addr v)
21{ 21{
22 if (v != (u32)v) { 22 if (v != (u32)v) {
23 pr_err("%s: value %016llx out of range for 32-bit field\n", 23 pr_err("%s: value %016llx out of range for 32-bit field\n",
24 me->name, v); 24 me->name, (long long)v);
25 return -EINVAL; 25 return -EINVAL;
26 } 26 }
27 *location = v; 27 *location = v;
@@ -102,7 +102,7 @@ static int apply_r_riscv_pcrel_hi20_rela(struct module *me, u32 *location,
102 if (offset != (s32)offset) { 102 if (offset != (s32)offset) {
103 pr_err( 103 pr_err(
104 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n", 104 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n",
105 me->name, v, location); 105 me->name, (long long)v, location);
106 return -EINVAL; 106 return -EINVAL;
107 } 107 }
108 108
@@ -144,7 +144,7 @@ static int apply_r_riscv_hi20_rela(struct module *me, u32 *location,
144 if (IS_ENABLED(CMODEL_MEDLOW)) { 144 if (IS_ENABLED(CMODEL_MEDLOW)) {
145 pr_err( 145 pr_err(
146 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n", 146 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n",
147 me->name, v, location); 147 me->name, (long long)v, location);
148 return -EINVAL; 148 return -EINVAL;
149 } 149 }
150 150
@@ -188,7 +188,7 @@ static int apply_r_riscv_got_hi20_rela(struct module *me, u32 *location,
188 } else { 188 } else {
189 pr_err( 189 pr_err(
190 "%s: can not generate the GOT entry for symbol = %016llx from PC = %p\n", 190 "%s: can not generate the GOT entry for symbol = %016llx from PC = %p\n",
191 me->name, v, location); 191 me->name, (long long)v, location);
192 return -EINVAL; 192 return -EINVAL;
193 } 193 }
194 194
@@ -212,7 +212,7 @@ static int apply_r_riscv_call_plt_rela(struct module *me, u32 *location,
212 } else { 212 } else {
213 pr_err( 213 pr_err(
214 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n", 214 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n",
215 me->name, v, location); 215 me->name, (long long)v, location);
216 return -EINVAL; 216 return -EINVAL;
217 } 217 }
218 } 218 }
@@ -234,7 +234,7 @@ static int apply_r_riscv_call_rela(struct module *me, u32 *location,
234 if (offset != fill_v) { 234 if (offset != fill_v) {
235 pr_err( 235 pr_err(
236 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n", 236 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n",
237 me->name, v, location); 237 me->name, (long long)v, location);
238 return -EINVAL; 238 return -EINVAL;
239 } 239 }
240 240
diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
index 5739bd05d289..4e2e600f7d53 100644
--- a/arch/riscv/lib/Makefile
+++ b/arch/riscv/lib/Makefile
@@ -3,6 +3,6 @@ lib-y += memcpy.o
3lib-y += memset.o 3lib-y += memset.o
4lib-y += uaccess.o 4lib-y += uaccess.o
5 5
6lib-(CONFIG_64BIT) += tishift.o 6lib-$(CONFIG_64BIT) += tishift.o
7 7
8lib-$(CONFIG_32BIT) += udivdi3.o 8lib-$(CONFIG_32BIT) += udivdi3.o
diff --git a/arch/xtensa/include/asm/processor.h b/arch/xtensa/include/asm/processor.h
index be9bfd9aa865..34a23016dd14 100644
--- a/arch/xtensa/include/asm/processor.h
+++ b/arch/xtensa/include/asm/processor.h
@@ -23,7 +23,11 @@
23# error Linux requires the Xtensa Windowed Registers Option. 23# error Linux requires the Xtensa Windowed Registers Option.
24#endif 24#endif
25 25
26#define ARCH_SLAB_MINALIGN XCHAL_DATA_WIDTH 26/* Xtensa ABI requires stack alignment to be at least 16 */
27
28#define STACK_ALIGN (XCHAL_DATA_WIDTH > 16 ? XCHAL_DATA_WIDTH : 16)
29
30#define ARCH_SLAB_MINALIGN STACK_ALIGN
27 31
28/* 32/*
29 * User space process size: 1 GB. 33 * User space process size: 1 GB.
diff --git a/arch/xtensa/kernel/head.S b/arch/xtensa/kernel/head.S
index 2f76118ecf62..9053a5622d2c 100644
--- a/arch/xtensa/kernel/head.S
+++ b/arch/xtensa/kernel/head.S
@@ -88,9 +88,12 @@ _SetupMMU:
88 initialize_mmu 88 initialize_mmu
89#if defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY 89#if defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
90 rsr a2, excsave1 90 rsr a2, excsave1
91 movi a3, 0x08000000 91 movi a3, XCHAL_KSEG_PADDR
92 bltu a2, a3, 1f
93 sub a2, a2, a3
94 movi a3, XCHAL_KSEG_SIZE
92 bgeu a2, a3, 1f 95 bgeu a2, a3, 1f
93 movi a3, 0xd0000000 96 movi a3, XCHAL_KSEG_CACHED_VADDR
94 add a2, a2, a3 97 add a2, a2, a3
95 wsr a2, excsave1 98 wsr a2, excsave1
961: 991:
diff --git a/block/bio.c b/block/bio.c
index a50d59236b19..4f4d9884443b 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -605,6 +605,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
605 if (bio_flagged(bio_src, BIO_THROTTLED)) 605 if (bio_flagged(bio_src, BIO_THROTTLED))
606 bio_set_flag(bio, BIO_THROTTLED); 606 bio_set_flag(bio, BIO_THROTTLED);
607 bio->bi_opf = bio_src->bi_opf; 607 bio->bi_opf = bio_src->bi_opf;
608 bio->bi_ioprio = bio_src->bi_ioprio;
608 bio->bi_write_hint = bio_src->bi_write_hint; 609 bio->bi_write_hint = bio_src->bi_write_hint;
609 bio->bi_iter = bio_src->bi_iter; 610 bio->bi_iter = bio_src->bi_iter;
610 bio->bi_io_vec = bio_src->bi_io_vec; 611 bio->bi_io_vec = bio_src->bi_io_vec;
diff --git a/block/blk-core.c b/block/blk-core.c
index ce12515f9b9b..deb56932f8c4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -798,9 +798,8 @@ void blk_cleanup_queue(struct request_queue *q)
798 * dispatch may still be in-progress since we dispatch requests 798 * dispatch may still be in-progress since we dispatch requests
799 * from more than one contexts. 799 * from more than one contexts.
800 * 800 *
801 * No need to quiesce queue if it isn't initialized yet since 801 * We rely on driver to deal with the race in case that queue
802 * blk_freeze_queue() should be enough for cases of passthrough 802 * initialization isn't done.
803 * request.
804 */ 803 */
805 if (q->mq_ops && blk_queue_init_done(q)) 804 if (q->mq_ops && blk_queue_init_done(q))
806 blk_mq_quiesce_queue(q); 805 blk_mq_quiesce_queue(q);
diff --git a/block/blk-lib.c b/block/blk-lib.c
index e8b3bb9bf375..5f2c429d4378 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -55,9 +55,11 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
55 return -EINVAL; 55 return -EINVAL;
56 56
57 while (nr_sects) { 57 while (nr_sects) {
58 unsigned int req_sects = min_t(unsigned int, nr_sects, 58 sector_t req_sects = min_t(sector_t, nr_sects,
59 bio_allowed_max_sectors(q)); 59 bio_allowed_max_sectors(q));
60 60
61 WARN_ON_ONCE((req_sects << 9) > UINT_MAX);
62
61 bio = blk_next_bio(bio, 0, gfp_mask); 63 bio = blk_next_bio(bio, 0, gfp_mask);
62 bio->bi_iter.bi_sector = sector; 64 bio->bi_iter.bi_sector = sector;
63 bio_set_dev(bio, bdev); 65 bio_set_dev(bio, bdev);
diff --git a/block/bounce.c b/block/bounce.c
index 36869afc258c..559c55bda040 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -248,6 +248,7 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
248 return NULL; 248 return NULL;
249 bio->bi_disk = bio_src->bi_disk; 249 bio->bi_disk = bio_src->bi_disk;
250 bio->bi_opf = bio_src->bi_opf; 250 bio->bi_opf = bio_src->bi_opf;
251 bio->bi_ioprio = bio_src->bi_ioprio;
251 bio->bi_write_hint = bio_src->bi_write_hint; 252 bio->bi_write_hint = bio_src->bi_write_hint;
252 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; 253 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector;
253 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; 254 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size;
diff --git a/crypto/crypto_user_base.c b/crypto/crypto_user_base.c
index e41f6cc33fff..784748dbb19f 100644
--- a/crypto/crypto_user_base.c
+++ b/crypto/crypto_user_base.c
@@ -84,7 +84,7 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
84{ 84{
85 struct crypto_report_cipher rcipher; 85 struct crypto_report_cipher rcipher;
86 86
87 strlcpy(rcipher.type, "cipher", sizeof(rcipher.type)); 87 strncpy(rcipher.type, "cipher", sizeof(rcipher.type));
88 88
89 rcipher.blocksize = alg->cra_blocksize; 89 rcipher.blocksize = alg->cra_blocksize;
90 rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; 90 rcipher.min_keysize = alg->cra_cipher.cia_min_keysize;
@@ -103,7 +103,7 @@ static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)
103{ 103{
104 struct crypto_report_comp rcomp; 104 struct crypto_report_comp rcomp;
105 105
106 strlcpy(rcomp.type, "compression", sizeof(rcomp.type)); 106 strncpy(rcomp.type, "compression", sizeof(rcomp.type));
107 if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, 107 if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS,
108 sizeof(struct crypto_report_comp), &rcomp)) 108 sizeof(struct crypto_report_comp), &rcomp))
109 goto nla_put_failure; 109 goto nla_put_failure;
@@ -117,7 +117,7 @@ static int crypto_report_acomp(struct sk_buff *skb, struct crypto_alg *alg)
117{ 117{
118 struct crypto_report_acomp racomp; 118 struct crypto_report_acomp racomp;
119 119
120 strlcpy(racomp.type, "acomp", sizeof(racomp.type)); 120 strncpy(racomp.type, "acomp", sizeof(racomp.type));
121 121
122 if (nla_put(skb, CRYPTOCFGA_REPORT_ACOMP, 122 if (nla_put(skb, CRYPTOCFGA_REPORT_ACOMP,
123 sizeof(struct crypto_report_acomp), &racomp)) 123 sizeof(struct crypto_report_acomp), &racomp))
@@ -132,7 +132,7 @@ static int crypto_report_akcipher(struct sk_buff *skb, struct crypto_alg *alg)
132{ 132{
133 struct crypto_report_akcipher rakcipher; 133 struct crypto_report_akcipher rakcipher;
134 134
135 strlcpy(rakcipher.type, "akcipher", sizeof(rakcipher.type)); 135 strncpy(rakcipher.type, "akcipher", sizeof(rakcipher.type));
136 136
137 if (nla_put(skb, CRYPTOCFGA_REPORT_AKCIPHER, 137 if (nla_put(skb, CRYPTOCFGA_REPORT_AKCIPHER,
138 sizeof(struct crypto_report_akcipher), &rakcipher)) 138 sizeof(struct crypto_report_akcipher), &rakcipher))
@@ -147,7 +147,7 @@ static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)
147{ 147{
148 struct crypto_report_kpp rkpp; 148 struct crypto_report_kpp rkpp;
149 149
150 strlcpy(rkpp.type, "kpp", sizeof(rkpp.type)); 150 strncpy(rkpp.type, "kpp", sizeof(rkpp.type));
151 151
152 if (nla_put(skb, CRYPTOCFGA_REPORT_KPP, 152 if (nla_put(skb, CRYPTOCFGA_REPORT_KPP,
153 sizeof(struct crypto_report_kpp), &rkpp)) 153 sizeof(struct crypto_report_kpp), &rkpp))
@@ -161,10 +161,10 @@ nla_put_failure:
161static int crypto_report_one(struct crypto_alg *alg, 161static int crypto_report_one(struct crypto_alg *alg,
162 struct crypto_user_alg *ualg, struct sk_buff *skb) 162 struct crypto_user_alg *ualg, struct sk_buff *skb)
163{ 163{
164 strlcpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name)); 164 strncpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));
165 strlcpy(ualg->cru_driver_name, alg->cra_driver_name, 165 strncpy(ualg->cru_driver_name, alg->cra_driver_name,
166 sizeof(ualg->cru_driver_name)); 166 sizeof(ualg->cru_driver_name));
167 strlcpy(ualg->cru_module_name, module_name(alg->cra_module), 167 strncpy(ualg->cru_module_name, module_name(alg->cra_module),
168 sizeof(ualg->cru_module_name)); 168 sizeof(ualg->cru_module_name));
169 169
170 ualg->cru_type = 0; 170 ualg->cru_type = 0;
@@ -177,7 +177,7 @@ static int crypto_report_one(struct crypto_alg *alg,
177 if (alg->cra_flags & CRYPTO_ALG_LARVAL) { 177 if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
178 struct crypto_report_larval rl; 178 struct crypto_report_larval rl;
179 179
180 strlcpy(rl.type, "larval", sizeof(rl.type)); 180 strncpy(rl.type, "larval", sizeof(rl.type));
181 if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL, 181 if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL,
182 sizeof(struct crypto_report_larval), &rl)) 182 sizeof(struct crypto_report_larval), &rl))
183 goto nla_put_failure; 183 goto nla_put_failure;
diff --git a/crypto/crypto_user_stat.c b/crypto/crypto_user_stat.c
index 021ad06bbb62..1dfaa0ccd555 100644
--- a/crypto/crypto_user_stat.c
+++ b/crypto/crypto_user_stat.c
@@ -37,6 +37,8 @@ static int crypto_report_aead(struct sk_buff *skb, struct crypto_alg *alg)
37 u64 v64; 37 u64 v64;
38 u32 v32; 38 u32 v32;
39 39
40 memset(&raead, 0, sizeof(raead));
41
40 strncpy(raead.type, "aead", sizeof(raead.type)); 42 strncpy(raead.type, "aead", sizeof(raead.type));
41 43
42 v32 = atomic_read(&alg->encrypt_cnt); 44 v32 = atomic_read(&alg->encrypt_cnt);
@@ -65,6 +67,8 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
65 u64 v64; 67 u64 v64;
66 u32 v32; 68 u32 v32;
67 69
70 memset(&rcipher, 0, sizeof(rcipher));
71
68 strlcpy(rcipher.type, "cipher", sizeof(rcipher.type)); 72 strlcpy(rcipher.type, "cipher", sizeof(rcipher.type));
69 73
70 v32 = atomic_read(&alg->encrypt_cnt); 74 v32 = atomic_read(&alg->encrypt_cnt);
@@ -93,6 +97,8 @@ static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)
93 u64 v64; 97 u64 v64;
94 u32 v32; 98 u32 v32;
95 99
100 memset(&rcomp, 0, sizeof(rcomp));
101
96 strlcpy(rcomp.type, "compression", sizeof(rcomp.type)); 102 strlcpy(rcomp.type, "compression", sizeof(rcomp.type));
97 v32 = atomic_read(&alg->compress_cnt); 103 v32 = atomic_read(&alg->compress_cnt);
98 rcomp.stat_compress_cnt = v32; 104 rcomp.stat_compress_cnt = v32;
@@ -120,6 +126,8 @@ static int crypto_report_acomp(struct sk_buff *skb, struct crypto_alg *alg)
120 u64 v64; 126 u64 v64;
121 u32 v32; 127 u32 v32;
122 128
129 memset(&racomp, 0, sizeof(racomp));
130
123 strlcpy(racomp.type, "acomp", sizeof(racomp.type)); 131 strlcpy(racomp.type, "acomp", sizeof(racomp.type));
124 v32 = atomic_read(&alg->compress_cnt); 132 v32 = atomic_read(&alg->compress_cnt);
125 racomp.stat_compress_cnt = v32; 133 racomp.stat_compress_cnt = v32;
@@ -147,6 +155,8 @@ static int crypto_report_akcipher(struct sk_buff *skb, struct crypto_alg *alg)
147 u64 v64; 155 u64 v64;
148 u32 v32; 156 u32 v32;
149 157
158 memset(&rakcipher, 0, sizeof(rakcipher));
159
150 strncpy(rakcipher.type, "akcipher", sizeof(rakcipher.type)); 160 strncpy(rakcipher.type, "akcipher", sizeof(rakcipher.type));
151 v32 = atomic_read(&alg->encrypt_cnt); 161 v32 = atomic_read(&alg->encrypt_cnt);
152 rakcipher.stat_encrypt_cnt = v32; 162 rakcipher.stat_encrypt_cnt = v32;
@@ -177,6 +187,8 @@ static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)
177 struct crypto_stat rkpp; 187 struct crypto_stat rkpp;
178 u32 v; 188 u32 v;
179 189
190 memset(&rkpp, 0, sizeof(rkpp));
191
180 strlcpy(rkpp.type, "kpp", sizeof(rkpp.type)); 192 strlcpy(rkpp.type, "kpp", sizeof(rkpp.type));
181 193
182 v = atomic_read(&alg->setsecret_cnt); 194 v = atomic_read(&alg->setsecret_cnt);
@@ -203,6 +215,8 @@ static int crypto_report_ahash(struct sk_buff *skb, struct crypto_alg *alg)
203 u64 v64; 215 u64 v64;
204 u32 v32; 216 u32 v32;
205 217
218 memset(&rhash, 0, sizeof(rhash));
219
206 strncpy(rhash.type, "ahash", sizeof(rhash.type)); 220 strncpy(rhash.type, "ahash", sizeof(rhash.type));
207 221
208 v32 = atomic_read(&alg->hash_cnt); 222 v32 = atomic_read(&alg->hash_cnt);
@@ -227,6 +241,8 @@ static int crypto_report_shash(struct sk_buff *skb, struct crypto_alg *alg)
227 u64 v64; 241 u64 v64;
228 u32 v32; 242 u32 v32;
229 243
244 memset(&rhash, 0, sizeof(rhash));
245
230 strncpy(rhash.type, "shash", sizeof(rhash.type)); 246 strncpy(rhash.type, "shash", sizeof(rhash.type));
231 247
232 v32 = atomic_read(&alg->hash_cnt); 248 v32 = atomic_read(&alg->hash_cnt);
@@ -251,6 +267,8 @@ static int crypto_report_rng(struct sk_buff *skb, struct crypto_alg *alg)
251 u64 v64; 267 u64 v64;
252 u32 v32; 268 u32 v32;
253 269
270 memset(&rrng, 0, sizeof(rrng));
271
254 strncpy(rrng.type, "rng", sizeof(rrng.type)); 272 strncpy(rrng.type, "rng", sizeof(rrng.type));
255 273
256 v32 = atomic_read(&alg->generate_cnt); 274 v32 = atomic_read(&alg->generate_cnt);
@@ -275,6 +293,8 @@ static int crypto_reportstat_one(struct crypto_alg *alg,
275 struct crypto_user_alg *ualg, 293 struct crypto_user_alg *ualg,
276 struct sk_buff *skb) 294 struct sk_buff *skb)
277{ 295{
296 memset(ualg, 0, sizeof(*ualg));
297
278 strlcpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name)); 298 strlcpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));
279 strlcpy(ualg->cru_driver_name, alg->cra_driver_name, 299 strlcpy(ualg->cru_driver_name, alg->cra_driver_name,
280 sizeof(ualg->cru_driver_name)); 300 sizeof(ualg->cru_driver_name));
@@ -291,6 +311,7 @@ static int crypto_reportstat_one(struct crypto_alg *alg,
291 if (alg->cra_flags & CRYPTO_ALG_LARVAL) { 311 if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
292 struct crypto_stat rl; 312 struct crypto_stat rl;
293 313
314 memset(&rl, 0, sizeof(rl));
294 strlcpy(rl.type, "larval", sizeof(rl.type)); 315 strlcpy(rl.type, "larval", sizeof(rl.type));
295 if (nla_put(skb, CRYPTOCFGA_STAT_LARVAL, 316 if (nla_put(skb, CRYPTOCFGA_STAT_LARVAL,
296 sizeof(struct crypto_stat), &rl)) 317 sizeof(struct crypto_stat), &rl))
diff --git a/crypto/simd.c b/crypto/simd.c
index ea7240be3001..78e8d037ae2b 100644
--- a/crypto/simd.c
+++ b/crypto/simd.c
@@ -124,8 +124,9 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
124 124
125 ctx->cryptd_tfm = cryptd_tfm; 125 ctx->cryptd_tfm = cryptd_tfm;
126 126
127 reqsize = sizeof(struct skcipher_request); 127 reqsize = crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
128 reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base); 128 reqsize = max(reqsize, crypto_skcipher_reqsize(&cryptd_tfm->base));
129 reqsize += sizeof(struct skcipher_request);
129 130
130 crypto_skcipher_set_reqsize(tfm, reqsize); 131 crypto_skcipher_set_reqsize(tfm, reqsize);
131 132
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 8f3a444c6ea9..7cea769c37df 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -512,7 +512,7 @@ config CRC_PMIC_OPREGION
512 512
513config XPOWER_PMIC_OPREGION 513config XPOWER_PMIC_OPREGION
514 bool "ACPI operation region support for XPower AXP288 PMIC" 514 bool "ACPI operation region support for XPower AXP288 PMIC"
515 depends on MFD_AXP20X_I2C && IOSF_MBI 515 depends on MFD_AXP20X_I2C && IOSF_MBI=y
516 help 516 help
517 This config adds ACPI operation region support for XPower AXP288 PMIC. 517 This config adds ACPI operation region support for XPower AXP288 PMIC.
518 518
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6e594644cb1d..a7f5202a4815 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4553,7 +4553,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4553 /* These specific Samsung models/firmware-revs do not handle LPM well */ 4553 /* These specific Samsung models/firmware-revs do not handle LPM well */
4554 { "SAMSUNG MZMPC128HBFU-000MV", "CXM14M1Q", ATA_HORKAGE_NOLPM, }, 4554 { "SAMSUNG MZMPC128HBFU-000MV", "CXM14M1Q", ATA_HORKAGE_NOLPM, },
4555 { "SAMSUNG SSD PM830 mSATA *", "CXM13D1Q", ATA_HORKAGE_NOLPM, }, 4555 { "SAMSUNG SSD PM830 mSATA *", "CXM13D1Q", ATA_HORKAGE_NOLPM, },
4556 { "SAMSUNG MZ7TD256HAFV-000L9", "DXT02L5Q", ATA_HORKAGE_NOLPM, }, 4556 { "SAMSUNG MZ7TD256HAFV-000L9", NULL, ATA_HORKAGE_NOLPM, },
4557 4557
4558 /* devices that don't properly handle queued TRIM commands */ 4558 /* devices that don't properly handle queued TRIM commands */
4559 { "Micron_M500IT_*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | 4559 { "Micron_M500IT_*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index a8cfa011c284..fb23578e9a41 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4148,10 +4148,11 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive)
4148 bio.bi_end_io = floppy_rb0_cb; 4148 bio.bi_end_io = floppy_rb0_cb;
4149 bio_set_op_attrs(&bio, REQ_OP_READ, 0); 4149 bio_set_op_attrs(&bio, REQ_OP_READ, 0);
4150 4150
4151 init_completion(&cbdata.complete);
4152
4151 submit_bio(&bio); 4153 submit_bio(&bio);
4152 process_fd_request(); 4154 process_fd_request();
4153 4155
4154 init_completion(&cbdata.complete);
4155 wait_for_completion(&cbdata.complete); 4156 wait_for_completion(&cbdata.complete);
4156 4157
4157 __free_page(page); 4158 __free_page(page);
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 8cfee0ab804b..d8c3595e9023 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -160,8 +160,13 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
160 /* Ensure the arm clock divider is what we expect */ 160 /* Ensure the arm clock divider is what we expect */
161 ret = clk_set_rate(clks[ARM].clk, new_freq * 1000); 161 ret = clk_set_rate(clks[ARM].clk, new_freq * 1000);
162 if (ret) { 162 if (ret) {
163 int ret1;
164
163 dev_err(cpu_dev, "failed to set clock rate: %d\n", ret); 165 dev_err(cpu_dev, "failed to set clock rate: %d\n", ret);
164 regulator_set_voltage_tol(arm_reg, volt_old, 0); 166 ret1 = regulator_set_voltage_tol(arm_reg, volt_old, 0);
167 if (ret1)
168 dev_warn(cpu_dev,
169 "failed to restore vddarm voltage: %d\n", ret1);
165 return ret; 170 return ret;
166 } 171 }
167 172
diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
index 073557f433eb..3a407a3ef22b 100644
--- a/drivers/cpuidle/cpuidle-arm.c
+++ b/drivers/cpuidle/cpuidle-arm.c
@@ -82,7 +82,6 @@ static int __init arm_idle_init_cpu(int cpu)
82{ 82{
83 int ret; 83 int ret;
84 struct cpuidle_driver *drv; 84 struct cpuidle_driver *drv;
85 struct cpuidle_device *dev;
86 85
87 drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL); 86 drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL);
88 if (!drv) 87 if (!drv)
@@ -103,13 +102,6 @@ static int __init arm_idle_init_cpu(int cpu)
103 goto out_kfree_drv; 102 goto out_kfree_drv;
104 } 103 }
105 104
106 ret = cpuidle_register_driver(drv);
107 if (ret) {
108 if (ret != -EBUSY)
109 pr_err("Failed to register cpuidle driver\n");
110 goto out_kfree_drv;
111 }
112
113 /* 105 /*
114 * Call arch CPU operations in order to initialize 106 * Call arch CPU operations in order to initialize
115 * idle states suspend back-end specific data 107 * idle states suspend back-end specific data
@@ -117,37 +109,21 @@ static int __init arm_idle_init_cpu(int cpu)
117 ret = arm_cpuidle_init(cpu); 109 ret = arm_cpuidle_init(cpu);
118 110
119 /* 111 /*
120 * Skip the cpuidle device initialization if the reported 112 * Allow the initialization to continue for other CPUs, if the reported
121 * failure is a HW misconfiguration/breakage (-ENXIO). 113 * failure is a HW misconfiguration/breakage (-ENXIO).
122 */ 114 */
123 if (ret == -ENXIO)
124 return 0;
125
126 if (ret) { 115 if (ret) {
127 pr_err("CPU %d failed to init idle CPU ops\n", cpu); 116 pr_err("CPU %d failed to init idle CPU ops\n", cpu);
128 goto out_unregister_drv; 117 ret = ret == -ENXIO ? 0 : ret;
129 } 118 goto out_kfree_drv;
130
131 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
132 if (!dev) {
133 ret = -ENOMEM;
134 goto out_unregister_drv;
135 } 119 }
136 dev->cpu = cpu;
137 120
138 ret = cpuidle_register_device(dev); 121 ret = cpuidle_register(drv, NULL);
139 if (ret) { 122 if (ret)
140 pr_err("Failed to register cpuidle device for CPU %d\n", 123 goto out_kfree_drv;
141 cpu);
142 goto out_kfree_dev;
143 }
144 124
145 return 0; 125 return 0;
146 126
147out_kfree_dev:
148 kfree(dev);
149out_unregister_drv:
150 cpuidle_unregister_driver(drv);
151out_kfree_drv: 127out_kfree_drv:
152 kfree(drv); 128 kfree(drv);
153 return ret; 129 return ret;
@@ -178,9 +154,7 @@ out_fail:
178 while (--cpu >= 0) { 154 while (--cpu >= 0) {
179 dev = per_cpu(cpuidle_devices, cpu); 155 dev = per_cpu(cpuidle_devices, cpu);
180 drv = cpuidle_get_cpu_driver(dev); 156 drv = cpuidle_get_cpu_driver(dev);
181 cpuidle_unregister_device(dev); 157 cpuidle_unregister(drv);
182 cpuidle_unregister_driver(drv);
183 kfree(dev);
184 kfree(drv); 158 kfree(drv);
185 } 159 }
186 160
diff --git a/drivers/crypto/hisilicon/sec/sec_algs.c b/drivers/crypto/hisilicon/sec/sec_algs.c
index f7d6d690116e..cdc4f9a171d9 100644
--- a/drivers/crypto/hisilicon/sec/sec_algs.c
+++ b/drivers/crypto/hisilicon/sec/sec_algs.c
@@ -732,6 +732,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
732 int *splits_in_nents; 732 int *splits_in_nents;
733 int *splits_out_nents = NULL; 733 int *splits_out_nents = NULL;
734 struct sec_request_el *el, *temp; 734 struct sec_request_el *el, *temp;
735 bool split = skreq->src != skreq->dst;
735 736
736 mutex_init(&sec_req->lock); 737 mutex_init(&sec_req->lock);
737 sec_req->req_base = &skreq->base; 738 sec_req->req_base = &skreq->base;
@@ -750,7 +751,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
750 if (ret) 751 if (ret)
751 goto err_free_split_sizes; 752 goto err_free_split_sizes;
752 753
753 if (skreq->src != skreq->dst) { 754 if (split) {
754 sec_req->len_out = sg_nents(skreq->dst); 755 sec_req->len_out = sg_nents(skreq->dst);
755 ret = sec_map_and_split_sg(skreq->dst, split_sizes, steps, 756 ret = sec_map_and_split_sg(skreq->dst, split_sizes, steps,
756 &splits_out, &splits_out_nents, 757 &splits_out, &splits_out_nents,
@@ -785,8 +786,9 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
785 split_sizes[i], 786 split_sizes[i],
786 skreq->src != skreq->dst, 787 skreq->src != skreq->dst,
787 splits_in[i], splits_in_nents[i], 788 splits_in[i], splits_in_nents[i],
788 splits_out[i], 789 split ? splits_out[i] : NULL,
789 splits_out_nents[i], info); 790 split ? splits_out_nents[i] : 0,
791 info);
790 if (IS_ERR(el)) { 792 if (IS_ERR(el)) {
791 ret = PTR_ERR(el); 793 ret = PTR_ERR(el);
792 goto err_free_elements; 794 goto err_free_elements;
@@ -806,13 +808,6 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
806 * more refined but this is unlikely to happen so no need. 808 * more refined but this is unlikely to happen so no need.
807 */ 809 */
808 810
809 /* Cleanup - all elements in pointer arrays have been coppied */
810 kfree(splits_in_nents);
811 kfree(splits_in);
812 kfree(splits_out_nents);
813 kfree(splits_out);
814 kfree(split_sizes);
815
816 /* Grab a big lock for a long time to avoid concurrency issues */ 811 /* Grab a big lock for a long time to avoid concurrency issues */
817 mutex_lock(&queue->queuelock); 812 mutex_lock(&queue->queuelock);
818 813
@@ -827,13 +822,13 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
827 (!queue->havesoftqueue || 822 (!queue->havesoftqueue ||
828 kfifo_avail(&queue->softqueue) > steps)) || 823 kfifo_avail(&queue->softqueue) > steps)) ||
829 !list_empty(&ctx->backlog)) { 824 !list_empty(&ctx->backlog)) {
825 ret = -EBUSY;
830 if ((skreq->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) { 826 if ((skreq->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) {
831 list_add_tail(&sec_req->backlog_head, &ctx->backlog); 827 list_add_tail(&sec_req->backlog_head, &ctx->backlog);
832 mutex_unlock(&queue->queuelock); 828 mutex_unlock(&queue->queuelock);
833 return -EBUSY; 829 goto out;
834 } 830 }
835 831
836 ret = -EBUSY;
837 mutex_unlock(&queue->queuelock); 832 mutex_unlock(&queue->queuelock);
838 goto err_free_elements; 833 goto err_free_elements;
839 } 834 }
@@ -842,7 +837,15 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
842 if (ret) 837 if (ret)
843 goto err_free_elements; 838 goto err_free_elements;
844 839
845 return -EINPROGRESS; 840 ret = -EINPROGRESS;
841out:
842 /* Cleanup - all elements in pointer arrays have been copied */
843 kfree(splits_in_nents);
844 kfree(splits_in);
845 kfree(splits_out_nents);
846 kfree(splits_out);
847 kfree(split_sizes);
848 return ret;
846 849
847err_free_elements: 850err_free_elements:
848 list_for_each_entry_safe(el, temp, &sec_req->elements, head) { 851 list_for_each_entry_safe(el, temp, &sec_req->elements, head) {
@@ -854,7 +857,7 @@ err_free_elements:
854 crypto_skcipher_ivsize(atfm), 857 crypto_skcipher_ivsize(atfm),
855 DMA_BIDIRECTIONAL); 858 DMA_BIDIRECTIONAL);
856err_unmap_out_sg: 859err_unmap_out_sg:
857 if (skreq->src != skreq->dst) 860 if (split)
858 sec_unmap_sg_on_err(skreq->dst, steps, splits_out, 861 sec_unmap_sg_on_err(skreq->dst, steps, splits_out,
859 splits_out_nents, sec_req->len_out, 862 splits_out_nents, sec_req->len_out,
860 info->dev); 863 info->dev);
diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
index 388a929baf95..1a6a77df8a5e 100644
--- a/drivers/firmware/efi/arm-init.c
+++ b/drivers/firmware/efi/arm-init.c
@@ -265,6 +265,10 @@ void __init efi_init(void)
265 (params.mmap & ~PAGE_MASK))); 265 (params.mmap & ~PAGE_MASK)));
266 266
267 init_screen_info(); 267 init_screen_info();
268
269 /* ARM does not permit early mappings to persist across paging_init() */
270 if (IS_ENABLED(CONFIG_ARM))
271 efi_memmap_unmap();
268} 272}
269 273
270static int __init register_gop_device(void) 274static int __init register_gop_device(void)
diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
index 922cfb813109..a00934d263c5 100644
--- a/drivers/firmware/efi/arm-runtime.c
+++ b/drivers/firmware/efi/arm-runtime.c
@@ -110,7 +110,7 @@ static int __init arm_enable_runtime_services(void)
110{ 110{
111 u64 mapsize; 111 u64 mapsize;
112 112
113 if (!efi_enabled(EFI_BOOT) || !efi_enabled(EFI_MEMMAP)) { 113 if (!efi_enabled(EFI_BOOT)) {
114 pr_info("EFI services will not be available.\n"); 114 pr_info("EFI services will not be available.\n");
115 return 0; 115 return 0;
116 } 116 }
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 249eb70691b0..fad7c62cfc0e 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -592,7 +592,11 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz,
592 592
593 early_memunmap(tbl, sizeof(*tbl)); 593 early_memunmap(tbl, sizeof(*tbl));
594 } 594 }
595 return 0;
596}
595 597
598int __init efi_apply_persistent_mem_reservations(void)
599{
596 if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) { 600 if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) {
597 unsigned long prsv = efi.mem_reserve; 601 unsigned long prsv = efi.mem_reserve;
598 602
@@ -963,36 +967,43 @@ bool efi_is_table_address(unsigned long phys_addr)
963} 967}
964 968
965static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock); 969static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock);
970static struct linux_efi_memreserve *efi_memreserve_root __ro_after_init;
966 971
967int efi_mem_reserve_persistent(phys_addr_t addr, u64 size) 972int efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
968{ 973{
969 struct linux_efi_memreserve *rsv, *parent; 974 struct linux_efi_memreserve *rsv;
970 975
971 if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR) 976 if (!efi_memreserve_root)
972 return -ENODEV; 977 return -ENODEV;
973 978
974 rsv = kmalloc(sizeof(*rsv), GFP_KERNEL); 979 rsv = kmalloc(sizeof(*rsv), GFP_ATOMIC);
975 if (!rsv) 980 if (!rsv)
976 return -ENOMEM; 981 return -ENOMEM;
977 982
978 parent = memremap(efi.mem_reserve, sizeof(*rsv), MEMREMAP_WB);
979 if (!parent) {
980 kfree(rsv);
981 return -ENOMEM;
982 }
983
984 rsv->base = addr; 983 rsv->base = addr;
985 rsv->size = size; 984 rsv->size = size;
986 985
987 spin_lock(&efi_mem_reserve_persistent_lock); 986 spin_lock(&efi_mem_reserve_persistent_lock);
988 rsv->next = parent->next; 987 rsv->next = efi_memreserve_root->next;
989 parent->next = __pa(rsv); 988 efi_memreserve_root->next = __pa(rsv);
990 spin_unlock(&efi_mem_reserve_persistent_lock); 989 spin_unlock(&efi_mem_reserve_persistent_lock);
991 990
992 memunmap(parent); 991 return 0;
992}
993 993
994static int __init efi_memreserve_root_init(void)
995{
996 if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR)
997 return -ENODEV;
998
999 efi_memreserve_root = memremap(efi.mem_reserve,
1000 sizeof(*efi_memreserve_root),
1001 MEMREMAP_WB);
1002 if (!efi_memreserve_root)
1003 return -ENOMEM;
994 return 0; 1004 return 0;
995} 1005}
1006early_initcall(efi_memreserve_root_init);
996 1007
997#ifdef CONFIG_KEXEC 1008#ifdef CONFIG_KEXEC
998static int update_efi_random_seed(struct notifier_block *nb, 1009static int update_efi_random_seed(struct notifier_block *nb,
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 30ac0c975f8a..3d36142cf812 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -75,6 +75,9 @@ void install_memreserve_table(efi_system_table_t *sys_table_arg)
75 efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID; 75 efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID;
76 efi_status_t status; 76 efi_status_t status;
77 77
78 if (IS_ENABLED(CONFIG_ARM))
79 return;
80
78 status = efi_call_early(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv), 81 status = efi_call_early(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv),
79 (void **)&rsv); 82 (void **)&rsv);
80 if (status != EFI_SUCCESS) { 83 if (status != EFI_SUCCESS) {
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index 8830fa601e45..0c0d2312f4a8 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -158,6 +158,10 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
158 return efi_status; 158 return efi_status;
159 } 159 }
160 } 160 }
161
162 /* shrink the FDT back to its minimum size */
163 fdt_pack(fdt);
164
161 return EFI_SUCCESS; 165 return EFI_SUCCESS;
162 166
163fdt_set_fail: 167fdt_set_fail:
diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c
index fa2904fb841f..38b686c67b17 100644
--- a/drivers/firmware/efi/memmap.c
+++ b/drivers/firmware/efi/memmap.c
@@ -118,6 +118,9 @@ int __init efi_memmap_init_early(struct efi_memory_map_data *data)
118 118
119void __init efi_memmap_unmap(void) 119void __init efi_memmap_unmap(void)
120{ 120{
121 if (!efi_enabled(EFI_MEMMAP))
122 return;
123
121 if (!efi.memmap.late) { 124 if (!efi.memmap.late) {
122 unsigned long size; 125 unsigned long size;
123 126
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index a19d845bdb06..8903b9ccfc2b 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -67,7 +67,7 @@ struct efi_runtime_work efi_rts_work;
67 } \ 67 } \
68 \ 68 \
69 init_completion(&efi_rts_work.efi_rts_comp); \ 69 init_completion(&efi_rts_work.efi_rts_comp); \
70 INIT_WORK_ONSTACK(&efi_rts_work.work, efi_call_rts); \ 70 INIT_WORK(&efi_rts_work.work, efi_call_rts); \
71 efi_rts_work.arg1 = _arg1; \ 71 efi_rts_work.arg1 = _arg1; \
72 efi_rts_work.arg2 = _arg2; \ 72 efi_rts_work.arg2 = _arg2; \
73 efi_rts_work.arg3 = _arg3; \ 73 efi_rts_work.arg3 = _arg3; \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 352b30409060..dad0e2342df9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1632,13 +1632,6 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
1632 continue; 1632 continue;
1633 } 1633 }
1634 1634
1635 /* First check if the entry is already handled */
1636 if (cursor.pfn < frag_start) {
1637 cursor.entry->huge = true;
1638 amdgpu_vm_pt_next(adev, &cursor);
1639 continue;
1640 }
1641
1642 /* If it isn't already handled it can't be a huge page */ 1635 /* If it isn't already handled it can't be a huge page */
1643 if (cursor.entry->huge) { 1636 if (cursor.entry->huge) {
1644 /* Add the entry to the relocated list to update it. */ 1637 /* Add the entry to the relocated list to update it. */
@@ -1701,8 +1694,17 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
1701 } 1694 }
1702 } while (frag_start < entry_end); 1695 } while (frag_start < entry_end);
1703 1696
1704 if (frag >= shift) 1697 if (amdgpu_vm_pt_descendant(adev, &cursor)) {
1698 /* Mark all child entries as huge */
1699 while (cursor.pfn < frag_start) {
1700 cursor.entry->huge = true;
1701 amdgpu_vm_pt_next(adev, &cursor);
1702 }
1703
1704 } else if (frag >= shift) {
1705 /* or just move on to the next on the same level. */
1705 amdgpu_vm_pt_next(adev, &cursor); 1706 amdgpu_vm_pt_next(adev, &cursor);
1707 }
1706 } 1708 }
1707 1709
1708 return 0; 1710 return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
index ceb7847b504f..bfa317ad20a9 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
@@ -72,7 +72,7 @@ static void gfxhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev)
72 72
73 /* Program the system aperture low logical page number. */ 73 /* Program the system aperture low logical page number. */
74 WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_LOW_ADDR, 74 WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_LOW_ADDR,
75 min(adev->gmc.vram_start, adev->gmc.agp_start) >> 18); 75 min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);
76 76
77 if (adev->asic_type == CHIP_RAVEN && adev->rev_id >= 0x8) 77 if (adev->asic_type == CHIP_RAVEN && adev->rev_id >= 0x8)
78 /* 78 /*
@@ -82,11 +82,11 @@ static void gfxhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev)
82 * to get rid of the VM fault and hardware hang. 82 * to get rid of the VM fault and hardware hang.
83 */ 83 */
84 WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, 84 WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
85 max((adev->gmc.vram_end >> 18) + 0x1, 85 max((adev->gmc.fb_end >> 18) + 0x1,
86 adev->gmc.agp_end >> 18)); 86 adev->gmc.agp_end >> 18));
87 else 87 else
88 WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, 88 WREG32_SOC15(GC, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
89 max(adev->gmc.vram_end, adev->gmc.agp_end) >> 18); 89 max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);
90 90
91 /* Set default page address. */ 91 /* Set default page address. */
92 value = adev->vram_scratch.gpu_addr - adev->gmc.vram_start 92 value = adev->vram_scratch.gpu_addr - adev->gmc.vram_start
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
index fd23ba1226a5..a0db67adc34c 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
@@ -90,7 +90,7 @@ static void mmhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev)
90 90
91 /* Program the system aperture low logical page number. */ 91 /* Program the system aperture low logical page number. */
92 WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_LOW_ADDR, 92 WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_LOW_ADDR,
93 min(adev->gmc.vram_start, adev->gmc.agp_start) >> 18); 93 min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);
94 94
95 if (adev->asic_type == CHIP_RAVEN && adev->rev_id >= 0x8) 95 if (adev->asic_type == CHIP_RAVEN && adev->rev_id >= 0x8)
96 /* 96 /*
@@ -100,11 +100,11 @@ static void mmhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev)
100 * to get rid of the VM fault and hardware hang. 100 * to get rid of the VM fault and hardware hang.
101 */ 101 */
102 WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, 102 WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
103 max((adev->gmc.vram_end >> 18) + 0x1, 103 max((adev->gmc.fb_end >> 18) + 0x1,
104 adev->gmc.agp_end >> 18)); 104 adev->gmc.agp_end >> 18));
105 else 105 else
106 WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR, 106 WREG32_SOC15(MMHUB, 0, mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
107 max(adev->gmc.vram_end, adev->gmc.agp_end) >> 18); 107 max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);
108 108
109 /* Set default page address. */ 109 /* Set default page address. */
110 value = adev->vram_scratch.gpu_addr - adev->gmc.vram_start + 110 value = adev->vram_scratch.gpu_addr - adev->gmc.vram_start +
diff --git a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
index a99f71797aa3..a0fda6f9252a 100644
--- a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
@@ -129,7 +129,7 @@ static int vega10_ih_irq_init(struct amdgpu_device *adev)
129 else 129 else
130 wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs * 4); 130 wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs * 4);
131 WREG32_SOC15(OSSSYS, 0, mmIH_RB_WPTR_ADDR_LO, lower_32_bits(wptr_off)); 131 WREG32_SOC15(OSSSYS, 0, mmIH_RB_WPTR_ADDR_LO, lower_32_bits(wptr_off));
132 WREG32_SOC15(OSSSYS, 0, mmIH_RB_WPTR_ADDR_HI, upper_32_bits(wptr_off) & 0xFF); 132 WREG32_SOC15(OSSSYS, 0, mmIH_RB_WPTR_ADDR_HI, upper_32_bits(wptr_off) & 0xFFFF);
133 133
134 /* set rptr, wptr to 0 */ 134 /* set rptr, wptr to 0 */
135 WREG32_SOC15(OSSSYS, 0, mmIH_RB_RPTR, 0); 135 WREG32_SOC15(OSSSYS, 0, mmIH_RB_RPTR, 0);
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c
index 99a33c33a32c..101c09b212ad 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c
@@ -713,20 +713,20 @@ int smu_set_watermarks_for_clocks_ranges(void *wt_table,
713 for (i = 0; i < wm_with_clock_ranges->num_wm_dmif_sets; i++) { 713 for (i = 0; i < wm_with_clock_ranges->num_wm_dmif_sets; i++) {
714 table->WatermarkRow[1][i].MinClock = 714 table->WatermarkRow[1][i].MinClock =
715 cpu_to_le16((uint16_t) 715 cpu_to_le16((uint16_t)
716 (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_min_dcfclk_clk_in_khz) / 716 (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_min_dcfclk_clk_in_khz /
717 1000); 717 1000));
718 table->WatermarkRow[1][i].MaxClock = 718 table->WatermarkRow[1][i].MaxClock =
719 cpu_to_le16((uint16_t) 719 cpu_to_le16((uint16_t)
720 (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_max_dcfclk_clk_in_khz) / 720 (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_max_dcfclk_clk_in_khz /
721 1000); 721 1000));
722 table->WatermarkRow[1][i].MinUclk = 722 table->WatermarkRow[1][i].MinUclk =
723 cpu_to_le16((uint16_t) 723 cpu_to_le16((uint16_t)
724 (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_min_mem_clk_in_khz) / 724 (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_min_mem_clk_in_khz /
725 1000); 725 1000));
726 table->WatermarkRow[1][i].MaxUclk = 726 table->WatermarkRow[1][i].MaxUclk =
727 cpu_to_le16((uint16_t) 727 cpu_to_le16((uint16_t)
728 (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_max_mem_clk_in_khz) / 728 (wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_max_mem_clk_in_khz /
729 1000); 729 1000));
730 table->WatermarkRow[1][i].WmSetting = (uint8_t) 730 table->WatermarkRow[1][i].WmSetting = (uint8_t)
731 wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_set_id; 731 wm_with_clock_ranges->wm_dmif_clocks_ranges[i].wm_set_id;
732 } 732 }
@@ -734,20 +734,20 @@ int smu_set_watermarks_for_clocks_ranges(void *wt_table,
734 for (i = 0; i < wm_with_clock_ranges->num_wm_mcif_sets; i++) { 734 for (i = 0; i < wm_with_clock_ranges->num_wm_mcif_sets; i++) {
735 table->WatermarkRow[0][i].MinClock = 735 table->WatermarkRow[0][i].MinClock =
736 cpu_to_le16((uint16_t) 736 cpu_to_le16((uint16_t)
737 (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_min_socclk_clk_in_khz) / 737 (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_min_socclk_clk_in_khz /
738 1000); 738 1000));
739 table->WatermarkRow[0][i].MaxClock = 739 table->WatermarkRow[0][i].MaxClock =
740 cpu_to_le16((uint16_t) 740 cpu_to_le16((uint16_t)
741 (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_max_socclk_clk_in_khz) / 741 (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_max_socclk_clk_in_khz /
742 1000); 742 1000));
743 table->WatermarkRow[0][i].MinUclk = 743 table->WatermarkRow[0][i].MinUclk =
744 cpu_to_le16((uint16_t) 744 cpu_to_le16((uint16_t)
745 (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_min_mem_clk_in_khz) / 745 (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_min_mem_clk_in_khz /
746 1000); 746 1000));
747 table->WatermarkRow[0][i].MaxUclk = 747 table->WatermarkRow[0][i].MaxUclk =
748 cpu_to_le16((uint16_t) 748 cpu_to_le16((uint16_t)
749 (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_max_mem_clk_in_khz) / 749 (wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_max_mem_clk_in_khz /
750 1000); 750 1000));
751 table->WatermarkRow[0][i].WmSetting = (uint8_t) 751 table->WatermarkRow[0][i].WmSetting = (uint8_t)
752 wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_set_id; 752 wm_with_clock_ranges->wm_mcif_clocks_ranges[i].wm_set_id;
753 } 753 }
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 5ff1d79b86c4..0e0df398222d 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -1275,6 +1275,9 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
1275 mutex_lock(&mgr->lock); 1275 mutex_lock(&mgr->lock);
1276 mstb = mgr->mst_primary; 1276 mstb = mgr->mst_primary;
1277 1277
1278 if (!mstb)
1279 goto out;
1280
1278 for (i = 0; i < lct - 1; i++) { 1281 for (i = 0; i < lct - 1; i++) {
1279 int shift = (i % 2) ? 0 : 4; 1282 int shift = (i % 2) ? 0 : 4;
1280 int port_num = (rad[i / 2] >> shift) & 0xf; 1283 int port_num = (rad[i / 2] >> shift) & 0xf;
diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 90a1c846fc25..8aaa5e86a979 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -97,9 +97,9 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);
97 97
98/** 98/**
99 * drm_driver_legacy_fb_format - compute drm fourcc code from legacy description 99 * drm_driver_legacy_fb_format - compute drm fourcc code from legacy description
100 * @dev: DRM device
100 * @bpp: bits per pixels 101 * @bpp: bits per pixels
101 * @depth: bit depth per pixel 102 * @depth: bit depth per pixel
102 * @native: use host native byte order
103 * 103 *
104 * Computes a drm fourcc pixel format code for the given @bpp/@depth values. 104 * Computes a drm fourcc pixel format code for the given @bpp/@depth values.
105 * Unlike drm_mode_legacy_fb_format() this looks at the drivers mode_config, 105 * Unlike drm_mode_legacy_fb_format() this looks at the drivers mode_config,
diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
index 0ef0c6448d53..01fa98299bae 100644
--- a/drivers/gpu/drm/i915/intel_device_info.c
+++ b/drivers/gpu/drm/i915/intel_device_info.c
@@ -474,7 +474,7 @@ static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
474 u8 eu_disabled_mask; 474 u8 eu_disabled_mask;
475 u32 n_disabled; 475 u32 n_disabled;
476 476
477 if (!(sseu->subslice_mask[ss] & BIT(ss))) 477 if (!(sseu->subslice_mask[s] & BIT(ss)))
478 /* skip disabled subslice */ 478 /* skip disabled subslice */
479 continue; 479 continue;
480 480
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 23d8008a93bb..a54843fdeb2f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4850,8 +4850,31 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
4850 * chroma samples for both of the luma samples, and thus we don't 4850 * chroma samples for both of the luma samples, and thus we don't
4851 * actually get the expected MPEG2 chroma siting convention :( 4851 * actually get the expected MPEG2 chroma siting convention :(
4852 * The same behaviour is observed on pre-SKL platforms as well. 4852 * The same behaviour is observed on pre-SKL platforms as well.
4853 *
4854 * Theory behind the formula (note that we ignore sub-pixel
4855 * source coordinates):
4856 * s = source sample position
4857 * d = destination sample position
4858 *
4859 * Downscaling 4:1:
4860 * -0.5
4861 * | 0.0
4862 * | | 1.5 (initial phase)
4863 * | | |
4864 * v v v
4865 * | s | s | s | s |
4866 * | d |
4867 *
4868 * Upscaling 1:4:
4869 * -0.5
4870 * | -0.375 (initial phase)
4871 * | | 0.0
4872 * | | |
4873 * v v v
4874 * | s |
4875 * | d | d | d | d |
4853 */ 4876 */
4854u16 skl_scaler_calc_phase(int sub, bool chroma_cosited) 4877u16 skl_scaler_calc_phase(int sub, int scale, bool chroma_cosited)
4855{ 4878{
4856 int phase = -0x8000; 4879 int phase = -0x8000;
4857 u16 trip = 0; 4880 u16 trip = 0;
@@ -4859,6 +4882,15 @@ u16 skl_scaler_calc_phase(int sub, bool chroma_cosited)
4859 if (chroma_cosited) 4882 if (chroma_cosited)
4860 phase += (sub - 1) * 0x8000 / sub; 4883 phase += (sub - 1) * 0x8000 / sub;
4861 4884
4885 phase += scale / (2 * sub);
4886
4887 /*
4888 * Hardware initial phase limited to [-0.5:1.5].
4889 * Since the max hardware scale factor is 3.0, we
4890 * should never actually excdeed 1.0 here.
4891 */
4892 WARN_ON(phase < -0x8000 || phase > 0x18000);
4893
4862 if (phase < 0) 4894 if (phase < 0)
4863 phase = 0x10000 + phase; 4895 phase = 0x10000 + phase;
4864 else 4896 else
@@ -5067,13 +5099,20 @@ static void skylake_pfit_enable(struct intel_crtc *crtc)
5067 5099
5068 if (crtc->config->pch_pfit.enabled) { 5100 if (crtc->config->pch_pfit.enabled) {
5069 u16 uv_rgb_hphase, uv_rgb_vphase; 5101 u16 uv_rgb_hphase, uv_rgb_vphase;
5102 int pfit_w, pfit_h, hscale, vscale;
5070 int id; 5103 int id;
5071 5104
5072 if (WARN_ON(crtc->config->scaler_state.scaler_id < 0)) 5105 if (WARN_ON(crtc->config->scaler_state.scaler_id < 0))
5073 return; 5106 return;
5074 5107
5075 uv_rgb_hphase = skl_scaler_calc_phase(1, false); 5108 pfit_w = (crtc->config->pch_pfit.size >> 16) & 0xFFFF;
5076 uv_rgb_vphase = skl_scaler_calc_phase(1, false); 5109 pfit_h = crtc->config->pch_pfit.size & 0xFFFF;
5110
5111 hscale = (crtc->config->pipe_src_w << 16) / pfit_w;
5112 vscale = (crtc->config->pipe_src_h << 16) / pfit_h;
5113
5114 uv_rgb_hphase = skl_scaler_calc_phase(1, hscale, false);
5115 uv_rgb_vphase = skl_scaler_calc_phase(1, vscale, false);
5077 5116
5078 id = scaler_state->scaler_id; 5117 id = scaler_state->scaler_id;
5079 I915_WRITE(SKL_PS_CTRL(pipe, id), PS_SCALER_EN | 5118 I915_WRITE(SKL_PS_CTRL(pipe, id), PS_SCALER_EN |
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
index 1b00f8ea145b..a911691dbd0f 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -452,6 +452,10 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
452 if (!intel_connector) 452 if (!intel_connector)
453 return NULL; 453 return NULL;
454 454
455 intel_connector->get_hw_state = intel_dp_mst_get_hw_state;
456 intel_connector->mst_port = intel_dp;
457 intel_connector->port = port;
458
455 connector = &intel_connector->base; 459 connector = &intel_connector->base;
456 ret = drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs, 460 ret = drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs,
457 DRM_MODE_CONNECTOR_DisplayPort); 461 DRM_MODE_CONNECTOR_DisplayPort);
@@ -462,10 +466,6 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
462 466
463 drm_connector_helper_add(connector, &intel_dp_mst_connector_helper_funcs); 467 drm_connector_helper_add(connector, &intel_dp_mst_connector_helper_funcs);
464 468
465 intel_connector->get_hw_state = intel_dp_mst_get_hw_state;
466 intel_connector->mst_port = intel_dp;
467 intel_connector->port = port;
468
469 for_each_pipe(dev_priv, pipe) { 469 for_each_pipe(dev_priv, pipe) {
470 struct drm_encoder *enc = 470 struct drm_encoder *enc =
471 &intel_dp->mst_encoders[pipe]->base.base; 471 &intel_dp->mst_encoders[pipe]->base.base;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index f8dc84b2d2d3..8b298e5f012d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1646,7 +1646,7 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
1646void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc, 1646void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc,
1647 struct intel_crtc_state *crtc_state); 1647 struct intel_crtc_state *crtc_state);
1648 1648
1649u16 skl_scaler_calc_phase(int sub, bool chroma_center); 1649u16 skl_scaler_calc_phase(int sub, int scale, bool chroma_center);
1650int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state); 1650int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
1651int skl_max_scale(const struct intel_crtc_state *crtc_state, 1651int skl_max_scale(const struct intel_crtc_state *crtc_state,
1652 u32 pixel_format); 1652 u32 pixel_format);
diff --git a/drivers/gpu/drm/i915/intel_hotplug.c b/drivers/gpu/drm/i915/intel_hotplug.c
index 648a13c6043c..9a8018130237 100644
--- a/drivers/gpu/drm/i915/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/intel_hotplug.c
@@ -228,7 +228,9 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work)
228 drm_for_each_connector_iter(connector, &conn_iter) { 228 drm_for_each_connector_iter(connector, &conn_iter) {
229 struct intel_connector *intel_connector = to_intel_connector(connector); 229 struct intel_connector *intel_connector = to_intel_connector(connector);
230 230
231 if (intel_connector->encoder->hpd_pin == pin) { 231 /* Don't check MST ports, they don't have pins */
232 if (!intel_connector->mst_port &&
233 intel_connector->encoder->hpd_pin == pin) {
232 if (connector->polled != intel_connector->polled) 234 if (connector->polled != intel_connector->polled)
233 DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n", 235 DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n",
234 connector->name); 236 connector->name);
@@ -395,37 +397,54 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
395 struct intel_encoder *encoder; 397 struct intel_encoder *encoder;
396 bool storm_detected = false; 398 bool storm_detected = false;
397 bool queue_dig = false, queue_hp = false; 399 bool queue_dig = false, queue_hp = false;
400 u32 long_hpd_pulse_mask = 0;
401 u32 short_hpd_pulse_mask = 0;
402 enum hpd_pin pin;
398 403
399 if (!pin_mask) 404 if (!pin_mask)
400 return; 405 return;
401 406
402 spin_lock(&dev_priv->irq_lock); 407 spin_lock(&dev_priv->irq_lock);
408
409 /*
410 * Determine whether ->hpd_pulse() exists for each pin, and
411 * whether we have a short or a long pulse. This is needed
412 * as each pin may have up to two encoders (HDMI and DP) and
413 * only the one of them (DP) will have ->hpd_pulse().
414 */
403 for_each_intel_encoder(&dev_priv->drm, encoder) { 415 for_each_intel_encoder(&dev_priv->drm, encoder) {
404 enum hpd_pin pin = encoder->hpd_pin;
405 bool has_hpd_pulse = intel_encoder_has_hpd_pulse(encoder); 416 bool has_hpd_pulse = intel_encoder_has_hpd_pulse(encoder);
417 enum port port = encoder->port;
418 bool long_hpd;
406 419
420 pin = encoder->hpd_pin;
407 if (!(BIT(pin) & pin_mask)) 421 if (!(BIT(pin) & pin_mask))
408 continue; 422 continue;
409 423
410 if (has_hpd_pulse) { 424 if (!has_hpd_pulse)
411 bool long_hpd = long_mask & BIT(pin); 425 continue;
412 enum port port = encoder->port;
413 426
414 DRM_DEBUG_DRIVER("digital hpd port %c - %s\n", port_name(port), 427 long_hpd = long_mask & BIT(pin);
415 long_hpd ? "long" : "short"); 428
416 /* 429 DRM_DEBUG_DRIVER("digital hpd port %c - %s\n", port_name(port),
417 * For long HPD pulses we want to have the digital queue happen, 430 long_hpd ? "long" : "short");
418 * but we still want HPD storm detection to function. 431 queue_dig = true;
419 */ 432
420 queue_dig = true; 433 if (long_hpd) {
421 if (long_hpd) { 434 long_hpd_pulse_mask |= BIT(pin);
422 dev_priv->hotplug.long_port_mask |= (1 << port); 435 dev_priv->hotplug.long_port_mask |= BIT(port);
423 } else { 436 } else {
424 /* for short HPD just trigger the digital queue */ 437 short_hpd_pulse_mask |= BIT(pin);
425 dev_priv->hotplug.short_port_mask |= (1 << port); 438 dev_priv->hotplug.short_port_mask |= BIT(port);
426 continue;
427 }
428 } 439 }
440 }
441
442 /* Now process each pin just once */
443 for_each_hpd_pin(pin) {
444 bool long_hpd;
445
446 if (!(BIT(pin) & pin_mask))
447 continue;
429 448
430 if (dev_priv->hotplug.stats[pin].state == HPD_DISABLED) { 449 if (dev_priv->hotplug.stats[pin].state == HPD_DISABLED) {
431 /* 450 /*
@@ -442,11 +461,22 @@ void intel_hpd_irq_handler(struct drm_i915_private *dev_priv,
442 if (dev_priv->hotplug.stats[pin].state != HPD_ENABLED) 461 if (dev_priv->hotplug.stats[pin].state != HPD_ENABLED)
443 continue; 462 continue;
444 463
445 if (!has_hpd_pulse) { 464 /*
465 * Delegate to ->hpd_pulse() if one of the encoders for this
466 * pin has it, otherwise let the hotplug_work deal with this
467 * pin directly.
468 */
469 if (((short_hpd_pulse_mask | long_hpd_pulse_mask) & BIT(pin))) {
470 long_hpd = long_hpd_pulse_mask & BIT(pin);
471 } else {
446 dev_priv->hotplug.event_bits |= BIT(pin); 472 dev_priv->hotplug.event_bits |= BIT(pin);
473 long_hpd = true;
447 queue_hp = true; 474 queue_hp = true;
448 } 475 }
449 476
477 if (!long_hpd)
478 continue;
479
450 if (intel_hpd_irq_storm_detect(dev_priv, pin)) { 480 if (intel_hpd_irq_storm_detect(dev_priv, pin)) {
451 dev_priv->hotplug.event_bits &= ~BIT(pin); 481 dev_priv->hotplug.event_bits &= ~BIT(pin);
452 storm_detected = true; 482 storm_detected = true;
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 43957bb37a42..37c94a54efcb 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -424,7 +424,8 @@ static u64 execlists_update_context(struct i915_request *rq)
424 424
425 reg_state[CTX_RING_TAIL+1] = intel_ring_set_tail(rq->ring, rq->tail); 425 reg_state[CTX_RING_TAIL+1] = intel_ring_set_tail(rq->ring, rq->tail);
426 426
427 /* True 32b PPGTT with dynamic page allocation: update PDP 427 /*
428 * True 32b PPGTT with dynamic page allocation: update PDP
428 * registers and point the unallocated PDPs to scratch page. 429 * registers and point the unallocated PDPs to scratch page.
429 * PML4 is allocated during ppgtt init, so this is not needed 430 * PML4 is allocated during ppgtt init, so this is not needed
430 * in 48-bit mode. 431 * in 48-bit mode.
@@ -432,6 +433,17 @@ static u64 execlists_update_context(struct i915_request *rq)
432 if (ppgtt && !i915_vm_is_48bit(&ppgtt->vm)) 433 if (ppgtt && !i915_vm_is_48bit(&ppgtt->vm))
433 execlists_update_context_pdps(ppgtt, reg_state); 434 execlists_update_context_pdps(ppgtt, reg_state);
434 435
436 /*
437 * Make sure the context image is complete before we submit it to HW.
438 *
439 * Ostensibly, writes (including the WCB) should be flushed prior to
440 * an uncached write such as our mmio register access, the empirical
441 * evidence (esp. on Braswell) suggests that the WC write into memory
442 * may not be visible to the HW prior to the completion of the UC
443 * register write and that we may begin execution from the context
444 * before its image is complete leading to invalid PD chasing.
445 */
446 wmb();
435 return ce->lrc_desc; 447 return ce->lrc_desc;
436} 448}
437 449
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index d0ef50bf930a..187bb0ceb4ac 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -91,6 +91,7 @@ static int
91gen4_render_ring_flush(struct i915_request *rq, u32 mode) 91gen4_render_ring_flush(struct i915_request *rq, u32 mode)
92{ 92{
93 u32 cmd, *cs; 93 u32 cmd, *cs;
94 int i;
94 95
95 /* 96 /*
96 * read/write caches: 97 * read/write caches:
@@ -127,12 +128,45 @@ gen4_render_ring_flush(struct i915_request *rq, u32 mode)
127 cmd |= MI_INVALIDATE_ISP; 128 cmd |= MI_INVALIDATE_ISP;
128 } 129 }
129 130
130 cs = intel_ring_begin(rq, 2); 131 i = 2;
132 if (mode & EMIT_INVALIDATE)
133 i += 20;
134
135 cs = intel_ring_begin(rq, i);
131 if (IS_ERR(cs)) 136 if (IS_ERR(cs))
132 return PTR_ERR(cs); 137 return PTR_ERR(cs);
133 138
134 *cs++ = cmd; 139 *cs++ = cmd;
135 *cs++ = MI_NOOP; 140
141 /*
142 * A random delay to let the CS invalidate take effect? Without this
143 * delay, the GPU relocation path fails as the CS does not see
144 * the updated contents. Just as important, if we apply the flushes
145 * to the EMIT_FLUSH branch (i.e. immediately after the relocation
146 * write and before the invalidate on the next batch), the relocations
147 * still fail. This implies that is a delay following invalidation
148 * that is required to reset the caches as opposed to a delay to
149 * ensure the memory is written.
150 */
151 if (mode & EMIT_INVALIDATE) {
152 *cs++ = GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE;
153 *cs++ = i915_ggtt_offset(rq->engine->scratch) |
154 PIPE_CONTROL_GLOBAL_GTT;
155 *cs++ = 0;
156 *cs++ = 0;
157
158 for (i = 0; i < 12; i++)
159 *cs++ = MI_FLUSH;
160
161 *cs++ = GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE;
162 *cs++ = i915_ggtt_offset(rq->engine->scratch) |
163 PIPE_CONTROL_GLOBAL_GTT;
164 *cs++ = 0;
165 *cs++ = 0;
166 }
167
168 *cs++ = cmd;
169
136 intel_ring_advance(rq, cs); 170 intel_ring_advance(rq, cs);
137 171
138 return 0; 172 return 0;
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
index 0fdabce647ab..44e4491a4918 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -2749,6 +2749,12 @@ static const struct i915_power_well_desc icl_power_wells[] = {
2749 }, 2749 },
2750 }, 2750 },
2751 { 2751 {
2752 .name = "DC off",
2753 .domains = ICL_DISPLAY_DC_OFF_POWER_DOMAINS,
2754 .ops = &gen9_dc_off_power_well_ops,
2755 .id = DISP_PW_ID_NONE,
2756 },
2757 {
2752 .name = "power well 2", 2758 .name = "power well 2",
2753 .domains = ICL_PW_2_POWER_DOMAINS, 2759 .domains = ICL_PW_2_POWER_DOMAINS,
2754 .ops = &hsw_power_well_ops, 2760 .ops = &hsw_power_well_ops,
@@ -2760,12 +2766,6 @@ static const struct i915_power_well_desc icl_power_wells[] = {
2760 }, 2766 },
2761 }, 2767 },
2762 { 2768 {
2763 .name = "DC off",
2764 .domains = ICL_DISPLAY_DC_OFF_POWER_DOMAINS,
2765 .ops = &gen9_dc_off_power_well_ops,
2766 .id = DISP_PW_ID_NONE,
2767 },
2768 {
2769 .name = "power well 3", 2769 .name = "power well 3",
2770 .domains = ICL_PW_3_POWER_DOMAINS, 2770 .domains = ICL_PW_3_POWER_DOMAINS,
2771 .ops = &hsw_power_well_ops, 2771 .ops = &hsw_power_well_ops,
@@ -3176,8 +3176,7 @@ static u8 intel_dbuf_max_slices(struct drm_i915_private *dev_priv)
3176void icl_dbuf_slices_update(struct drm_i915_private *dev_priv, 3176void icl_dbuf_slices_update(struct drm_i915_private *dev_priv,
3177 u8 req_slices) 3177 u8 req_slices)
3178{ 3178{
3179 u8 hw_enabled_slices = dev_priv->wm.skl_hw.ddb.enabled_slices; 3179 const u8 hw_enabled_slices = dev_priv->wm.skl_hw.ddb.enabled_slices;
3180 u32 val;
3181 bool ret; 3180 bool ret;
3182 3181
3183 if (req_slices > intel_dbuf_max_slices(dev_priv)) { 3182 if (req_slices > intel_dbuf_max_slices(dev_priv)) {
@@ -3188,7 +3187,6 @@ void icl_dbuf_slices_update(struct drm_i915_private *dev_priv,
3188 if (req_slices == hw_enabled_slices || req_slices == 0) 3187 if (req_slices == hw_enabled_slices || req_slices == 0)
3189 return; 3188 return;
3190 3189
3191 val = I915_READ(DBUF_CTL_S2);
3192 if (req_slices > hw_enabled_slices) 3190 if (req_slices > hw_enabled_slices)
3193 ret = intel_dbuf_slice_set(dev_priv, DBUF_CTL_S2, true); 3191 ret = intel_dbuf_slice_set(dev_priv, DBUF_CTL_S2, true);
3194 else 3192 else
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 5fd2f7bf3927..d3090a7537bb 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -302,13 +302,65 @@ skl_plane_max_stride(struct intel_plane *plane,
302 return min(8192 * cpp, 32768); 302 return min(8192 * cpp, 32768);
303} 303}
304 304
305static void
306skl_program_scaler(struct intel_plane *plane,
307 const struct intel_crtc_state *crtc_state,
308 const struct intel_plane_state *plane_state)
309{
310 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
311 enum pipe pipe = plane->pipe;
312 int scaler_id = plane_state->scaler_id;
313 const struct intel_scaler *scaler =
314 &crtc_state->scaler_state.scalers[scaler_id];
315 int crtc_x = plane_state->base.dst.x1;
316 int crtc_y = plane_state->base.dst.y1;
317 uint32_t crtc_w = drm_rect_width(&plane_state->base.dst);
318 uint32_t crtc_h = drm_rect_height(&plane_state->base.dst);
319 u16 y_hphase, uv_rgb_hphase;
320 u16 y_vphase, uv_rgb_vphase;
321 int hscale, vscale;
322
323 hscale = drm_rect_calc_hscale(&plane_state->base.src,
324 &plane_state->base.dst,
325 0, INT_MAX);
326 vscale = drm_rect_calc_vscale(&plane_state->base.src,
327 &plane_state->base.dst,
328 0, INT_MAX);
329
330 /* TODO: handle sub-pixel coordinates */
331 if (plane_state->base.fb->format->format == DRM_FORMAT_NV12) {
332 y_hphase = skl_scaler_calc_phase(1, hscale, false);
333 y_vphase = skl_scaler_calc_phase(1, vscale, false);
334
335 /* MPEG2 chroma siting convention */
336 uv_rgb_hphase = skl_scaler_calc_phase(2, hscale, true);
337 uv_rgb_vphase = skl_scaler_calc_phase(2, vscale, false);
338 } else {
339 /* not used */
340 y_hphase = 0;
341 y_vphase = 0;
342
343 uv_rgb_hphase = skl_scaler_calc_phase(1, hscale, false);
344 uv_rgb_vphase = skl_scaler_calc_phase(1, vscale, false);
345 }
346
347 I915_WRITE_FW(SKL_PS_CTRL(pipe, scaler_id),
348 PS_SCALER_EN | PS_PLANE_SEL(plane->id) | scaler->mode);
349 I915_WRITE_FW(SKL_PS_PWR_GATE(pipe, scaler_id), 0);
350 I915_WRITE_FW(SKL_PS_VPHASE(pipe, scaler_id),
351 PS_Y_PHASE(y_vphase) | PS_UV_RGB_PHASE(uv_rgb_vphase));
352 I915_WRITE_FW(SKL_PS_HPHASE(pipe, scaler_id),
353 PS_Y_PHASE(y_hphase) | PS_UV_RGB_PHASE(uv_rgb_hphase));
354 I915_WRITE_FW(SKL_PS_WIN_POS(pipe, scaler_id), (crtc_x << 16) | crtc_y);
355 I915_WRITE_FW(SKL_PS_WIN_SZ(pipe, scaler_id), (crtc_w << 16) | crtc_h);
356}
357
305void 358void
306skl_update_plane(struct intel_plane *plane, 359skl_update_plane(struct intel_plane *plane,
307 const struct intel_crtc_state *crtc_state, 360 const struct intel_crtc_state *crtc_state,
308 const struct intel_plane_state *plane_state) 361 const struct intel_plane_state *plane_state)
309{ 362{
310 struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 363 struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
311 const struct drm_framebuffer *fb = plane_state->base.fb;
312 enum plane_id plane_id = plane->id; 364 enum plane_id plane_id = plane->id;
313 enum pipe pipe = plane->pipe; 365 enum pipe pipe = plane->pipe;
314 u32 plane_ctl = plane_state->ctl; 366 u32 plane_ctl = plane_state->ctl;
@@ -318,8 +370,6 @@ skl_update_plane(struct intel_plane *plane,
318 u32 aux_stride = skl_plane_stride(plane_state, 1); 370 u32 aux_stride = skl_plane_stride(plane_state, 1);
319 int crtc_x = plane_state->base.dst.x1; 371 int crtc_x = plane_state->base.dst.x1;
320 int crtc_y = plane_state->base.dst.y1; 372 int crtc_y = plane_state->base.dst.y1;
321 uint32_t crtc_w = drm_rect_width(&plane_state->base.dst);
322 uint32_t crtc_h = drm_rect_height(&plane_state->base.dst);
323 uint32_t x = plane_state->color_plane[0].x; 373 uint32_t x = plane_state->color_plane[0].x;
324 uint32_t y = plane_state->color_plane[0].y; 374 uint32_t y = plane_state->color_plane[0].y;
325 uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16; 375 uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16;
@@ -329,8 +379,6 @@ skl_update_plane(struct intel_plane *plane,
329 /* Sizes are 0 based */ 379 /* Sizes are 0 based */
330 src_w--; 380 src_w--;
331 src_h--; 381 src_h--;
332 crtc_w--;
333 crtc_h--;
334 382
335 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); 383 spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
336 384
@@ -353,41 +401,8 @@ skl_update_plane(struct intel_plane *plane,
353 (plane_state->color_plane[1].y << 16) | 401 (plane_state->color_plane[1].y << 16) |
354 plane_state->color_plane[1].x); 402 plane_state->color_plane[1].x);
355 403
356 /* program plane scaler */
357 if (plane_state->scaler_id >= 0) { 404 if (plane_state->scaler_id >= 0) {
358 int scaler_id = plane_state->scaler_id; 405 skl_program_scaler(plane, crtc_state, plane_state);
359 const struct intel_scaler *scaler =
360 &crtc_state->scaler_state.scalers[scaler_id];
361 u16 y_hphase, uv_rgb_hphase;
362 u16 y_vphase, uv_rgb_vphase;
363
364 /* TODO: handle sub-pixel coordinates */
365 if (fb->format->format == DRM_FORMAT_NV12) {
366 y_hphase = skl_scaler_calc_phase(1, false);
367 y_vphase = skl_scaler_calc_phase(1, false);
368
369 /* MPEG2 chroma siting convention */
370 uv_rgb_hphase = skl_scaler_calc_phase(2, true);
371 uv_rgb_vphase = skl_scaler_calc_phase(2, false);
372 } else {
373 /* not used */
374 y_hphase = 0;
375 y_vphase = 0;
376
377 uv_rgb_hphase = skl_scaler_calc_phase(1, false);
378 uv_rgb_vphase = skl_scaler_calc_phase(1, false);
379 }
380
381 I915_WRITE_FW(SKL_PS_CTRL(pipe, scaler_id),
382 PS_SCALER_EN | PS_PLANE_SEL(plane_id) | scaler->mode);
383 I915_WRITE_FW(SKL_PS_PWR_GATE(pipe, scaler_id), 0);
384 I915_WRITE_FW(SKL_PS_VPHASE(pipe, scaler_id),
385 PS_Y_PHASE(y_vphase) | PS_UV_RGB_PHASE(uv_rgb_vphase));
386 I915_WRITE_FW(SKL_PS_HPHASE(pipe, scaler_id),
387 PS_Y_PHASE(y_hphase) | PS_UV_RGB_PHASE(uv_rgb_hphase));
388 I915_WRITE_FW(SKL_PS_WIN_POS(pipe, scaler_id), (crtc_x << 16) | crtc_y);
389 I915_WRITE_FW(SKL_PS_WIN_SZ(pipe, scaler_id),
390 ((crtc_w + 1) << 16)|(crtc_h + 1));
391 406
392 I915_WRITE_FW(PLANE_POS(pipe, plane_id), 0); 407 I915_WRITE_FW(PLANE_POS(pipe, plane_id), 0);
393 } else { 408 } else {
diff --git a/drivers/gpu/drm/meson/meson_venc.c b/drivers/gpu/drm/meson/meson_venc.c
index 514245e69b38..acbbad3e322c 100644
--- a/drivers/gpu/drm/meson/meson_venc.c
+++ b/drivers/gpu/drm/meson/meson_venc.c
@@ -854,6 +854,13 @@ void meson_venc_hdmi_mode_set(struct meson_drm *priv, int vic,
854 unsigned int sof_lines; 854 unsigned int sof_lines;
855 unsigned int vsync_lines; 855 unsigned int vsync_lines;
856 856
857 /* Use VENCI for 480i and 576i and double HDMI pixels */
858 if (mode->flags & DRM_MODE_FLAG_DBLCLK) {
859 hdmi_repeat = true;
860 use_enci = true;
861 venc_hdmi_latency = 1;
862 }
863
857 if (meson_venc_hdmi_supported_vic(vic)) { 864 if (meson_venc_hdmi_supported_vic(vic)) {
858 vmode = meson_venc_hdmi_get_vic_vmode(vic); 865 vmode = meson_venc_hdmi_get_vic_vmode(vic);
859 if (!vmode) { 866 if (!vmode) {
@@ -865,13 +872,7 @@ void meson_venc_hdmi_mode_set(struct meson_drm *priv, int vic,
865 } else { 872 } else {
866 meson_venc_hdmi_get_dmt_vmode(mode, &vmode_dmt); 873 meson_venc_hdmi_get_dmt_vmode(mode, &vmode_dmt);
867 vmode = &vmode_dmt; 874 vmode = &vmode_dmt;
868 } 875 use_enci = false;
869
870 /* Use VENCI for 480i and 576i and double HDMI pixels */
871 if (mode->flags & DRM_MODE_FLAG_DBLCLK) {
872 hdmi_repeat = true;
873 use_enci = true;
874 venc_hdmi_latency = 1;
875 } 876 }
876 877
877 /* Repeat VENC pixels for 480/576i/p, 720p50/60 and 1080p50/60 */ 878 /* Repeat VENC pixels for 480/576i/p, 720p50/60 and 1080p50/60 */
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 394c129cfb3b..0a485c5b982e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5409,11 +5409,14 @@ static int dsi_probe(struct platform_device *pdev)
5409 5409
5410 /* DSI on OMAP3 doesn't have register DSI_GNQ, set number 5410 /* DSI on OMAP3 doesn't have register DSI_GNQ, set number
5411 * of data to 3 by default */ 5411 * of data to 3 by default */
5412 if (dsi->data->quirks & DSI_QUIRK_GNQ) 5412 if (dsi->data->quirks & DSI_QUIRK_GNQ) {
5413 dsi_runtime_get(dsi);
5413 /* NB_DATA_LANES */ 5414 /* NB_DATA_LANES */
5414 dsi->num_lanes_supported = 1 + REG_GET(dsi, DSI_GNQ, 11, 9); 5415 dsi->num_lanes_supported = 1 + REG_GET(dsi, DSI_GNQ, 11, 9);
5415 else 5416 dsi_runtime_put(dsi);
5417 } else {
5416 dsi->num_lanes_supported = 3; 5418 dsi->num_lanes_supported = 3;
5419 }
5417 5420
5418 r = dsi_init_output(dsi); 5421 r = dsi_init_output(dsi);
5419 if (r) 5422 if (r)
@@ -5426,15 +5429,19 @@ static int dsi_probe(struct platform_device *pdev)
5426 } 5429 }
5427 5430
5428 r = of_platform_populate(dev->of_node, NULL, NULL, dev); 5431 r = of_platform_populate(dev->of_node, NULL, NULL, dev);
5429 if (r) 5432 if (r) {
5430 DSSERR("Failed to populate DSI child devices: %d\n", r); 5433 DSSERR("Failed to populate DSI child devices: %d\n", r);
5434 goto err_uninit_output;
5435 }
5431 5436
5432 r = component_add(&pdev->dev, &dsi_component_ops); 5437 r = component_add(&pdev->dev, &dsi_component_ops);
5433 if (r) 5438 if (r)
5434 goto err_uninit_output; 5439 goto err_of_depopulate;
5435 5440
5436 return 0; 5441 return 0;
5437 5442
5443err_of_depopulate:
5444 of_platform_depopulate(dev);
5438err_uninit_output: 5445err_uninit_output:
5439 dsi_uninit_output(dsi); 5446 dsi_uninit_output(dsi);
5440err_pm_disable: 5447err_pm_disable:
@@ -5470,19 +5477,12 @@ static int dsi_runtime_suspend(struct device *dev)
5470 /* wait for current handler to finish before turning the DSI off */ 5477 /* wait for current handler to finish before turning the DSI off */
5471 synchronize_irq(dsi->irq); 5478 synchronize_irq(dsi->irq);
5472 5479
5473 dispc_runtime_put(dsi->dss->dispc);
5474
5475 return 0; 5480 return 0;
5476} 5481}
5477 5482
5478static int dsi_runtime_resume(struct device *dev) 5483static int dsi_runtime_resume(struct device *dev)
5479{ 5484{
5480 struct dsi_data *dsi = dev_get_drvdata(dev); 5485 struct dsi_data *dsi = dev_get_drvdata(dev);
5481 int r;
5482
5483 r = dispc_runtime_get(dsi->dss->dispc);
5484 if (r)
5485 return r;
5486 5486
5487 dsi->is_enabled = true; 5487 dsi->is_enabled = true;
5488 /* ensure the irq handler sees the is_enabled value */ 5488 /* ensure the irq handler sees the is_enabled value */
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 1aaf260aa9b8..7553c7fc1c45 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1484,16 +1484,23 @@ static int dss_probe(struct platform_device *pdev)
1484 dss); 1484 dss);
1485 1485
1486 /* Add all the child devices as components. */ 1486 /* Add all the child devices as components. */
1487 r = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
1488 if (r)
1489 goto err_uninit_debugfs;
1490
1487 omapdss_gather_components(&pdev->dev); 1491 omapdss_gather_components(&pdev->dev);
1488 1492
1489 device_for_each_child(&pdev->dev, &match, dss_add_child_component); 1493 device_for_each_child(&pdev->dev, &match, dss_add_child_component);
1490 1494
1491 r = component_master_add_with_match(&pdev->dev, &dss_component_ops, match); 1495 r = component_master_add_with_match(&pdev->dev, &dss_component_ops, match);
1492 if (r) 1496 if (r)
1493 goto err_uninit_debugfs; 1497 goto err_of_depopulate;
1494 1498
1495 return 0; 1499 return 0;
1496 1500
1501err_of_depopulate:
1502 of_platform_depopulate(&pdev->dev);
1503
1497err_uninit_debugfs: 1504err_uninit_debugfs:
1498 dss_debugfs_remove_file(dss->debugfs.clk); 1505 dss_debugfs_remove_file(dss->debugfs.clk);
1499 dss_debugfs_remove_file(dss->debugfs.dss); 1506 dss_debugfs_remove_file(dss->debugfs.dss);
@@ -1522,6 +1529,8 @@ static int dss_remove(struct platform_device *pdev)
1522{ 1529{
1523 struct dss_device *dss = platform_get_drvdata(pdev); 1530 struct dss_device *dss = platform_get_drvdata(pdev);
1524 1531
1532 of_platform_depopulate(&pdev->dev);
1533
1525 component_master_del(&pdev->dev, &dss_component_ops); 1534 component_master_del(&pdev->dev, &dss_component_ops);
1526 1535
1527 dss_debugfs_remove_file(dss->debugfs.clk); 1536 dss_debugfs_remove_file(dss->debugfs.clk);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index cf6230eac31a..aabdda394c9c 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -635,10 +635,14 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
635 635
636 hdmi->dss = dss; 636 hdmi->dss = dss;
637 637
638 r = hdmi_pll_init(dss, hdmi->pdev, &hdmi->pll, &hdmi->wp); 638 r = hdmi_runtime_get(hdmi);
639 if (r) 639 if (r)
640 return r; 640 return r;
641 641
642 r = hdmi_pll_init(dss, hdmi->pdev, &hdmi->pll, &hdmi->wp);
643 if (r)
644 goto err_runtime_put;
645
642 r = hdmi4_cec_init(hdmi->pdev, &hdmi->core, &hdmi->wp); 646 r = hdmi4_cec_init(hdmi->pdev, &hdmi->core, &hdmi->wp);
643 if (r) 647 if (r)
644 goto err_pll_uninit; 648 goto err_pll_uninit;
@@ -652,12 +656,16 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
652 hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs, 656 hdmi->debugfs = dss_debugfs_create_file(dss, "hdmi", hdmi_dump_regs,
653 hdmi); 657 hdmi);
654 658
659 hdmi_runtime_put(hdmi);
660
655 return 0; 661 return 0;
656 662
657err_cec_uninit: 663err_cec_uninit:
658 hdmi4_cec_uninit(&hdmi->core); 664 hdmi4_cec_uninit(&hdmi->core);
659err_pll_uninit: 665err_pll_uninit:
660 hdmi_pll_uninit(&hdmi->pll); 666 hdmi_pll_uninit(&hdmi->pll);
667err_runtime_put:
668 hdmi_runtime_put(hdmi);
661 return r; 669 return r;
662} 670}
663 671
@@ -833,32 +841,6 @@ static int hdmi4_remove(struct platform_device *pdev)
833 return 0; 841 return 0;
834} 842}
835 843
836static int hdmi_runtime_suspend(struct device *dev)
837{
838 struct omap_hdmi *hdmi = dev_get_drvdata(dev);
839
840 dispc_runtime_put(hdmi->dss->dispc);
841
842 return 0;
843}
844
845static int hdmi_runtime_resume(struct device *dev)
846{
847 struct omap_hdmi *hdmi = dev_get_drvdata(dev);
848 int r;
849
850 r = dispc_runtime_get(hdmi->dss->dispc);
851 if (r < 0)
852 return r;
853
854 return 0;
855}
856
857static const struct dev_pm_ops hdmi_pm_ops = {
858 .runtime_suspend = hdmi_runtime_suspend,
859 .runtime_resume = hdmi_runtime_resume,
860};
861
862static const struct of_device_id hdmi_of_match[] = { 844static const struct of_device_id hdmi_of_match[] = {
863 { .compatible = "ti,omap4-hdmi", }, 845 { .compatible = "ti,omap4-hdmi", },
864 {}, 846 {},
@@ -869,7 +851,6 @@ struct platform_driver omapdss_hdmi4hw_driver = {
869 .remove = hdmi4_remove, 851 .remove = hdmi4_remove,
870 .driver = { 852 .driver = {
871 .name = "omapdss_hdmi", 853 .name = "omapdss_hdmi",
872 .pm = &hdmi_pm_ops,
873 .of_match_table = hdmi_of_match, 854 .of_match_table = hdmi_of_match,
874 .suppress_bind_attrs = true, 855 .suppress_bind_attrs = true,
875 }, 856 },
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index b0e4a7463f8c..9e8556f67a29 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -825,32 +825,6 @@ static int hdmi5_remove(struct platform_device *pdev)
825 return 0; 825 return 0;
826} 826}
827 827
828static int hdmi_runtime_suspend(struct device *dev)
829{
830 struct omap_hdmi *hdmi = dev_get_drvdata(dev);
831
832 dispc_runtime_put(hdmi->dss->dispc);
833
834 return 0;
835}
836
837static int hdmi_runtime_resume(struct device *dev)
838{
839 struct omap_hdmi *hdmi = dev_get_drvdata(dev);
840 int r;
841
842 r = dispc_runtime_get(hdmi->dss->dispc);
843 if (r < 0)
844 return r;
845
846 return 0;
847}
848
849static const struct dev_pm_ops hdmi_pm_ops = {
850 .runtime_suspend = hdmi_runtime_suspend,
851 .runtime_resume = hdmi_runtime_resume,
852};
853
854static const struct of_device_id hdmi_of_match[] = { 828static const struct of_device_id hdmi_of_match[] = {
855 { .compatible = "ti,omap5-hdmi", }, 829 { .compatible = "ti,omap5-hdmi", },
856 { .compatible = "ti,dra7-hdmi", }, 830 { .compatible = "ti,dra7-hdmi", },
@@ -862,7 +836,6 @@ struct platform_driver omapdss_hdmi5hw_driver = {
862 .remove = hdmi5_remove, 836 .remove = hdmi5_remove,
863 .driver = { 837 .driver = {
864 .name = "omapdss_hdmi5", 838 .name = "omapdss_hdmi5",
865 .pm = &hdmi_pm_ops,
866 .of_match_table = hdmi_of_match, 839 .of_match_table = hdmi_of_match,
867 .suppress_bind_attrs = true, 840 .suppress_bind_attrs = true,
868 }, 841 },
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index ff0b18c8e4ac..b5f52727f8b1 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -946,19 +946,12 @@ static int venc_runtime_suspend(struct device *dev)
946 if (venc->tv_dac_clk) 946 if (venc->tv_dac_clk)
947 clk_disable_unprepare(venc->tv_dac_clk); 947 clk_disable_unprepare(venc->tv_dac_clk);
948 948
949 dispc_runtime_put(venc->dss->dispc);
950
951 return 0; 949 return 0;
952} 950}
953 951
954static int venc_runtime_resume(struct device *dev) 952static int venc_runtime_resume(struct device *dev)
955{ 953{
956 struct venc_device *venc = dev_get_drvdata(dev); 954 struct venc_device *venc = dev_get_drvdata(dev);
957 int r;
958
959 r = dispc_runtime_get(venc->dss->dispc);
960 if (r < 0)
961 return r;
962 955
963 if (venc->tv_dac_clk) 956 if (venc->tv_dac_clk)
964 clk_prepare_enable(venc->tv_dac_clk); 957 clk_prepare_enable(venc->tv_dac_clk);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 62928ec0e7db..caffc547ef97 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -350,11 +350,14 @@ static void omap_crtc_arm_event(struct drm_crtc *crtc)
350static void omap_crtc_atomic_enable(struct drm_crtc *crtc, 350static void omap_crtc_atomic_enable(struct drm_crtc *crtc,
351 struct drm_crtc_state *old_state) 351 struct drm_crtc_state *old_state)
352{ 352{
353 struct omap_drm_private *priv = crtc->dev->dev_private;
353 struct omap_crtc *omap_crtc = to_omap_crtc(crtc); 354 struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
354 int ret; 355 int ret;
355 356
356 DBG("%s", omap_crtc->name); 357 DBG("%s", omap_crtc->name);
357 358
359 priv->dispc_ops->runtime_get(priv->dispc);
360
358 spin_lock_irq(&crtc->dev->event_lock); 361 spin_lock_irq(&crtc->dev->event_lock);
359 drm_crtc_vblank_on(crtc); 362 drm_crtc_vblank_on(crtc);
360 ret = drm_crtc_vblank_get(crtc); 363 ret = drm_crtc_vblank_get(crtc);
@@ -367,6 +370,7 @@ static void omap_crtc_atomic_enable(struct drm_crtc *crtc,
367static void omap_crtc_atomic_disable(struct drm_crtc *crtc, 370static void omap_crtc_atomic_disable(struct drm_crtc *crtc,
368 struct drm_crtc_state *old_state) 371 struct drm_crtc_state *old_state)
369{ 372{
373 struct omap_drm_private *priv = crtc->dev->dev_private;
370 struct omap_crtc *omap_crtc = to_omap_crtc(crtc); 374 struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
371 375
372 DBG("%s", omap_crtc->name); 376 DBG("%s", omap_crtc->name);
@@ -379,6 +383,8 @@ static void omap_crtc_atomic_disable(struct drm_crtc *crtc,
379 spin_unlock_irq(&crtc->dev->event_lock); 383 spin_unlock_irq(&crtc->dev->event_lock);
380 384
381 drm_crtc_vblank_off(crtc); 385 drm_crtc_vblank_off(crtc);
386
387 priv->dispc_ops->runtime_put(priv->dispc);
382} 388}
383 389
384static enum drm_mode_status omap_crtc_mode_valid(struct drm_crtc *crtc, 390static enum drm_mode_status omap_crtc_mode_valid(struct drm_crtc *crtc,
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 2a4aa6468579..921db6f80340 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -793,15 +793,10 @@ static void pci_acpi_setup(struct device *dev)
793{ 793{
794 struct pci_dev *pci_dev = to_pci_dev(dev); 794 struct pci_dev *pci_dev = to_pci_dev(dev);
795 struct acpi_device *adev = ACPI_COMPANION(dev); 795 struct acpi_device *adev = ACPI_COMPANION(dev);
796 int node;
797 796
798 if (!adev) 797 if (!adev)
799 return; 798 return;
800 799
801 node = acpi_get_node(adev->handle);
802 if (node != NUMA_NO_NODE)
803 set_dev_node(dev, node);
804
805 pci_acpi_optimize_delay(pci_dev, adev->handle); 800 pci_acpi_optimize_delay(pci_dev, adev->handle);
806 801
807 pci_acpi_add_pm_notifier(adev, pci_dev); 802 pci_acpi_add_pm_notifier(adev, pci_dev);
diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
index 4ceb06f8a33c..4edeb4cae72a 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c
@@ -830,7 +830,7 @@ static struct meson_bank meson_gxbb_periphs_banks[] = {
830 830
831static struct meson_bank meson_gxbb_aobus_banks[] = { 831static struct meson_bank meson_gxbb_aobus_banks[] = {
832 /* name first last irq pullen pull dir out in */ 832 /* name first last irq pullen pull dir out in */
833 BANK("AO", GPIOAO_0, GPIOAO_13, 0, 13, 0, 0, 0, 16, 0, 0, 0, 16, 1, 0), 833 BANK("AO", GPIOAO_0, GPIOAO_13, 0, 13, 0, 16, 0, 0, 0, 0, 0, 16, 1, 0),
834}; 834};
835 835
836static struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data = { 836static struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data = {
diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxl.c b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
index 7dae1d7bf6b0..158f618f1695 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-gxl.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-gxl.c
@@ -807,7 +807,7 @@ static struct meson_bank meson_gxl_periphs_banks[] = {
807 807
808static struct meson_bank meson_gxl_aobus_banks[] = { 808static struct meson_bank meson_gxl_aobus_banks[] = {
809 /* name first last irq pullen pull dir out in */ 809 /* name first last irq pullen pull dir out in */
810 BANK("AO", GPIOAO_0, GPIOAO_9, 0, 9, 0, 0, 0, 16, 0, 0, 0, 16, 1, 0), 810 BANK("AO", GPIOAO_0, GPIOAO_9, 0, 9, 0, 16, 0, 0, 0, 0, 0, 16, 1, 0),
811}; 811};
812 812
813static struct meson_pinctrl_data meson_gxl_periphs_pinctrl_data = { 813static struct meson_pinctrl_data meson_gxl_periphs_pinctrl_data = {
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index f8b778a7d471..53d449076dee 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -192,7 +192,7 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
192 dev_dbg(pc->dev, "pin %u: disable bias\n", pin); 192 dev_dbg(pc->dev, "pin %u: disable bias\n", pin);
193 193
194 meson_calc_reg_and_bit(bank, pin, REG_PULL, &reg, &bit); 194 meson_calc_reg_and_bit(bank, pin, REG_PULL, &reg, &bit);
195 ret = regmap_update_bits(pc->reg_pull, reg, 195 ret = regmap_update_bits(pc->reg_pullen, reg,
196 BIT(bit), 0); 196 BIT(bit), 0);
197 if (ret) 197 if (ret)
198 return ret; 198 return ret;
diff --git a/drivers/pinctrl/meson/pinctrl-meson8.c b/drivers/pinctrl/meson/pinctrl-meson8.c
index c6d79315218f..86466173114d 100644
--- a/drivers/pinctrl/meson/pinctrl-meson8.c
+++ b/drivers/pinctrl/meson/pinctrl-meson8.c
@@ -1053,7 +1053,7 @@ static struct meson_bank meson8_cbus_banks[] = {
1053 1053
1054static struct meson_bank meson8_aobus_banks[] = { 1054static struct meson_bank meson8_aobus_banks[] = {
1055 /* name first last irq pullen pull dir out in */ 1055 /* name first last irq pullen pull dir out in */
1056 BANK("AO", GPIOAO_0, GPIO_TEST_N, 0, 13, 0, 0, 0, 16, 0, 0, 0, 16, 1, 0), 1056 BANK("AO", GPIOAO_0, GPIO_TEST_N, 0, 13, 0, 16, 0, 0, 0, 0, 0, 16, 1, 0),
1057}; 1057};
1058 1058
1059static struct meson_pinctrl_data meson8_cbus_pinctrl_data = { 1059static struct meson_pinctrl_data meson8_cbus_pinctrl_data = {
diff --git a/drivers/pinctrl/meson/pinctrl-meson8b.c b/drivers/pinctrl/meson/pinctrl-meson8b.c
index bb2a30964fc6..647ad15d5c3c 100644
--- a/drivers/pinctrl/meson/pinctrl-meson8b.c
+++ b/drivers/pinctrl/meson/pinctrl-meson8b.c
@@ -906,7 +906,7 @@ static struct meson_bank meson8b_cbus_banks[] = {
906 906
907static struct meson_bank meson8b_aobus_banks[] = { 907static struct meson_bank meson8b_aobus_banks[] = {
908 /* name first lastc irq pullen pull dir out in */ 908 /* name first lastc irq pullen pull dir out in */
909 BANK("AO", GPIOAO_0, GPIO_TEST_N, 0, 13, 0, 0, 0, 16, 0, 0, 0, 16, 1, 0), 909 BANK("AO", GPIOAO_0, GPIO_TEST_N, 0, 13, 0, 16, 0, 0, 0, 0, 0, 16, 1, 0),
910}; 910};
911 911
912static struct meson_pinctrl_data meson8b_cbus_pinctrl_data = { 912static struct meson_pinctrl_data meson8b_cbus_pinctrl_data = {
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index e79f2a181ad2..b9ec4a16db1f 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -50,8 +50,10 @@ static int __init rtc_hctosys(void)
50 tv64.tv_sec = rtc_tm_to_time64(&tm); 50 tv64.tv_sec = rtc_tm_to_time64(&tm);
51 51
52#if BITS_PER_LONG == 32 52#if BITS_PER_LONG == 32
53 if (tv64.tv_sec > INT_MAX) 53 if (tv64.tv_sec > INT_MAX) {
54 err = -ERANGE;
54 goto err_read; 55 goto err_read;
56 }
55#endif 57#endif
56 58
57 err = do_settimeofday64(&tv64); 59 err = do_settimeofday64(&tv64);
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index df0c5776d49b..a5a19ff10535 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -257,6 +257,7 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
257 struct cmos_rtc *cmos = dev_get_drvdata(dev); 257 struct cmos_rtc *cmos = dev_get_drvdata(dev);
258 unsigned char rtc_control; 258 unsigned char rtc_control;
259 259
260 /* This not only a rtc_op, but also called directly */
260 if (!is_valid_irq(cmos->irq)) 261 if (!is_valid_irq(cmos->irq))
261 return -EIO; 262 return -EIO;
262 263
@@ -452,6 +453,7 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
452 unsigned char mon, mday, hrs, min, sec, rtc_control; 453 unsigned char mon, mday, hrs, min, sec, rtc_control;
453 int ret; 454 int ret;
454 455
456 /* This not only a rtc_op, but also called directly */
455 if (!is_valid_irq(cmos->irq)) 457 if (!is_valid_irq(cmos->irq))
456 return -EIO; 458 return -EIO;
457 459
@@ -516,9 +518,6 @@ static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled)
516 struct cmos_rtc *cmos = dev_get_drvdata(dev); 518 struct cmos_rtc *cmos = dev_get_drvdata(dev);
517 unsigned long flags; 519 unsigned long flags;
518 520
519 if (!is_valid_irq(cmos->irq))
520 return -EINVAL;
521
522 spin_lock_irqsave(&rtc_lock, flags); 521 spin_lock_irqsave(&rtc_lock, flags);
523 522
524 if (enabled) 523 if (enabled)
@@ -579,6 +578,12 @@ static const struct rtc_class_ops cmos_rtc_ops = {
579 .alarm_irq_enable = cmos_alarm_irq_enable, 578 .alarm_irq_enable = cmos_alarm_irq_enable,
580}; 579};
581 580
581static const struct rtc_class_ops cmos_rtc_ops_no_alarm = {
582 .read_time = cmos_read_time,
583 .set_time = cmos_set_time,
584 .proc = cmos_procfs,
585};
586
582/*----------------------------------------------------------------*/ 587/*----------------------------------------------------------------*/
583 588
584/* 589/*
@@ -855,9 +860,12 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
855 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq); 860 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
856 goto cleanup1; 861 goto cleanup1;
857 } 862 }
863
864 cmos_rtc.rtc->ops = &cmos_rtc_ops;
865 } else {
866 cmos_rtc.rtc->ops = &cmos_rtc_ops_no_alarm;
858 } 867 }
859 868
860 cmos_rtc.rtc->ops = &cmos_rtc_ops;
861 cmos_rtc.rtc->nvram_old_abi = true; 869 cmos_rtc.rtc->nvram_old_abi = true;
862 retval = rtc_register_device(cmos_rtc.rtc); 870 retval = rtc_register_device(cmos_rtc.rtc);
863 if (retval) 871 if (retval)
diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index 9f99a0966550..7cb786d76e3c 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -303,6 +303,9 @@ static int pcf2127_i2c_gather_write(void *context,
303 memcpy(buf + 1, val, val_size); 303 memcpy(buf + 1, val, val_size);
304 304
305 ret = i2c_master_send(client, buf, val_size + 1); 305 ret = i2c_master_send(client, buf, val_size + 1);
306
307 kfree(buf);
308
306 if (ret != val_size + 1) 309 if (ret != val_size + 1)
307 return ret < 0 ? ret : -EIO; 310 return ret < 0 ? ret : -EIO;
308 311
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index f07444d30b21..640cd1b31a18 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -578,6 +578,7 @@ config SCSI_MYRB
578config SCSI_MYRS 578config SCSI_MYRS
579 tristate "Mylex DAC960/DAC1100 PCI RAID Controller (SCSI Interface)" 579 tristate "Mylex DAC960/DAC1100 PCI RAID Controller (SCSI Interface)"
580 depends on PCI 580 depends on PCI
581 depends on !CPU_BIG_ENDIAN || COMPILE_TEST
581 select RAID_ATTRS 582 select RAID_ATTRS
582 help 583 help
583 This driver adds support for the Mylex DAC960, AcceleRAID, and 584 This driver adds support for the Mylex DAC960, AcceleRAID, and
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 8429c855701f..01c23d27f290 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -1198,7 +1198,7 @@ static bool NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
1198 1198
1199out: 1199out:
1200 if (!hostdata->selecting) 1200 if (!hostdata->selecting)
1201 return NULL; 1201 return false;
1202 hostdata->selecting = NULL; 1202 hostdata->selecting = NULL;
1203 return ret; 1203 return ret;
1204} 1204}
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index f0e457e6884e..8df822a4a1bd 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -904,11 +904,9 @@ static void start_delivery_v1_hw(struct hisi_sas_dq *dq)
904{ 904{
905 struct hisi_hba *hisi_hba = dq->hisi_hba; 905 struct hisi_hba *hisi_hba = dq->hisi_hba;
906 struct hisi_sas_slot *s, *s1, *s2 = NULL; 906 struct hisi_sas_slot *s, *s1, *s2 = NULL;
907 struct list_head *dq_list;
908 int dlvry_queue = dq->id; 907 int dlvry_queue = dq->id;
909 int wp; 908 int wp;
910 909
911 dq_list = &dq->list;
912 list_for_each_entry_safe(s, s1, &dq->list, delivery) { 910 list_for_each_entry_safe(s, s1, &dq->list, delivery) {
913 if (!s->ready) 911 if (!s->ready)
914 break; 912 break;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index cc36b6473e98..77a85ead483e 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1670,11 +1670,9 @@ static void start_delivery_v2_hw(struct hisi_sas_dq *dq)
1670{ 1670{
1671 struct hisi_hba *hisi_hba = dq->hisi_hba; 1671 struct hisi_hba *hisi_hba = dq->hisi_hba;
1672 struct hisi_sas_slot *s, *s1, *s2 = NULL; 1672 struct hisi_sas_slot *s, *s1, *s2 = NULL;
1673 struct list_head *dq_list;
1674 int dlvry_queue = dq->id; 1673 int dlvry_queue = dq->id;
1675 int wp; 1674 int wp;
1676 1675
1677 dq_list = &dq->list;
1678 list_for_each_entry_safe(s, s1, &dq->list, delivery) { 1676 list_for_each_entry_safe(s, s1, &dq->list, delivery) {
1679 if (!s->ready) 1677 if (!s->ready)
1680 break; 1678 break;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index bd4ce38b98d2..a369450a1fa7 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -886,11 +886,9 @@ static void start_delivery_v3_hw(struct hisi_sas_dq *dq)
886{ 886{
887 struct hisi_hba *hisi_hba = dq->hisi_hba; 887 struct hisi_hba *hisi_hba = dq->hisi_hba;
888 struct hisi_sas_slot *s, *s1, *s2 = NULL; 888 struct hisi_sas_slot *s, *s1, *s2 = NULL;
889 struct list_head *dq_list;
890 int dlvry_queue = dq->id; 889 int dlvry_queue = dq->id;
891 int wp; 890 int wp;
892 891
893 dq_list = &dq->list;
894 list_for_each_entry_safe(s, s1, &dq->list, delivery) { 892 list_for_each_entry_safe(s, s1, &dq->list, delivery) {
895 if (!s->ready) 893 if (!s->ready)
896 break; 894 break;
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 0c8005bb0f53..34d311a7dbef 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -698,6 +698,8 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
698 rport = lpfc_ndlp_get_nrport(ndlp); 698 rport = lpfc_ndlp_get_nrport(ndlp);
699 if (rport) 699 if (rport)
700 nrport = rport->remoteport; 700 nrport = rport->remoteport;
701 else
702 nrport = NULL;
701 spin_unlock(&phba->hbalock); 703 spin_unlock(&phba->hbalock);
702 if (!nrport) 704 if (!nrport)
703 continue; 705 continue;
diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index aeb282f617c5..0642f2d0a3bb 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -1049,7 +1049,8 @@ static int myrb_get_hba_config(struct myrb_hba *cb)
1049 enquiry2->fw.firmware_type = '0'; 1049 enquiry2->fw.firmware_type = '0';
1050 enquiry2->fw.turn_id = 0; 1050 enquiry2->fw.turn_id = 0;
1051 } 1051 }
1052 sprintf(cb->fw_version, "%d.%02d-%c-%02d", 1052 snprintf(cb->fw_version, sizeof(cb->fw_version),
1053 "%d.%02d-%c-%02d",
1053 enquiry2->fw.major_version, 1054 enquiry2->fw.major_version,
1054 enquiry2->fw.minor_version, 1055 enquiry2->fw.minor_version,
1055 enquiry2->fw.firmware_type, 1056 enquiry2->fw.firmware_type,
diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index 0264a2e2bc19..b8d54ef8cf6d 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -163,9 +163,12 @@ static unsigned char myrs_get_ctlr_info(struct myrs_hba *cs)
163 dma_addr_t ctlr_info_addr; 163 dma_addr_t ctlr_info_addr;
164 union myrs_sgl *sgl; 164 union myrs_sgl *sgl;
165 unsigned char status; 165 unsigned char status;
166 struct myrs_ctlr_info old; 166 unsigned short ldev_present, ldev_critical, ldev_offline;
167
168 ldev_present = cs->ctlr_info->ldev_present;
169 ldev_critical = cs->ctlr_info->ldev_critical;
170 ldev_offline = cs->ctlr_info->ldev_offline;
167 171
168 memcpy(&old, cs->ctlr_info, sizeof(struct myrs_ctlr_info));
169 ctlr_info_addr = dma_map_single(&cs->pdev->dev, cs->ctlr_info, 172 ctlr_info_addr = dma_map_single(&cs->pdev->dev, cs->ctlr_info,
170 sizeof(struct myrs_ctlr_info), 173 sizeof(struct myrs_ctlr_info),
171 DMA_FROM_DEVICE); 174 DMA_FROM_DEVICE);
@@ -198,9 +201,9 @@ static unsigned char myrs_get_ctlr_info(struct myrs_hba *cs)
198 cs->ctlr_info->rbld_active + 201 cs->ctlr_info->rbld_active +
199 cs->ctlr_info->exp_active != 0) 202 cs->ctlr_info->exp_active != 0)
200 cs->needs_update = true; 203 cs->needs_update = true;
201 if (cs->ctlr_info->ldev_present != old.ldev_present || 204 if (cs->ctlr_info->ldev_present != ldev_present ||
202 cs->ctlr_info->ldev_critical != old.ldev_critical || 205 cs->ctlr_info->ldev_critical != ldev_critical ||
203 cs->ctlr_info->ldev_offline != old.ldev_offline) 206 cs->ctlr_info->ldev_offline != ldev_offline)
204 shost_printk(KERN_INFO, cs->host, 207 shost_printk(KERN_INFO, cs->host,
205 "Logical drive count changes (%d/%d/%d)\n", 208 "Logical drive count changes (%d/%d/%d)\n",
206 cs->ctlr_info->ldev_critical, 209 cs->ctlr_info->ldev_critical,
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 6fe20c27acc1..eb59c796a795 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -4763,6 +4763,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
4763 fcport->loop_id = FC_NO_LOOP_ID; 4763 fcport->loop_id = FC_NO_LOOP_ID;
4764 qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED); 4764 qla2x00_set_fcport_state(fcport, FCS_UNCONFIGURED);
4765 fcport->supported_classes = FC_COS_UNSPECIFIED; 4765 fcport->supported_classes = FC_COS_UNSPECIFIED;
4766 fcport->fp_speed = PORT_SPEED_UNKNOWN;
4766 4767
4767 fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev, 4768 fcport->ct_desc.ct_sns = dma_alloc_coherent(&vha->hw->pdev->dev,
4768 sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma, 4769 sizeof(struct ct_sns_pkt), &fcport->ct_desc.ct_sns_dma,
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 518f15141170..20c85eed1a75 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -67,7 +67,7 @@ module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
67MODULE_PARM_DESC(ql2xplogiabsentdevice, 67MODULE_PARM_DESC(ql2xplogiabsentdevice,
68 "Option to enable PLOGI to devices that are not present after " 68 "Option to enable PLOGI to devices that are not present after "
69 "a Fabric scan. This is needed for several broken switches. " 69 "a Fabric scan. This is needed for several broken switches. "
70 "Default is 0 - no PLOGI. 1 - perfom PLOGI."); 70 "Default is 0 - no PLOGI. 1 - perform PLOGI.");
71 71
72int ql2xloginretrycount = 0; 72int ql2xloginretrycount = 0;
73module_param(ql2xloginretrycount, int, S_IRUGO); 73module_param(ql2xloginretrycount, int, S_IRUGO);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c7fccbb8f554..fa6e0c3b3aa6 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -697,6 +697,12 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
697 */ 697 */
698 scsi_mq_uninit_cmd(cmd); 698 scsi_mq_uninit_cmd(cmd);
699 699
700 /*
701 * queue is still alive, so grab the ref for preventing it
702 * from being cleaned up during running queue.
703 */
704 percpu_ref_get(&q->q_usage_counter);
705
700 __blk_mq_end_request(req, error); 706 __blk_mq_end_request(req, error);
701 707
702 if (scsi_target(sdev)->single_lun || 708 if (scsi_target(sdev)->single_lun ||
@@ -704,6 +710,8 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
704 kblockd_schedule_work(&sdev->requeue_work); 710 kblockd_schedule_work(&sdev->requeue_work);
705 else 711 else
706 blk_mq_run_hw_queues(q, true); 712 blk_mq_run_hw_queues(q, true);
713
714 percpu_ref_put(&q->q_usage_counter);
707 } else { 715 } else {
708 unsigned long flags; 716 unsigned long flags;
709 717
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 23d7cca36ff0..27db55b0ca7f 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8099,13 +8099,6 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle)
8099 err = -ENOMEM; 8099 err = -ENOMEM;
8100 goto out_error; 8100 goto out_error;
8101 } 8101 }
8102
8103 /*
8104 * Do not use blk-mq at this time because blk-mq does not support
8105 * runtime pm.
8106 */
8107 host->use_blk_mq = false;
8108
8109 hba = shost_priv(host); 8102 hba = shost_priv(host);
8110 hba->host = host; 8103 hba->host = host;
8111 hba->dev = dev; 8104 hba->dev = dev;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index e31e4fc31aa1..2cfd61d62e97 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1778,7 +1778,7 @@ EXPORT_SYMBOL(target_submit_tmr);
1778void transport_generic_request_failure(struct se_cmd *cmd, 1778void transport_generic_request_failure(struct se_cmd *cmd,
1779 sense_reason_t sense_reason) 1779 sense_reason_t sense_reason)
1780{ 1780{
1781 int ret = 0; 1781 int ret = 0, post_ret;
1782 1782
1783 pr_debug("-----[ Storage Engine Exception; sense_reason %d\n", 1783 pr_debug("-----[ Storage Engine Exception; sense_reason %d\n",
1784 sense_reason); 1784 sense_reason);
@@ -1790,7 +1790,7 @@ void transport_generic_request_failure(struct se_cmd *cmd,
1790 transport_complete_task_attr(cmd); 1790 transport_complete_task_attr(cmd);
1791 1791
1792 if (cmd->transport_complete_callback) 1792 if (cmd->transport_complete_callback)
1793 cmd->transport_complete_callback(cmd, false, NULL); 1793 cmd->transport_complete_callback(cmd, false, &post_ret);
1794 1794
1795 if (transport_check_aborted_status(cmd, 1)) 1795 if (transport_check_aborted_status(cmd, 1))
1796 return; 1796 return;
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index ae813e609932..a5e516a40e7a 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -165,9 +165,13 @@ static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background)
165 165
166static void fuse_drop_waiting(struct fuse_conn *fc) 166static void fuse_drop_waiting(struct fuse_conn *fc)
167{ 167{
168 if (fc->connected) { 168 /*
169 atomic_dec(&fc->num_waiting); 169 * lockess check of fc->connected is okay, because atomic_dec_and_test()
170 } else if (atomic_dec_and_test(&fc->num_waiting)) { 170 * provides a memory barrier mached with the one in fuse_wait_aborted()
171 * to ensure no wake-up is missed.
172 */
173 if (atomic_dec_and_test(&fc->num_waiting) &&
174 !READ_ONCE(fc->connected)) {
171 /* wake up aborters */ 175 /* wake up aborters */
172 wake_up_all(&fc->blocked_waitq); 176 wake_up_all(&fc->blocked_waitq);
173 } 177 }
@@ -1768,8 +1772,10 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
1768 req->in.args[1].size = total_len; 1772 req->in.args[1].size = total_len;
1769 1773
1770 err = fuse_request_send_notify_reply(fc, req, outarg->notify_unique); 1774 err = fuse_request_send_notify_reply(fc, req, outarg->notify_unique);
1771 if (err) 1775 if (err) {
1772 fuse_retrieve_end(fc, req); 1776 fuse_retrieve_end(fc, req);
1777 fuse_put_request(fc, req);
1778 }
1773 1779
1774 return err; 1780 return err;
1775} 1781}
@@ -2219,6 +2225,8 @@ EXPORT_SYMBOL_GPL(fuse_abort_conn);
2219 2225
2220void fuse_wait_aborted(struct fuse_conn *fc) 2226void fuse_wait_aborted(struct fuse_conn *fc)
2221{ 2227{
2228 /* matches implicit memory barrier in fuse_drop_waiting() */
2229 smp_mb();
2222 wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0); 2230 wait_event(fc->blocked_waitq, atomic_read(&fc->num_waiting) == 0);
2223} 2231}
2224 2232
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index cc2121b37bf5..b52f9baaa3e7 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2924,10 +2924,12 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
2924 } 2924 }
2925 2925
2926 if (io->async) { 2926 if (io->async) {
2927 bool blocking = io->blocking;
2928
2927 fuse_aio_complete(io, ret < 0 ? ret : 0, -1); 2929 fuse_aio_complete(io, ret < 0 ? ret : 0, -1);
2928 2930
2929 /* we have a non-extending, async request, so return */ 2931 /* we have a non-extending, async request, so return */
2930 if (!io->blocking) 2932 if (!blocking)
2931 return -EIOCBQUEUED; 2933 return -EIOCBQUEUED;
2932 2934
2933 wait_for_completion(&wait); 2935 wait_for_completion(&wait);
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index a683d9b27d76..9a4a15d646eb 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -826,7 +826,7 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
826 ret = gfs2_meta_inode_buffer(ip, &dibh); 826 ret = gfs2_meta_inode_buffer(ip, &dibh);
827 if (ret) 827 if (ret)
828 goto unlock; 828 goto unlock;
829 iomap->private = dibh; 829 mp->mp_bh[0] = dibh;
830 830
831 if (gfs2_is_stuffed(ip)) { 831 if (gfs2_is_stuffed(ip)) {
832 if (flags & IOMAP_WRITE) { 832 if (flags & IOMAP_WRITE) {
@@ -863,9 +863,6 @@ unstuff:
863 len = lblock_stop - lblock + 1; 863 len = lblock_stop - lblock + 1;
864 iomap->length = len << inode->i_blkbits; 864 iomap->length = len << inode->i_blkbits;
865 865
866 get_bh(dibh);
867 mp->mp_bh[0] = dibh;
868
869 height = ip->i_height; 866 height = ip->i_height;
870 while ((lblock + 1) * sdp->sd_sb.sb_bsize > sdp->sd_heightsize[height]) 867 while ((lblock + 1) * sdp->sd_sb.sb_bsize > sdp->sd_heightsize[height])
871 height++; 868 height++;
@@ -898,8 +895,6 @@ out:
898 iomap->bdev = inode->i_sb->s_bdev; 895 iomap->bdev = inode->i_sb->s_bdev;
899unlock: 896unlock:
900 up_read(&ip->i_rw_mutex); 897 up_read(&ip->i_rw_mutex);
901 if (ret && dibh)
902 brelse(dibh);
903 return ret; 898 return ret;
904 899
905do_alloc: 900do_alloc:
@@ -980,9 +975,9 @@ static void gfs2_iomap_journaled_page_done(struct inode *inode, loff_t pos,
980 975
981static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos, 976static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
982 loff_t length, unsigned flags, 977 loff_t length, unsigned flags,
983 struct iomap *iomap) 978 struct iomap *iomap,
979 struct metapath *mp)
984{ 980{
985 struct metapath mp = { .mp_aheight = 1, };
986 struct gfs2_inode *ip = GFS2_I(inode); 981 struct gfs2_inode *ip = GFS2_I(inode);
987 struct gfs2_sbd *sdp = GFS2_SB(inode); 982 struct gfs2_sbd *sdp = GFS2_SB(inode);
988 unsigned int data_blocks = 0, ind_blocks = 0, rblocks; 983 unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
@@ -996,9 +991,9 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
996 unstuff = gfs2_is_stuffed(ip) && 991 unstuff = gfs2_is_stuffed(ip) &&
997 pos + length > gfs2_max_stuffed_size(ip); 992 pos + length > gfs2_max_stuffed_size(ip);
998 993
999 ret = gfs2_iomap_get(inode, pos, length, flags, iomap, &mp); 994 ret = gfs2_iomap_get(inode, pos, length, flags, iomap, mp);
1000 if (ret) 995 if (ret)
1001 goto out_release; 996 goto out_unlock;
1002 997
1003 alloc_required = unstuff || iomap->type == IOMAP_HOLE; 998 alloc_required = unstuff || iomap->type == IOMAP_HOLE;
1004 999
@@ -1013,7 +1008,7 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
1013 1008
1014 ret = gfs2_quota_lock_check(ip, &ap); 1009 ret = gfs2_quota_lock_check(ip, &ap);
1015 if (ret) 1010 if (ret)
1016 goto out_release; 1011 goto out_unlock;
1017 1012
1018 ret = gfs2_inplace_reserve(ip, &ap); 1013 ret = gfs2_inplace_reserve(ip, &ap);
1019 if (ret) 1014 if (ret)
@@ -1038,17 +1033,15 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
1038 ret = gfs2_unstuff_dinode(ip, NULL); 1033 ret = gfs2_unstuff_dinode(ip, NULL);
1039 if (ret) 1034 if (ret)
1040 goto out_trans_end; 1035 goto out_trans_end;
1041 release_metapath(&mp); 1036 release_metapath(mp);
1042 brelse(iomap->private);
1043 iomap->private = NULL;
1044 ret = gfs2_iomap_get(inode, iomap->offset, iomap->length, 1037 ret = gfs2_iomap_get(inode, iomap->offset, iomap->length,
1045 flags, iomap, &mp); 1038 flags, iomap, mp);
1046 if (ret) 1039 if (ret)
1047 goto out_trans_end; 1040 goto out_trans_end;
1048 } 1041 }
1049 1042
1050 if (iomap->type == IOMAP_HOLE) { 1043 if (iomap->type == IOMAP_HOLE) {
1051 ret = gfs2_iomap_alloc(inode, iomap, flags, &mp); 1044 ret = gfs2_iomap_alloc(inode, iomap, flags, mp);
1052 if (ret) { 1045 if (ret) {
1053 gfs2_trans_end(sdp); 1046 gfs2_trans_end(sdp);
1054 gfs2_inplace_release(ip); 1047 gfs2_inplace_release(ip);
@@ -1056,7 +1049,6 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
1056 goto out_qunlock; 1049 goto out_qunlock;
1057 } 1050 }
1058 } 1051 }
1059 release_metapath(&mp);
1060 if (!gfs2_is_stuffed(ip) && gfs2_is_jdata(ip)) 1052 if (!gfs2_is_stuffed(ip) && gfs2_is_jdata(ip))
1061 iomap->page_done = gfs2_iomap_journaled_page_done; 1053 iomap->page_done = gfs2_iomap_journaled_page_done;
1062 return 0; 1054 return 0;
@@ -1069,10 +1061,7 @@ out_trans_fail:
1069out_qunlock: 1061out_qunlock:
1070 if (alloc_required) 1062 if (alloc_required)
1071 gfs2_quota_unlock(ip); 1063 gfs2_quota_unlock(ip);
1072out_release: 1064out_unlock:
1073 if (iomap->private)
1074 brelse(iomap->private);
1075 release_metapath(&mp);
1076 gfs2_write_unlock(inode); 1065 gfs2_write_unlock(inode);
1077 return ret; 1066 return ret;
1078} 1067}
@@ -1088,10 +1077,10 @@ static int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length,
1088 1077
1089 trace_gfs2_iomap_start(ip, pos, length, flags); 1078 trace_gfs2_iomap_start(ip, pos, length, flags);
1090 if ((flags & IOMAP_WRITE) && !(flags & IOMAP_DIRECT)) { 1079 if ((flags & IOMAP_WRITE) && !(flags & IOMAP_DIRECT)) {
1091 ret = gfs2_iomap_begin_write(inode, pos, length, flags, iomap); 1080 ret = gfs2_iomap_begin_write(inode, pos, length, flags, iomap, &mp);
1092 } else { 1081 } else {
1093 ret = gfs2_iomap_get(inode, pos, length, flags, iomap, &mp); 1082 ret = gfs2_iomap_get(inode, pos, length, flags, iomap, &mp);
1094 release_metapath(&mp); 1083
1095 /* 1084 /*
1096 * Silently fall back to buffered I/O for stuffed files or if 1085 * Silently fall back to buffered I/O for stuffed files or if
1097 * we've hot a hole (see gfs2_file_direct_write). 1086 * we've hot a hole (see gfs2_file_direct_write).
@@ -1100,6 +1089,11 @@ static int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length,
1100 iomap->type != IOMAP_MAPPED) 1089 iomap->type != IOMAP_MAPPED)
1101 ret = -ENOTBLK; 1090 ret = -ENOTBLK;
1102 } 1091 }
1092 if (!ret) {
1093 get_bh(mp.mp_bh[0]);
1094 iomap->private = mp.mp_bh[0];
1095 }
1096 release_metapath(&mp);
1103 trace_gfs2_iomap_end(ip, iomap, ret); 1097 trace_gfs2_iomap_end(ip, iomap, ret);
1104 return ret; 1098 return ret;
1105} 1099}
@@ -1908,10 +1902,16 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)
1908 if (ret < 0) 1902 if (ret < 0)
1909 goto out; 1903 goto out;
1910 1904
1911 /* issue read-ahead on metadata */ 1905 /* On the first pass, issue read-ahead on metadata. */
1912 if (mp.mp_aheight > 1) { 1906 if (mp.mp_aheight > 1 && strip_h == ip->i_height - 1) {
1913 for (; ret > 1; ret--) { 1907 unsigned int height = mp.mp_aheight - 1;
1914 metapointer_range(&mp, mp.mp_aheight - ret, 1908
1909 /* No read-ahead for data blocks. */
1910 if (mp.mp_aheight - 1 == strip_h)
1911 height--;
1912
1913 for (; height >= mp.mp_aheight - ret; height--) {
1914 metapointer_range(&mp, height,
1915 start_list, start_aligned, 1915 start_list, start_aligned,
1916 end_list, end_aligned, 1916 end_list, end_aligned,
1917 &start, &end); 1917 &start, &end);
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index ffe3032b1043..b08a530433ad 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -733,6 +733,7 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp)
733 733
734 if (gl) { 734 if (gl) {
735 glock_clear_object(gl, rgd); 735 glock_clear_object(gl, rgd);
736 gfs2_rgrp_brelse(rgd);
736 gfs2_glock_put(gl); 737 gfs2_glock_put(gl);
737 } 738 }
738 739
@@ -1174,7 +1175,7 @@ static u32 count_unlinked(struct gfs2_rgrpd *rgd)
1174 * @rgd: the struct gfs2_rgrpd describing the RG to read in 1175 * @rgd: the struct gfs2_rgrpd describing the RG to read in
1175 * 1176 *
1176 * Read in all of a Resource Group's header and bitmap blocks. 1177 * Read in all of a Resource Group's header and bitmap blocks.
1177 * Caller must eventually call gfs2_rgrp_relse() to free the bitmaps. 1178 * Caller must eventually call gfs2_rgrp_brelse() to free the bitmaps.
1178 * 1179 *
1179 * Returns: errno 1180 * Returns: errno
1180 */ 1181 */
diff --git a/fs/namespace.c b/fs/namespace.c
index 74f64294a410..a7f91265ea67 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -695,9 +695,6 @@ static struct mountpoint *lookup_mountpoint(struct dentry *dentry)
695 695
696 hlist_for_each_entry(mp, chain, m_hash) { 696 hlist_for_each_entry(mp, chain, m_hash) {
697 if (mp->m_dentry == dentry) { 697 if (mp->m_dentry == dentry) {
698 /* might be worth a WARN_ON() */
699 if (d_unlinked(dentry))
700 return ERR_PTR(-ENOENT);
701 mp->m_count++; 698 mp->m_count++;
702 return mp; 699 return mp;
703 } 700 }
@@ -711,6 +708,9 @@ static struct mountpoint *get_mountpoint(struct dentry *dentry)
711 int ret; 708 int ret;
712 709
713 if (d_mountpoint(dentry)) { 710 if (d_mountpoint(dentry)) {
711 /* might be worth a WARN_ON() */
712 if (d_unlinked(dentry))
713 return ERR_PTR(-ENOENT);
714mountpoint: 714mountpoint:
715 read_seqlock_excl(&mount_lock); 715 read_seqlock_excl(&mount_lock);
716 mp = lookup_mountpoint(dentry); 716 mp = lookup_mountpoint(dentry);
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index fa515d5ea5ba..7b861bbc0b43 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -66,7 +66,7 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
66out_iput: 66out_iput:
67 rcu_read_unlock(); 67 rcu_read_unlock();
68 trace_nfs4_cb_getattr(cps->clp, &args->fh, inode, -ntohl(res->status)); 68 trace_nfs4_cb_getattr(cps->clp, &args->fh, inode, -ntohl(res->status));
69 iput(inode); 69 nfs_iput_and_deactive(inode);
70out: 70out:
71 dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status)); 71 dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status));
72 return res->status; 72 return res->status;
@@ -108,7 +108,7 @@ __be32 nfs4_callback_recall(void *argp, void *resp,
108 } 108 }
109 trace_nfs4_cb_recall(cps->clp, &args->fh, inode, 109 trace_nfs4_cb_recall(cps->clp, &args->fh, inode,
110 &args->stateid, -ntohl(res)); 110 &args->stateid, -ntohl(res));
111 iput(inode); 111 nfs_iput_and_deactive(inode);
112out: 112out:
113 dprintk("%s: exit with status = %d\n", __func__, ntohl(res)); 113 dprintk("%s: exit with status = %d\n", __func__, ntohl(res));
114 return res; 114 return res;
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 07b839560576..6ec2f78c1e19 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -850,16 +850,23 @@ nfs_delegation_find_inode_server(struct nfs_server *server,
850 const struct nfs_fh *fhandle) 850 const struct nfs_fh *fhandle)
851{ 851{
852 struct nfs_delegation *delegation; 852 struct nfs_delegation *delegation;
853 struct inode *res = NULL; 853 struct inode *freeme, *res = NULL;
854 854
855 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { 855 list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
856 spin_lock(&delegation->lock); 856 spin_lock(&delegation->lock);
857 if (delegation->inode != NULL && 857 if (delegation->inode != NULL &&
858 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) { 858 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) {
859 res = igrab(delegation->inode); 859 freeme = igrab(delegation->inode);
860 if (freeme && nfs_sb_active(freeme->i_sb))
861 res = freeme;
860 spin_unlock(&delegation->lock); 862 spin_unlock(&delegation->lock);
861 if (res != NULL) 863 if (res != NULL)
862 return res; 864 return res;
865 if (freeme) {
866 rcu_read_unlock();
867 iput(freeme);
868 rcu_read_lock();
869 }
863 return ERR_PTR(-EAGAIN); 870 return ERR_PTR(-EAGAIN);
864 } 871 }
865 spin_unlock(&delegation->lock); 872 spin_unlock(&delegation->lock);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 62ae0fd345ad..ffea57885394 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -2601,11 +2601,12 @@ static void nfs4_state_manager(struct nfs_client *clp)
2601 nfs4_clear_state_manager_bit(clp); 2601 nfs4_clear_state_manager_bit(clp);
2602 /* Did we race with an attempt to give us more work? */ 2602 /* Did we race with an attempt to give us more work? */
2603 if (clp->cl_state == 0) 2603 if (clp->cl_state == 0)
2604 break; 2604 return;
2605 if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0) 2605 if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0)
2606 break; 2606 return;
2607 } while (refcount_read(&clp->cl_count) > 1); 2607 } while (refcount_read(&clp->cl_count) > 1 && !signalled());
2608 return; 2608 goto out_drain;
2609
2609out_error: 2610out_error:
2610 if (strlen(section)) 2611 if (strlen(section))
2611 section_sep = ": "; 2612 section_sep = ": ";
@@ -2613,6 +2614,7 @@ out_error:
2613 " with error %d\n", section_sep, section, 2614 " with error %d\n", section_sep, section,
2614 clp->cl_hostname, -status); 2615 clp->cl_hostname, -status);
2615 ssleep(1); 2616 ssleep(1);
2617out_drain:
2616 nfs4_end_drain_session(clp); 2618 nfs4_end_drain_session(clp);
2617 nfs4_clear_state_manager_bit(clp); 2619 nfs4_clear_state_manager_bit(clp);
2618} 2620}
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index edff074d38c7..d505990dac7c 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1038,6 +1038,9 @@ nfsd4_verify_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
1038{ 1038{
1039 __be32 status; 1039 __be32 status;
1040 1040
1041 if (!cstate->save_fh.fh_dentry)
1042 return nfserr_nofilehandle;
1043
1041 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->save_fh, 1044 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->save_fh,
1042 src_stateid, RD_STATE, src, NULL); 1045 src_stateid, RD_STATE, src, NULL);
1043 if (status) { 1046 if (status) {
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 5769cf3ff035..e08a6647267b 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -115,12 +115,12 @@ static bool fanotify_should_send_event(struct fsnotify_iter_info *iter_info,
115 continue; 115 continue;
116 mark = iter_info->marks[type]; 116 mark = iter_info->marks[type];
117 /* 117 /*
118 * if the event is for a child and this inode doesn't care about 118 * If the event is for a child and this mark doesn't care about
119 * events on the child, don't send it! 119 * events on a child, don't send it!
120 */ 120 */
121 if (type == FSNOTIFY_OBJ_TYPE_INODE && 121 if (event_mask & FS_EVENT_ON_CHILD &&
122 (event_mask & FS_EVENT_ON_CHILD) && 122 (type != FSNOTIFY_OBJ_TYPE_INODE ||
123 !(mark->mask & FS_EVENT_ON_CHILD)) 123 !(mark->mask & FS_EVENT_ON_CHILD)))
124 continue; 124 continue;
125 125
126 marks_mask |= mark->mask; 126 marks_mask |= mark->mask;
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 2172ba516c61..d2c34900ae05 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -167,9 +167,9 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
167 parent = dget_parent(dentry); 167 parent = dget_parent(dentry);
168 p_inode = parent->d_inode; 168 p_inode = parent->d_inode;
169 169
170 if (unlikely(!fsnotify_inode_watches_children(p_inode))) 170 if (unlikely(!fsnotify_inode_watches_children(p_inode))) {
171 __fsnotify_update_child_dentry_flags(p_inode); 171 __fsnotify_update_child_dentry_flags(p_inode);
172 else if (p_inode->i_fsnotify_mask & mask) { 172 } else if (p_inode->i_fsnotify_mask & mask & ALL_FSNOTIFY_EVENTS) {
173 struct name_snapshot name; 173 struct name_snapshot name;
174 174
175 /* we are notifying a parent so come up with the new mask which 175 /* we are notifying a parent so come up with the new mask which
@@ -339,6 +339,9 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
339 sb = mnt->mnt.mnt_sb; 339 sb = mnt->mnt.mnt_sb;
340 mnt_or_sb_mask = mnt->mnt_fsnotify_mask | sb->s_fsnotify_mask; 340 mnt_or_sb_mask = mnt->mnt_fsnotify_mask | sb->s_fsnotify_mask;
341 } 341 }
342 /* An event "on child" is not intended for a mount/sb mark */
343 if (mask & FS_EVENT_ON_CHILD)
344 mnt_or_sb_mask = 0;
342 345
343 /* 346 /*
344 * Optimization: srcu_read_lock() has a memory barrier which can 347 * Optimization: srcu_read_lock() has a memory barrier which can
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 845174e113ce..100ce4a4aff6 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1167,6 +1167,8 @@ static inline bool efi_enabled(int feature)
1167extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); 1167extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
1168 1168
1169extern bool efi_is_table_address(unsigned long phys_addr); 1169extern bool efi_is_table_address(unsigned long phys_addr);
1170
1171extern int efi_apply_persistent_mem_reservations(void);
1170#else 1172#else
1171static inline bool efi_enabled(int feature) 1173static inline bool efi_enabled(int feature)
1172{ 1174{
@@ -1185,6 +1187,11 @@ static inline bool efi_is_table_address(unsigned long phys_addr)
1185{ 1187{
1186 return false; 1188 return false;
1187} 1189}
1190
1191static inline int efi_apply_persistent_mem_reservations(void)
1192{
1193 return 0;
1194}
1188#endif 1195#endif
1189 1196
1190extern int efi_status_to_err(efi_status_t status); 1197extern int efi_status_to_err(efi_status_t status);
diff --git a/include/trace/events/kyber.h b/include/trace/events/kyber.h
index a9834c37ac40..c0e7d24ca256 100644
--- a/include/trace/events/kyber.h
+++ b/include/trace/events/kyber.h
@@ -31,8 +31,8 @@ TRACE_EVENT(kyber_latency,
31 31
32 TP_fast_assign( 32 TP_fast_assign(
33 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent))); 33 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
34 strlcpy(__entry->domain, domain, DOMAIN_LEN); 34 strlcpy(__entry->domain, domain, sizeof(__entry->domain));
35 strlcpy(__entry->type, type, DOMAIN_LEN); 35 strlcpy(__entry->type, type, sizeof(__entry->type));
36 __entry->percentile = percentile; 36 __entry->percentile = percentile;
37 __entry->numerator = numerator; 37 __entry->numerator = numerator;
38 __entry->denominator = denominator; 38 __entry->denominator = denominator;
@@ -60,7 +60,7 @@ TRACE_EVENT(kyber_adjust,
60 60
61 TP_fast_assign( 61 TP_fast_assign(
62 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent))); 62 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
63 strlcpy(__entry->domain, domain, DOMAIN_LEN); 63 strlcpy(__entry->domain, domain, sizeof(__entry->domain));
64 __entry->depth = depth; 64 __entry->depth = depth;
65 ), 65 ),
66 66
@@ -82,7 +82,7 @@ TRACE_EVENT(kyber_throttled,
82 82
83 TP_fast_assign( 83 TP_fast_assign(
84 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent))); 84 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
85 strlcpy(__entry->domain, domain, DOMAIN_LEN); 85 strlcpy(__entry->domain, domain, sizeof(__entry->domain));
86 ), 86 ),
87 87
88 TP_printk("%d,%d %s", MAJOR(__entry->dev), MINOR(__entry->dev), 88 TP_printk("%d,%d %s", MAJOR(__entry->dev), MINOR(__entry->dev),
diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
index 6ad4a9fcbd6f..7921ae4fca8d 100644
--- a/kernel/debug/kdb/kdb_bt.c
+++ b/kernel/debug/kdb/kdb_bt.c
@@ -179,14 +179,14 @@ kdb_bt(int argc, const char **argv)
179 kdb_printf("no process for cpu %ld\n", cpu); 179 kdb_printf("no process for cpu %ld\n", cpu);
180 return 0; 180 return 0;
181 } 181 }
182 sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu)); 182 sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
183 kdb_parse(buf); 183 kdb_parse(buf);
184 return 0; 184 return 0;
185 } 185 }
186 kdb_printf("btc: cpu status: "); 186 kdb_printf("btc: cpu status: ");
187 kdb_parse("cpu\n"); 187 kdb_parse("cpu\n");
188 for_each_online_cpu(cpu) { 188 for_each_online_cpu(cpu) {
189 sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu)); 189 sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
190 kdb_parse(buf); 190 kdb_parse(buf);
191 touch_nmi_watchdog(); 191 touch_nmi_watchdog();
192 } 192 }
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index ed5d34925ad0..6a4b41484afe 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -216,7 +216,7 @@ static char *kdb_read(char *buffer, size_t bufsize)
216 int count; 216 int count;
217 int i; 217 int i;
218 int diag, dtab_count; 218 int diag, dtab_count;
219 int key; 219 int key, buf_size, ret;
220 220
221 221
222 diag = kdbgetintenv("DTABCOUNT", &dtab_count); 222 diag = kdbgetintenv("DTABCOUNT", &dtab_count);
@@ -336,9 +336,8 @@ poll_again:
336 else 336 else
337 p_tmp = tmpbuffer; 337 p_tmp = tmpbuffer;
338 len = strlen(p_tmp); 338 len = strlen(p_tmp);
339 count = kallsyms_symbol_complete(p_tmp, 339 buf_size = sizeof(tmpbuffer) - (p_tmp - tmpbuffer);
340 sizeof(tmpbuffer) - 340 count = kallsyms_symbol_complete(p_tmp, buf_size);
341 (p_tmp - tmpbuffer));
342 if (tab == 2 && count > 0) { 341 if (tab == 2 && count > 0) {
343 kdb_printf("\n%d symbols are found.", count); 342 kdb_printf("\n%d symbols are found.", count);
344 if (count > dtab_count) { 343 if (count > dtab_count) {
@@ -350,9 +349,13 @@ poll_again:
350 } 349 }
351 kdb_printf("\n"); 350 kdb_printf("\n");
352 for (i = 0; i < count; i++) { 351 for (i = 0; i < count; i++) {
353 if (WARN_ON(!kallsyms_symbol_next(p_tmp, i))) 352 ret = kallsyms_symbol_next(p_tmp, i, buf_size);
353 if (WARN_ON(!ret))
354 break; 354 break;
355 kdb_printf("%s ", p_tmp); 355 if (ret != -E2BIG)
356 kdb_printf("%s ", p_tmp);
357 else
358 kdb_printf("%s... ", p_tmp);
356 *(p_tmp + len) = '\0'; 359 *(p_tmp + len) = '\0';
357 } 360 }
358 if (i >= dtab_count) 361 if (i >= dtab_count)
diff --git a/kernel/debug/kdb/kdb_keyboard.c b/kernel/debug/kdb/kdb_keyboard.c
index 118527aa60ea..750497b0003a 100644
--- a/kernel/debug/kdb/kdb_keyboard.c
+++ b/kernel/debug/kdb/kdb_keyboard.c
@@ -173,11 +173,11 @@ int kdb_get_kbd_char(void)
173 case KT_LATIN: 173 case KT_LATIN:
174 if (isprint(keychar)) 174 if (isprint(keychar))
175 break; /* printable characters */ 175 break; /* printable characters */
176 /* drop through */ 176 /* fall through */
177 case KT_SPEC: 177 case KT_SPEC:
178 if (keychar == K_ENTER) 178 if (keychar == K_ENTER)
179 break; 179 break;
180 /* drop through */ 180 /* fall through */
181 default: 181 default:
182 return -1; /* ignore unprintables */ 182 return -1; /* ignore unprintables */
183 } 183 }
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index bb4fe4e1a601..d72b32c66f7d 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -1192,7 +1192,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
1192 if (reason == KDB_REASON_DEBUG) { 1192 if (reason == KDB_REASON_DEBUG) {
1193 /* special case below */ 1193 /* special case below */
1194 } else { 1194 } else {
1195 kdb_printf("\nEntering kdb (current=0x%p, pid %d) ", 1195 kdb_printf("\nEntering kdb (current=0x%px, pid %d) ",
1196 kdb_current, kdb_current ? kdb_current->pid : 0); 1196 kdb_current, kdb_current ? kdb_current->pid : 0);
1197#if defined(CONFIG_SMP) 1197#if defined(CONFIG_SMP)
1198 kdb_printf("on processor %d ", raw_smp_processor_id()); 1198 kdb_printf("on processor %d ", raw_smp_processor_id());
@@ -1208,7 +1208,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
1208 */ 1208 */
1209 switch (db_result) { 1209 switch (db_result) {
1210 case KDB_DB_BPT: 1210 case KDB_DB_BPT:
1211 kdb_printf("\nEntering kdb (0x%p, pid %d) ", 1211 kdb_printf("\nEntering kdb (0x%px, pid %d) ",
1212 kdb_current, kdb_current->pid); 1212 kdb_current, kdb_current->pid);
1213#if defined(CONFIG_SMP) 1213#if defined(CONFIG_SMP)
1214 kdb_printf("on processor %d ", raw_smp_processor_id()); 1214 kdb_printf("on processor %d ", raw_smp_processor_id());
@@ -1493,6 +1493,7 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr,
1493 char cbuf[32]; 1493 char cbuf[32];
1494 char *c = cbuf; 1494 char *c = cbuf;
1495 int i; 1495 int i;
1496 int j;
1496 unsigned long word; 1497 unsigned long word;
1497 1498
1498 memset(cbuf, '\0', sizeof(cbuf)); 1499 memset(cbuf, '\0', sizeof(cbuf));
@@ -1538,25 +1539,9 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr,
1538 wc.word = word; 1539 wc.word = word;
1539#define printable_char(c) \ 1540#define printable_char(c) \
1540 ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; }) 1541 ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; })
1541 switch (bytesperword) { 1542 for (j = 0; j < bytesperword; j++)
1542 case 8:
1543 *c++ = printable_char(*cp++); 1543 *c++ = printable_char(*cp++);
1544 *c++ = printable_char(*cp++); 1544 addr += bytesperword;
1545 *c++ = printable_char(*cp++);
1546 *c++ = printable_char(*cp++);
1547 addr += 4;
1548 case 4:
1549 *c++ = printable_char(*cp++);
1550 *c++ = printable_char(*cp++);
1551 addr += 2;
1552 case 2:
1553 *c++ = printable_char(*cp++);
1554 addr++;
1555 case 1:
1556 *c++ = printable_char(*cp++);
1557 addr++;
1558 break;
1559 }
1560#undef printable_char 1545#undef printable_char
1561 } 1546 }
1562 } 1547 }
@@ -2048,7 +2033,7 @@ static int kdb_lsmod(int argc, const char **argv)
2048 if (mod->state == MODULE_STATE_UNFORMED) 2033 if (mod->state == MODULE_STATE_UNFORMED)
2049 continue; 2034 continue;
2050 2035
2051 kdb_printf("%-20s%8u 0x%p ", mod->name, 2036 kdb_printf("%-20s%8u 0x%px ", mod->name,
2052 mod->core_layout.size, (void *)mod); 2037 mod->core_layout.size, (void *)mod);
2053#ifdef CONFIG_MODULE_UNLOAD 2038#ifdef CONFIG_MODULE_UNLOAD
2054 kdb_printf("%4d ", module_refcount(mod)); 2039 kdb_printf("%4d ", module_refcount(mod));
@@ -2059,7 +2044,7 @@ static int kdb_lsmod(int argc, const char **argv)
2059 kdb_printf(" (Loading)"); 2044 kdb_printf(" (Loading)");
2060 else 2045 else
2061 kdb_printf(" (Live)"); 2046 kdb_printf(" (Live)");
2062 kdb_printf(" 0x%p", mod->core_layout.base); 2047 kdb_printf(" 0x%px", mod->core_layout.base);
2063 2048
2064#ifdef CONFIG_MODULE_UNLOAD 2049#ifdef CONFIG_MODULE_UNLOAD
2065 { 2050 {
@@ -2341,7 +2326,7 @@ void kdb_ps1(const struct task_struct *p)
2341 return; 2326 return;
2342 2327
2343 cpu = kdb_process_cpu(p); 2328 cpu = kdb_process_cpu(p);
2344 kdb_printf("0x%p %8d %8d %d %4d %c 0x%p %c%s\n", 2329 kdb_printf("0x%px %8d %8d %d %4d %c 0x%px %c%s\n",
2345 (void *)p, p->pid, p->parent->pid, 2330 (void *)p, p->pid, p->parent->pid,
2346 kdb_task_has_cpu(p), kdb_process_cpu(p), 2331 kdb_task_has_cpu(p), kdb_process_cpu(p),
2347 kdb_task_state_char(p), 2332 kdb_task_state_char(p),
@@ -2354,7 +2339,7 @@ void kdb_ps1(const struct task_struct *p)
2354 } else { 2339 } else {
2355 if (KDB_TSK(cpu) != p) 2340 if (KDB_TSK(cpu) != p)
2356 kdb_printf(" Error: does not match running " 2341 kdb_printf(" Error: does not match running "
2357 "process table (0x%p)\n", KDB_TSK(cpu)); 2342 "process table (0x%px)\n", KDB_TSK(cpu));
2358 } 2343 }
2359 } 2344 }
2360} 2345}
@@ -2687,7 +2672,7 @@ int kdb_register_flags(char *cmd,
2687 for_each_kdbcmd(kp, i) { 2672 for_each_kdbcmd(kp, i) {
2688 if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) { 2673 if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) {
2689 kdb_printf("Duplicate kdb command registered: " 2674 kdb_printf("Duplicate kdb command registered: "
2690 "%s, func %p help %s\n", cmd, func, help); 2675 "%s, func %px help %s\n", cmd, func, help);
2691 return 1; 2676 return 1;
2692 } 2677 }
2693 } 2678 }
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index 1e5a502ba4a7..2118d8258b7c 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -83,7 +83,7 @@ typedef struct __ksymtab {
83 unsigned long sym_start; 83 unsigned long sym_start;
84 unsigned long sym_end; 84 unsigned long sym_end;
85 } kdb_symtab_t; 85 } kdb_symtab_t;
86extern int kallsyms_symbol_next(char *prefix_name, int flag); 86extern int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size);
87extern int kallsyms_symbol_complete(char *prefix_name, int max_len); 87extern int kallsyms_symbol_complete(char *prefix_name, int max_len);
88 88
89/* Exported Symbols for kernel loadable modules to use. */ 89/* Exported Symbols for kernel loadable modules to use. */
diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
index 990b3cc526c8..50bf9b119bad 100644
--- a/kernel/debug/kdb/kdb_support.c
+++ b/kernel/debug/kdb/kdb_support.c
@@ -40,7 +40,7 @@
40int kdbgetsymval(const char *symname, kdb_symtab_t *symtab) 40int kdbgetsymval(const char *symname, kdb_symtab_t *symtab)
41{ 41{
42 if (KDB_DEBUG(AR)) 42 if (KDB_DEBUG(AR))
43 kdb_printf("kdbgetsymval: symname=%s, symtab=%p\n", symname, 43 kdb_printf("kdbgetsymval: symname=%s, symtab=%px\n", symname,
44 symtab); 44 symtab);
45 memset(symtab, 0, sizeof(*symtab)); 45 memset(symtab, 0, sizeof(*symtab));
46 symtab->sym_start = kallsyms_lookup_name(symname); 46 symtab->sym_start = kallsyms_lookup_name(symname);
@@ -88,7 +88,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
88 char *knt1 = NULL; 88 char *knt1 = NULL;
89 89
90 if (KDB_DEBUG(AR)) 90 if (KDB_DEBUG(AR))
91 kdb_printf("kdbnearsym: addr=0x%lx, symtab=%p\n", addr, symtab); 91 kdb_printf("kdbnearsym: addr=0x%lx, symtab=%px\n", addr, symtab);
92 memset(symtab, 0, sizeof(*symtab)); 92 memset(symtab, 0, sizeof(*symtab));
93 93
94 if (addr < 4096) 94 if (addr < 4096)
@@ -149,7 +149,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
149 symtab->mod_name = "kernel"; 149 symtab->mod_name = "kernel";
150 if (KDB_DEBUG(AR)) 150 if (KDB_DEBUG(AR))
151 kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, " 151 kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, "
152 "symtab->mod_name=%p, symtab->sym_name=%p (%s)\n", ret, 152 "symtab->mod_name=%px, symtab->sym_name=%px (%s)\n", ret,
153 symtab->sym_start, symtab->mod_name, symtab->sym_name, 153 symtab->sym_start, symtab->mod_name, symtab->sym_name,
154 symtab->sym_name); 154 symtab->sym_name);
155 155
@@ -221,11 +221,13 @@ int kallsyms_symbol_complete(char *prefix_name, int max_len)
221 * Parameters: 221 * Parameters:
222 * prefix_name prefix of a symbol name to lookup 222 * prefix_name prefix of a symbol name to lookup
223 * flag 0 means search from the head, 1 means continue search. 223 * flag 0 means search from the head, 1 means continue search.
224 * buf_size maximum length that can be written to prefix_name
225 * buffer
224 * Returns: 226 * Returns:
225 * 1 if a symbol matches the given prefix. 227 * 1 if a symbol matches the given prefix.
226 * 0 if no string found 228 * 0 if no string found
227 */ 229 */
228int kallsyms_symbol_next(char *prefix_name, int flag) 230int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size)
229{ 231{
230 int prefix_len = strlen(prefix_name); 232 int prefix_len = strlen(prefix_name);
231 static loff_t pos; 233 static loff_t pos;
@@ -235,10 +237,8 @@ int kallsyms_symbol_next(char *prefix_name, int flag)
235 pos = 0; 237 pos = 0;
236 238
237 while ((name = kdb_walk_kallsyms(&pos))) { 239 while ((name = kdb_walk_kallsyms(&pos))) {
238 if (strncmp(name, prefix_name, prefix_len) == 0) { 240 if (!strncmp(name, prefix_name, prefix_len))
239 strncpy(prefix_name, name, strlen(name)+1); 241 return strscpy(prefix_name, name, buf_size);
240 return 1;
241 }
242 } 242 }
243 return 0; 243 return 0;
244} 244}
@@ -432,7 +432,7 @@ int kdb_getphysword(unsigned long *word, unsigned long addr, size_t size)
432 *word = w8; 432 *word = w8;
433 break; 433 break;
434 } 434 }
435 /* drop through */ 435 /* fall through */
436 default: 436 default:
437 diag = KDB_BADWIDTH; 437 diag = KDB_BADWIDTH;
438 kdb_printf("kdb_getphysword: bad width %ld\n", (long) size); 438 kdb_printf("kdb_getphysword: bad width %ld\n", (long) size);
@@ -481,7 +481,7 @@ int kdb_getword(unsigned long *word, unsigned long addr, size_t size)
481 *word = w8; 481 *word = w8;
482 break; 482 break;
483 } 483 }
484 /* drop through */ 484 /* fall through */
485 default: 485 default:
486 diag = KDB_BADWIDTH; 486 diag = KDB_BADWIDTH;
487 kdb_printf("kdb_getword: bad width %ld\n", (long) size); 487 kdb_printf("kdb_getword: bad width %ld\n", (long) size);
@@ -525,7 +525,7 @@ int kdb_putword(unsigned long addr, unsigned long word, size_t size)
525 diag = kdb_putarea(addr, w8); 525 diag = kdb_putarea(addr, w8);
526 break; 526 break;
527 } 527 }
528 /* drop through */ 528 /* fall through */
529 default: 529 default:
530 diag = KDB_BADWIDTH; 530 diag = KDB_BADWIDTH;
531 kdb_printf("kdb_putword: bad width %ld\n", (long) size); 531 kdb_printf("kdb_putword: bad width %ld\n", (long) size);
@@ -887,13 +887,13 @@ void debug_kusage(void)
887 __func__, dah_first); 887 __func__, dah_first);
888 if (dah_first) { 888 if (dah_first) {
889 h_used = (struct debug_alloc_header *)debug_alloc_pool; 889 h_used = (struct debug_alloc_header *)debug_alloc_pool;
890 kdb_printf("%s: h_used %p size %d\n", __func__, h_used, 890 kdb_printf("%s: h_used %px size %d\n", __func__, h_used,
891 h_used->size); 891 h_used->size);
892 } 892 }
893 do { 893 do {
894 h_used = (struct debug_alloc_header *) 894 h_used = (struct debug_alloc_header *)
895 ((char *)h_free + dah_overhead + h_free->size); 895 ((char *)h_free + dah_overhead + h_free->size);
896 kdb_printf("%s: h_used %p size %d caller %p\n", 896 kdb_printf("%s: h_used %px size %d caller %px\n",
897 __func__, h_used, h_used->size, h_used->caller); 897 __func__, h_used, h_used->size, h_used->caller);
898 h_free = (struct debug_alloc_header *) 898 h_free = (struct debug_alloc_header *)
899 (debug_alloc_pool + h_free->next); 899 (debug_alloc_pool + h_free->next);
@@ -902,7 +902,7 @@ void debug_kusage(void)
902 ((char *)h_free + dah_overhead + h_free->size); 902 ((char *)h_free + dah_overhead + h_free->size);
903 if ((char *)h_used - debug_alloc_pool != 903 if ((char *)h_used - debug_alloc_pool !=
904 sizeof(debug_alloc_pool_aligned)) 904 sizeof(debug_alloc_pool_aligned))
905 kdb_printf("%s: h_used %p size %d caller %p\n", 905 kdb_printf("%s: h_used %px size %d caller %px\n",
906 __func__, h_used, h_used->size, h_used->caller); 906 __func__, h_used, h_used->size, h_used->caller);
907out: 907out:
908 spin_unlock(&dap_lock); 908 spin_unlock(&dap_lock);
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
index d8831b988b1e..ab4a3be1542a 100644
--- a/net/sunrpc/auth_generic.c
+++ b/net/sunrpc/auth_generic.c
@@ -281,13 +281,7 @@ static bool generic_key_to_expire(struct rpc_cred *cred)
281{ 281{
282 struct auth_cred *acred = &container_of(cred, struct generic_cred, 282 struct auth_cred *acred = &container_of(cred, struct generic_cred,
283 gc_base)->acred; 283 gc_base)->acred;
284 bool ret; 284 return test_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags);
285
286 get_rpccred(cred);
287 ret = test_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags);
288 put_rpccred(cred);
289
290 return ret;
291} 285}
292 286
293static const struct rpc_credops generic_credops = { 287static const struct rpc_credops generic_credops = {
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 30f970cdc7f6..5d3f252659f1 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -1239,36 +1239,59 @@ gss_create(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
1239 return &gss_auth->rpc_auth; 1239 return &gss_auth->rpc_auth;
1240} 1240}
1241 1241
1242static struct gss_cred *
1243gss_dup_cred(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
1244{
1245 struct gss_cred *new;
1246
1247 /* Make a copy of the cred so that we can reference count it */
1248 new = kzalloc(sizeof(*gss_cred), GFP_NOIO);
1249 if (new) {
1250 struct auth_cred acred = {
1251 .uid = gss_cred->gc_base.cr_uid,
1252 };
1253 struct gss_cl_ctx *ctx =
1254 rcu_dereference_protected(gss_cred->gc_ctx, 1);
1255
1256 rpcauth_init_cred(&new->gc_base, &acred,
1257 &gss_auth->rpc_auth,
1258 &gss_nullops);
1259 new->gc_base.cr_flags = 1UL << RPCAUTH_CRED_UPTODATE;
1260 new->gc_service = gss_cred->gc_service;
1261 new->gc_principal = gss_cred->gc_principal;
1262 kref_get(&gss_auth->kref);
1263 rcu_assign_pointer(new->gc_ctx, ctx);
1264 gss_get_ctx(ctx);
1265 }
1266 return new;
1267}
1268
1242/* 1269/*
1243 * gss_destroying_context will cause the RPCSEC_GSS to send a NULL RPC call 1270 * gss_send_destroy_context will cause the RPCSEC_GSS to send a NULL RPC call
1244 * to the server with the GSS control procedure field set to 1271 * to the server with the GSS control procedure field set to
1245 * RPC_GSS_PROC_DESTROY. This should normally cause the server to release 1272 * RPC_GSS_PROC_DESTROY. This should normally cause the server to release
1246 * all RPCSEC_GSS state associated with that context. 1273 * all RPCSEC_GSS state associated with that context.
1247 */ 1274 */
1248static int 1275static void
1249gss_destroying_context(struct rpc_cred *cred) 1276gss_send_destroy_context(struct rpc_cred *cred)
1250{ 1277{
1251 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, gc_base); 1278 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, gc_base);
1252 struct gss_auth *gss_auth = container_of(cred->cr_auth, struct gss_auth, rpc_auth); 1279 struct gss_auth *gss_auth = container_of(cred->cr_auth, struct gss_auth, rpc_auth);
1253 struct gss_cl_ctx *ctx = rcu_dereference_protected(gss_cred->gc_ctx, 1); 1280 struct gss_cl_ctx *ctx = rcu_dereference_protected(gss_cred->gc_ctx, 1);
1281 struct gss_cred *new;
1254 struct rpc_task *task; 1282 struct rpc_task *task;
1255 1283
1256 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) == 0) 1284 new = gss_dup_cred(gss_auth, gss_cred);
1257 return 0; 1285 if (new) {
1258 1286 ctx->gc_proc = RPC_GSS_PROC_DESTROY;
1259 ctx->gc_proc = RPC_GSS_PROC_DESTROY;
1260 cred->cr_ops = &gss_nullops;
1261
1262 /* Take a reference to ensure the cred will be destroyed either
1263 * by the RPC call or by the put_rpccred() below */
1264 get_rpccred(cred);
1265 1287
1266 task = rpc_call_null(gss_auth->client, cred, RPC_TASK_ASYNC|RPC_TASK_SOFT); 1288 task = rpc_call_null(gss_auth->client, &new->gc_base,
1267 if (!IS_ERR(task)) 1289 RPC_TASK_ASYNC|RPC_TASK_SOFT);
1268 rpc_put_task(task); 1290 if (!IS_ERR(task))
1291 rpc_put_task(task);
1269 1292
1270 put_rpccred(cred); 1293 put_rpccred(&new->gc_base);
1271 return 1; 1294 }
1272} 1295}
1273 1296
1274/* gss_destroy_cred (and gss_free_ctx) are used to clean up after failure 1297/* gss_destroy_cred (and gss_free_ctx) are used to clean up after failure
@@ -1330,8 +1353,8 @@ static void
1330gss_destroy_cred(struct rpc_cred *cred) 1353gss_destroy_cred(struct rpc_cred *cred)
1331{ 1354{
1332 1355
1333 if (gss_destroying_context(cred)) 1356 if (test_and_clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0)
1334 return; 1357 gss_send_destroy_context(cred);
1335 gss_destroy_nullcred(cred); 1358 gss_destroy_nullcred(cred);
1336} 1359}
1337 1360
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 2bbb8d38d2bf..f302c6eb8779 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -546,7 +546,7 @@ EXPORT_SYMBOL_GPL(xdr_commit_encode);
546static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, 546static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,
547 size_t nbytes) 547 size_t nbytes)
548{ 548{
549 static __be32 *p; 549 __be32 *p;
550 int space_left; 550 int space_left;
551 int frag1bytes, frag2bytes; 551 int frag1bytes, frag2bytes;
552 552
@@ -673,11 +673,10 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len)
673 WARN_ON_ONCE(xdr->iov); 673 WARN_ON_ONCE(xdr->iov);
674 return; 674 return;
675 } 675 }
676 if (fraglen) { 676 if (fraglen)
677 xdr->end = head->iov_base + head->iov_len; 677 xdr->end = head->iov_base + head->iov_len;
678 xdr->page_ptr--;
679 }
680 /* (otherwise assume xdr->end is already set) */ 678 /* (otherwise assume xdr->end is already set) */
679 xdr->page_ptr--;
681 head->iov_len = len; 680 head->iov_len = len;
682 buf->len = len; 681 buf->len = len;
683 xdr->p = head->iov_base + head->iov_len; 682 xdr->p = head->iov_base + head->iov_len;
diff --git a/security/integrity/digsig_asymmetric.c b/security/integrity/digsig_asymmetric.c
index 6dc075144508..d775e03fbbcc 100644
--- a/security/integrity/digsig_asymmetric.c
+++ b/security/integrity/digsig_asymmetric.c
@@ -106,6 +106,7 @@ int asymmetric_verify(struct key *keyring, const char *sig,
106 106
107 pks.pkey_algo = "rsa"; 107 pks.pkey_algo = "rsa";
108 pks.hash_algo = hash_algo_name[hdr->hash_algo]; 108 pks.hash_algo = hash_algo_name[hdr->hash_algo];
109 pks.encoding = "pkcs1";
109 pks.digest = (u8 *)data; 110 pks.digest = (u8 *)data;
110 pks.digest_size = datalen; 111 pks.digest_size = datalen;
111 pks.s = hdr->sig; 112 pks.s = hdr->sig;
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 7ce683259357..a67459eb62d5 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -5318,6 +5318,9 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname,
5318 addr_buf = address; 5318 addr_buf = address;
5319 5319
5320 while (walk_size < addrlen) { 5320 while (walk_size < addrlen) {
5321 if (walk_size + sizeof(sa_family_t) > addrlen)
5322 return -EINVAL;
5323
5321 addr = addr_buf; 5324 addr = addr_buf;
5322 switch (addr->sa_family) { 5325 switch (addr->sa_family) {
5323 case AF_UNSPEC: 5326 case AF_UNSPEC:
diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c
index 2fe459df3c85..b7efa2296969 100644
--- a/security/selinux/ss/mls.c
+++ b/security/selinux/ss/mls.c
@@ -245,9 +245,13 @@ int mls_context_to_sid(struct policydb *pol,
245 char *rangep[2]; 245 char *rangep[2];
246 246
247 if (!pol->mls_enabled) { 247 if (!pol->mls_enabled) {
248 if ((def_sid != SECSID_NULL && oldc) || (*scontext) == '\0') 248 /*
249 return 0; 249 * With no MLS, only return -EINVAL if there is a MLS field
250 return -EINVAL; 250 * and it did not come from an xattr.
251 */
252 if (oldc && def_sid == SECSID_NULL)
253 return -EINVAL;
254 return 0;
251 } 255 }
252 256
253 /* 257 /*
diff --git a/tools/testing/selftests/powerpc/mm/wild_bctr.c b/tools/testing/selftests/powerpc/mm/wild_bctr.c
index 1b0e9e9a2ddc..f2fa101c5a6a 100644
--- a/tools/testing/selftests/powerpc/mm/wild_bctr.c
+++ b/tools/testing/selftests/powerpc/mm/wild_bctr.c
@@ -47,8 +47,9 @@ static int ok(void)
47 return 0; 47 return 0;
48} 48}
49 49
50#define REG_POISON 0x5a5aUL 50#define REG_POISON 0x5a5a
51#define POISONED_REG(n) ((REG_POISON << 48) | ((n) << 32) | (REG_POISON << 16) | (n)) 51#define POISONED_REG(n) ((((unsigned long)REG_POISON) << 48) | ((n) << 32) | \
52 (((unsigned long)REG_POISON) << 16) | (n))
52 53
53static inline void poison_regs(void) 54static inline void poison_regs(void)
54{ 55{
@@ -105,6 +106,20 @@ static void dump_regs(void)
105 } 106 }
106} 107}
107 108
109#ifdef _CALL_AIXDESC
110struct opd {
111 unsigned long ip;
112 unsigned long toc;
113 unsigned long env;
114};
115static struct opd bad_opd = {
116 .ip = BAD_NIP,
117};
118#define BAD_FUNC (&bad_opd)
119#else
120#define BAD_FUNC BAD_NIP
121#endif
122
108int test_wild_bctr(void) 123int test_wild_bctr(void)
109{ 124{
110 int (*func_ptr)(void); 125 int (*func_ptr)(void);
@@ -133,7 +148,7 @@ int test_wild_bctr(void)
133 148
134 poison_regs(); 149 poison_regs();
135 150
136 func_ptr = (int (*)(void))BAD_NIP; 151 func_ptr = (int (*)(void))BAD_FUNC;
137 func_ptr(); 152 func_ptr();
138 153
139 FAIL_IF(1); /* we didn't segv? */ 154 FAIL_IF(1); /* we didn't segv? */