Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.9 commit in: /
Date: Tue, 05 Dec 2017 11:38:59
Message-Id: 1512473927.051c70468e420f463e1e5f571f644af0736679e5.mpagano@gentoo
1 commit: 051c70468e420f463e1e5f571f644af0736679e5
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 5 11:38:47 2017 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 5 11:38:47 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=051c7046
7
8 Linux patch 4.9.67
9
10 0000_README | 4 +
11 1066_linux-4.9.67.patch | 1089 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 1093 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 045a3d8..baf7aeb 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -307,6 +307,10 @@ Patch: 1065_linux-4.9.66.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.9.66
21
22 +Patch: 1066_linux-4.9.67.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.9.67
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1066_linux-4.9.67.patch b/1066_linux-4.9.67.patch
31 new file mode 100644
32 index 0000000..3d65c36
33 --- /dev/null
34 +++ b/1066_linux-4.9.67.patch
35 @@ -0,0 +1,1089 @@
36 +diff --git a/Documentation/devicetree/bindings/hwmon/jc42.txt b/Documentation/devicetree/bindings/hwmon/jc42.txt
37 +index 07a250498fbb..f569db58f64a 100644
38 +--- a/Documentation/devicetree/bindings/hwmon/jc42.txt
39 ++++ b/Documentation/devicetree/bindings/hwmon/jc42.txt
40 +@@ -34,6 +34,10 @@ Required properties:
41 +
42 + - reg: I2C address
43 +
44 ++Optional properties:
45 ++- smbus-timeout-disable: When set, the smbus timeout function will be disabled.
46 ++ This is not supported on all chips.
47 ++
48 + Example:
49 +
50 + temp-sensor@1a {
51 +diff --git a/Makefile b/Makefile
52 +index 8e62f9e2a08c..70546af61a0a 100644
53 +--- a/Makefile
54 ++++ b/Makefile
55 +@@ -1,6 +1,6 @@
56 + VERSION = 4
57 + PATCHLEVEL = 9
58 +-SUBLEVEL = 66
59 ++SUBLEVEL = 67
60 + EXTRAVERSION =
61 + NAME = Roaring Lionus
62 +
63 +diff --git a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
64 +index 08cce17a25a0..b4575bbaf085 100644
65 +--- a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
66 ++++ b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
67 +@@ -192,7 +192,7 @@
68 + interrupts-extended = <&intc 83 &omap3_pmx_core 0x11a>;
69 + pinctrl-names = "default";
70 + pinctrl-0 = <&mmc1_pins &mmc1_cd>;
71 +- cd-gpios = <&gpio4 31 IRQ_TYPE_LEVEL_LOW>; /* gpio127 */
72 ++ cd-gpios = <&gpio4 31 GPIO_ACTIVE_LOW>; /* gpio127 */
73 + vmmc-supply = <&vmmc1>;
74 + bus-width = <4>;
75 + cap-power-off-card;
76 +@@ -249,9 +249,9 @@
77 + OMAP3_CORE1_IOPAD(0x2110, PIN_INPUT | MUX_MODE0) /* cam_xclka.cam_xclka */
78 + OMAP3_CORE1_IOPAD(0x2112, PIN_INPUT | MUX_MODE0) /* cam_pclk.cam_pclk */
79 +
80 +- OMAP3_CORE1_IOPAD(0x2114, PIN_INPUT | MUX_MODE0) /* cam_d0.cam_d0 */
81 +- OMAP3_CORE1_IOPAD(0x2116, PIN_INPUT | MUX_MODE0) /* cam_d1.cam_d1 */
82 +- OMAP3_CORE1_IOPAD(0x2118, PIN_INPUT | MUX_MODE0) /* cam_d2.cam_d2 */
83 ++ OMAP3_CORE1_IOPAD(0x2116, PIN_INPUT | MUX_MODE0) /* cam_d0.cam_d0 */
84 ++ OMAP3_CORE1_IOPAD(0x2118, PIN_INPUT | MUX_MODE0) /* cam_d1.cam_d1 */
85 ++ OMAP3_CORE1_IOPAD(0x211a, PIN_INPUT | MUX_MODE0) /* cam_d2.cam_d2 */
86 + OMAP3_CORE1_IOPAD(0x211c, PIN_INPUT | MUX_MODE0) /* cam_d3.cam_d3 */
87 + OMAP3_CORE1_IOPAD(0x211e, PIN_INPUT | MUX_MODE0) /* cam_d4.cam_d4 */
88 + OMAP3_CORE1_IOPAD(0x2120, PIN_INPUT | MUX_MODE0) /* cam_d5.cam_d5 */
89 +diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
90 +index 770216baa737..da310bb779b9 100644
91 +--- a/arch/arm/mach-omap2/pdata-quirks.c
92 ++++ b/arch/arm/mach-omap2/pdata-quirks.c
93 +@@ -162,7 +162,7 @@ static struct ti_st_plat_data wilink7_pdata = {
94 + .nshutdown_gpio = 162,
95 + .dev_name = "/dev/ttyO1",
96 + .flow_cntrl = 1,
97 +- .baud_rate = 300000,
98 ++ .baud_rate = 3000000,
99 + };
100 +
101 + static struct platform_device wl128x_device = {
102 +diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
103 +index be9df513141e..e7b0e7ff4c58 100644
104 +--- a/arch/x86/entry/entry_64.S
105 ++++ b/arch/x86/entry/entry_64.S
106 +@@ -54,19 +54,15 @@ ENTRY(native_usergs_sysret64)
107 + ENDPROC(native_usergs_sysret64)
108 + #endif /* CONFIG_PARAVIRT */
109 +
110 +-.macro TRACE_IRQS_FLAGS flags:req
111 ++.macro TRACE_IRQS_IRETQ
112 + #ifdef CONFIG_TRACE_IRQFLAGS
113 +- bt $9, \flags /* interrupts off? */
114 ++ bt $9, EFLAGS(%rsp) /* interrupts off? */
115 + jnc 1f
116 + TRACE_IRQS_ON
117 + 1:
118 + #endif
119 + .endm
120 +
121 +-.macro TRACE_IRQS_IRETQ
122 +- TRACE_IRQS_FLAGS EFLAGS(%rsp)
123 +-.endm
124 +-
125 + /*
126 + * When dynamic function tracer is enabled it will add a breakpoint
127 + * to all locations that it is about to modify, sync CPUs, update
128 +@@ -872,13 +868,11 @@ idtentry simd_coprocessor_error do_simd_coprocessor_error has_error_code=0
129 + ENTRY(native_load_gs_index)
130 + pushfq
131 + DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
132 +- TRACE_IRQS_OFF
133 + SWAPGS
134 + .Lgs_change:
135 + movl %edi, %gs
136 + 2: ALTERNATIVE "", "mfence", X86_BUG_SWAPGS_FENCE
137 + SWAPGS
138 +- TRACE_IRQS_FLAGS (%rsp)
139 + popfq
140 + ret
141 + END(native_load_gs_index)
142 +diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
143 +index 3f05c044720b..b24b3c6d686e 100644
144 +--- a/arch/x86/kvm/lapic.c
145 ++++ b/arch/x86/kvm/lapic.c
146 +@@ -246,9 +246,14 @@ static inline void kvm_apic_set_ldr(struct kvm_lapic *apic, u32 id)
147 + recalculate_apic_map(apic->vcpu->kvm);
148 + }
149 +
150 ++static inline u32 kvm_apic_calc_x2apic_ldr(u32 id)
151 ++{
152 ++ return ((id >> 4) << 16) | (1 << (id & 0xf));
153 ++}
154 ++
155 + static inline void kvm_apic_set_x2apic_id(struct kvm_lapic *apic, u32 id)
156 + {
157 +- u32 ldr = ((id >> 4) << 16) | (1 << (id & 0xf));
158 ++ u32 ldr = kvm_apic_calc_x2apic_ldr(id);
159 +
160 + kvm_lapic_set_reg(apic, APIC_ID, id);
161 + kvm_lapic_set_reg(apic, APIC_LDR, ldr);
162 +@@ -2029,6 +2034,7 @@ static int kvm_apic_state_fixup(struct kvm_vcpu *vcpu,
163 + {
164 + if (apic_x2apic_mode(vcpu->arch.apic)) {
165 + u32 *id = (u32 *)(s->regs + APIC_ID);
166 ++ u32 *ldr = (u32 *)(s->regs + APIC_LDR);
167 +
168 + if (vcpu->kvm->arch.x2apic_format) {
169 + if (*id != vcpu->vcpu_id)
170 +@@ -2039,6 +2045,10 @@ static int kvm_apic_state_fixup(struct kvm_vcpu *vcpu,
171 + else
172 + *id <<= 24;
173 + }
174 ++
175 ++ /* In x2APIC mode, the LDR is fixed and based on the id */
176 ++ if (set)
177 ++ *ldr = kvm_apic_calc_x2apic_ldr(*id);
178 + }
179 +
180 + return 0;
181 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
182 +index 4fbf0c94f2d1..23f1a6bd7a0d 100644
183 +--- a/arch/x86/kvm/svm.c
184 ++++ b/arch/x86/kvm/svm.c
185 +@@ -2149,6 +2149,8 @@ static int ud_interception(struct vcpu_svm *svm)
186 + int er;
187 +
188 + er = emulate_instruction(&svm->vcpu, EMULTYPE_TRAP_UD);
189 ++ if (er == EMULATE_USER_EXIT)
190 ++ return 0;
191 + if (er != EMULATE_DONE)
192 + kvm_queue_exception(&svm->vcpu, UD_VECTOR);
193 + return 1;
194 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
195 +index 0f0b27d96f27..f0d3de153e29 100644
196 +--- a/arch/x86/kvm/vmx.c
197 ++++ b/arch/x86/kvm/vmx.c
198 +@@ -5502,6 +5502,8 @@ static int handle_exception(struct kvm_vcpu *vcpu)
199 + return 1;
200 + }
201 + er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
202 ++ if (er == EMULATE_USER_EXIT)
203 ++ return 0;
204 + if (er != EMULATE_DONE)
205 + kvm_queue_exception(vcpu, UD_VECTOR);
206 + return 1;
207 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
208 +index 595f8149c0d9..02d45296a97c 100644
209 +--- a/arch/x86/kvm/x86.c
210 ++++ b/arch/x86/kvm/x86.c
211 +@@ -1797,6 +1797,9 @@ static void kvm_setup_pvclock_page(struct kvm_vcpu *v)
212 + */
213 + BUILD_BUG_ON(offsetof(struct pvclock_vcpu_time_info, version) != 0);
214 +
215 ++ if (guest_hv_clock.version & 1)
216 ++ ++guest_hv_clock.version; /* first time write, random junk */
217 ++
218 + vcpu->hv_clock.version = guest_hv_clock.version + 1;
219 + kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
220 + &vcpu->hv_clock,
221 +@@ -5576,6 +5579,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
222 + if (reexecute_instruction(vcpu, cr2, write_fault_to_spt,
223 + emulation_type))
224 + return EMULATE_DONE;
225 ++ if (ctxt->have_exception && inject_emulated_exception(vcpu))
226 ++ return EMULATE_DONE;
227 + if (emulation_type & EMULTYPE_SKIP)
228 + return EMULATE_FAIL;
229 + return handle_emulation_failure(vcpu);
230 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
231 +index f8fdbd1378a7..26afdffab5a0 100644
232 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
233 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
234 +@@ -1788,34 +1788,32 @@ void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev)
235 + WREG32(mmBIOS_SCRATCH_0 + i, adev->bios_scratch[i]);
236 + }
237 +
238 +-/* Atom needs data in little endian format
239 +- * so swap as appropriate when copying data to
240 +- * or from atom. Note that atom operates on
241 +- * dw units.
242 ++/* Atom needs data in little endian format so swap as appropriate when copying
243 ++ * data to or from atom. Note that atom operates on dw units.
244 ++ *
245 ++ * Use to_le=true when sending data to atom and provide at least
246 ++ * ALIGN(num_bytes,4) bytes in the dst buffer.
247 ++ *
248 ++ * Use to_le=false when receiving data from atom and provide ALIGN(num_bytes,4)
249 ++ * byes in the src buffer.
250 + */
251 + void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
252 + {
253 + #ifdef __BIG_ENDIAN
254 +- u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
255 +- u32 *dst32, *src32;
256 ++ u32 src_tmp[5], dst_tmp[5];
257 + int i;
258 ++ u8 align_num_bytes = ALIGN(num_bytes, 4);
259 +
260 +- memcpy(src_tmp, src, num_bytes);
261 +- src32 = (u32 *)src_tmp;
262 +- dst32 = (u32 *)dst_tmp;
263 + if (to_le) {
264 +- for (i = 0; i < ((num_bytes + 3) / 4); i++)
265 +- dst32[i] = cpu_to_le32(src32[i]);
266 +- memcpy(dst, dst_tmp, num_bytes);
267 ++ memcpy(src_tmp, src, num_bytes);
268 ++ for (i = 0; i < align_num_bytes / 4; i++)
269 ++ dst_tmp[i] = cpu_to_le32(src_tmp[i]);
270 ++ memcpy(dst, dst_tmp, align_num_bytes);
271 + } else {
272 +- u8 dws = num_bytes & ~3;
273 +- for (i = 0; i < ((num_bytes + 3) / 4); i++)
274 +- dst32[i] = le32_to_cpu(src32[i]);
275 +- memcpy(dst, dst_tmp, dws);
276 +- if (num_bytes % 4) {
277 +- for (i = 0; i < (num_bytes % 4); i++)
278 +- dst[dws+i] = dst_tmp[dws+i];
279 +- }
280 ++ memcpy(src_tmp, src, align_num_bytes);
281 ++ for (i = 0; i < align_num_bytes / 4; i++)
282 ++ dst_tmp[i] = le32_to_cpu(src_tmp[i]);
283 ++ memcpy(dst, dst_tmp, num_bytes);
284 + }
285 + #else
286 + memcpy(dst, src, num_bytes);
287 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
288 +index 743a12df6971..3bb2b9b5ef9c 100644
289 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
290 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
291 +@@ -648,7 +648,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)
292 + uint32_t allocated = 0;
293 + uint32_t tmp, handle = 0;
294 + uint32_t *size = &tmp;
295 +- int i, r, idx = 0;
296 ++ int i, r = 0, idx = 0;
297 +
298 + r = amdgpu_cs_sysvm_access_required(p);
299 + if (r)
300 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
301 +index 968c4260d7a7..47503759906b 100644
302 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
303 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
304 +@@ -744,7 +744,7 @@ static int amdgpu_vm_update_pd_or_shadow(struct amdgpu_device *adev,
305 + int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
306 + struct amdgpu_vm *vm)
307 + {
308 +- int r;
309 ++ int r = 0;
310 +
311 + r = amdgpu_vm_update_pd_or_shadow(adev, vm, true);
312 + if (r)
313 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
314 +index 4477c55a58e3..a8b59b3decd8 100644
315 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
316 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
317 +@@ -850,9 +850,9 @@ static int init_over_drive_limits(
318 + const ATOM_Tonga_POWERPLAYTABLE *powerplay_table)
319 + {
320 + hwmgr->platform_descriptor.overdriveLimit.engineClock =
321 +- le16_to_cpu(powerplay_table->ulMaxODEngineClock);
322 ++ le32_to_cpu(powerplay_table->ulMaxODEngineClock);
323 + hwmgr->platform_descriptor.overdriveLimit.memoryClock =
324 +- le16_to_cpu(powerplay_table->ulMaxODMemoryClock);
325 ++ le32_to_cpu(powerplay_table->ulMaxODMemoryClock);
326 +
327 + hwmgr->platform_descriptor.minOverdriveVDDC = 0;
328 + hwmgr->platform_descriptor.maxOverdriveVDDC = 0;
329 +diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
330 +index 7e7a4d43d6b6..0f563c954520 100644
331 +--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
332 ++++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
333 +@@ -521,9 +521,12 @@ static void ade_crtc_atomic_begin(struct drm_crtc *crtc,
334 + {
335 + struct ade_crtc *acrtc = to_ade_crtc(crtc);
336 + struct ade_hw_ctx *ctx = acrtc->ctx;
337 ++ struct drm_display_mode *mode = &crtc->state->mode;
338 ++ struct drm_display_mode *adj_mode = &crtc->state->adjusted_mode;
339 +
340 + if (!ctx->power_on)
341 + (void)ade_power_up(ctx);
342 ++ ade_ldi_set_mode(acrtc, mode, adj_mode);
343 + }
344 +
345 + static void ade_crtc_atomic_flush(struct drm_crtc *crtc,
346 +diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
347 +index 79aab9ad6faa..6769aa1b6922 100644
348 +--- a/drivers/gpu/drm/i915/intel_i2c.c
349 ++++ b/drivers/gpu/drm/i915/intel_i2c.c
350 +@@ -430,7 +430,9 @@ static bool
351 + gmbus_is_index_read(struct i2c_msg *msgs, int i, int num)
352 + {
353 + return (i + 1 < num &&
354 +- !(msgs[i].flags & I2C_M_RD) && msgs[i].len <= 2 &&
355 ++ msgs[i].addr == msgs[i + 1].addr &&
356 ++ !(msgs[i].flags & I2C_M_RD) &&
357 ++ (msgs[i].len == 1 || msgs[i].len == 2) &&
358 + (msgs[i + 1].flags & I2C_M_RD));
359 + }
360 +
361 +diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
362 +index 27cb42467b20..6f65846b1783 100644
363 +--- a/drivers/gpu/drm/panel/panel-simple.c
364 ++++ b/drivers/gpu/drm/panel/panel-simple.c
365 +@@ -369,6 +369,7 @@ static int panel_simple_remove(struct device *dev)
366 + drm_panel_remove(&panel->base);
367 +
368 + panel_simple_disable(&panel->base);
369 ++ panel_simple_unprepare(&panel->base);
370 +
371 + if (panel->ddc)
372 + put_device(&panel->ddc->dev);
373 +@@ -384,6 +385,7 @@ static void panel_simple_shutdown(struct device *dev)
374 + struct panel_simple *panel = dev_get_drvdata(dev);
375 +
376 + panel_simple_disable(&panel->base);
377 ++ panel_simple_unprepare(&panel->base);
378 + }
379 +
380 + static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode = {
381 +diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
382 +index 432cb46f6a34..fd7682bf335d 100644
383 +--- a/drivers/gpu/drm/radeon/atombios_dp.c
384 ++++ b/drivers/gpu/drm/radeon/atombios_dp.c
385 +@@ -45,34 +45,32 @@ static char *pre_emph_names[] = {
386 +
387 + /***** radeon AUX functions *****/
388 +
389 +-/* Atom needs data in little endian format
390 +- * so swap as appropriate when copying data to
391 +- * or from atom. Note that atom operates on
392 +- * dw units.
393 ++/* Atom needs data in little endian format so swap as appropriate when copying
394 ++ * data to or from atom. Note that atom operates on dw units.
395 ++ *
396 ++ * Use to_le=true when sending data to atom and provide at least
397 ++ * ALIGN(num_bytes,4) bytes in the dst buffer.
398 ++ *
399 ++ * Use to_le=false when receiving data from atom and provide ALIGN(num_bytes,4)
400 ++ * byes in the src buffer.
401 + */
402 + void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
403 + {
404 + #ifdef __BIG_ENDIAN
405 +- u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
406 +- u32 *dst32, *src32;
407 ++ u32 src_tmp[5], dst_tmp[5];
408 + int i;
409 ++ u8 align_num_bytes = ALIGN(num_bytes, 4);
410 +
411 +- memcpy(src_tmp, src, num_bytes);
412 +- src32 = (u32 *)src_tmp;
413 +- dst32 = (u32 *)dst_tmp;
414 + if (to_le) {
415 +- for (i = 0; i < ((num_bytes + 3) / 4); i++)
416 +- dst32[i] = cpu_to_le32(src32[i]);
417 +- memcpy(dst, dst_tmp, num_bytes);
418 ++ memcpy(src_tmp, src, num_bytes);
419 ++ for (i = 0; i < align_num_bytes / 4; i++)
420 ++ dst_tmp[i] = cpu_to_le32(src_tmp[i]);
421 ++ memcpy(dst, dst_tmp, align_num_bytes);
422 + } else {
423 +- u8 dws = num_bytes & ~3;
424 +- for (i = 0; i < ((num_bytes + 3) / 4); i++)
425 +- dst32[i] = le32_to_cpu(src32[i]);
426 +- memcpy(dst, dst_tmp, dws);
427 +- if (num_bytes % 4) {
428 +- for (i = 0; i < (num_bytes % 4); i++)
429 +- dst[dws+i] = dst_tmp[dws+i];
430 +- }
431 ++ memcpy(src_tmp, src, align_num_bytes);
432 ++ for (i = 0; i < align_num_bytes / 4; i++)
433 ++ dst_tmp[i] = le32_to_cpu(src_tmp[i]);
434 ++ memcpy(dst, dst_tmp, num_bytes);
435 + }
436 + #else
437 + memcpy(dst, src, num_bytes);
438 +diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
439 +index 0daad446d2c7..af84705b82ed 100644
440 +--- a/drivers/gpu/drm/radeon/radeon_fb.c
441 ++++ b/drivers/gpu/drm/radeon/radeon_fb.c
442 +@@ -252,7 +252,6 @@ static int radeonfb_create(struct drm_fb_helper *helper,
443 + }
444 +
445 + info->par = rfbdev;
446 +- info->skip_vt_switch = true;
447 +
448 + ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->rfb, &mode_cmd, gobj);
449 + if (ret) {
450 +diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
451 +index bf6e21655c57..7d22f9874d5f 100644
452 +--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
453 ++++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
454 +@@ -473,6 +473,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
455 + INIT_LIST_HEAD(&fbo->lru);
456 + INIT_LIST_HEAD(&fbo->swap);
457 + INIT_LIST_HEAD(&fbo->io_reserve_lru);
458 ++ mutex_init(&fbo->wu_mutex);
459 + fbo->moving = NULL;
460 + drm_vma_node_reset(&fbo->vma_node);
461 + atomic_set(&fbo->cpu_writers, 0);
462 +diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
463 +index 1bf22eff0b08..0f1f6421845f 100644
464 +--- a/drivers/hwmon/jc42.c
465 ++++ b/drivers/hwmon/jc42.c
466 +@@ -22,6 +22,7 @@
467 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
468 + */
469 +
470 ++#include <linux/bitops.h>
471 + #include <linux/module.h>
472 + #include <linux/init.h>
473 + #include <linux/slab.h>
474 +@@ -45,6 +46,7 @@ static const unsigned short normal_i2c[] = {
475 + #define JC42_REG_TEMP 0x05
476 + #define JC42_REG_MANID 0x06
477 + #define JC42_REG_DEVICEID 0x07
478 ++#define JC42_REG_SMBUS 0x22 /* NXP and Atmel, possibly others? */
479 +
480 + /* Status bits in temperature register */
481 + #define JC42_ALARM_CRIT_BIT 15
482 +@@ -73,6 +75,9 @@ static const unsigned short normal_i2c[] = {
483 + #define ONS_MANID 0x1b09 /* ON Semiconductor */
484 + #define STM_MANID 0x104a /* ST Microelectronics */
485 +
486 ++/* SMBUS register */
487 ++#define SMBUS_STMOUT BIT(7) /* SMBus time-out, active low */
488 ++
489 + /* Supported chips */
490 +
491 + /* Analog Devices */
492 +@@ -476,6 +481,22 @@ static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id)
493 +
494 + data->extended = !!(cap & JC42_CAP_RANGE);
495 +
496 ++ if (device_property_read_bool(dev, "smbus-timeout-disable")) {
497 ++ int smbus;
498 ++
499 ++ /*
500 ++ * Not all chips support this register, but from a
501 ++ * quick read of various datasheets no chip appears
502 ++ * incompatible with the below attempt to disable
503 ++ * the timeout. And the whole thing is opt-in...
504 ++ */
505 ++ smbus = i2c_smbus_read_word_swapped(client, JC42_REG_SMBUS);
506 ++ if (smbus < 0)
507 ++ return smbus;
508 ++ i2c_smbus_write_word_swapped(client, JC42_REG_SMBUS,
509 ++ smbus | SMBUS_STMOUT);
510 ++ }
511 ++
512 + config = i2c_smbus_read_word_swapped(client, JC42_REG_CONFIG);
513 + if (config < 0)
514 + return config;
515 +diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
516 +index eb3627f35d12..e6fe21a6135b 100644
517 +--- a/drivers/i2c/busses/i2c-i801.c
518 ++++ b/drivers/i2c/busses/i2c-i801.c
519 +@@ -1592,6 +1592,9 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
520 + /* Default timeout in interrupt mode: 200 ms */
521 + priv->adapter.timeout = HZ / 5;
522 +
523 ++ if (dev->irq == IRQ_NOTCONNECTED)
524 ++ priv->features &= ~FEATURE_IRQ;
525 ++
526 + if (priv->features & FEATURE_IRQ) {
527 + u16 pcictl, pcists;
528 +
529 +diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
530 +index 3fba31cea66e..537903bf9add 100644
531 +--- a/drivers/md/bcache/alloc.c
532 ++++ b/drivers/md/bcache/alloc.c
533 +@@ -477,7 +477,7 @@ int __bch_bucket_alloc_set(struct cache_set *c, unsigned reserve,
534 + if (b == -1)
535 + goto err;
536 +
537 +- k->ptr[i] = PTR(ca->buckets[b].gen,
538 ++ k->ptr[i] = MAKE_PTR(ca->buckets[b].gen,
539 + bucket_to_sector(c, b),
540 + ca->sb.nr_this_dev);
541 +
542 +diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
543 +index 243de0bf15cd..4bf15182c4da 100644
544 +--- a/drivers/md/bcache/extents.c
545 ++++ b/drivers/md/bcache/extents.c
546 +@@ -584,7 +584,7 @@ static bool bch_extent_merge(struct btree_keys *bk, struct bkey *l, struct bkey
547 + return false;
548 +
549 + for (i = 0; i < KEY_PTRS(l); i++)
550 +- if (l->ptr[i] + PTR(0, KEY_SIZE(l), 0) != r->ptr[i] ||
551 ++ if (l->ptr[i] + MAKE_PTR(0, KEY_SIZE(l), 0) != r->ptr[i] ||
552 + PTR_BUCKET_NR(b->c, l, i) != PTR_BUCKET_NR(b->c, r, i))
553 + return false;
554 +
555 +diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
556 +index 6925023e12d4..08f20b7cd199 100644
557 +--- a/drivers/md/bcache/journal.c
558 ++++ b/drivers/md/bcache/journal.c
559 +@@ -508,7 +508,7 @@ static void journal_reclaim(struct cache_set *c)
560 + continue;
561 +
562 + ja->cur_idx = next;
563 +- k->ptr[n++] = PTR(0,
564 ++ k->ptr[n++] = MAKE_PTR(0,
565 + bucket_to_sector(c, ca->sb.d[ja->cur_idx]),
566 + ca->sb.nr_this_dev);
567 + }
568 +diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
569 +index 1beb722f6080..e1e69a480c56 100644
570 +--- a/drivers/mfd/twl4030-power.c
571 ++++ b/drivers/mfd/twl4030-power.c
572 +@@ -701,6 +701,7 @@ static struct twl4030_ins omap3_wrst_seq[] = {
573 + TWL_RESOURCE_RESET(RES_MAIN_REF),
574 + TWL_RESOURCE_GROUP_RESET(RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2),
575 + TWL_RESOURCE_RESET(RES_VUSB_3V1),
576 ++ TWL_RESOURCE_RESET(RES_VMMC1),
577 + TWL_RESOURCE_GROUP_RESET(RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1),
578 + TWL_RESOURCE_GROUP_RESET(RES_GRP_RC, RES_TYPE_ALL, RES_TYPE2_R0),
579 + TWL_RESOURCE_ON(RES_RESET),
580 +diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
581 +index 051b14766ef9..19c10dc56513 100644
582 +--- a/drivers/misc/eeprom/at24.c
583 ++++ b/drivers/misc/eeprom/at24.c
584 +@@ -365,7 +365,8 @@ static ssize_t at24_eeprom_read_mac(struct at24_data *at24, char *buf,
585 + memset(msg, 0, sizeof(msg));
586 + msg[0].addr = client->addr;
587 + msg[0].buf = addrbuf;
588 +- addrbuf[0] = 0x90 + offset;
589 ++ /* EUI-48 starts from 0x9a, EUI-64 from 0x98 */
590 ++ addrbuf[0] = 0xa0 - at24->chip.byte_len + offset;
591 + msg[0].len = 1;
592 + msg[1].addr = client->addr;
593 + msg[1].flags = I2C_M_RD;
594 +@@ -506,6 +507,9 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
595 + if (unlikely(!count))
596 + return count;
597 +
598 ++ if (off + count > at24->chip.byte_len)
599 ++ return -EINVAL;
600 ++
601 + /*
602 + * Read data from chip, protecting against concurrent updates
603 + * from this host, but not from other I2C masters.
604 +@@ -538,6 +542,9 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
605 + if (unlikely(!count))
606 + return -EINVAL;
607 +
608 ++ if (off + count > at24->chip.byte_len)
609 ++ return -EINVAL;
610 ++
611 + /*
612 + * Write data to chip, protecting against concurrent updates
613 + * from this host, but not from other I2C masters.
614 +@@ -638,6 +645,16 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
615 + dev_warn(&client->dev,
616 + "page_size looks suspicious (no power of 2)!\n");
617 +
618 ++ /*
619 ++ * REVISIT: the size of the EUI-48 byte array is 6 in at24mac402, while
620 ++ * the call to ilog2() in AT24_DEVICE_MAGIC() rounds it down to 4.
621 ++ *
622 ++ * Eventually we'll get rid of the magic values altoghether in favor of
623 ++ * real structs, but for now just manually set the right size.
624 ++ */
625 ++ if (chip.flags & AT24_FLAG_MAC && chip.byte_len == 4)
626 ++ chip.byte_len = 6;
627 ++
628 + /* Use I2C operations unless we're stuck with SMBus extensions. */
629 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
630 + if (chip.flags & AT24_FLAG_ADDR16)
631 +diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
632 +index c64266f5a399..60ebe5b4500b 100644
633 +--- a/drivers/mmc/core/bus.c
634 ++++ b/drivers/mmc/core/bus.c
635 +@@ -155,6 +155,9 @@ static int mmc_bus_suspend(struct device *dev)
636 + return ret;
637 +
638 + ret = host->bus_ops->suspend(host);
639 ++ if (ret)
640 ++ pm_generic_resume(dev);
641 ++
642 + return ret;
643 + }
644 +
645 +diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
646 +index 4f4a627f6b20..0c6de9f12ee8 100644
647 +--- a/drivers/mmc/core/mmc.c
648 ++++ b/drivers/mmc/core/mmc.c
649 +@@ -752,7 +752,7 @@ MMC_DEV_ATTR(enhanced_area_offset, "%llu\n",
650 + MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
651 + MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
652 + MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors);
653 +-MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
654 ++MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
655 +
656 + static ssize_t mmc_fwrev_show(struct device *dev,
657 + struct device_attribute *attr,
658 +diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
659 +index f6f40a1673ae..f09148a4ab55 100644
660 +--- a/drivers/mmc/core/sd.c
661 ++++ b/drivers/mmc/core/sd.c
662 +@@ -683,7 +683,7 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
663 + MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
664 + MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
665 + MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
666 +-MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
667 ++MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
668 +
669 +
670 + static ssize_t mmc_dsr_show(struct device *dev,
671 +diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
672 +index 8edafd8cb8ce..5c52a6182765 100644
673 +--- a/drivers/nvme/host/nvme.h
674 ++++ b/drivers/nvme/host/nvme.h
675 +@@ -84,7 +84,7 @@ enum nvme_quirks {
676 + * NVME_QUIRK_DELAY_BEFORE_CHK_RDY quirk enabled. The value (in ms) was
677 + * found empirically.
678 + */
679 +-#define NVME_QUIRK_DELAY_AMOUNT 2000
680 ++#define NVME_QUIRK_DELAY_AMOUNT 2300
681 +
682 + enum nvme_ctrl_state {
683 + NVME_CTRL_NEW,
684 +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
685 +index 54ea90f89b70..e48ecb9303ca 100644
686 +--- a/drivers/nvme/host/pci.c
687 ++++ b/drivers/nvme/host/pci.c
688 +@@ -2109,6 +2109,8 @@ static const struct pci_device_id nvme_id_table[] = {
689 + .driver_data = NVME_QUIRK_IDENTIFY_CNS, },
690 + { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */
691 + .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
692 ++ { PCI_DEVICE(0x1c58, 0x0023), /* WDC SN200 adapter */
693 ++ .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
694 + { PCI_DEVICE(0x1c5f, 0x0540), /* Memblaze Pblaze4 adapter */
695 + .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
696 + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
697 +diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
698 +index 705bb5f5a87f..c4cff5cc9c93 100644
699 +--- a/fs/btrfs/extent-tree.c
700 ++++ b/fs/btrfs/extent-tree.c
701 +@@ -3397,13 +3397,6 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
702 + goto again;
703 + }
704 +
705 +- /* We've already setup this transaction, go ahead and exit */
706 +- if (block_group->cache_generation == trans->transid &&
707 +- i_size_read(inode)) {
708 +- dcs = BTRFS_DC_SETUP;
709 +- goto out_put;
710 +- }
711 +-
712 + /*
713 + * We want to set the generation to 0, that way if anything goes wrong
714 + * from here on out we know not to trust this cache when we load up next
715 +@@ -3427,6 +3420,13 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
716 + }
717 + WARN_ON(ret);
718 +
719 ++ /* We've already setup this transaction, go ahead and exit */
720 ++ if (block_group->cache_generation == trans->transid &&
721 ++ i_size_read(inode)) {
722 ++ dcs = BTRFS_DC_SETUP;
723 ++ goto out_put;
724 ++ }
725 ++
726 + if (i_size_read(inode) > 0) {
727 + ret = btrfs_check_trunc_cache_free_space(root,
728 + &root->fs_info->global_block_rsv);
729 +diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
730 +index d04ec3814779..65566d5fcf39 100644
731 +--- a/fs/nfs/dir.c
732 ++++ b/fs/nfs/dir.c
733 +@@ -1292,7 +1292,7 @@ static int nfs_weak_revalidate(struct dentry *dentry, unsigned int flags)
734 + return 0;
735 + }
736 +
737 +- error = nfs_revalidate_inode(NFS_SERVER(inode), inode);
738 ++ error = nfs_lookup_verify_inode(inode, flags);
739 + dfprintk(LOOKUPCACHE, "NFS: %s: inode %lu is %s\n",
740 + __func__, inode->i_ino, error ? "invalid" : "valid");
741 + return !error;
742 +@@ -1443,6 +1443,7 @@ static int nfs4_lookup_revalidate(struct dentry *, unsigned int);
743 +
744 + const struct dentry_operations nfs4_dentry_operations = {
745 + .d_revalidate = nfs4_lookup_revalidate,
746 ++ .d_weak_revalidate = nfs_weak_revalidate,
747 + .d_delete = nfs_dentry_delete,
748 + .d_iput = nfs_dentry_iput,
749 + .d_automount = nfs_d_automount,
750 +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
751 +index ec2a69dac536..9ebb2d7c8182 100644
752 +--- a/fs/nfsd/nfs4state.c
753 ++++ b/fs/nfsd/nfs4state.c
754 +@@ -3513,7 +3513,9 @@ nfsd4_find_existing_open(struct nfs4_file *fp, struct nfsd4_open *open)
755 + /* ignore lock owners */
756 + if (local->st_stateowner->so_is_open_owner == 0)
757 + continue;
758 +- if (local->st_stateowner == &oo->oo_owner) {
759 ++ if (local->st_stateowner != &oo->oo_owner)
760 ++ continue;
761 ++ if (local->st_stid.sc_type == NFS4_OPEN_STID) {
762 + ret = local;
763 + atomic_inc(&ret->st_stid.sc_count);
764 + break;
765 +@@ -3522,6 +3524,52 @@ nfsd4_find_existing_open(struct nfs4_file *fp, struct nfsd4_open *open)
766 + return ret;
767 + }
768 +
769 ++static __be32
770 ++nfsd4_verify_open_stid(struct nfs4_stid *s)
771 ++{
772 ++ __be32 ret = nfs_ok;
773 ++
774 ++ switch (s->sc_type) {
775 ++ default:
776 ++ break;
777 ++ case NFS4_CLOSED_STID:
778 ++ case NFS4_CLOSED_DELEG_STID:
779 ++ ret = nfserr_bad_stateid;
780 ++ break;
781 ++ case NFS4_REVOKED_DELEG_STID:
782 ++ ret = nfserr_deleg_revoked;
783 ++ }
784 ++ return ret;
785 ++}
786 ++
787 ++/* Lock the stateid st_mutex, and deal with races with CLOSE */
788 ++static __be32
789 ++nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp)
790 ++{
791 ++ __be32 ret;
792 ++
793 ++ mutex_lock(&stp->st_mutex);
794 ++ ret = nfsd4_verify_open_stid(&stp->st_stid);
795 ++ if (ret != nfs_ok)
796 ++ mutex_unlock(&stp->st_mutex);
797 ++ return ret;
798 ++}
799 ++
800 ++static struct nfs4_ol_stateid *
801 ++nfsd4_find_and_lock_existing_open(struct nfs4_file *fp, struct nfsd4_open *open)
802 ++{
803 ++ struct nfs4_ol_stateid *stp;
804 ++ for (;;) {
805 ++ spin_lock(&fp->fi_lock);
806 ++ stp = nfsd4_find_existing_open(fp, open);
807 ++ spin_unlock(&fp->fi_lock);
808 ++ if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok)
809 ++ break;
810 ++ nfs4_put_stid(&stp->st_stid);
811 ++ }
812 ++ return stp;
813 ++}
814 ++
815 + static struct nfs4_openowner *
816 + alloc_init_open_stateowner(unsigned int strhashval, struct nfsd4_open *open,
817 + struct nfsd4_compound_state *cstate)
818 +@@ -3566,6 +3614,7 @@ init_open_stateid(struct nfs4_file *fp, struct nfsd4_open *open)
819 + mutex_init(&stp->st_mutex);
820 + mutex_lock(&stp->st_mutex);
821 +
822 ++retry:
823 + spin_lock(&oo->oo_owner.so_client->cl_lock);
824 + spin_lock(&fp->fi_lock);
825 +
826 +@@ -3590,7 +3639,11 @@ init_open_stateid(struct nfs4_file *fp, struct nfsd4_open *open)
827 + spin_unlock(&fp->fi_lock);
828 + spin_unlock(&oo->oo_owner.so_client->cl_lock);
829 + if (retstp) {
830 +- mutex_lock(&retstp->st_mutex);
831 ++ /* Handle races with CLOSE */
832 ++ if (nfsd4_lock_ol_stateid(retstp) != nfs_ok) {
833 ++ nfs4_put_stid(&retstp->st_stid);
834 ++ goto retry;
835 ++ }
836 + /* To keep mutex tracking happy */
837 + mutex_unlock(&stp->st_mutex);
838 + stp = retstp;
839 +@@ -4400,6 +4453,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
840 + struct nfs4_ol_stateid *stp = NULL;
841 + struct nfs4_delegation *dp = NULL;
842 + __be32 status;
843 ++ bool new_stp = false;
844 +
845 + /*
846 + * Lookup file; if found, lookup stateid and check open request,
847 +@@ -4411,9 +4465,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
848 + status = nfs4_check_deleg(cl, open, &dp);
849 + if (status)
850 + goto out;
851 +- spin_lock(&fp->fi_lock);
852 +- stp = nfsd4_find_existing_open(fp, open);
853 +- spin_unlock(&fp->fi_lock);
854 ++ stp = nfsd4_find_and_lock_existing_open(fp, open);
855 + } else {
856 + open->op_file = NULL;
857 + status = nfserr_bad_stateid;
858 +@@ -4421,35 +4473,31 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
859 + goto out;
860 + }
861 +
862 ++ if (!stp) {
863 ++ stp = init_open_stateid(fp, open);
864 ++ if (!open->op_stp)
865 ++ new_stp = true;
866 ++ }
867 ++
868 + /*
869 + * OPEN the file, or upgrade an existing OPEN.
870 + * If truncate fails, the OPEN fails.
871 ++ *
872 ++ * stp is already locked.
873 + */
874 +- if (stp) {
875 ++ if (!new_stp) {
876 + /* Stateid was found, this is an OPEN upgrade */
877 +- mutex_lock(&stp->st_mutex);
878 + status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open);
879 + if (status) {
880 + mutex_unlock(&stp->st_mutex);
881 + goto out;
882 + }
883 + } else {
884 +- /* stp is returned locked. */
885 +- stp = init_open_stateid(fp, open);
886 +- /* See if we lost the race to some other thread */
887 +- if (stp->st_access_bmap != 0) {
888 +- status = nfs4_upgrade_open(rqstp, fp, current_fh,
889 +- stp, open);
890 +- if (status) {
891 +- mutex_unlock(&stp->st_mutex);
892 +- goto out;
893 +- }
894 +- goto upgrade_out;
895 +- }
896 + status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open);
897 + if (status) {
898 +- mutex_unlock(&stp->st_mutex);
899 ++ stp->st_stid.sc_type = NFS4_CLOSED_STID;
900 + release_open_stateid(stp);
901 ++ mutex_unlock(&stp->st_mutex);
902 + goto out;
903 + }
904 +
905 +@@ -4458,7 +4506,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
906 + if (stp->st_clnt_odstate == open->op_odstate)
907 + open->op_odstate = NULL;
908 + }
909 +-upgrade_out:
910 ++
911 + nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid);
912 + mutex_unlock(&stp->st_mutex);
913 +
914 +@@ -4684,7 +4732,7 @@ nfs4_laundromat(struct nfsd_net *nn)
915 + spin_unlock(&nn->blocked_locks_lock);
916 +
917 + while (!list_empty(&reaplist)) {
918 +- nbl = list_first_entry(&nn->blocked_locks_lru,
919 ++ nbl = list_first_entry(&reaplist,
920 + struct nfsd4_blocked_lock, nbl_lru);
921 + list_del_init(&nbl->nbl_lru);
922 + posix_unblock_lock(&nbl->nbl_lock);
923 +@@ -5314,7 +5362,6 @@ static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s)
924 + bool unhashed;
925 + LIST_HEAD(reaplist);
926 +
927 +- s->st_stid.sc_type = NFS4_CLOSED_STID;
928 + spin_lock(&clp->cl_lock);
929 + unhashed = unhash_open_stateid(s, &reaplist);
930 +
931 +@@ -5353,10 +5400,12 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
932 + nfsd4_bump_seqid(cstate, status);
933 + if (status)
934 + goto out;
935 ++
936 ++ stp->st_stid.sc_type = NFS4_CLOSED_STID;
937 + nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid);
938 +- mutex_unlock(&stp->st_mutex);
939 +
940 + nfsd4_close_open_stateid(stp);
941 ++ mutex_unlock(&stp->st_mutex);
942 +
943 + /* put reference from nfs4_preprocess_seqid_op */
944 + nfs4_put_stid(&stp->st_stid);
945 +@@ -7094,7 +7143,7 @@ nfs4_state_shutdown_net(struct net *net)
946 + spin_unlock(&nn->blocked_locks_lock);
947 +
948 + while (!list_empty(&reaplist)) {
949 +- nbl = list_first_entry(&nn->blocked_locks_lru,
950 ++ nbl = list_first_entry(&reaplist,
951 + struct nfsd4_blocked_lock, nbl_lru);
952 + list_del_init(&nbl->nbl_lru);
953 + posix_unblock_lock(&nbl->nbl_lock);
954 +diff --git a/include/linux/mm.h b/include/linux/mm.h
955 +index 6c9e1ad12831..2217e2f18247 100644
956 +--- a/include/linux/mm.h
957 ++++ b/include/linux/mm.h
958 +@@ -347,6 +347,7 @@ struct fault_env {
959 + struct vm_operations_struct {
960 + void (*open)(struct vm_area_struct * area);
961 + void (*close)(struct vm_area_struct * area);
962 ++ int (*split)(struct vm_area_struct * area, unsigned long addr);
963 + int (*mremap)(struct vm_area_struct * area);
964 + int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf);
965 + int (*pmd_fault)(struct vm_area_struct *, unsigned long address,
966 +diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
967 +index 22b6ad31c706..8562b1cb776b 100644
968 +--- a/include/uapi/linux/bcache.h
969 ++++ b/include/uapi/linux/bcache.h
970 +@@ -90,7 +90,7 @@ PTR_FIELD(PTR_GEN, 0, 8)
971 +
972 + #define PTR_CHECK_DEV ((1 << PTR_DEV_BITS) - 1)
973 +
974 +-#define PTR(gen, offset, dev) \
975 ++#define MAKE_PTR(gen, offset, dev) \
976 + ((((__u64) dev) << 51) | ((__u64) offset) << 8 | gen)
977 +
978 + /* Bkey utility code */
979 +diff --git a/mm/huge_memory.c b/mm/huge_memory.c
980 +index 8258e9eee806..3cae1dcf069c 100644
981 +--- a/mm/huge_memory.c
982 ++++ b/mm/huge_memory.c
983 +@@ -745,20 +745,15 @@ int vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
984 + EXPORT_SYMBOL_GPL(vmf_insert_pfn_pmd);
985 +
986 + static void touch_pmd(struct vm_area_struct *vma, unsigned long addr,
987 +- pmd_t *pmd)
988 ++ pmd_t *pmd, int flags)
989 + {
990 + pmd_t _pmd;
991 +
992 +- /*
993 +- * We should set the dirty bit only for FOLL_WRITE but for now
994 +- * the dirty bit in the pmd is meaningless. And if the dirty
995 +- * bit will become meaningful and we'll only set it with
996 +- * FOLL_WRITE, an atomic set_bit will be required on the pmd to
997 +- * set the young bit, instead of the current set_pmd_at.
998 +- */
999 +- _pmd = pmd_mkyoung(pmd_mkdirty(*pmd));
1000 ++ _pmd = pmd_mkyoung(*pmd);
1001 ++ if (flags & FOLL_WRITE)
1002 ++ _pmd = pmd_mkdirty(_pmd);
1003 + if (pmdp_set_access_flags(vma, addr & HPAGE_PMD_MASK,
1004 +- pmd, _pmd, 1))
1005 ++ pmd, _pmd, flags & FOLL_WRITE))
1006 + update_mmu_cache_pmd(vma, addr, pmd);
1007 + }
1008 +
1009 +@@ -787,7 +782,7 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
1010 + return NULL;
1011 +
1012 + if (flags & FOLL_TOUCH)
1013 +- touch_pmd(vma, addr, pmd);
1014 ++ touch_pmd(vma, addr, pmd, flags);
1015 +
1016 + /*
1017 + * device mapped pages can only be returned if the
1018 +@@ -1158,7 +1153,7 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
1019 + page = pmd_page(*pmd);
1020 + VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page);
1021 + if (flags & FOLL_TOUCH)
1022 +- touch_pmd(vma, addr, pmd);
1023 ++ touch_pmd(vma, addr, pmd, flags);
1024 + if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {
1025 + /*
1026 + * We don't mlock() pte-mapped THPs. This way we can avoid
1027 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
1028 +index 65c36acf8a6b..6ff65c405243 100644
1029 +--- a/mm/hugetlb.c
1030 ++++ b/mm/hugetlb.c
1031 +@@ -3135,6 +3135,13 @@ static void hugetlb_vm_op_close(struct vm_area_struct *vma)
1032 + }
1033 + }
1034 +
1035 ++static int hugetlb_vm_op_split(struct vm_area_struct *vma, unsigned long addr)
1036 ++{
1037 ++ if (addr & ~(huge_page_mask(hstate_vma(vma))))
1038 ++ return -EINVAL;
1039 ++ return 0;
1040 ++}
1041 ++
1042 + /*
1043 + * We cannot handle pagefaults against hugetlb pages at all. They cause
1044 + * handle_mm_fault() to try to instantiate regular-sized pages in the
1045 +@@ -3151,6 +3158,7 @@ const struct vm_operations_struct hugetlb_vm_ops = {
1046 + .fault = hugetlb_vm_op_fault,
1047 + .open = hugetlb_vm_op_open,
1048 + .close = hugetlb_vm_op_close,
1049 ++ .split = hugetlb_vm_op_split,
1050 + };
1051 +
1052 + static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page,
1053 +diff --git a/mm/madvise.c b/mm/madvise.c
1054 +index 55f30ec32e5b..a49afe08698b 100644
1055 +--- a/mm/madvise.c
1056 ++++ b/mm/madvise.c
1057 +@@ -228,15 +228,14 @@ static long madvise_willneed(struct vm_area_struct *vma,
1058 + {
1059 + struct file *file = vma->vm_file;
1060 +
1061 ++ *prev = vma;
1062 + #ifdef CONFIG_SWAP
1063 + if (!file) {
1064 +- *prev = vma;
1065 + force_swapin_readahead(vma, start, end);
1066 + return 0;
1067 + }
1068 +
1069 + if (shmem_mapping(file->f_mapping)) {
1070 +- *prev = vma;
1071 + force_shm_swapin_readahead(vma, start, end,
1072 + file->f_mapping);
1073 + return 0;
1074 +@@ -251,7 +250,6 @@ static long madvise_willneed(struct vm_area_struct *vma,
1075 + return 0;
1076 + }
1077 +
1078 +- *prev = vma;
1079 + start = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
1080 + if (end > vma->vm_end)
1081 + end = vma->vm_end;
1082 +diff --git a/mm/mmap.c b/mm/mmap.c
1083 +index 75d263bd8739..5b48adb4aa56 100644
1084 +--- a/mm/mmap.c
1085 ++++ b/mm/mmap.c
1086 +@@ -2538,9 +2538,11 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
1087 + struct vm_area_struct *new;
1088 + int err;
1089 +
1090 +- if (is_vm_hugetlb_page(vma) && (addr &
1091 +- ~(huge_page_mask(hstate_vma(vma)))))
1092 +- return -EINVAL;
1093 ++ if (vma->vm_ops && vma->vm_ops->split) {
1094 ++ err = vma->vm_ops->split(vma, addr);
1095 ++ if (err)
1096 ++ return err;
1097 ++ }
1098 +
1099 + new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
1100 + if (!new)
1101 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
1102 +index 4a044134ce84..ef5ee56095e8 100644
1103 +--- a/mm/page_alloc.c
1104 ++++ b/mm/page_alloc.c
1105 +@@ -7309,11 +7309,18 @@ int alloc_contig_range(unsigned long start, unsigned long end,
1106 +
1107 + /*
1108 + * In case of -EBUSY, we'd like to know which page causes problem.
1109 +- * So, just fall through. We will check it in test_pages_isolated().
1110 ++ * So, just fall through. test_pages_isolated() has a tracepoint
1111 ++ * which will report the busy page.
1112 ++ *
1113 ++ * It is possible that busy pages could become available before
1114 ++ * the call to test_pages_isolated, and the range will actually be
1115 ++ * allocated. So, if we fall through be sure to clear ret so that
1116 ++ * -EBUSY is not accidentally used or returned to caller.
1117 + */
1118 + ret = __alloc_contig_migrate_range(&cc, start, end);
1119 + if (ret && ret != -EBUSY)
1120 + goto done;
1121 ++ ret =0;
1122 +
1123 + /*
1124 + * Pages from [start, end) are within a MAX_ORDER_NR_PAGES