Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.1 commit in: /
Date: Thu, 28 Apr 2016 18:56:22
Message-Id: 1461869772.26c5b0bcb48671f84a02d4f62590131aa4566f9b.mpagano@gentoo
1 commit: 26c5b0bcb48671f84a02d4f62590131aa4566f9b
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Apr 28 18:56:12 2016 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 28 18:56:12 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=26c5b0bc
7
8 Linux patch 4.1.23
9
10 0000_README | 4 +
11 1022_linux-4.1.23.patch | 2721 +++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 2725 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 3075177..a797069 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -131,6 +131,10 @@ Patch: 1021_linux-4.1.22.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.1.22
21
22 +Patch: 1022_linux-4.1.23.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.1.23
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/1022_linux-4.1.23.patch b/1022_linux-4.1.23.patch
31 new file mode 100644
32 index 0000000..68a28a4
33 --- /dev/null
34 +++ b/1022_linux-4.1.23.patch
35 @@ -0,0 +1,2721 @@
36 +diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
37 +index cd03a0faca8f..7bcd7a26f885 100644
38 +--- a/Documentation/kernel-parameters.txt
39 ++++ b/Documentation/kernel-parameters.txt
40 +@@ -3808,6 +3808,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
41 + sector if the number is odd);
42 + i = IGNORE_DEVICE (don't bind to this
43 + device);
44 ++ j = NO_REPORT_LUNS (don't use report luns
45 ++ command, uas only);
46 + l = NOT_LOCKABLE (don't try to lock and
47 + unlock ejectable media);
48 + m = MAX_SECTORS_64 (don't transfer more
49 +diff --git a/Makefile b/Makefile
50 +index 7f4a4039fdd9..9956129bb106 100644
51 +--- a/Makefile
52 ++++ b/Makefile
53 +@@ -1,6 +1,6 @@
54 + VERSION = 4
55 + PATCHLEVEL = 1
56 +-SUBLEVEL = 22
57 ++SUBLEVEL = 23
58 + EXTRAVERSION =
59 + NAME = Series 4800
60 +
61 +diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
62 +index 9185bb958503..dee6831c0434 100644
63 +--- a/arch/arm/mach-omap2/omap_hwmod.c
64 ++++ b/arch/arm/mach-omap2/omap_hwmod.c
65 +@@ -1402,9 +1402,7 @@ static void _enable_sysc(struct omap_hwmod *oh)
66 + (sf & SYSC_HAS_CLOCKACTIVITY))
67 + _set_clockactivity(oh, oh->class->sysc->clockact, &v);
68 +
69 +- /* If the cached value is the same as the new value, skip the write */
70 +- if (oh->_sysc_cache != v)
71 +- _write_sysconfig(v, oh);
72 ++ _write_sysconfig(v, oh);
73 +
74 + /*
75 + * Set the autoidle bit only after setting the smartidle bit
76 +@@ -1467,7 +1465,9 @@ static void _idle_sysc(struct omap_hwmod *oh)
77 + _set_master_standbymode(oh, idlemode, &v);
78 + }
79 +
80 +- _write_sysconfig(v, oh);
81 ++ /* If the cached value is the same as the new value, skip the write */
82 ++ if (oh->_sysc_cache != v)
83 ++ _write_sysconfig(v, oh);
84 + }
85 +
86 + /**
87 +diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
88 +index 0abdd4c607ed..1960b87c1c8b 100644
89 +--- a/arch/parisc/include/asm/uaccess.h
90 ++++ b/arch/parisc/include/asm/uaccess.h
91 +@@ -76,6 +76,7 @@ struct exception_table_entry {
92 + */
93 + struct exception_data {
94 + unsigned long fault_ip;
95 ++ unsigned long fault_gp;
96 + unsigned long fault_space;
97 + unsigned long fault_addr;
98 + };
99 +diff --git a/arch/parisc/kernel/asm-offsets.c b/arch/parisc/kernel/asm-offsets.c
100 +index 59001cea13f9..c972e6550f56 100644
101 +--- a/arch/parisc/kernel/asm-offsets.c
102 ++++ b/arch/parisc/kernel/asm-offsets.c
103 +@@ -291,6 +291,7 @@ int main(void)
104 + DEFINE(ASM_PT_INITIAL, PT_INITIAL);
105 + BLANK();
106 + DEFINE(EXCDATA_IP, offsetof(struct exception_data, fault_ip));
107 ++ DEFINE(EXCDATA_GP, offsetof(struct exception_data, fault_gp));
108 + DEFINE(EXCDATA_SPACE, offsetof(struct exception_data, fault_space));
109 + DEFINE(EXCDATA_ADDR, offsetof(struct exception_data, fault_addr));
110 + BLANK();
111 +diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c
112 +index 568b2c61ea02..3cad8aadc69e 100644
113 +--- a/arch/parisc/kernel/parisc_ksyms.c
114 ++++ b/arch/parisc/kernel/parisc_ksyms.c
115 +@@ -47,11 +47,11 @@ EXPORT_SYMBOL(__cmpxchg_u64);
116 + EXPORT_SYMBOL(lclear_user);
117 + EXPORT_SYMBOL(lstrnlen_user);
118 +
119 +-/* Global fixups */
120 +-extern void fixup_get_user_skip_1(void);
121 +-extern void fixup_get_user_skip_2(void);
122 +-extern void fixup_put_user_skip_1(void);
123 +-extern void fixup_put_user_skip_2(void);
124 ++/* Global fixups - defined as int to avoid creation of function pointers */
125 ++extern int fixup_get_user_skip_1;
126 ++extern int fixup_get_user_skip_2;
127 ++extern int fixup_put_user_skip_1;
128 ++extern int fixup_put_user_skip_2;
129 + EXPORT_SYMBOL(fixup_get_user_skip_1);
130 + EXPORT_SYMBOL(fixup_get_user_skip_2);
131 + EXPORT_SYMBOL(fixup_put_user_skip_1);
132 +diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
133 +index 7f67c4c96a7a..bbf22658d1a3 100644
134 +--- a/arch/parisc/kernel/traps.c
135 ++++ b/arch/parisc/kernel/traps.c
136 +@@ -798,6 +798,9 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
137 +
138 + if (fault_space == 0 && !in_atomic())
139 + {
140 ++ /* Clean up and return if in exception table. */
141 ++ if (fixup_exception(regs))
142 ++ return;
143 + pdc_chassis_send_status(PDC_CHASSIS_DIRECT_PANIC);
144 + parisc_terminate("Kernel Fault", regs, code, fault_address);
145 + }
146 +diff --git a/arch/parisc/lib/fixup.S b/arch/parisc/lib/fixup.S
147 +index 536ef66bb94b..1052b747e011 100644
148 +--- a/arch/parisc/lib/fixup.S
149 ++++ b/arch/parisc/lib/fixup.S
150 +@@ -26,6 +26,7 @@
151 +
152 + #ifdef CONFIG_SMP
153 + .macro get_fault_ip t1 t2
154 ++ loadgp
155 + addil LT%__per_cpu_offset,%r27
156 + LDREG RT%__per_cpu_offset(%r1),\t1
157 + /* t2 = smp_processor_id() */
158 +@@ -40,14 +41,19 @@
159 + LDREG RT%exception_data(%r1),\t1
160 + /* t1 = this_cpu_ptr(&exception_data) */
161 + add,l \t1,\t2,\t1
162 ++ /* %r27 = t1->fault_gp - restore gp */
163 ++ LDREG EXCDATA_GP(\t1), %r27
164 + /* t1 = t1->fault_ip */
165 + LDREG EXCDATA_IP(\t1), \t1
166 + .endm
167 + #else
168 + .macro get_fault_ip t1 t2
169 ++ loadgp
170 + /* t1 = this_cpu_ptr(&exception_data) */
171 + addil LT%exception_data,%r27
172 + LDREG RT%exception_data(%r1),\t2
173 ++ /* %r27 = t2->fault_gp - restore gp */
174 ++ LDREG EXCDATA_GP(\t2), %r27
175 + /* t1 = t2->fault_ip */
176 + LDREG EXCDATA_IP(\t2), \t1
177 + .endm
178 +diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
179 +index e5120e653240..50d64a7fc672 100644
180 +--- a/arch/parisc/mm/fault.c
181 ++++ b/arch/parisc/mm/fault.c
182 +@@ -151,6 +151,7 @@ int fixup_exception(struct pt_regs *regs)
183 + struct exception_data *d;
184 + d = this_cpu_ptr(&exception_data);
185 + d->fault_ip = regs->iaoq[0];
186 ++ d->fault_gp = regs->gr[27];
187 + d->fault_space = regs->isr;
188 + d->fault_addr = regs->ior;
189 +
190 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
191 +index c228d8da1f8c..75eb9603ed29 100644
192 +--- a/arch/x86/kvm/x86.c
193 ++++ b/arch/x86/kvm/x86.c
194 +@@ -680,7 +680,6 @@ static int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
195 + if ((xcr0 & XSTATE_AVX512) != XSTATE_AVX512)
196 + return 1;
197 + }
198 +- kvm_put_guest_xcr0(vcpu);
199 + vcpu->arch.xcr0 = xcr0;
200 +
201 + if ((xcr0 ^ old_xcr0) & XSTATE_EXTEND_MASK)
202 +@@ -6115,12 +6114,10 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win)
203 + }
204 +
205 + /* try to inject new event if pending */
206 +- if (vcpu->arch.nmi_pending) {
207 +- if (kvm_x86_ops->nmi_allowed(vcpu)) {
208 +- --vcpu->arch.nmi_pending;
209 +- vcpu->arch.nmi_injected = true;
210 +- kvm_x86_ops->set_nmi(vcpu);
211 +- }
212 ++ if (vcpu->arch.nmi_pending && kvm_x86_ops->nmi_allowed(vcpu)) {
213 ++ --vcpu->arch.nmi_pending;
214 ++ vcpu->arch.nmi_injected = true;
215 ++ kvm_x86_ops->set_nmi(vcpu);
216 + } else if (kvm_cpu_has_injectable_intr(vcpu)) {
217 + /*
218 + * Because interrupts can be injected asynchronously, we are
219 +@@ -6290,10 +6287,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
220 + if (inject_pending_event(vcpu, req_int_win) != 0)
221 + req_immediate_exit = true;
222 + /* enable NMI/IRQ window open exits if needed */
223 +- else if (vcpu->arch.nmi_pending)
224 +- kvm_x86_ops->enable_nmi_window(vcpu);
225 +- else if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win)
226 +- kvm_x86_ops->enable_irq_window(vcpu);
227 ++ else {
228 ++ if (vcpu->arch.nmi_pending)
229 ++ kvm_x86_ops->enable_nmi_window(vcpu);
230 ++ if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win)
231 ++ kvm_x86_ops->enable_irq_window(vcpu);
232 ++ }
233 +
234 + if (kvm_lapic_enabled(vcpu)) {
235 + /*
236 +@@ -6318,8 +6317,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
237 + kvm_x86_ops->prepare_guest_switch(vcpu);
238 + if (vcpu->fpu_active)
239 + kvm_load_guest_fpu(vcpu);
240 +- kvm_load_guest_xcr0(vcpu);
241 +-
242 + vcpu->mode = IN_GUEST_MODE;
243 +
244 + srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
245 +@@ -6342,6 +6339,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
246 + goto cancel_injection;
247 + }
248 +
249 ++ kvm_load_guest_xcr0(vcpu);
250 ++
251 + if (req_immediate_exit)
252 + smp_send_reschedule(vcpu->cpu);
253 +
254 +@@ -6392,6 +6391,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
255 + vcpu->mode = OUTSIDE_GUEST_MODE;
256 + smp_wmb();
257 +
258 ++ kvm_put_guest_xcr0(vcpu);
259 ++
260 + /* Interrupt is enabled by handle_external_intr() */
261 + kvm_x86_ops->handle_external_intr(vcpu);
262 +
263 +@@ -7040,7 +7041,6 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
264 + * and assume host would use all available bits.
265 + * Guest xcr0 would be loaded later.
266 + */
267 +- kvm_put_guest_xcr0(vcpu);
268 + vcpu->guest_fpu_loaded = 1;
269 + __kernel_fpu_begin();
270 + fpu_restore_checking(&vcpu->arch.guest_fpu);
271 +@@ -7049,8 +7049,6 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
272 +
273 + void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
274 + {
275 +- kvm_put_guest_xcr0(vcpu);
276 +-
277 + if (!vcpu->guest_fpu_loaded)
278 + return;
279 +
280 +diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
281 +index 09138ceba046..89ecec13c567 100644
282 +--- a/drivers/block/rbd.c
283 ++++ b/drivers/block/rbd.c
284 +@@ -1934,7 +1934,7 @@ static struct ceph_osd_request *rbd_osd_req_create(
285 +
286 + osdc = &rbd_dev->rbd_client->client->osdc;
287 + osd_req = ceph_osdc_alloc_request(osdc, snapc, num_ops, false,
288 +- GFP_ATOMIC);
289 ++ GFP_NOIO);
290 + if (!osd_req)
291 + return NULL; /* ENOMEM */
292 +
293 +@@ -1983,7 +1983,7 @@ rbd_osd_req_create_copyup(struct rbd_obj_request *obj_request)
294 + rbd_dev = img_request->rbd_dev;
295 + osdc = &rbd_dev->rbd_client->client->osdc;
296 + osd_req = ceph_osdc_alloc_request(osdc, snapc, num_osd_ops,
297 +- false, GFP_ATOMIC);
298 ++ false, GFP_NOIO);
299 + if (!osd_req)
300 + return NULL; /* ENOMEM */
301 +
302 +@@ -2482,7 +2482,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
303 + bio_chain_clone_range(&bio_list,
304 + &bio_offset,
305 + clone_size,
306 +- GFP_ATOMIC);
307 ++ GFP_NOIO);
308 + if (!obj_request->bio_list)
309 + goto out_unwind;
310 + } else if (type == OBJ_REQUEST_PAGES) {
311 +diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
312 +index ebffc744cb1b..5ec92ce0e5ac 100644
313 +--- a/drivers/dma/dw/core.c
314 ++++ b/drivers/dma/dw/core.c
315 +@@ -130,26 +130,14 @@ static void dwc_desc_put(struct dw_dma_chan *dwc, struct dw_desc *desc)
316 + static void dwc_initialize(struct dw_dma_chan *dwc)
317 + {
318 + struct dw_dma *dw = to_dw_dma(dwc->chan.device);
319 +- struct dw_dma_slave *dws = dwc->chan.private;
320 + u32 cfghi = DWC_CFGH_FIFO_MODE;
321 + u32 cfglo = DWC_CFGL_CH_PRIOR(dwc->priority);
322 +
323 + if (dwc->initialized == true)
324 + return;
325 +
326 +- if (dws) {
327 +- /*
328 +- * We need controller-specific data to set up slave
329 +- * transfers.
330 +- */
331 +- BUG_ON(!dws->dma_dev || dws->dma_dev != dw->dma.dev);
332 +-
333 +- cfghi |= DWC_CFGH_DST_PER(dws->dst_id);
334 +- cfghi |= DWC_CFGH_SRC_PER(dws->src_id);
335 +- } else {
336 +- cfghi |= DWC_CFGH_DST_PER(dwc->dst_id);
337 +- cfghi |= DWC_CFGH_SRC_PER(dwc->src_id);
338 +- }
339 ++ cfghi |= DWC_CFGH_DST_PER(dwc->dst_id);
340 ++ cfghi |= DWC_CFGH_SRC_PER(dwc->src_id);
341 +
342 + channel_writel(dwc, CFG_LO, cfglo);
343 + channel_writel(dwc, CFG_HI, cfghi);
344 +@@ -936,7 +924,7 @@ bool dw_dma_filter(struct dma_chan *chan, void *param)
345 + struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
346 + struct dw_dma_slave *dws = param;
347 +
348 +- if (!dws || dws->dma_dev != chan->device->dev)
349 ++ if (dws->dma_dev != chan->device->dev)
350 + return false;
351 +
352 + /* We have to copy data since dws can be temporary storage */
353 +@@ -1160,6 +1148,14 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan)
354 + * doesn't mean what you think it means), and status writeback.
355 + */
356 +
357 ++ /*
358 ++ * We need controller-specific data to set up slave transfers.
359 ++ */
360 ++ if (chan->private && !dw_dma_filter(chan, chan->private)) {
361 ++ dev_warn(chan2dev(chan), "Wrong controller-specific data\n");
362 ++ return -EINVAL;
363 ++ }
364 ++
365 + /* Enable controller here if needed */
366 + if (!dw->in_use)
367 + dw_dma_on(dw);
368 +@@ -1221,6 +1217,14 @@ static void dwc_free_chan_resources(struct dma_chan *chan)
369 + spin_lock_irqsave(&dwc->lock, flags);
370 + list_splice_init(&dwc->free_list, &list);
371 + dwc->descs_allocated = 0;
372 ++
373 ++ /* Clear custom channel configuration */
374 ++ dwc->src_id = 0;
375 ++ dwc->dst_id = 0;
376 ++
377 ++ dwc->src_master = 0;
378 ++ dwc->dst_master = 0;
379 ++
380 + dwc->initialized = false;
381 +
382 + /* Disable interrupts */
383 +diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c
384 +index f42f71e37e73..b863b685d2d5 100644
385 +--- a/drivers/dma/hsu/hsu.c
386 ++++ b/drivers/dma/hsu/hsu.c
387 +@@ -143,7 +143,7 @@ static u32 hsu_dma_chan_get_sr(struct hsu_dma_chan *hsuc)
388 + sr = hsu_chan_readl(hsuc, HSU_CH_SR);
389 + spin_unlock_irqrestore(&hsuc->lock, flags);
390 +
391 +- return sr;
392 ++ return sr & ~(HSU_CH_SR_DESCE_ANY | HSU_CH_SR_CDESC_ANY);
393 + }
394 +
395 + irqreturn_t hsu_dma_irq(struct hsu_dma_chip *chip, unsigned short nr)
396 +diff --git a/drivers/dma/hsu/hsu.h b/drivers/dma/hsu/hsu.h
397 +index 0275233cf550..6a54f351df90 100644
398 +--- a/drivers/dma/hsu/hsu.h
399 ++++ b/drivers/dma/hsu/hsu.h
400 +@@ -41,6 +41,9 @@
401 + #define HSU_CH_SR_DESCTO(x) BIT(8 + (x))
402 + #define HSU_CH_SR_DESCTO_ANY (BIT(11) | BIT(10) | BIT(9) | BIT(8))
403 + #define HSU_CH_SR_CHE BIT(15)
404 ++#define HSU_CH_SR_DESCE(x) BIT(16 + (x))
405 ++#define HSU_CH_SR_DESCE_ANY (BIT(19) | BIT(18) | BIT(17) | BIT(16))
406 ++#define HSU_CH_SR_CDESC_ANY (BIT(31) | BIT(30))
407 +
408 + /* Bits in HSU_CH_CR */
409 + #define HSU_CH_CR_CHA BIT(0)
410 +diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
411 +index e2da64abbccd..16f7c4f2d8c8 100644
412 +--- a/drivers/gpio/gpio-pca953x.c
413 ++++ b/drivers/gpio/gpio-pca953x.c
414 +@@ -21,6 +21,7 @@
415 + #ifdef CONFIG_OF_GPIO
416 + #include <linux/of_platform.h>
417 + #endif
418 ++#include <asm/unaligned.h>
419 +
420 + #define PCA953X_INPUT 0
421 + #define PCA953X_OUTPUT 1
422 +@@ -154,7 +155,7 @@ static int pca953x_write_regs(struct pca953x_chip *chip, int reg, u8 *val)
423 + switch (chip->chip_type) {
424 + case PCA953X_TYPE:
425 + ret = i2c_smbus_write_word_data(chip->client,
426 +- reg << 1, (u16) *val);
427 ++ reg << 1, cpu_to_le16(get_unaligned((u16 *)val)));
428 + break;
429 + case PCA957X_TYPE:
430 + ret = i2c_smbus_write_byte_data(chip->client, reg << 1,
431 +diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
432 +index b103773df2a3..56323732c748 100644
433 +--- a/drivers/gpu/drm/i915/intel_display.c
434 ++++ b/drivers/gpu/drm/i915/intel_display.c
435 +@@ -5609,10 +5609,6 @@ static void intel_connector_check_state(struct intel_connector *connector)
436 + connector->base.base.id,
437 + connector->base.name);
438 +
439 +- /* there is no real hw state for MST connectors */
440 +- if (connector->mst_port)
441 +- return;
442 +-
443 + I915_STATE_WARN(connector->base.dpms == DRM_MODE_DPMS_OFF,
444 + "wrong connector dpms state\n");
445 + I915_STATE_WARN(connector->base.encoder != &encoder->base,
446 +@@ -11225,13 +11221,6 @@ check_encoder_state(struct drm_device *dev)
447 + if (connector->base.dpms != DRM_MODE_DPMS_OFF)
448 + active = true;
449 + }
450 +- /*
451 +- * for MST connectors if we unplug the connector is gone
452 +- * away but the encoder is still connected to a crtc
453 +- * until a modeset happens in response to the hotplug.
454 +- */
455 +- if (!enabled && encoder->base.encoder_type == DRM_MODE_ENCODER_DPMST)
456 +- continue;
457 +
458 + I915_STATE_WARN(!!encoder->base.crtc != enabled,
459 + "encoder's enabled state mismatch "
460 +diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
461 +index 88c557551b89..8266a8d8b9df 100644
462 +--- a/drivers/gpu/drm/i915/intel_dp_mst.c
463 ++++ b/drivers/gpu/drm/i915/intel_dp_mst.c
464 +@@ -451,14 +451,23 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
465 + {
466 + struct intel_connector *intel_connector = to_intel_connector(connector);
467 + struct drm_device *dev = connector->dev;
468 +- /* need to nuke the connector */
469 +- drm_modeset_lock_all(dev);
470 +- intel_connector_dpms(connector, DRM_MODE_DPMS_OFF);
471 +- drm_modeset_unlock_all(dev);
472 +
473 + intel_connector->unregister(intel_connector);
474 +
475 ++ /* need to nuke the connector */
476 + drm_modeset_lock_all(dev);
477 ++ if (connector->state->crtc) {
478 ++ struct drm_mode_set set;
479 ++ int ret;
480 ++
481 ++ memset(&set, 0, sizeof(set));
482 ++ set.crtc = connector->state->crtc,
483 ++
484 ++ ret = drm_atomic_helper_set_config(&set);
485 ++
486 ++ WARN(ret, "Disabling mst crtc failed with %i\n", ret);
487 ++ }
488 ++
489 + intel_connector_remove_from_fbdev(intel_connector);
490 + drm_connector_cleanup(connector);
491 + drm_modeset_unlock_all(dev);
492 +diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
493 +index 52921a871230..18484301fc3e 100644
494 +--- a/drivers/gpu/drm/qxl/qxl_display.c
495 ++++ b/drivers/gpu/drm/qxl/qxl_display.c
496 +@@ -367,10 +367,15 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
497 +
498 + qxl_bo_kunmap(user_bo);
499 +
500 ++ qcrtc->cur_x += qcrtc->hot_spot_x - hot_x;
501 ++ qcrtc->cur_y += qcrtc->hot_spot_y - hot_y;
502 ++ qcrtc->hot_spot_x = hot_x;
503 ++ qcrtc->hot_spot_y = hot_y;
504 ++
505 + cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
506 + cmd->type = QXL_CURSOR_SET;
507 +- cmd->u.set.position.x = qcrtc->cur_x;
508 +- cmd->u.set.position.y = qcrtc->cur_y;
509 ++ cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
510 ++ cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
511 +
512 + cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0);
513 +
514 +@@ -433,8 +438,8 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
515 +
516 + cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
517 + cmd->type = QXL_CURSOR_MOVE;
518 +- cmd->u.position.x = qcrtc->cur_x;
519 +- cmd->u.position.y = qcrtc->cur_y;
520 ++ cmd->u.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
521 ++ cmd->u.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
522 + qxl_release_unmap(qdev, release, &cmd->release_info);
523 +
524 + qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
525 +diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
526 +index e66143cc1a7a..eef66769245f 100644
527 +--- a/drivers/gpu/drm/qxl/qxl_drv.h
528 ++++ b/drivers/gpu/drm/qxl/qxl_drv.h
529 +@@ -135,6 +135,8 @@ struct qxl_crtc {
530 + int index;
531 + int cur_x;
532 + int cur_y;
533 ++ int hot_spot_x;
534 ++ int hot_spot_y;
535 + };
536 +
537 + struct qxl_output {
538 +diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
539 +index 1764a168888c..49a259fc610e 100644
540 +--- a/drivers/hid/usbhid/hid-core.c
541 ++++ b/drivers/hid/usbhid/hid-core.c
542 +@@ -950,14 +950,6 @@ static int usbhid_output_report(struct hid_device *hid, __u8 *buf, size_t count)
543 + return ret;
544 + }
545 +
546 +-static void usbhid_restart_queues(struct usbhid_device *usbhid)
547 +-{
548 +- if (usbhid->urbout && !test_bit(HID_OUT_RUNNING, &usbhid->iofl))
549 +- usbhid_restart_out_queue(usbhid);
550 +- if (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl))
551 +- usbhid_restart_ctrl_queue(usbhid);
552 +-}
553 +-
554 + static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
555 + {
556 + struct usbhid_device *usbhid = hid->driver_data;
557 +@@ -1403,6 +1395,37 @@ static void hid_cease_io(struct usbhid_device *usbhid)
558 + usb_kill_urb(usbhid->urbout);
559 + }
560 +
561 ++static void hid_restart_io(struct hid_device *hid)
562 ++{
563 ++ struct usbhid_device *usbhid = hid->driver_data;
564 ++ int clear_halt = test_bit(HID_CLEAR_HALT, &usbhid->iofl);
565 ++ int reset_pending = test_bit(HID_RESET_PENDING, &usbhid->iofl);
566 ++
567 ++ spin_lock_irq(&usbhid->lock);
568 ++ clear_bit(HID_SUSPENDED, &usbhid->iofl);
569 ++ usbhid_mark_busy(usbhid);
570 ++
571 ++ if (clear_halt || reset_pending)
572 ++ schedule_work(&usbhid->reset_work);
573 ++ usbhid->retry_delay = 0;
574 ++ spin_unlock_irq(&usbhid->lock);
575 ++
576 ++ if (reset_pending || !test_bit(HID_STARTED, &usbhid->iofl))
577 ++ return;
578 ++
579 ++ if (!clear_halt) {
580 ++ if (hid_start_in(hid) < 0)
581 ++ hid_io_error(hid);
582 ++ }
583 ++
584 ++ spin_lock_irq(&usbhid->lock);
585 ++ if (usbhid->urbout && !test_bit(HID_OUT_RUNNING, &usbhid->iofl))
586 ++ usbhid_restart_out_queue(usbhid);
587 ++ if (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl))
588 ++ usbhid_restart_ctrl_queue(usbhid);
589 ++ spin_unlock_irq(&usbhid->lock);
590 ++}
591 ++
592 + /* Treat USB reset pretty much the same as suspend/resume */
593 + static int hid_pre_reset(struct usb_interface *intf)
594 + {
595 +@@ -1452,14 +1475,14 @@ static int hid_post_reset(struct usb_interface *intf)
596 + return 1;
597 + }
598 +
599 ++ /* No need to do another reset or clear a halted endpoint */
600 + spin_lock_irq(&usbhid->lock);
601 + clear_bit(HID_RESET_PENDING, &usbhid->iofl);
602 ++ clear_bit(HID_CLEAR_HALT, &usbhid->iofl);
603 + spin_unlock_irq(&usbhid->lock);
604 + hid_set_idle(dev, intf->cur_altsetting->desc.bInterfaceNumber, 0, 0);
605 +- status = hid_start_in(hid);
606 +- if (status < 0)
607 +- hid_io_error(hid);
608 +- usbhid_restart_queues(usbhid);
609 ++
610 ++ hid_restart_io(hid);
611 +
612 + return 0;
613 + }
614 +@@ -1482,25 +1505,9 @@ void usbhid_put_power(struct hid_device *hid)
615 + #ifdef CONFIG_PM
616 + static int hid_resume_common(struct hid_device *hid, bool driver_suspended)
617 + {
618 +- struct usbhid_device *usbhid = hid->driver_data;
619 +- int status;
620 +-
621 +- spin_lock_irq(&usbhid->lock);
622 +- clear_bit(HID_SUSPENDED, &usbhid->iofl);
623 +- usbhid_mark_busy(usbhid);
624 +-
625 +- if (test_bit(HID_CLEAR_HALT, &usbhid->iofl) ||
626 +- test_bit(HID_RESET_PENDING, &usbhid->iofl))
627 +- schedule_work(&usbhid->reset_work);
628 +- usbhid->retry_delay = 0;
629 +-
630 +- usbhid_restart_queues(usbhid);
631 +- spin_unlock_irq(&usbhid->lock);
632 +-
633 +- status = hid_start_in(hid);
634 +- if (status < 0)
635 +- hid_io_error(hid);
636 ++ int status = 0;
637 +
638 ++ hid_restart_io(hid);
639 + if (driver_suspended && hid->driver && hid->driver->resume)
640 + status = hid->driver->resume(hid);
641 + return status;
642 +@@ -1569,12 +1576,8 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
643 + static int hid_resume(struct usb_interface *intf)
644 + {
645 + struct hid_device *hid = usb_get_intfdata (intf);
646 +- struct usbhid_device *usbhid = hid->driver_data;
647 + int status;
648 +
649 +- if (!test_bit(HID_STARTED, &usbhid->iofl))
650 +- return 0;
651 +-
652 + status = hid_resume_common(hid, true);
653 + dev_dbg(&intf->dev, "resume status %d\n", status);
654 + return 0;
655 +@@ -1583,10 +1586,8 @@ static int hid_resume(struct usb_interface *intf)
656 + static int hid_reset_resume(struct usb_interface *intf)
657 + {
658 + struct hid_device *hid = usb_get_intfdata(intf);
659 +- struct usbhid_device *usbhid = hid->driver_data;
660 + int status;
661 +
662 +- clear_bit(HID_SUSPENDED, &usbhid->iofl);
663 + status = hid_post_reset(intf);
664 + if (status >= 0 && hid->driver && hid->driver->reset_resume) {
665 + int ret = hid->driver->reset_resume(hid);
666 +diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
667 +index 082ae6ba492f..1741c33674c3 100644
668 +--- a/drivers/media/usb/au0828/au0828-core.c
669 ++++ b/drivers/media/usb/au0828/au0828-core.c
670 +@@ -159,7 +159,7 @@ static void au0828_usb_disconnect(struct usb_interface *interface)
671 + Set the status so poll routines can check and avoid
672 + access after disconnect.
673 + */
674 +- dev->dev_state = DEV_DISCONNECTED;
675 ++ set_bit(DEV_DISCONNECTED, &dev->dev_state);
676 +
677 + au0828_rc_unregister(dev);
678 + /* Digital TV */
679 +diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c
680 +index b0f067971979..3d6687f0407d 100644
681 +--- a/drivers/media/usb/au0828/au0828-input.c
682 ++++ b/drivers/media/usb/au0828/au0828-input.c
683 +@@ -130,7 +130,7 @@ static int au0828_get_key_au8522(struct au0828_rc *ir)
684 + bool first = true;
685 +
686 + /* do nothing if device is disconnected */
687 +- if (ir->dev->dev_state == DEV_DISCONNECTED)
688 ++ if (test_bit(DEV_DISCONNECTED, &ir->dev->dev_state))
689 + return 0;
690 +
691 + /* Check IR int */
692 +@@ -260,7 +260,7 @@ static void au0828_rc_stop(struct rc_dev *rc)
693 + cancel_delayed_work_sync(&ir->work);
694 +
695 + /* do nothing if device is disconnected */
696 +- if (ir->dev->dev_state != DEV_DISCONNECTED) {
697 ++ if (!test_bit(DEV_DISCONNECTED, &ir->dev->dev_state)) {
698 + /* Disable IR */
699 + au8522_rc_clear(ir, 0xe0, 1 << 4);
700 + }
701 +diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
702 +index 1a362a041ab3..0605c0f35059 100644
703 +--- a/drivers/media/usb/au0828/au0828-video.c
704 ++++ b/drivers/media/usb/au0828/au0828-video.c
705 +@@ -104,14 +104,13 @@ static inline void print_err_status(struct au0828_dev *dev,
706 +
707 + static int check_dev(struct au0828_dev *dev)
708 + {
709 +- if (dev->dev_state & DEV_DISCONNECTED) {
710 ++ if (test_bit(DEV_DISCONNECTED, &dev->dev_state)) {
711 + pr_info("v4l2 ioctl: device not present\n");
712 + return -ENODEV;
713 + }
714 +
715 +- if (dev->dev_state & DEV_MISCONFIGURED) {
716 +- pr_info("v4l2 ioctl: device is misconfigured; "
717 +- "close and open it again\n");
718 ++ if (test_bit(DEV_MISCONFIGURED, &dev->dev_state)) {
719 ++ pr_info("v4l2 ioctl: device is misconfigured; close and open it again\n");
720 + return -EIO;
721 + }
722 + return 0;
723 +@@ -519,8 +518,8 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
724 + if (!dev)
725 + return 0;
726 +
727 +- if ((dev->dev_state & DEV_DISCONNECTED) ||
728 +- (dev->dev_state & DEV_MISCONFIGURED))
729 ++ if (test_bit(DEV_DISCONNECTED, &dev->dev_state) ||
730 ++ test_bit(DEV_MISCONFIGURED, &dev->dev_state))
731 + return 0;
732 +
733 + if (urb->status < 0) {
734 +@@ -761,10 +760,10 @@ static int au0828_stream_interrupt(struct au0828_dev *dev)
735 + int ret = 0;
736 +
737 + dev->stream_state = STREAM_INTERRUPT;
738 +- if (dev->dev_state == DEV_DISCONNECTED)
739 ++ if (test_bit(DEV_DISCONNECTED, &dev->dev_state))
740 + return -ENODEV;
741 + else if (ret) {
742 +- dev->dev_state = DEV_MISCONFIGURED;
743 ++ set_bit(DEV_MISCONFIGURED, &dev->dev_state);
744 + dprintk(1, "%s device is misconfigured!\n", __func__);
745 + return ret;
746 + }
747 +@@ -952,7 +951,7 @@ static int au0828_v4l2_open(struct file *filp)
748 + int ret;
749 +
750 + dprintk(1,
751 +- "%s called std_set %d dev_state %d stream users %d users %d\n",
752 ++ "%s called std_set %d dev_state %ld stream users %d users %d\n",
753 + __func__, dev->std_set_in_tuner_core, dev->dev_state,
754 + dev->streaming_users, dev->users);
755 +
756 +@@ -971,7 +970,7 @@ static int au0828_v4l2_open(struct file *filp)
757 + au0828_analog_stream_enable(dev);
758 + au0828_analog_stream_reset(dev);
759 + dev->stream_state = STREAM_OFF;
760 +- dev->dev_state |= DEV_INITIALIZED;
761 ++ set_bit(DEV_INITIALIZED, &dev->dev_state);
762 + }
763 + dev->users++;
764 + mutex_unlock(&dev->lock);
765 +@@ -985,7 +984,7 @@ static int au0828_v4l2_close(struct file *filp)
766 + struct video_device *vdev = video_devdata(filp);
767 +
768 + dprintk(1,
769 +- "%s called std_set %d dev_state %d stream users %d users %d\n",
770 ++ "%s called std_set %d dev_state %ld stream users %d users %d\n",
771 + __func__, dev->std_set_in_tuner_core, dev->dev_state,
772 + dev->streaming_users, dev->users);
773 +
774 +@@ -1001,7 +1000,7 @@ static int au0828_v4l2_close(struct file *filp)
775 + del_timer_sync(&dev->vbi_timeout);
776 + }
777 +
778 +- if (dev->dev_state == DEV_DISCONNECTED)
779 ++ if (test_bit(DEV_DISCONNECTED, &dev->dev_state))
780 + goto end;
781 +
782 + if (dev->users == 1) {
783 +@@ -1030,7 +1029,7 @@ static void au0828_init_tuner(struct au0828_dev *dev)
784 + .type = V4L2_TUNER_ANALOG_TV,
785 + };
786 +
787 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
788 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
789 + dev->std_set_in_tuner_core, dev->dev_state);
790 +
791 + if (dev->std_set_in_tuner_core)
792 +@@ -1102,7 +1101,7 @@ static int vidioc_querycap(struct file *file, void *priv,
793 + struct video_device *vdev = video_devdata(file);
794 + struct au0828_dev *dev = video_drvdata(file);
795 +
796 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
797 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
798 + dev->std_set_in_tuner_core, dev->dev_state);
799 +
800 + strlcpy(cap->driver, "au0828", sizeof(cap->driver));
801 +@@ -1145,7 +1144,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
802 + {
803 + struct au0828_dev *dev = video_drvdata(file);
804 +
805 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
806 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
807 + dev->std_set_in_tuner_core, dev->dev_state);
808 +
809 + f->fmt.pix.width = dev->width;
810 +@@ -1164,7 +1163,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
811 + {
812 + struct au0828_dev *dev = video_drvdata(file);
813 +
814 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
815 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
816 + dev->std_set_in_tuner_core, dev->dev_state);
817 +
818 + return au0828_set_format(dev, VIDIOC_TRY_FMT, f);
819 +@@ -1176,7 +1175,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
820 + struct au0828_dev *dev = video_drvdata(file);
821 + int rc;
822 +
823 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
824 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
825 + dev->std_set_in_tuner_core, dev->dev_state);
826 +
827 + rc = check_dev(dev);
828 +@@ -1198,7 +1197,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm)
829 + {
830 + struct au0828_dev *dev = video_drvdata(file);
831 +
832 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
833 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
834 + dev->std_set_in_tuner_core, dev->dev_state);
835 +
836 + if (norm == dev->std)
837 +@@ -1230,7 +1229,7 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm)
838 + {
839 + struct au0828_dev *dev = video_drvdata(file);
840 +
841 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
842 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
843 + dev->std_set_in_tuner_core, dev->dev_state);
844 +
845 + *norm = dev->std;
846 +@@ -1253,7 +1252,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
847 + [AU0828_VMUX_DEBUG] = "tv debug"
848 + };
849 +
850 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
851 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
852 + dev->std_set_in_tuner_core, dev->dev_state);
853 +
854 + tmp = input->index;
855 +@@ -1283,7 +1282,7 @@ static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
856 + {
857 + struct au0828_dev *dev = video_drvdata(file);
858 +
859 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
860 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
861 + dev->std_set_in_tuner_core, dev->dev_state);
862 +
863 + *i = dev->ctrl_input;
864 +@@ -1294,7 +1293,7 @@ static void au0828_s_input(struct au0828_dev *dev, int index)
865 + {
866 + int i;
867 +
868 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
869 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
870 + dev->std_set_in_tuner_core, dev->dev_state);
871 +
872 + switch (AUVI_INPUT(index).type) {
873 +@@ -1379,7 +1378,7 @@ static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
874 + {
875 + struct au0828_dev *dev = video_drvdata(file);
876 +
877 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
878 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
879 + dev->std_set_in_tuner_core, dev->dev_state);
880 +
881 + a->index = dev->ctrl_ainput;
882 +@@ -1399,7 +1398,7 @@ static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audio
883 + if (a->index != dev->ctrl_ainput)
884 + return -EINVAL;
885 +
886 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
887 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
888 + dev->std_set_in_tuner_core, dev->dev_state);
889 + return 0;
890 + }
891 +@@ -1411,7 +1410,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
892 + if (t->index != 0)
893 + return -EINVAL;
894 +
895 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
896 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
897 + dev->std_set_in_tuner_core, dev->dev_state);
898 +
899 + strcpy(t->name, "Auvitek tuner");
900 +@@ -1431,7 +1430,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
901 + if (t->index != 0)
902 + return -EINVAL;
903 +
904 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
905 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
906 + dev->std_set_in_tuner_core, dev->dev_state);
907 +
908 + au0828_init_tuner(dev);
909 +@@ -1453,7 +1452,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
910 +
911 + if (freq->tuner != 0)
912 + return -EINVAL;
913 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
914 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
915 + dev->std_set_in_tuner_core, dev->dev_state);
916 + freq->frequency = dev->ctrl_freq;
917 + return 0;
918 +@@ -1468,7 +1467,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
919 + if (freq->tuner != 0)
920 + return -EINVAL;
921 +
922 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
923 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
924 + dev->std_set_in_tuner_core, dev->dev_state);
925 +
926 + au0828_init_tuner(dev);
927 +@@ -1494,7 +1493,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
928 + {
929 + struct au0828_dev *dev = video_drvdata(file);
930 +
931 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
932 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
933 + dev->std_set_in_tuner_core, dev->dev_state);
934 +
935 + format->fmt.vbi.samples_per_line = dev->vbi_width;
936 +@@ -1520,7 +1519,7 @@ static int vidioc_cropcap(struct file *file, void *priv,
937 + if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
938 + return -EINVAL;
939 +
940 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
941 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
942 + dev->std_set_in_tuner_core, dev->dev_state);
943 +
944 + cc->bounds.left = 0;
945 +@@ -1542,7 +1541,7 @@ static int vidioc_g_register(struct file *file, void *priv,
946 + {
947 + struct au0828_dev *dev = video_drvdata(file);
948 +
949 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
950 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
951 + dev->std_set_in_tuner_core, dev->dev_state);
952 +
953 + reg->val = au0828_read(dev, reg->reg);
954 +@@ -1555,7 +1554,7 @@ static int vidioc_s_register(struct file *file, void *priv,
955 + {
956 + struct au0828_dev *dev = video_drvdata(file);
957 +
958 +- dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
959 ++ dprintk(1, "%s called std_set %d dev_state %ld\n", __func__,
960 + dev->std_set_in_tuner_core, dev->dev_state);
961 +
962 + return au0828_writereg(dev, reg->reg, reg->val);
963 +diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h
964 +index 3b480005ce3b..42a5379c6aa3 100644
965 +--- a/drivers/media/usb/au0828/au0828.h
966 ++++ b/drivers/media/usb/au0828/au0828.h
967 +@@ -21,6 +21,7 @@
968 +
969 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
970 +
971 ++#include <linux/bitops.h>
972 + #include <linux/usb.h>
973 + #include <linux/i2c.h>
974 + #include <linux/i2c-algo-bit.h>
975 +@@ -121,9 +122,9 @@ enum au0828_stream_state {
976 +
977 + /* device state */
978 + enum au0828_dev_state {
979 +- DEV_INITIALIZED = 0x01,
980 +- DEV_DISCONNECTED = 0x02,
981 +- DEV_MISCONFIGURED = 0x04
982 ++ DEV_INITIALIZED = 0,
983 ++ DEV_DISCONNECTED = 1,
984 ++ DEV_MISCONFIGURED = 2
985 + };
986 +
987 + struct au0828_dev;
988 +@@ -247,7 +248,7 @@ struct au0828_dev {
989 + int input_type;
990 + int std_set_in_tuner_core;
991 + unsigned int ctrl_input;
992 +- enum au0828_dev_state dev_state;
993 ++ long unsigned int dev_state; /* defined at enum au0828_dev_state */;
994 + enum au0828_stream_state stream_state;
995 + wait_queue_head_t open;
996 +
997 +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
998 +index c66fd23b3c13..1a82a8552182 100644
999 +--- a/drivers/scsi/sd.c
1000 ++++ b/drivers/scsi/sd.c
1001 +@@ -1260,18 +1260,19 @@ static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1002 + struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk);
1003 + struct scsi_device *sdp = sdkp->device;
1004 + struct Scsi_Host *host = sdp->host;
1005 ++ sector_t capacity = logical_to_sectors(sdp, sdkp->capacity);
1006 + int diskinfo[4];
1007 +
1008 + /* default to most commonly used values */
1009 +- diskinfo[0] = 0x40; /* 1 << 6 */
1010 +- diskinfo[1] = 0x20; /* 1 << 5 */
1011 +- diskinfo[2] = sdkp->capacity >> 11;
1012 +-
1013 ++ diskinfo[0] = 0x40; /* 1 << 6 */
1014 ++ diskinfo[1] = 0x20; /* 1 << 5 */
1015 ++ diskinfo[2] = capacity >> 11;
1016 ++
1017 + /* override with calculated, extended default, or driver values */
1018 + if (host->hostt->bios_param)
1019 +- host->hostt->bios_param(sdp, bdev, sdkp->capacity, diskinfo);
1020 ++ host->hostt->bios_param(sdp, bdev, capacity, diskinfo);
1021 + else
1022 +- scsicam_bios_param(bdev, sdkp->capacity, diskinfo);
1023 ++ scsicam_bios_param(bdev, capacity, diskinfo);
1024 +
1025 + geo->heads = diskinfo[0];
1026 + geo->sectors = diskinfo[1];
1027 +@@ -2230,14 +2231,6 @@ got_data:
1028 + } else
1029 + sdkp->max_xfer_blocks = SD_DEF_XFER_BLOCKS;
1030 +
1031 +- /* Rescale capacity to 512-byte units */
1032 +- if (sector_size == 4096)
1033 +- sdkp->capacity <<= 3;
1034 +- else if (sector_size == 2048)
1035 +- sdkp->capacity <<= 2;
1036 +- else if (sector_size == 1024)
1037 +- sdkp->capacity <<= 1;
1038 +-
1039 + blk_queue_physical_block_size(sdp->request_queue,
1040 + sdkp->physical_block_size);
1041 + sdkp->device->sector_size = sector_size;
1042 +@@ -2773,7 +2766,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
1043 + sdkp->disk->queue->limits.max_sectors =
1044 + min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
1045 +
1046 +- set_capacity(disk, sdkp->capacity);
1047 ++ set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity));
1048 + sd_config_write_same(sdkp);
1049 + kfree(buffer);
1050 +
1051 +diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
1052 +index 63ba5ca7f9a1..0264936a855a 100644
1053 +--- a/drivers/scsi/sd.h
1054 ++++ b/drivers/scsi/sd.h
1055 +@@ -65,7 +65,7 @@ struct scsi_disk {
1056 + struct device dev;
1057 + struct gendisk *disk;
1058 + atomic_t openers;
1059 +- sector_t capacity; /* size in 512-byte sectors */
1060 ++ sector_t capacity; /* size in logical blocks */
1061 + u32 max_xfer_blocks;
1062 + u32 max_ws_blocks;
1063 + u32 max_unmap_blocks;
1064 +@@ -145,6 +145,11 @@ static inline int scsi_medium_access_command(struct scsi_cmnd *scmd)
1065 + return 0;
1066 + }
1067 +
1068 ++static inline sector_t logical_to_sectors(struct scsi_device *sdev, sector_t blocks)
1069 ++{
1070 ++ return blocks << (ilog2(sdev->sector_size) - 9);
1071 ++}
1072 ++
1073 + /*
1074 + * A DIF-capable target device can be formatted with different
1075 + * protection schemes. Currently 0 through 3 are defined:
1076 +diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
1077 +index 09f1e5f2f013..a61386ce41ee 100644
1078 +--- a/drivers/thermal/thermal_core.c
1079 ++++ b/drivers/thermal/thermal_core.c
1080 +@@ -1491,7 +1491,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
1081 + {
1082 + struct thermal_zone_device *tz;
1083 + enum thermal_trip_type trip_type;
1084 +- int trip_temp;
1085 ++ unsigned long trip_temp;
1086 + int result;
1087 + int count;
1088 + int passive = 0;
1089 +diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
1090 +index 9eb1cff28bd4..b8b580e5ae6e 100644
1091 +--- a/drivers/usb/core/hcd-pci.c
1092 ++++ b/drivers/usb/core/hcd-pci.c
1093 +@@ -74,6 +74,15 @@ static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
1094 + if (companion->bus != pdev->bus ||
1095 + PCI_SLOT(companion->devfn) != slot)
1096 + continue;
1097 ++
1098 ++ /*
1099 ++ * Companion device should be either UHCI,OHCI or EHCI host
1100 ++ * controller, otherwise skip.
1101 ++ */
1102 ++ if (companion->class != CL_UHCI && companion->class != CL_OHCI &&
1103 ++ companion->class != CL_EHCI)
1104 ++ continue;
1105 ++
1106 + companion_hcd = pci_get_drvdata(companion);
1107 + if (!companion_hcd || !companion_hcd->self.root_hub)
1108 + continue;
1109 +diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
1110 +index 41f841fa6c4d..5ab70afd5624 100644
1111 +--- a/drivers/usb/host/xhci-mem.c
1112 ++++ b/drivers/usb/host/xhci-mem.c
1113 +@@ -1879,6 +1879,12 @@ no_bw:
1114 + kfree(xhci->rh_bw);
1115 + kfree(xhci->ext_caps);
1116 +
1117 ++ xhci->usb2_ports = NULL;
1118 ++ xhci->usb3_ports = NULL;
1119 ++ xhci->port_array = NULL;
1120 ++ xhci->rh_bw = NULL;
1121 ++ xhci->ext_caps = NULL;
1122 ++
1123 + xhci->page_size = 0;
1124 + xhci->page_shift = 0;
1125 + xhci->bus_state[0].bus_suspended = 0;
1126 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
1127 +index 3ff5fcc7c94b..c6027acb6263 100644
1128 +--- a/drivers/usb/host/xhci-pci.c
1129 ++++ b/drivers/usb/host/xhci-pci.c
1130 +@@ -48,6 +48,7 @@
1131 + #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
1132 + #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
1133 + #define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
1134 ++#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
1135 +
1136 + static const char hcd_name[] = "xhci_hcd";
1137 +
1138 +@@ -149,7 +150,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
1139 + (pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
1140 + pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
1141 + pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
1142 +- pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI)) {
1143 ++ pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
1144 ++ pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) {
1145 + xhci->quirks |= XHCI_PME_STUCK_QUIRK;
1146 + }
1147 + if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
1148 +@@ -296,6 +298,7 @@ static void xhci_pci_remove(struct pci_dev *dev)
1149 + struct xhci_hcd *xhci;
1150 +
1151 + xhci = hcd_to_xhci(pci_get_drvdata(dev));
1152 ++ xhci->xhc_state |= XHCI_STATE_REMOVING;
1153 + if (xhci->shared_hcd) {
1154 + usb_remove_hcd(xhci->shared_hcd);
1155 + usb_put_hcd(xhci->shared_hcd);
1156 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
1157 +index e6d858a49d04..6fe0377ec5cf 100644
1158 +--- a/drivers/usb/host/xhci-ring.c
1159 ++++ b/drivers/usb/host/xhci-ring.c
1160 +@@ -3823,8 +3823,12 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
1161 + {
1162 + int reserved_trbs = xhci->cmd_ring_reserved_trbs;
1163 + int ret;
1164 +- if (xhci->xhc_state & XHCI_STATE_DYING)
1165 ++
1166 ++ if ((xhci->xhc_state & XHCI_STATE_DYING) ||
1167 ++ (xhci->xhc_state & XHCI_STATE_HALTED)) {
1168 ++ xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
1169 + return -ESHUTDOWN;
1170 ++ }
1171 +
1172 + if (!command_must_succeed)
1173 + reserved_trbs++;
1174 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
1175 +index 910f7fac031f..896b928f7412 100644
1176 +--- a/drivers/usb/host/xhci.c
1177 ++++ b/drivers/usb/host/xhci.c
1178 +@@ -146,7 +146,8 @@ static int xhci_start(struct xhci_hcd *xhci)
1179 + "waited %u microseconds.\n",
1180 + XHCI_MAX_HALT_USEC);
1181 + if (!ret)
1182 +- xhci->xhc_state &= ~(XHCI_STATE_HALTED | XHCI_STATE_DYING);
1183 ++ /* clear state flags. Including dying, halted or removing */
1184 ++ xhci->xhc_state = 0;
1185 +
1186 + return ret;
1187 + }
1188 +@@ -1113,8 +1114,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1189 + /* Resume root hubs only when have pending events. */
1190 + status = readl(&xhci->op_regs->status);
1191 + if (status & STS_EINT) {
1192 +- usb_hcd_resume_root_hub(hcd);
1193 + usb_hcd_resume_root_hub(xhci->shared_hcd);
1194 ++ usb_hcd_resume_root_hub(hcd);
1195 + }
1196 + }
1197 +
1198 +@@ -1129,10 +1130,10 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1199 +
1200 + /* Re-enable port polling. */
1201 + xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
1202 +- set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
1203 +- usb_hcd_poll_rh_status(hcd);
1204 + set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
1205 + usb_hcd_poll_rh_status(xhci->shared_hcd);
1206 ++ set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
1207 ++ usb_hcd_poll_rh_status(hcd);
1208 +
1209 + return retval;
1210 + }
1211 +@@ -2763,7 +2764,8 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
1212 + if (ret <= 0)
1213 + return ret;
1214 + xhci = hcd_to_xhci(hcd);
1215 +- if (xhci->xhc_state & XHCI_STATE_DYING)
1216 ++ if ((xhci->xhc_state & XHCI_STATE_DYING) ||
1217 ++ (xhci->xhc_state & XHCI_STATE_REMOVING))
1218 + return -ENODEV;
1219 +
1220 + xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
1221 +@@ -3812,7 +3814,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
1222 +
1223 + mutex_lock(&xhci->mutex);
1224 +
1225 +- if (xhci->xhc_state) /* dying or halted */
1226 ++ if (xhci->xhc_state) /* dying, removing or halted */
1227 + goto out;
1228 +
1229 + if (!udev->slot_id) {
1230 +@@ -4939,6 +4941,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
1231 + goto error;
1232 + xhci_dbg(xhci, "Reset complete\n");
1233 +
1234 ++ /*
1235 ++ * On some xHCI controllers (e.g. R-Car SoCs), the AC64 bit (bit 0)
1236 ++ * of HCCPARAMS1 is set to 1. However, the xHCs don't support 64-bit
1237 ++ * address memory pointers actually. So, this driver clears the AC64
1238 ++ * bit of xhci->hcc_params to call dma_set_coherent_mask(dev,
1239 ++ * DMA_BIT_MASK(32)) in this xhci_gen_setup().
1240 ++ */
1241 ++ if (xhci->quirks & XHCI_NO_64BIT_SUPPORT)
1242 ++ xhci->hcc_params &= ~BIT(0);
1243 ++
1244 + /* Set dma_mask and coherent_dma_mask to 64-bits,
1245 + * if xHC supports 64-bit addressing */
1246 + if (HCC_64BIT_ADDR(xhci->hcc_params) &&
1247 +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
1248 +index f18cdf0ec795..c5d6963e9cbe 100644
1249 +--- a/drivers/usb/host/xhci.h
1250 ++++ b/drivers/usb/host/xhci.h
1251 +@@ -1536,6 +1536,7 @@ struct xhci_hcd {
1252 + */
1253 + #define XHCI_STATE_DYING (1 << 0)
1254 + #define XHCI_STATE_HALTED (1 << 1)
1255 ++#define XHCI_STATE_REMOVING (1 << 2)
1256 + /* Statistics */
1257 + int error_bitmask;
1258 + unsigned int quirks;
1259 +@@ -1571,6 +1572,7 @@ struct xhci_hcd {
1260 + #define XHCI_BROKEN_STREAMS (1 << 19)
1261 + #define XHCI_PME_STUCK_QUIRK (1 << 20)
1262 + #define XHCI_SSIC_PORT_UNUSED (1 << 22)
1263 ++#define XHCI_NO_64BIT_SUPPORT (1 << 23)
1264 + unsigned int num_active_eps;
1265 + unsigned int limit_active_eps;
1266 + /* There are two roothubs to keep track of bus suspend info for */
1267 +diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
1268 +index c0f5c652d272..f1893e08e51a 100644
1269 +--- a/drivers/usb/renesas_usbhs/fifo.c
1270 ++++ b/drivers/usb/renesas_usbhs/fifo.c
1271 +@@ -190,7 +190,8 @@ static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type)
1272 + goto __usbhs_pkt_handler_end;
1273 + }
1274 +
1275 +- ret = func(pkt, &is_done);
1276 ++ if (likely(func))
1277 ++ ret = func(pkt, &is_done);
1278 +
1279 + if (is_done)
1280 + __usbhsf_pkt_del(pkt);
1281 +@@ -889,6 +890,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
1282 +
1283 + pkt->trans = len;
1284 +
1285 ++ usbhsf_tx_irq_ctrl(pipe, 0);
1286 + INIT_WORK(&pkt->work, xfer_work);
1287 + schedule_work(&pkt->work);
1288 +
1289 +diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
1290 +index dc2aa3261202..046529656465 100644
1291 +--- a/drivers/usb/renesas_usbhs/mod_gadget.c
1292 ++++ b/drivers/usb/renesas_usbhs/mod_gadget.c
1293 +@@ -154,10 +154,14 @@ static void usbhsg_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt)
1294 + struct usbhs_pipe *pipe = pkt->pipe;
1295 + struct usbhsg_uep *uep = usbhsg_pipe_to_uep(pipe);
1296 + struct usbhsg_request *ureq = usbhsg_pkt_to_ureq(pkt);
1297 ++ unsigned long flags;
1298 +
1299 + ureq->req.actual = pkt->actual;
1300 +
1301 +- usbhsg_queue_pop(uep, ureq, 0);
1302 ++ usbhs_lock(priv, flags);
1303 ++ if (uep)
1304 ++ __usbhsg_queue_pop(uep, ureq, 0);
1305 ++ usbhs_unlock(priv, flags);
1306 + }
1307 +
1308 + static void usbhsg_queue_push(struct usbhsg_uep *uep,
1309 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
1310 +index 7a76fe4c2f9e..bdc0f2f24f19 100644
1311 +--- a/drivers/usb/serial/cp210x.c
1312 ++++ b/drivers/usb/serial/cp210x.c
1313 +@@ -164,6 +164,7 @@ static const struct usb_device_id id_table[] = {
1314 + { USB_DEVICE(0x18EF, 0xE025) }, /* ELV Marble Sound Board 1 */
1315 + { USB_DEVICE(0x1901, 0x0190) }, /* GE B850 CP2105 Recorder interface */
1316 + { USB_DEVICE(0x1901, 0x0193) }, /* GE B650 CP2104 PMC interface */
1317 ++ { USB_DEVICE(0x1901, 0x0194) }, /* GE Healthcare Remote Alarm Box */
1318 + { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */
1319 + { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
1320 + { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
1321 +diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
1322 +index 01bf53392819..244acb1299a9 100644
1323 +--- a/drivers/usb/serial/cypress_m8.c
1324 ++++ b/drivers/usb/serial/cypress_m8.c
1325 +@@ -447,6 +447,11 @@ static int cypress_generic_port_probe(struct usb_serial_port *port)
1326 + struct usb_serial *serial = port->serial;
1327 + struct cypress_private *priv;
1328 +
1329 ++ if (!port->interrupt_out_urb || !port->interrupt_in_urb) {
1330 ++ dev_err(&port->dev, "required endpoint is missing\n");
1331 ++ return -ENODEV;
1332 ++ }
1333 ++
1334 + priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
1335 + if (!priv)
1336 + return -ENOMEM;
1337 +@@ -606,12 +611,6 @@ static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
1338 + cypress_set_termios(tty, port, &priv->tmp_termios);
1339 +
1340 + /* setup the port and start reading from the device */
1341 +- if (!port->interrupt_in_urb) {
1342 +- dev_err(&port->dev, "%s - interrupt_in_urb is empty!\n",
1343 +- __func__);
1344 +- return -1;
1345 +- }
1346 +-
1347 + usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
1348 + usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
1349 + port->interrupt_in_urb->transfer_buffer,
1350 +diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
1351 +index 12b0e67473ba..3df7b7ec178e 100644
1352 +--- a/drivers/usb/serial/digi_acceleport.c
1353 ++++ b/drivers/usb/serial/digi_acceleport.c
1354 +@@ -1251,8 +1251,27 @@ static int digi_port_init(struct usb_serial_port *port, unsigned port_num)
1355 +
1356 + static int digi_startup(struct usb_serial *serial)
1357 + {
1358 ++ struct device *dev = &serial->interface->dev;
1359 + struct digi_serial *serial_priv;
1360 + int ret;
1361 ++ int i;
1362 ++
1363 ++ /* check whether the device has the expected number of endpoints */
1364 ++ if (serial->num_port_pointers < serial->type->num_ports + 1) {
1365 ++ dev_err(dev, "OOB endpoints missing\n");
1366 ++ return -ENODEV;
1367 ++ }
1368 ++
1369 ++ for (i = 0; i < serial->type->num_ports + 1 ; i++) {
1370 ++ if (!serial->port[i]->read_urb) {
1371 ++ dev_err(dev, "bulk-in endpoint missing\n");
1372 ++ return -ENODEV;
1373 ++ }
1374 ++ if (!serial->port[i]->write_urb) {
1375 ++ dev_err(dev, "bulk-out endpoint missing\n");
1376 ++ return -ENODEV;
1377 ++ }
1378 ++ }
1379 +
1380 + serial_priv = kzalloc(sizeof(*serial_priv), GFP_KERNEL);
1381 + if (!serial_priv)
1382 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
1383 +index 8c660ae401d8..b61f12160d37 100644
1384 +--- a/drivers/usb/serial/ftdi_sio.c
1385 ++++ b/drivers/usb/serial/ftdi_sio.c
1386 +@@ -1004,6 +1004,10 @@ static const struct usb_device_id id_table_combined[] = {
1387 + { USB_DEVICE(FTDI_VID, CHETCO_SEASMART_DISPLAY_PID) },
1388 + { USB_DEVICE(FTDI_VID, CHETCO_SEASMART_LITE_PID) },
1389 + { USB_DEVICE(FTDI_VID, CHETCO_SEASMART_ANALOG_PID) },
1390 ++ /* ICP DAS I-756xU devices */
1391 ++ { USB_DEVICE(ICPDAS_VID, ICPDAS_I7560U_PID) },
1392 ++ { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) },
1393 ++ { USB_DEVICE(ICPDAS_VID, ICPDAS_I7563U_PID) },
1394 + { } /* Terminating entry */
1395 + };
1396 +
1397 +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
1398 +index 7850071c0ae1..334bc600282d 100644
1399 +--- a/drivers/usb/serial/ftdi_sio_ids.h
1400 ++++ b/drivers/usb/serial/ftdi_sio_ids.h
1401 +@@ -872,6 +872,14 @@
1402 + #define NOVITUS_BONO_E_PID 0x6010
1403 +
1404 + /*
1405 ++ * ICPDAS I-756*U devices
1406 ++ */
1407 ++#define ICPDAS_VID 0x1b5c
1408 ++#define ICPDAS_I7560U_PID 0x0103
1409 ++#define ICPDAS_I7561U_PID 0x0104
1410 ++#define ICPDAS_I7563U_PID 0x0105
1411 ++
1412 ++/*
1413 + * RT Systems programming cables for various ham radios
1414 + */
1415 + #define RTSYSTEMS_VID 0x2100 /* Vendor ID */
1416 +diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
1417 +index fd707d6a10e2..89726f702202 100644
1418 +--- a/drivers/usb/serial/mct_u232.c
1419 ++++ b/drivers/usb/serial/mct_u232.c
1420 +@@ -376,14 +376,21 @@ static void mct_u232_msr_to_state(struct usb_serial_port *port,
1421 +
1422 + static int mct_u232_port_probe(struct usb_serial_port *port)
1423 + {
1424 ++ struct usb_serial *serial = port->serial;
1425 + struct mct_u232_private *priv;
1426 +
1427 ++ /* check first to simplify error handling */
1428 ++ if (!serial->port[1] || !serial->port[1]->interrupt_in_urb) {
1429 ++ dev_err(&port->dev, "expected endpoint missing\n");
1430 ++ return -ENODEV;
1431 ++ }
1432 ++
1433 + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1434 + if (!priv)
1435 + return -ENOMEM;
1436 +
1437 + /* Use second interrupt-in endpoint for reading. */
1438 +- priv->read_urb = port->serial->port[1]->interrupt_in_urb;
1439 ++ priv->read_urb = serial->port[1]->interrupt_in_urb;
1440 + priv->read_urb->context = port;
1441 +
1442 + spin_lock_init(&priv->lock);
1443 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1444 +index ce3d6af977b7..94e520de6404 100644
1445 +--- a/drivers/usb/serial/option.c
1446 ++++ b/drivers/usb/serial/option.c
1447 +@@ -1830,6 +1830,8 @@ static const struct usb_device_id option_ids[] = {
1448 + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) },
1449 + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) },
1450 + { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
1451 ++ { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff), /* D-Link DWM-221 B1 */
1452 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1453 + { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
1454 + { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
1455 + { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */
1456 +diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
1457 +index 637ee7754ad5..546bb2b1ffc2 100644
1458 +--- a/drivers/usb/storage/uas.c
1459 ++++ b/drivers/usb/storage/uas.c
1460 +@@ -2,7 +2,7 @@
1461 + * USB Attached SCSI
1462 + * Note that this is not the same as the USB Mass Storage driver
1463 + *
1464 +- * Copyright Hans de Goede <hdegoede@××××××.com> for Red Hat, Inc. 2013 - 2014
1465 ++ * Copyright Hans de Goede <hdegoede@××××××.com> for Red Hat, Inc. 2013 - 2016
1466 + * Copyright Matthew Wilcox for Intel Corp, 2010
1467 + * Copyright Sarah Sharp for Intel Corp, 2010
1468 + *
1469 +@@ -757,6 +757,17 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd)
1470 + return SUCCESS;
1471 + }
1472 +
1473 ++static int uas_target_alloc(struct scsi_target *starget)
1474 ++{
1475 ++ struct uas_dev_info *devinfo = (struct uas_dev_info *)
1476 ++ dev_to_shost(starget->dev.parent)->hostdata;
1477 ++
1478 ++ if (devinfo->flags & US_FL_NO_REPORT_LUNS)
1479 ++ starget->no_report_luns = 1;
1480 ++
1481 ++ return 0;
1482 ++}
1483 ++
1484 + static int uas_slave_alloc(struct scsi_device *sdev)
1485 + {
1486 + struct uas_dev_info *devinfo =
1487 +@@ -808,6 +819,7 @@ static struct scsi_host_template uas_host_template = {
1488 + .module = THIS_MODULE,
1489 + .name = "uas",
1490 + .queuecommand = uas_queuecommand,
1491 ++ .target_alloc = uas_target_alloc,
1492 + .slave_alloc = uas_slave_alloc,
1493 + .slave_configure = uas_slave_configure,
1494 + .eh_abort_handler = uas_eh_abort_handler,
1495 +diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
1496 +index ccc113e83d88..53341a77d89f 100644
1497 +--- a/drivers/usb/storage/unusual_uas.h
1498 ++++ b/drivers/usb/storage/unusual_uas.h
1499 +@@ -64,6 +64,13 @@ UNUSUAL_DEV(0x0bc2, 0x3312, 0x0000, 0x9999,
1500 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1501 + US_FL_NO_ATA_1X),
1502 +
1503 ++/* Reported-by: David Webb <djw@××××××.uk> */
1504 ++UNUSUAL_DEV(0x0bc2, 0x331a, 0x0000, 0x9999,
1505 ++ "Seagate",
1506 ++ "Expansion Desk",
1507 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1508 ++ US_FL_NO_REPORT_LUNS),
1509 ++
1510 + /* Reported-by: Hans de Goede <hdegoede@××××××.com> */
1511 + UNUSUAL_DEV(0x0bc2, 0x3320, 0x0000, 0x9999,
1512 + "Seagate",
1513 +diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
1514 +index 6c10c888f35f..ba8f759e723f 100644
1515 +--- a/drivers/usb/storage/usb.c
1516 ++++ b/drivers/usb/storage/usb.c
1517 +@@ -480,7 +480,7 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
1518 + US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 |
1519 + US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE |
1520 + US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES |
1521 +- US_FL_MAX_SECTORS_240);
1522 ++ US_FL_MAX_SECTORS_240 | US_FL_NO_REPORT_LUNS);
1523 +
1524 + p = quirks;
1525 + while (*p) {
1526 +@@ -530,6 +530,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
1527 + case 'i':
1528 + f |= US_FL_IGNORE_DEVICE;
1529 + break;
1530 ++ case 'j':
1531 ++ f |= US_FL_NO_REPORT_LUNS;
1532 ++ break;
1533 + case 'l':
1534 + f |= US_FL_NOT_LOCKABLE;
1535 + break;
1536 +diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
1537 +index e88e0997a889..6652258048df 100644
1538 +--- a/drivers/virtio/virtio_pci_modern.c
1539 ++++ b/drivers/virtio/virtio_pci_modern.c
1540 +@@ -17,6 +17,7 @@
1541 + *
1542 + */
1543 +
1544 ++#include <linux/delay.h>
1545 + #define VIRTIO_PCI_NO_LEGACY
1546 + #include "virtio_pci_common.h"
1547 +
1548 +@@ -271,9 +272,13 @@ static void vp_reset(struct virtio_device *vdev)
1549 + struct virtio_pci_device *vp_dev = to_vp_device(vdev);
1550 + /* 0 status means a reset. */
1551 + vp_iowrite8(0, &vp_dev->common->device_status);
1552 +- /* Flush out the status write, and flush in device writes,
1553 +- * including MSI-X interrupts, if any. */
1554 +- vp_ioread8(&vp_dev->common->device_status);
1555 ++ /* After writing 0 to device_status, the driver MUST wait for a read of
1556 ++ * device_status to return 0 before reinitializing the device.
1557 ++ * This will flush out the status write, and flush in device writes,
1558 ++ * including MSI-X interrupts, if any.
1559 ++ */
1560 ++ while (vp_ioread8(&vp_dev->common->device_status))
1561 ++ msleep(1);
1562 + /* Flush pending VQ/configuration callbacks. */
1563 + vp_synchronize_vectors(vdev);
1564 + }
1565 +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
1566 +index 38387950490e..511aab3b9206 100644
1567 +--- a/drivers/xen/events/events_base.c
1568 ++++ b/drivers/xen/events/events_base.c
1569 +@@ -483,9 +483,19 @@ static void eoi_pirq(struct irq_data *data)
1570 + struct physdev_eoi eoi = { .irq = pirq_from_irq(data->irq) };
1571 + int rc = 0;
1572 +
1573 +- irq_move_irq(data);
1574 ++ if (!VALID_EVTCHN(evtchn))
1575 ++ return;
1576 +
1577 +- if (VALID_EVTCHN(evtchn))
1578 ++ if (unlikely(irqd_is_setaffinity_pending(data))) {
1579 ++ int masked = test_and_set_mask(evtchn);
1580 ++
1581 ++ clear_evtchn(evtchn);
1582 ++
1583 ++ irq_move_masked_irq(data);
1584 ++
1585 ++ if (!masked)
1586 ++ unmask_evtchn(evtchn);
1587 ++ } else
1588 + clear_evtchn(evtchn);
1589 +
1590 + if (pirq_needs_eoi(data->irq)) {
1591 +@@ -1360,9 +1370,19 @@ static void ack_dynirq(struct irq_data *data)
1592 + {
1593 + int evtchn = evtchn_from_irq(data->irq);
1594 +
1595 +- irq_move_irq(data);
1596 ++ if (!VALID_EVTCHN(evtchn))
1597 ++ return;
1598 +
1599 +- if (VALID_EVTCHN(evtchn))
1600 ++ if (unlikely(irqd_is_setaffinity_pending(data))) {
1601 ++ int masked = test_and_set_mask(evtchn);
1602 ++
1603 ++ clear_evtchn(evtchn);
1604 ++
1605 ++ irq_move_masked_irq(data);
1606 ++
1607 ++ if (!masked)
1608 ++ unmask_evtchn(evtchn);
1609 ++ } else
1610 + clear_evtchn(evtchn);
1611 + }
1612 +
1613 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
1614 +index 4920fceffacb..5c222f3c4841 100644
1615 +--- a/fs/btrfs/tree-log.c
1616 ++++ b/fs/btrfs/tree-log.c
1617 +@@ -4123,6 +4123,308 @@ static int logged_inode_size(struct btrfs_root *log, struct inode *inode,
1618 + return 0;
1619 + }
1620 +
1621 ++/*
1622 ++ * At the moment we always log all xattrs. This is to figure out at log replay
1623 ++ * time which xattrs must have their deletion replayed. If a xattr is missing
1624 ++ * in the log tree and exists in the fs/subvol tree, we delete it. This is
1625 ++ * because if a xattr is deleted, the inode is fsynced and a power failure
1626 ++ * happens, causing the log to be replayed the next time the fs is mounted,
1627 ++ * we want the xattr to not exist anymore (same behaviour as other filesystems
1628 ++ * with a journal, ext3/4, xfs, f2fs, etc).
1629 ++ */
1630 ++static int btrfs_log_all_xattrs(struct btrfs_trans_handle *trans,
1631 ++ struct btrfs_root *root,
1632 ++ struct inode *inode,
1633 ++ struct btrfs_path *path,
1634 ++ struct btrfs_path *dst_path)
1635 ++{
1636 ++ int ret;
1637 ++ struct btrfs_key key;
1638 ++ const u64 ino = btrfs_ino(inode);
1639 ++ int ins_nr = 0;
1640 ++ int start_slot = 0;
1641 ++
1642 ++ key.objectid = ino;
1643 ++ key.type = BTRFS_XATTR_ITEM_KEY;
1644 ++ key.offset = 0;
1645 ++
1646 ++ ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
1647 ++ if (ret < 0)
1648 ++ return ret;
1649 ++
1650 ++ while (true) {
1651 ++ int slot = path->slots[0];
1652 ++ struct extent_buffer *leaf = path->nodes[0];
1653 ++ int nritems = btrfs_header_nritems(leaf);
1654 ++
1655 ++ if (slot >= nritems) {
1656 ++ if (ins_nr > 0) {
1657 ++ u64 last_extent = 0;
1658 ++
1659 ++ ret = copy_items(trans, inode, dst_path, path,
1660 ++ &last_extent, start_slot,
1661 ++ ins_nr, 1, 0);
1662 ++ /* can't be 1, extent items aren't processed */
1663 ++ ASSERT(ret <= 0);
1664 ++ if (ret < 0)
1665 ++ return ret;
1666 ++ ins_nr = 0;
1667 ++ }
1668 ++ ret = btrfs_next_leaf(root, path);
1669 ++ if (ret < 0)
1670 ++ return ret;
1671 ++ else if (ret > 0)
1672 ++ break;
1673 ++ continue;
1674 ++ }
1675 ++
1676 ++ btrfs_item_key_to_cpu(leaf, &key, slot);
1677 ++ if (key.objectid != ino || key.type != BTRFS_XATTR_ITEM_KEY)
1678 ++ break;
1679 ++
1680 ++ if (ins_nr == 0)
1681 ++ start_slot = slot;
1682 ++ ins_nr++;
1683 ++ path->slots[0]++;
1684 ++ cond_resched();
1685 ++ }
1686 ++ if (ins_nr > 0) {
1687 ++ u64 last_extent = 0;
1688 ++
1689 ++ ret = copy_items(trans, inode, dst_path, path,
1690 ++ &last_extent, start_slot,
1691 ++ ins_nr, 1, 0);
1692 ++ /* can't be 1, extent items aren't processed */
1693 ++ ASSERT(ret <= 0);
1694 ++ if (ret < 0)
1695 ++ return ret;
1696 ++ }
1697 ++
1698 ++ return 0;
1699 ++}
1700 ++
1701 ++/*
1702 ++ * If the no holes feature is enabled we need to make sure any hole between the
1703 ++ * last extent and the i_size of our inode is explicitly marked in the log. This
1704 ++ * is to make sure that doing something like:
1705 ++ *
1706 ++ * 1) create file with 128Kb of data
1707 ++ * 2) truncate file to 64Kb
1708 ++ * 3) truncate file to 256Kb
1709 ++ * 4) fsync file
1710 ++ * 5) <crash/power failure>
1711 ++ * 6) mount fs and trigger log replay
1712 ++ *
1713 ++ * Will give us a file with a size of 256Kb, the first 64Kb of data match what
1714 ++ * the file had in its first 64Kb of data at step 1 and the last 192Kb of the
1715 ++ * file correspond to a hole. The presence of explicit holes in a log tree is
1716 ++ * what guarantees that log replay will remove/adjust file extent items in the
1717 ++ * fs/subvol tree.
1718 ++ *
1719 ++ * Here we do not need to care about holes between extents, that is already done
1720 ++ * by copy_items(). We also only need to do this in the full sync path, where we
1721 ++ * lookup for extents from the fs/subvol tree only. In the fast path case, we
1722 ++ * lookup the list of modified extent maps and if any represents a hole, we
1723 ++ * insert a corresponding extent representing a hole in the log tree.
1724 ++ */
1725 ++static int btrfs_log_trailing_hole(struct btrfs_trans_handle *trans,
1726 ++ struct btrfs_root *root,
1727 ++ struct inode *inode,
1728 ++ struct btrfs_path *path)
1729 ++{
1730 ++ int ret;
1731 ++ struct btrfs_key key;
1732 ++ u64 hole_start;
1733 ++ u64 hole_size;
1734 ++ struct extent_buffer *leaf;
1735 ++ struct btrfs_root *log = root->log_root;
1736 ++ const u64 ino = btrfs_ino(inode);
1737 ++ const u64 i_size = i_size_read(inode);
1738 ++
1739 ++ if (!btrfs_fs_incompat(root->fs_info, NO_HOLES))
1740 ++ return 0;
1741 ++
1742 ++ key.objectid = ino;
1743 ++ key.type = BTRFS_EXTENT_DATA_KEY;
1744 ++ key.offset = (u64)-1;
1745 ++
1746 ++ ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
1747 ++ ASSERT(ret != 0);
1748 ++ if (ret < 0)
1749 ++ return ret;
1750 ++
1751 ++ ASSERT(path->slots[0] > 0);
1752 ++ path->slots[0]--;
1753 ++ leaf = path->nodes[0];
1754 ++ btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
1755 ++
1756 ++ if (key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY) {
1757 ++ /* inode does not have any extents */
1758 ++ hole_start = 0;
1759 ++ hole_size = i_size;
1760 ++ } else {
1761 ++ struct btrfs_file_extent_item *extent;
1762 ++ u64 len;
1763 ++
1764 ++ /*
1765 ++ * If there's an extent beyond i_size, an explicit hole was
1766 ++ * already inserted by copy_items().
1767 ++ */
1768 ++ if (key.offset >= i_size)
1769 ++ return 0;
1770 ++
1771 ++ extent = btrfs_item_ptr(leaf, path->slots[0],
1772 ++ struct btrfs_file_extent_item);
1773 ++
1774 ++ if (btrfs_file_extent_type(leaf, extent) ==
1775 ++ BTRFS_FILE_EXTENT_INLINE) {
1776 ++ len = btrfs_file_extent_inline_len(leaf,
1777 ++ path->slots[0],
1778 ++ extent);
1779 ++ ASSERT(len == i_size);
1780 ++ return 0;
1781 ++ }
1782 ++
1783 ++ len = btrfs_file_extent_num_bytes(leaf, extent);
1784 ++ /* Last extent goes beyond i_size, no need to log a hole. */
1785 ++ if (key.offset + len > i_size)
1786 ++ return 0;
1787 ++ hole_start = key.offset + len;
1788 ++ hole_size = i_size - hole_start;
1789 ++ }
1790 ++ btrfs_release_path(path);
1791 ++
1792 ++ /* Last extent ends at i_size. */
1793 ++ if (hole_size == 0)
1794 ++ return 0;
1795 ++
1796 ++ hole_size = ALIGN(hole_size, root->sectorsize);
1797 ++ ret = btrfs_insert_file_extent(trans, log, ino, hole_start, 0, 0,
1798 ++ hole_size, 0, hole_size, 0, 0, 0);
1799 ++ return ret;
1800 ++}
1801 ++
1802 ++/*
1803 ++ * When we are logging a new inode X, check if it doesn't have a reference that
1804 ++ * matches the reference from some other inode Y created in a past transaction
1805 ++ * and that was renamed in the current transaction. If we don't do this, then at
1806 ++ * log replay time we can lose inode Y (and all its files if it's a directory):
1807 ++ *
1808 ++ * mkdir /mnt/x
1809 ++ * echo "hello world" > /mnt/x/foobar
1810 ++ * sync
1811 ++ * mv /mnt/x /mnt/y
1812 ++ * mkdir /mnt/x # or touch /mnt/x
1813 ++ * xfs_io -c fsync /mnt/x
1814 ++ * <power fail>
1815 ++ * mount fs, trigger log replay
1816 ++ *
1817 ++ * After the log replay procedure, we would lose the first directory and all its
1818 ++ * files (file foobar).
1819 ++ * For the case where inode Y is not a directory we simply end up losing it:
1820 ++ *
1821 ++ * echo "123" > /mnt/foo
1822 ++ * sync
1823 ++ * mv /mnt/foo /mnt/bar
1824 ++ * echo "abc" > /mnt/foo
1825 ++ * xfs_io -c fsync /mnt/foo
1826 ++ * <power fail>
1827 ++ *
1828 ++ * We also need this for cases where a snapshot entry is replaced by some other
1829 ++ * entry (file or directory) otherwise we end up with an unreplayable log due to
1830 ++ * attempts to delete the snapshot entry (entry of type BTRFS_ROOT_ITEM_KEY) as
1831 ++ * if it were a regular entry:
1832 ++ *
1833 ++ * mkdir /mnt/x
1834 ++ * btrfs subvolume snapshot /mnt /mnt/x/snap
1835 ++ * btrfs subvolume delete /mnt/x/snap
1836 ++ * rmdir /mnt/x
1837 ++ * mkdir /mnt/x
1838 ++ * fsync /mnt/x or fsync some new file inside it
1839 ++ * <power fail>
1840 ++ *
1841 ++ * The snapshot delete, rmdir of x, mkdir of a new x and the fsync all happen in
1842 ++ * the same transaction.
1843 ++ */
1844 ++static int btrfs_check_ref_name_override(struct extent_buffer *eb,
1845 ++ const int slot,
1846 ++ const struct btrfs_key *key,
1847 ++ struct inode *inode)
1848 ++{
1849 ++ int ret;
1850 ++ struct btrfs_path *search_path;
1851 ++ char *name = NULL;
1852 ++ u32 name_len = 0;
1853 ++ u32 item_size = btrfs_item_size_nr(eb, slot);
1854 ++ u32 cur_offset = 0;
1855 ++ unsigned long ptr = btrfs_item_ptr_offset(eb, slot);
1856 ++
1857 ++ search_path = btrfs_alloc_path();
1858 ++ if (!search_path)
1859 ++ return -ENOMEM;
1860 ++ search_path->search_commit_root = 1;
1861 ++ search_path->skip_locking = 1;
1862 ++
1863 ++ while (cur_offset < item_size) {
1864 ++ u64 parent;
1865 ++ u32 this_name_len;
1866 ++ u32 this_len;
1867 ++ unsigned long name_ptr;
1868 ++ struct btrfs_dir_item *di;
1869 ++
1870 ++ if (key->type == BTRFS_INODE_REF_KEY) {
1871 ++ struct btrfs_inode_ref *iref;
1872 ++
1873 ++ iref = (struct btrfs_inode_ref *)(ptr + cur_offset);
1874 ++ parent = key->offset;
1875 ++ this_name_len = btrfs_inode_ref_name_len(eb, iref);
1876 ++ name_ptr = (unsigned long)(iref + 1);
1877 ++ this_len = sizeof(*iref) + this_name_len;
1878 ++ } else {
1879 ++ struct btrfs_inode_extref *extref;
1880 ++
1881 ++ extref = (struct btrfs_inode_extref *)(ptr +
1882 ++ cur_offset);
1883 ++ parent = btrfs_inode_extref_parent(eb, extref);
1884 ++ this_name_len = btrfs_inode_extref_name_len(eb, extref);
1885 ++ name_ptr = (unsigned long)&extref->name;
1886 ++ this_len = sizeof(*extref) + this_name_len;
1887 ++ }
1888 ++
1889 ++ if (this_name_len > name_len) {
1890 ++ char *new_name;
1891 ++
1892 ++ new_name = krealloc(name, this_name_len, GFP_NOFS);
1893 ++ if (!new_name) {
1894 ++ ret = -ENOMEM;
1895 ++ goto out;
1896 ++ }
1897 ++ name_len = this_name_len;
1898 ++ name = new_name;
1899 ++ }
1900 ++
1901 ++ read_extent_buffer(eb, name, name_ptr, this_name_len);
1902 ++ di = btrfs_lookup_dir_item(NULL, BTRFS_I(inode)->root,
1903 ++ search_path, parent,
1904 ++ name, this_name_len, 0);
1905 ++ if (di && !IS_ERR(di)) {
1906 ++ ret = 1;
1907 ++ goto out;
1908 ++ } else if (IS_ERR(di)) {
1909 ++ ret = PTR_ERR(di);
1910 ++ goto out;
1911 ++ }
1912 ++ btrfs_release_path(search_path);
1913 ++
1914 ++ cur_offset += this_len;
1915 ++ }
1916 ++ ret = 0;
1917 ++out:
1918 ++ btrfs_free_path(search_path);
1919 ++ kfree(name);
1920 ++ return ret;
1921 ++}
1922 ++
1923 + /* log a single inode in the tree log.
1924 + * At least one parent directory for this inode must exist in the tree
1925 + * or be logged already.
1926 +@@ -4295,6 +4597,41 @@ again:
1927 + if (min_key.type == BTRFS_INODE_ITEM_KEY)
1928 + need_log_inode_item = false;
1929 +
1930 ++ if ((min_key.type == BTRFS_INODE_REF_KEY ||
1931 ++ min_key.type == BTRFS_INODE_EXTREF_KEY) &&
1932 ++ BTRFS_I(inode)->generation == trans->transid) {
1933 ++ ret = btrfs_check_ref_name_override(path->nodes[0],
1934 ++ path->slots[0],
1935 ++ &min_key, inode);
1936 ++ if (ret < 0) {
1937 ++ err = ret;
1938 ++ goto out_unlock;
1939 ++ } else if (ret > 0) {
1940 ++ err = 1;
1941 ++ btrfs_set_log_full_commit(root->fs_info, trans);
1942 ++ goto out_unlock;
1943 ++ }
1944 ++ }
1945 ++
1946 ++ /* Skip xattrs, we log them later with btrfs_log_all_xattrs() */
1947 ++ if (min_key.type == BTRFS_XATTR_ITEM_KEY) {
1948 ++ if (ins_nr == 0)
1949 ++ goto next_slot;
1950 ++ ret = copy_items(trans, inode, dst_path, path,
1951 ++ &last_extent, ins_start_slot,
1952 ++ ins_nr, inode_only, logged_isize);
1953 ++ if (ret < 0) {
1954 ++ err = ret;
1955 ++ goto out_unlock;
1956 ++ }
1957 ++ ins_nr = 0;
1958 ++ if (ret) {
1959 ++ btrfs_release_path(path);
1960 ++ continue;
1961 ++ }
1962 ++ goto next_slot;
1963 ++ }
1964 ++
1965 + src = path->nodes[0];
1966 + if (ins_nr && ins_start_slot + ins_nr == path->slots[0]) {
1967 + ins_nr++;
1968 +@@ -4362,6 +4699,18 @@ next_slot:
1969 + ins_nr = 0;
1970 + }
1971 +
1972 ++ btrfs_release_path(path);
1973 ++ btrfs_release_path(dst_path);
1974 ++ err = btrfs_log_all_xattrs(trans, root, inode, path, dst_path);
1975 ++ if (err)
1976 ++ goto out_unlock;
1977 ++ if (max_key.type >= BTRFS_EXTENT_DATA_KEY && !fast_search) {
1978 ++ btrfs_release_path(path);
1979 ++ btrfs_release_path(dst_path);
1980 ++ err = btrfs_log_trailing_hole(trans, root, inode, path);
1981 ++ if (err)
1982 ++ goto out_unlock;
1983 ++ }
1984 + log_extents:
1985 + btrfs_release_path(path);
1986 + btrfs_release_path(dst_path);
1987 +diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
1988 +index 8bec8f1e4b31..153c9a0db303 100644
1989 +--- a/fs/debugfs/inode.c
1990 ++++ b/fs/debugfs/inode.c
1991 +@@ -462,7 +462,7 @@ struct dentry *debugfs_create_automount(const char *name,
1992 + if (unlikely(!inode))
1993 + return failed_creating(dentry);
1994 +
1995 +- inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
1996 ++ make_empty_dir_inode(inode);
1997 + inode->i_flags |= S_AUTOMOUNT;
1998 + inode->i_private = data;
1999 + dentry->d_fsdata = (void *)f;
2000 +diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
2001 +index 95dfff88de11..15213a567301 100644
2002 +--- a/fs/ext4/ext4.h
2003 ++++ b/fs/ext4/ext4.h
2004 +@@ -813,6 +813,29 @@ do { \
2005 + #include "extents_status.h"
2006 +
2007 + /*
2008 ++ * Lock subclasses for i_data_sem in the ext4_inode_info structure.
2009 ++ *
2010 ++ * These are needed to avoid lockdep false positives when we need to
2011 ++ * allocate blocks to the quota inode during ext4_map_blocks(), while
2012 ++ * holding i_data_sem for a normal (non-quota) inode. Since we don't
2013 ++ * do quota tracking for the quota inode, this avoids deadlock (as
2014 ++ * well as infinite recursion, since it isn't turtles all the way
2015 ++ * down...)
2016 ++ *
2017 ++ * I_DATA_SEM_NORMAL - Used for most inodes
2018 ++ * I_DATA_SEM_OTHER - Used by move_inode.c for the second normal inode
2019 ++ * where the second inode has larger inode number
2020 ++ * than the first
2021 ++ * I_DATA_SEM_QUOTA - Used for quota inodes only
2022 ++ */
2023 ++enum {
2024 ++ I_DATA_SEM_NORMAL = 0,
2025 ++ I_DATA_SEM_OTHER,
2026 ++ I_DATA_SEM_QUOTA,
2027 ++};
2028 ++
2029 ++
2030 ++/*
2031 + * fourth extended file system inode data in memory
2032 + */
2033 + struct ext4_inode_info {
2034 +diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
2035 +index 3fb92abe5707..bd059e985485 100644
2036 +--- a/fs/ext4/move_extent.c
2037 ++++ b/fs/ext4/move_extent.c
2038 +@@ -60,10 +60,10 @@ ext4_double_down_write_data_sem(struct inode *first, struct inode *second)
2039 + {
2040 + if (first < second) {
2041 + down_write(&EXT4_I(first)->i_data_sem);
2042 +- down_write_nested(&EXT4_I(second)->i_data_sem, SINGLE_DEPTH_NESTING);
2043 ++ down_write_nested(&EXT4_I(second)->i_data_sem, I_DATA_SEM_OTHER);
2044 + } else {
2045 + down_write(&EXT4_I(second)->i_data_sem);
2046 +- down_write_nested(&EXT4_I(first)->i_data_sem, SINGLE_DEPTH_NESTING);
2047 ++ down_write_nested(&EXT4_I(first)->i_data_sem, I_DATA_SEM_OTHER);
2048 +
2049 + }
2050 + }
2051 +@@ -487,6 +487,13 @@ mext_check_arguments(struct inode *orig_inode,
2052 + return -EBUSY;
2053 + }
2054 +
2055 ++ if (IS_NOQUOTA(orig_inode) || IS_NOQUOTA(donor_inode)) {
2056 ++ ext4_debug("ext4 move extent: The argument files should "
2057 ++ "not be quota files [ino:orig %lu, donor %lu]\n",
2058 ++ orig_inode->i_ino, donor_inode->i_ino);
2059 ++ return -EBUSY;
2060 ++ }
2061 ++
2062 + /* Ext4 move extent supports only extent based file */
2063 + if (!(ext4_test_inode_flag(orig_inode, EXT4_INODE_EXTENTS))) {
2064 + ext4_debug("ext4 move extent: orig file is not extents "
2065 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
2066 +index 6f5ca3e92246..aedff7963468 100644
2067 +--- a/fs/ext4/super.c
2068 ++++ b/fs/ext4/super.c
2069 +@@ -1276,9 +1276,9 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
2070 + return -1;
2071 + }
2072 + if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) {
2073 +- ext4_msg(sb, KERN_ERR, "Cannot set journaled quota options "
2074 +- "when QUOTA feature is enabled");
2075 +- return -1;
2076 ++ ext4_msg(sb, KERN_INFO, "Journaled quota options "
2077 ++ "ignored when QUOTA feature is enabled");
2078 ++ return 1;
2079 + }
2080 + qname = match_strdup(args);
2081 + if (!qname) {
2082 +@@ -1636,10 +1636,10 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
2083 + }
2084 + if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
2085 + EXT4_FEATURE_RO_COMPAT_QUOTA)) {
2086 +- ext4_msg(sb, KERN_ERR,
2087 +- "Cannot set journaled quota options "
2088 ++ ext4_msg(sb, KERN_INFO,
2089 ++ "Quota format mount options ignored "
2090 + "when QUOTA feature is enabled");
2091 +- return -1;
2092 ++ return 1;
2093 + }
2094 + sbi->s_jquota_fmt = m->mount_opt;
2095 + #endif
2096 +@@ -1696,11 +1696,11 @@ static int parse_options(char *options, struct super_block *sb,
2097 + #ifdef CONFIG_QUOTA
2098 + if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) &&
2099 + (test_opt(sb, USRQUOTA) || test_opt(sb, GRPQUOTA))) {
2100 +- ext4_msg(sb, KERN_ERR, "Cannot set quota options when QUOTA "
2101 +- "feature is enabled");
2102 +- return 0;
2103 +- }
2104 +- if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
2105 ++ ext4_msg(sb, KERN_INFO, "Quota feature enabled, usrquota and grpquota "
2106 ++ "mount options ignored.");
2107 ++ clear_opt(sb, USRQUOTA);
2108 ++ clear_opt(sb, GRPQUOTA);
2109 ++ } else if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
2110 + if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA])
2111 + clear_opt(sb, USRQUOTA);
2112 +
2113 +@@ -5272,6 +5272,20 @@ static int ext4_quota_on_mount(struct super_block *sb, int type)
2114 + EXT4_SB(sb)->s_jquota_fmt, type);
2115 + }
2116 +
2117 ++static void lockdep_set_quota_inode(struct inode *inode, int subclass)
2118 ++{
2119 ++ struct ext4_inode_info *ei = EXT4_I(inode);
2120 ++
2121 ++ /* The first argument of lockdep_set_subclass has to be
2122 ++ * *exactly* the same as the argument to init_rwsem() --- in
2123 ++ * this case, in init_once() --- or lockdep gets unhappy
2124 ++ * because the name of the lock is set using the
2125 ++ * stringification of the argument to init_rwsem().
2126 ++ */
2127 ++ (void) ei; /* shut up clang warning if !CONFIG_LOCKDEP */
2128 ++ lockdep_set_subclass(&ei->i_data_sem, subclass);
2129 ++}
2130 ++
2131 + /*
2132 + * Standard function to be called on quota_on
2133 + */
2134 +@@ -5311,8 +5325,12 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
2135 + if (err)
2136 + return err;
2137 + }
2138 +-
2139 +- return dquot_quota_on(sb, type, format_id, path);
2140 ++ lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA);
2141 ++ err = dquot_quota_on(sb, type, format_id, path);
2142 ++ if (err)
2143 ++ lockdep_set_quota_inode(path->dentry->d_inode,
2144 ++ I_DATA_SEM_NORMAL);
2145 ++ return err;
2146 + }
2147 +
2148 + static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
2149 +@@ -5338,8 +5356,11 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
2150 +
2151 + /* Don't account quota for quota files to avoid recursion */
2152 + qf_inode->i_flags |= S_NOQUOTA;
2153 ++ lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA);
2154 + err = dquot_enable(qf_inode, type, format_id, flags);
2155 + iput(qf_inode);
2156 ++ if (err)
2157 ++ lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL);
2158 +
2159 + return err;
2160 + }
2161 +diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
2162 +index 371e560d13cf..27fa57322550 100644
2163 +--- a/include/linux/compiler-gcc.h
2164 ++++ b/include/linux/compiler-gcc.h
2165 +@@ -115,10 +115,122 @@
2166 + #define __maybe_unused __attribute__((unused))
2167 + #define __always_unused __attribute__((unused))
2168 +
2169 +-#define __gcc_header(x) #x
2170 +-#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
2171 +-#define gcc_header(x) _gcc_header(x)
2172 +-#include gcc_header(__GNUC__)
2173 ++/* gcc version specific checks */
2174 ++
2175 ++#if GCC_VERSION < 30200
2176 ++# error Sorry, your compiler is too old - please upgrade it.
2177 ++#endif
2178 ++
2179 ++#if GCC_VERSION < 30300
2180 ++# define __used __attribute__((__unused__))
2181 ++#else
2182 ++# define __used __attribute__((__used__))
2183 ++#endif
2184 ++
2185 ++#ifdef CONFIG_GCOV_KERNEL
2186 ++# if GCC_VERSION < 30400
2187 ++# error "GCOV profiling support for gcc versions below 3.4 not included"
2188 ++# endif /* __GNUC_MINOR__ */
2189 ++#endif /* CONFIG_GCOV_KERNEL */
2190 ++
2191 ++#if GCC_VERSION >= 30400
2192 ++#define __must_check __attribute__((warn_unused_result))
2193 ++#endif
2194 ++
2195 ++#if GCC_VERSION >= 40000
2196 ++
2197 ++/* GCC 4.1.[01] miscompiles __weak */
2198 ++#ifdef __KERNEL__
2199 ++# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
2200 ++# error Your version of gcc miscompiles the __weak directive
2201 ++# endif
2202 ++#endif
2203 ++
2204 ++#define __used __attribute__((__used__))
2205 ++#define __compiler_offsetof(a, b) \
2206 ++ __builtin_offsetof(a, b)
2207 ++
2208 ++#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
2209 ++# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
2210 ++#endif
2211 ++
2212 ++#if GCC_VERSION >= 40300
2213 ++/* Mark functions as cold. gcc will assume any path leading to a call
2214 ++ * to them will be unlikely. This means a lot of manual unlikely()s
2215 ++ * are unnecessary now for any paths leading to the usual suspects
2216 ++ * like BUG(), printk(), panic() etc. [but let's keep them for now for
2217 ++ * older compilers]
2218 ++ *
2219 ++ * Early snapshots of gcc 4.3 don't support this and we can't detect this
2220 ++ * in the preprocessor, but we can live with this because they're unreleased.
2221 ++ * Maketime probing would be overkill here.
2222 ++ *
2223 ++ * gcc also has a __attribute__((__hot__)) to move hot functions into
2224 ++ * a special section, but I don't see any sense in this right now in
2225 ++ * the kernel context
2226 ++ */
2227 ++#define __cold __attribute__((__cold__))
2228 ++
2229 ++#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
2230 ++
2231 ++#ifndef __CHECKER__
2232 ++# define __compiletime_warning(message) __attribute__((warning(message)))
2233 ++# define __compiletime_error(message) __attribute__((error(message)))
2234 ++#endif /* __CHECKER__ */
2235 ++#endif /* GCC_VERSION >= 40300 */
2236 ++
2237 ++#if GCC_VERSION >= 40500
2238 ++/*
2239 ++ * Mark a position in code as unreachable. This can be used to
2240 ++ * suppress control flow warnings after asm blocks that transfer
2241 ++ * control elsewhere.
2242 ++ *
2243 ++ * Early snapshots of gcc 4.5 don't support this and we can't detect
2244 ++ * this in the preprocessor, but we can live with this because they're
2245 ++ * unreleased. Really, we need to have autoconf for the kernel.
2246 ++ */
2247 ++#define unreachable() __builtin_unreachable()
2248 ++
2249 ++/* Mark a function definition as prohibited from being cloned. */
2250 ++#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
2251 ++
2252 ++#endif /* GCC_VERSION >= 40500 */
2253 ++
2254 ++#if GCC_VERSION >= 40600
2255 ++/*
2256 ++ * Tell the optimizer that something else uses this function or variable.
2257 ++ */
2258 ++#define __visible __attribute__((externally_visible))
2259 ++#endif
2260 ++
2261 ++/*
2262 ++ * GCC 'asm goto' miscompiles certain code sequences:
2263 ++ *
2264 ++ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
2265 ++ *
2266 ++ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
2267 ++ *
2268 ++ * (asm goto is automatically volatile - the naming reflects this.)
2269 ++ */
2270 ++#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
2271 ++
2272 ++#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
2273 ++#if GCC_VERSION >= 40400
2274 ++#define __HAVE_BUILTIN_BSWAP32__
2275 ++#define __HAVE_BUILTIN_BSWAP64__
2276 ++#endif
2277 ++#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
2278 ++#define __HAVE_BUILTIN_BSWAP16__
2279 ++#endif
2280 ++#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
2281 ++
2282 ++#if GCC_VERSION >= 50000
2283 ++#define KASAN_ABI_VERSION 4
2284 ++#elif GCC_VERSION >= 40902
2285 ++#define KASAN_ABI_VERSION 3
2286 ++#endif
2287 ++
2288 ++#endif /* gcc version >= 40000 specific checks */
2289 +
2290 + #if !defined(__noclone)
2291 + #define __noclone /* not needed */
2292 +diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
2293 +deleted file mode 100644
2294 +index 7d89febe4d79..000000000000
2295 +--- a/include/linux/compiler-gcc3.h
2296 ++++ /dev/null
2297 +@@ -1,23 +0,0 @@
2298 +-#ifndef __LINUX_COMPILER_H
2299 +-#error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead."
2300 +-#endif
2301 +-
2302 +-#if GCC_VERSION < 30200
2303 +-# error Sorry, your compiler is too old - please upgrade it.
2304 +-#endif
2305 +-
2306 +-#if GCC_VERSION >= 30300
2307 +-# define __used __attribute__((__used__))
2308 +-#else
2309 +-# define __used __attribute__((__unused__))
2310 +-#endif
2311 +-
2312 +-#if GCC_VERSION >= 30400
2313 +-#define __must_check __attribute__((warn_unused_result))
2314 +-#endif
2315 +-
2316 +-#ifdef CONFIG_GCOV_KERNEL
2317 +-# if GCC_VERSION < 30400
2318 +-# error "GCOV profiling support for gcc versions below 3.4 not included"
2319 +-# endif /* __GNUC_MINOR__ */
2320 +-#endif /* CONFIG_GCOV_KERNEL */
2321 +diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
2322 +deleted file mode 100644
2323 +index 769e19864632..000000000000
2324 +--- a/include/linux/compiler-gcc4.h
2325 ++++ /dev/null
2326 +@@ -1,91 +0,0 @@
2327 +-#ifndef __LINUX_COMPILER_H
2328 +-#error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead."
2329 +-#endif
2330 +-
2331 +-/* GCC 4.1.[01] miscompiles __weak */
2332 +-#ifdef __KERNEL__
2333 +-# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
2334 +-# error Your version of gcc miscompiles the __weak directive
2335 +-# endif
2336 +-#endif
2337 +-
2338 +-#define __used __attribute__((__used__))
2339 +-#define __must_check __attribute__((warn_unused_result))
2340 +-#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
2341 +-
2342 +-#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
2343 +-# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
2344 +-#endif
2345 +-
2346 +-#if GCC_VERSION >= 40300
2347 +-/* Mark functions as cold. gcc will assume any path leading to a call
2348 +- to them will be unlikely. This means a lot of manual unlikely()s
2349 +- are unnecessary now for any paths leading to the usual suspects
2350 +- like BUG(), printk(), panic() etc. [but let's keep them for now for
2351 +- older compilers]
2352 +-
2353 +- Early snapshots of gcc 4.3 don't support this and we can't detect this
2354 +- in the preprocessor, but we can live with this because they're unreleased.
2355 +- Maketime probing would be overkill here.
2356 +-
2357 +- gcc also has a __attribute__((__hot__)) to move hot functions into
2358 +- a special section, but I don't see any sense in this right now in
2359 +- the kernel context */
2360 +-#define __cold __attribute__((__cold__))
2361 +-
2362 +-#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
2363 +-
2364 +-#ifndef __CHECKER__
2365 +-# define __compiletime_warning(message) __attribute__((warning(message)))
2366 +-# define __compiletime_error(message) __attribute__((error(message)))
2367 +-#endif /* __CHECKER__ */
2368 +-#endif /* GCC_VERSION >= 40300 */
2369 +-
2370 +-#if GCC_VERSION >= 40500
2371 +-/*
2372 +- * Mark a position in code as unreachable. This can be used to
2373 +- * suppress control flow warnings after asm blocks that transfer
2374 +- * control elsewhere.
2375 +- *
2376 +- * Early snapshots of gcc 4.5 don't support this and we can't detect
2377 +- * this in the preprocessor, but we can live with this because they're
2378 +- * unreleased. Really, we need to have autoconf for the kernel.
2379 +- */
2380 +-#define unreachable() __builtin_unreachable()
2381 +-
2382 +-/* Mark a function definition as prohibited from being cloned. */
2383 +-#define __noclone __attribute__((__noclone__))
2384 +-
2385 +-#endif /* GCC_VERSION >= 40500 */
2386 +-
2387 +-#if GCC_VERSION >= 40600
2388 +-/*
2389 +- * Tell the optimizer that something else uses this function or variable.
2390 +- */
2391 +-#define __visible __attribute__((externally_visible))
2392 +-#endif
2393 +-
2394 +-/*
2395 +- * GCC 'asm goto' miscompiles certain code sequences:
2396 +- *
2397 +- * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
2398 +- *
2399 +- * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
2400 +- *
2401 +- * (asm goto is automatically volatile - the naming reflects this.)
2402 +- */
2403 +-#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
2404 +-
2405 +-#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
2406 +-#if GCC_VERSION >= 40400
2407 +-#define __HAVE_BUILTIN_BSWAP32__
2408 +-#define __HAVE_BUILTIN_BSWAP64__
2409 +-#endif
2410 +-#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
2411 +-#define __HAVE_BUILTIN_BSWAP16__
2412 +-#endif
2413 +-#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
2414 +-
2415 +-#if GCC_VERSION >= 40902
2416 +-#define KASAN_ABI_VERSION 3
2417 +-#endif
2418 +diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
2419 +deleted file mode 100644
2420 +index efee493714eb..000000000000
2421 +--- a/include/linux/compiler-gcc5.h
2422 ++++ /dev/null
2423 +@@ -1,67 +0,0 @@
2424 +-#ifndef __LINUX_COMPILER_H
2425 +-#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
2426 +-#endif
2427 +-
2428 +-#define __used __attribute__((__used__))
2429 +-#define __must_check __attribute__((warn_unused_result))
2430 +-#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
2431 +-
2432 +-/* Mark functions as cold. gcc will assume any path leading to a call
2433 +- to them will be unlikely. This means a lot of manual unlikely()s
2434 +- are unnecessary now for any paths leading to the usual suspects
2435 +- like BUG(), printk(), panic() etc. [but let's keep them for now for
2436 +- older compilers]
2437 +-
2438 +- Early snapshots of gcc 4.3 don't support this and we can't detect this
2439 +- in the preprocessor, but we can live with this because they're unreleased.
2440 +- Maketime probing would be overkill here.
2441 +-
2442 +- gcc also has a __attribute__((__hot__)) to move hot functions into
2443 +- a special section, but I don't see any sense in this right now in
2444 +- the kernel context */
2445 +-#define __cold __attribute__((__cold__))
2446 +-
2447 +-#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
2448 +-
2449 +-#ifndef __CHECKER__
2450 +-# define __compiletime_warning(message) __attribute__((warning(message)))
2451 +-# define __compiletime_error(message) __attribute__((error(message)))
2452 +-#endif /* __CHECKER__ */
2453 +-
2454 +-/*
2455 +- * Mark a position in code as unreachable. This can be used to
2456 +- * suppress control flow warnings after asm blocks that transfer
2457 +- * control elsewhere.
2458 +- *
2459 +- * Early snapshots of gcc 4.5 don't support this and we can't detect
2460 +- * this in the preprocessor, but we can live with this because they're
2461 +- * unreleased. Really, we need to have autoconf for the kernel.
2462 +- */
2463 +-#define unreachable() __builtin_unreachable()
2464 +-
2465 +-/* Mark a function definition as prohibited from being cloned. */
2466 +-#define __noclone __attribute__((__noclone__))
2467 +-
2468 +-/*
2469 +- * Tell the optimizer that something else uses this function or variable.
2470 +- */
2471 +-#define __visible __attribute__((externally_visible))
2472 +-
2473 +-/*
2474 +- * GCC 'asm goto' miscompiles certain code sequences:
2475 +- *
2476 +- * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
2477 +- *
2478 +- * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
2479 +- *
2480 +- * (asm goto is automatically volatile - the naming reflects this.)
2481 +- */
2482 +-#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
2483 +-
2484 +-#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
2485 +-#define __HAVE_BUILTIN_BSWAP32__
2486 +-#define __HAVE_BUILTIN_BSWAP64__
2487 +-#define __HAVE_BUILTIN_BSWAP16__
2488 +-#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
2489 +-
2490 +-#define KASAN_ABI_VERSION 4
2491 +diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
2492 +index 7f5f78bd15ad..245f57dbbb61 100644
2493 +--- a/include/linux/usb_usual.h
2494 ++++ b/include/linux/usb_usual.h
2495 +@@ -79,6 +79,8 @@
2496 + /* Cannot handle MI_REPORT_SUPPORTED_OPERATION_CODES */ \
2497 + US_FLAG(MAX_SECTORS_240, 0x08000000) \
2498 + /* Sets max_sectors to 240 */ \
2499 ++ US_FLAG(NO_REPORT_LUNS, 0x10000000) \
2500 ++ /* Cannot handle REPORT_LUNS */ \
2501 +
2502 + #define US_FLAG(name, value) US_FL_##name = value ,
2503 + enum { US_DO_ALL_FLAGS };
2504 +diff --git a/lib/assoc_array.c b/lib/assoc_array.c
2505 +index 03dd576e6773..59fd7c0b119c 100644
2506 +--- a/lib/assoc_array.c
2507 ++++ b/lib/assoc_array.c
2508 +@@ -524,7 +524,9 @@ static bool assoc_array_insert_into_terminal_node(struct assoc_array_edit *edit,
2509 + free_slot = i;
2510 + continue;
2511 + }
2512 +- if (ops->compare_object(assoc_array_ptr_to_leaf(ptr), index_key)) {
2513 ++ if (assoc_array_ptr_is_leaf(ptr) &&
2514 ++ ops->compare_object(assoc_array_ptr_to_leaf(ptr),
2515 ++ index_key)) {
2516 + pr_devel("replace in slot %d\n", i);
2517 + edit->leaf_p = &node->slots[i];
2518 + edit->dead_leaf = node->slots[i];
2519 +diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
2520 +index abcecdc2d0f2..0710a62ad2f6 100644
2521 +--- a/lib/lz4/lz4defs.h
2522 ++++ b/lib/lz4/lz4defs.h
2523 +@@ -11,8 +11,7 @@
2524 + /*
2525 + * Detects 64 bits mode
2526 + */
2527 +-#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \
2528 +- || defined(__ppc64__) || defined(__LP64__))
2529 ++#if defined(CONFIG_64BIT)
2530 + #define LZ4_ARCH64 1
2531 + #else
2532 + #define LZ4_ARCH64 0
2533 +@@ -35,6 +34,10 @@ typedef struct _U64_S { u64 v; } U64_S;
2534 +
2535 + #define PUT4(s, d) (A32(d) = A32(s))
2536 + #define PUT8(s, d) (A64(d) = A64(s))
2537 ++
2538 ++#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
2539 ++ (d = s - A16(p))
2540 ++
2541 + #define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
2542 + do { \
2543 + A16(p) = v; \
2544 +@@ -51,10 +54,13 @@ typedef struct _U64_S { u64 v; } U64_S;
2545 + #define PUT8(s, d) \
2546 + put_unaligned(get_unaligned((const u64 *) s), (u64 *) d)
2547 +
2548 +-#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
2549 +- do { \
2550 +- put_unaligned(v, (u16 *)(p)); \
2551 +- p += 2; \
2552 ++#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
2553 ++ (d = s - get_unaligned_le16(p))
2554 ++
2555 ++#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
2556 ++ do { \
2557 ++ put_unaligned_le16(v, (u16 *)(p)); \
2558 ++ p += 2; \
2559 + } while (0)
2560 + #endif
2561 +
2562 +@@ -140,9 +146,6 @@ typedef struct _U64_S { u64 v; } U64_S;
2563 +
2564 + #endif
2565 +
2566 +-#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
2567 +- (d = s - get_unaligned_le16(p))
2568 +-
2569 + #define LZ4_WILDCOPY(s, d, e) \
2570 + do { \
2571 + LZ4_COPYPACKET(s, d); \
2572 +diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
2573 +index 06d3d665a9fd..3ce0b861cc0e 100644
2574 +--- a/net/ipv4/tcp_cubic.c
2575 ++++ b/net/ipv4/tcp_cubic.c
2576 +@@ -151,6 +151,27 @@ static void bictcp_init(struct sock *sk)
2577 + tcp_sk(sk)->snd_ssthresh = initial_ssthresh;
2578 + }
2579 +
2580 ++static void bictcp_cwnd_event(struct sock *sk, enum tcp_ca_event event)
2581 ++{
2582 ++ if (event == CA_EVENT_TX_START) {
2583 ++ struct bictcp *ca = inet_csk_ca(sk);
2584 ++ u32 now = tcp_time_stamp;
2585 ++ s32 delta;
2586 ++
2587 ++ delta = now - tcp_sk(sk)->lsndtime;
2588 ++
2589 ++ /* We were application limited (idle) for a while.
2590 ++ * Shift epoch_start to keep cwnd growth to cubic curve.
2591 ++ */
2592 ++ if (ca->epoch_start && delta > 0) {
2593 ++ ca->epoch_start += delta;
2594 ++ if (after(ca->epoch_start, now))
2595 ++ ca->epoch_start = now;
2596 ++ }
2597 ++ return;
2598 ++ }
2599 ++}
2600 ++
2601 + /* calculate the cubic root of x using a table lookup followed by one
2602 + * Newton-Raphson iteration.
2603 + * Avg err ~= 0.195%
2604 +@@ -450,6 +471,7 @@ static struct tcp_congestion_ops cubictcp __read_mostly = {
2605 + .cong_avoid = bictcp_cong_avoid,
2606 + .set_state = bictcp_state,
2607 + .undo_cwnd = bictcp_undo_cwnd,
2608 ++ .cwnd_event = bictcp_cwnd_event,
2609 + .pkts_acked = bictcp_acked,
2610 + .owner = THIS_MODULE,
2611 + .name = "cubic",
2612 +diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
2613 +index 2880f2ae99ab..a7027190f298 100644
2614 +--- a/net/mac80211/sta_info.c
2615 ++++ b/net/mac80211/sta_info.c
2616 +@@ -252,11 +252,11 @@ void sta_info_free(struct ieee80211_local *local, struct sta_info *sta)
2617 + }
2618 +
2619 + /* Caller must hold local->sta_mtx */
2620 +-static void sta_info_hash_add(struct ieee80211_local *local,
2621 +- struct sta_info *sta)
2622 ++static int sta_info_hash_add(struct ieee80211_local *local,
2623 ++ struct sta_info *sta)
2624 + {
2625 +- rhashtable_insert_fast(&local->sta_hash, &sta->hash_node,
2626 +- sta_rht_params);
2627 ++ return rhashtable_insert_fast(&local->sta_hash, &sta->hash_node,
2628 ++ sta_rht_params);
2629 + }
2630 +
2631 + static void sta_deliver_ps_frames(struct work_struct *wk)
2632 +@@ -491,7 +491,9 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
2633 + set_sta_flag(sta, WLAN_STA_BLOCK_BA);
2634 +
2635 + /* make the station visible */
2636 +- sta_info_hash_add(local, sta);
2637 ++ err = sta_info_hash_add(local, sta);
2638 ++ if (err)
2639 ++ goto out_drop_sta;
2640 +
2641 + list_add_tail_rcu(&sta->list, &local->sta_list);
2642 +
2643 +@@ -526,6 +528,7 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
2644 + out_remove:
2645 + sta_info_hash_del(local, sta);
2646 + list_del_rcu(&sta->list);
2647 ++ out_drop_sta:
2648 + local->num_sta--;
2649 + synchronize_net();
2650 + __cleanup_single_sta(sta);
2651 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
2652 +index 90cf6168267e..cc1a7a4a7cbd 100644
2653 +--- a/sound/pci/hda/patch_realtek.c
2654 ++++ b/sound/pci/hda/patch_realtek.c
2655 +@@ -4638,6 +4638,8 @@ enum {
2656 + ALC255_FIXUP_DELL_SPK_NOISE,
2657 + ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
2658 + ALC280_FIXUP_HP_HEADSET_MIC,
2659 ++ ALC221_FIXUP_HP_FRONT_MIC,
2660 ++ ALC292_FIXUP_TPT460,
2661 + };
2662 +
2663 + static const struct hda_fixup alc269_fixups[] = {
2664 +@@ -5270,6 +5272,19 @@ static const struct hda_fixup alc269_fixups[] = {
2665 + .chained = true,
2666 + .chain_id = ALC269_FIXUP_HEADSET_MIC,
2667 + },
2668 ++ [ALC221_FIXUP_HP_FRONT_MIC] = {
2669 ++ .type = HDA_FIXUP_PINS,
2670 ++ .v.pins = (const struct hda_pintbl[]) {
2671 ++ { 0x19, 0x02a19020 }, /* Front Mic */
2672 ++ { }
2673 ++ },
2674 ++ },
2675 ++ [ALC292_FIXUP_TPT460] = {
2676 ++ .type = HDA_FIXUP_FUNC,
2677 ++ .v.func = alc_fixup_tpt440_dock,
2678 ++ .chained = true,
2679 ++ .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
2680 ++ },
2681 + };
2682 +
2683 + static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2684 +@@ -5374,6 +5389,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2685 + SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
2686 + SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
2687 + SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
2688 ++ SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
2689 + SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
2690 + SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
2691 + SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
2692 +@@ -5421,7 +5437,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2693 + SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
2694 + SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
2695 + SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
2696 +- SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
2697 ++ SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
2698 + SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
2699 + SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
2700 + SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
2701 +@@ -5514,6 +5530,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
2702 + {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
2703 + {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
2704 + {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
2705 ++ {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
2706 + {}
2707 + };
2708 + #define ALC225_STANDARD_PINS \
2709 +diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c
2710 +index ddca6547399b..1f8fb0d904e0 100644
2711 +--- a/sound/usb/mixer_maps.c
2712 ++++ b/sound/usb/mixer_maps.c
2713 +@@ -349,6 +349,16 @@ static struct usbmix_name_map bose_companion5_map[] = {
2714 + };
2715 +
2716 + /*
2717 ++ * Dell usb dock with ALC4020 codec had a firmware problem where it got
2718 ++ * screwed up when zero volume is passed; just skip it as a workaround
2719 ++ */
2720 ++static const struct usbmix_name_map dell_alc4020_map[] = {
2721 ++ { 16, NULL },
2722 ++ { 19, NULL },
2723 ++ { 0 }
2724 ++};
2725 ++
2726 ++/*
2727 + * Control map entries
2728 + */
2729 +
2730 +@@ -431,6 +441,10 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
2731 + .map = aureon_51_2_map,
2732 + },
2733 + {
2734 ++ .id = USB_ID(0x0bda, 0x4014),
2735 ++ .map = dell_alc4020_map,
2736 ++ },
2737 ++ {
2738 + .id = USB_ID(0x0dba, 0x1000),
2739 + .map = mbox1_map,
2740 + },
2741 +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
2742 +index 5fb308d39e2a..5ad43cba860c 100644
2743 +--- a/sound/usb/quirks.c
2744 ++++ b/sound/usb/quirks.c
2745 +@@ -1128,9 +1128,11 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
2746 + case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */
2747 + case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */
2748 + case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */
2749 ++ case USB_ID(0x047F, 0x0415): /* Plantronics BT-300 */
2750 + case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */
2751 + case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
2752 + case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
2753 ++ case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */
2754 + case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */
2755 + return true;
2756 + }