Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:3.15 commit in: /
Date: Wed, 09 Jul 2014 23:30:48
Message-Id: 1404948634.215078c1f4dac8d746a0e323a968cdd7cc571527.mpagano@gentoo
1 commit: 215078c1f4dac8d746a0e323a968cdd7cc571527
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 9 23:30:34 2014 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 9 23:30:34 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/linux-patches.git;a=commit;h=215078c1
7
8 Linux patch 3.15.5. Removal of redundant patch
9
10 ---
11 0000_README | 8 +-
12 1004_linux-3.15.5.patch | 3987 +++++++++++++++++++++++++++++++++++++++++++++
13 2405_G-PHY-freq-fix.patch | 19 -
14 3 files changed, 3991 insertions(+), 23 deletions(-)
15
16 diff --git a/0000_README b/0000_README
17 index be75984..03708fb 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -59,6 +59,10 @@ Patch: 1003_linux-3.15.4.patch
21 From: http://www.kernel.org
22 Desc: Linux 3.15.4
23
24 +Patch: 1004_linux-3.15.5.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 3.15.5
27 +
28 Patch: 1700_enable-thinkpad-micled.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=449248
30 Desc: Enable mic mute led in thinkpads
31 @@ -67,10 +71,6 @@ Patch: 2400_kcopy-patch-for-infiniband-driver.patch
32 From: Alexey Shvetsov <alexxy@g.o>
33 Desc: Zero copy for infiniband psm userspace driver
34
35 -Patch: 2405_G-PHY-freq-fix.patch
36 -From: https://bugs.gentoo.org/show_bug.cgi?id=516392
37 -Desc: b43: fix frequency reported on G-PHY with /new/ firmware
38 -
39 Patch: 2700_ThinkPad-30-brightness-control-fix.patch
40 From: Seth Forshee <seth.forshee@×××××××××.com>
41 Desc: ACPI: Disable Windows 8 compatibility for some Lenovo ThinkPads
42
43 diff --git a/1004_linux-3.15.5.patch b/1004_linux-3.15.5.patch
44 new file mode 100644
45 index 0000000..4d06501
46 --- /dev/null
47 +++ b/1004_linux-3.15.5.patch
48 @@ -0,0 +1,3987 @@
49 +diff --git a/Documentation/devicetree/bindings/arm/armada-38x.txt b/Documentation/devicetree/bindings/arm/armada-38x.txt
50 +index 11f2330a6554..ad9f8ed4d9bd 100644
51 +--- a/Documentation/devicetree/bindings/arm/armada-38x.txt
52 ++++ b/Documentation/devicetree/bindings/arm/armada-38x.txt
53 +@@ -6,5 +6,15 @@ following property:
54 +
55 + Required root node property:
56 +
57 +- - compatible: must contain either "marvell,armada380" or
58 +- "marvell,armada385" depending on the variant of the SoC being used.
59 ++ - compatible: must contain "marvell,armada380"
60 ++
61 ++In addition, boards using the Marvell Armada 385 SoC shall have the
62 ++following property before the previous one:
63 ++
64 ++Required root node property:
65 ++
66 ++compatible: must contain "marvell,armada385"
67 ++
68 ++Example:
69 ++
70 ++compatible = "marvell,a385-rd", "marvell,armada385", "marvell,armada380";
71 +diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt
72 +index dd9d0e33b443..d3e6d844fa14 100644
73 +--- a/Documentation/sysctl/vm.txt
74 ++++ b/Documentation/sysctl/vm.txt
75 +@@ -702,7 +702,8 @@ The batch value of each per cpu pagelist is also updated as a result. It is
76 + set to pcp->high/4. The upper limit of batch is (PAGE_SHIFT * 8)
77 +
78 + The initial value is zero. Kernel does not use this value at boot time to set
79 +-the high water marks for each per cpu page list.
80 ++the high water marks for each per cpu page list. If the user writes '0' to this
81 ++sysctl, it will revert to this default behavior.
82 +
83 + ==============================================================
84 +
85 +diff --git a/Makefile b/Makefile
86 +index 25ecc1dd5bb5..e6b01ed8fd9f 100644
87 +--- a/Makefile
88 ++++ b/Makefile
89 +@@ -1,6 +1,6 @@
90 + VERSION = 3
91 + PATCHLEVEL = 15
92 +-SUBLEVEL = 4
93 ++SUBLEVEL = 5
94 + EXTRAVERSION =
95 + NAME = Shuffling Zombie Juror
96 +
97 +diff --git a/arch/arc/kernel/ctx_sw_asm.S b/arch/arc/kernel/ctx_sw_asm.S
98 +index 2ff0347a2fd7..e248594097e7 100644
99 +--- a/arch/arc/kernel/ctx_sw_asm.S
100 ++++ b/arch/arc/kernel/ctx_sw_asm.S
101 +@@ -10,9 +10,9 @@
102 + * -This is the more "natural" hand written assembler
103 + */
104 +
105 ++#include <linux/linkage.h>
106 + #include <asm/entry.h> /* For the SAVE_* macros */
107 + #include <asm/asm-offsets.h>
108 +-#include <asm/linkage.h>
109 +
110 + #define KSP_WORD_OFF ((TASK_THREAD + THREAD_KSP) / 4)
111 +
112 +diff --git a/arch/arm/boot/dts/armada-380.dtsi b/arch/arm/boot/dts/armada-380.dtsi
113 +index 6d0f03c98ee9..a284b611d3e3 100644
114 +--- a/arch/arm/boot/dts/armada-380.dtsi
115 ++++ b/arch/arm/boot/dts/armada-380.dtsi
116 +@@ -16,7 +16,7 @@
117 +
118 + / {
119 + model = "Marvell Armada 380 family SoC";
120 +- compatible = "marvell,armada380", "marvell,armada38x";
121 ++ compatible = "marvell,armada380";
122 +
123 + cpus {
124 + #address-cells = <1>;
125 +diff --git a/arch/arm/boot/dts/armada-385-db.dts b/arch/arm/boot/dts/armada-385-db.dts
126 +index 6828d77696a6..b0e27e169712 100644
127 +--- a/arch/arm/boot/dts/armada-385-db.dts
128 ++++ b/arch/arm/boot/dts/armada-385-db.dts
129 +@@ -16,7 +16,7 @@
130 +
131 + / {
132 + model = "Marvell Armada 385 Development Board";
133 +- compatible = "marvell,a385-db", "marvell,armada385", "marvell,armada38x";
134 ++ compatible = "marvell,a385-db", "marvell,armada385", "marvell,armada380";
135 +
136 + chosen {
137 + bootargs = "console=ttyS0,115200 earlyprintk";
138 +diff --git a/arch/arm/boot/dts/armada-385-rd.dts b/arch/arm/boot/dts/armada-385-rd.dts
139 +index 45250c88814b..229408aeecb2 100644
140 +--- a/arch/arm/boot/dts/armada-385-rd.dts
141 ++++ b/arch/arm/boot/dts/armada-385-rd.dts
142 +@@ -17,7 +17,7 @@
143 +
144 + / {
145 + model = "Marvell Armada 385 Reference Design";
146 +- compatible = "marvell,a385-rd", "marvell,armada385", "marvell,armada38x";
147 ++ compatible = "marvell,a385-rd", "marvell,armada385", "marvell,armada380";
148 +
149 + chosen {
150 + bootargs = "console=ttyS0,115200 earlyprintk";
151 +diff --git a/arch/arm/boot/dts/armada-385.dtsi b/arch/arm/boot/dts/armada-385.dtsi
152 +index da801964a257..2dff97fb46bc 100644
153 +--- a/arch/arm/boot/dts/armada-385.dtsi
154 ++++ b/arch/arm/boot/dts/armada-385.dtsi
155 +@@ -16,7 +16,7 @@
156 +
157 + / {
158 + model = "Marvell Armada 385 family SoC";
159 +- compatible = "marvell,armada385", "marvell,armada38x";
160 ++ compatible = "marvell,armada385", "marvell,armada380";
161 +
162 + cpus {
163 + #address-cells = <1>;
164 +diff --git a/arch/arm/boot/dts/armada-38x.dtsi b/arch/arm/boot/dts/armada-38x.dtsi
165 +index ca8813bb99ba..9a5914ddb4ea 100644
166 +--- a/arch/arm/boot/dts/armada-38x.dtsi
167 ++++ b/arch/arm/boot/dts/armada-38x.dtsi
168 +@@ -20,7 +20,7 @@
169 +
170 + / {
171 + model = "Marvell Armada 38x family SoC";
172 +- compatible = "marvell,armada38x";
173 ++ compatible = "marvell,armada380";
174 +
175 + aliases {
176 + gpio0 = &gpio0;
177 +diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
178 +index 48094b58c88f..b12a4f9fc9d0 100644
179 +--- a/arch/arm/mach-omap2/mux.c
180 ++++ b/arch/arm/mach-omap2/mux.c
181 +@@ -183,8 +183,10 @@ static int __init _omap_mux_get_by_name(struct omap_mux_partition *partition,
182 + m0_entry = mux->muxnames[0];
183 +
184 + /* First check for full name in mode0.muxmode format */
185 +- if (mode0_len && strncmp(muxname, m0_entry, mode0_len))
186 +- continue;
187 ++ if (mode0_len)
188 ++ if (strncmp(muxname, m0_entry, mode0_len) ||
189 ++ (strlen(m0_entry) != mode0_len))
190 ++ continue;
191 +
192 + /* Then check for muxmode only */
193 + for (i = 0; i < OMAP_MUX_NR_MODES; i++) {
194 +diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
195 +index 39ac630d83de..a8e4bdbbb4b8 100644
196 +--- a/arch/arm64/kernel/entry.S
197 ++++ b/arch/arm64/kernel/entry.S
198 +@@ -275,7 +275,6 @@ el1_sp_pc:
199 + * Stack or PC alignment exception handling
200 + */
201 + mrs x0, far_el1
202 +- mov x1, x25
203 + mov x2, sp
204 + b do_sp_pc_abort
205 + el1_undef:
206 +diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c
207 +index e4193e3adc7f..0d64089d28b5 100644
208 +--- a/arch/arm64/mm/flush.c
209 ++++ b/arch/arm64/mm/flush.c
210 +@@ -79,7 +79,8 @@ void __sync_icache_dcache(pte_t pte, unsigned long addr)
211 + return;
212 +
213 + if (!test_and_set_bit(PG_dcache_clean, &page->flags)) {
214 +- __flush_dcache_area(page_address(page), PAGE_SIZE);
215 ++ __flush_dcache_area(page_address(page),
216 ++ PAGE_SIZE << compound_order(page));
217 + __flush_icache_all();
218 + } else if (icache_is_aivivt()) {
219 + __flush_icache_all();
220 +diff --git a/arch/ia64/include/uapi/asm/fcntl.h b/arch/ia64/include/uapi/asm/fcntl.h
221 +index 1dd275dc8f65..7b485876cad4 100644
222 +--- a/arch/ia64/include/uapi/asm/fcntl.h
223 ++++ b/arch/ia64/include/uapi/asm/fcntl.h
224 +@@ -8,6 +8,7 @@
225 + #define force_o_largefile() \
226 + (personality(current->personality) != PER_LINUX32)
227 +
228 ++#include <linux/personality.h>
229 + #include <asm-generic/fcntl.h>
230 +
231 + #endif /* _ASM_IA64_FCNTL_H */
232 +diff --git a/arch/unicore32/mm/alignment.c b/arch/unicore32/mm/alignment.c
233 +index de7dc5fdd58b..24e836023e6c 100644
234 +--- a/arch/unicore32/mm/alignment.c
235 ++++ b/arch/unicore32/mm/alignment.c
236 +@@ -21,6 +21,7 @@
237 + #include <linux/sched.h>
238 + #include <linux/uaccess.h>
239 +
240 ++#include <asm/pgtable.h>
241 + #include <asm/tlbflush.h>
242 + #include <asm/unaligned.h>
243 +
244 +diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
245 +index 7de069afb382..520197517138 100644
246 +--- a/arch/x86/include/asm/kvm_host.h
247 ++++ b/arch/x86/include/asm/kvm_host.h
248 +@@ -99,7 +99,7 @@ static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
249 + #define KVM_REFILL_PAGES 25
250 + #define KVM_MAX_CPUID_ENTRIES 80
251 + #define KVM_NR_FIXED_MTRR_REGION 88
252 +-#define KVM_NR_VAR_MTRR 8
253 ++#define KVM_NR_VAR_MTRR 10
254 +
255 + #define ASYNC_PF_PER_VCPU 64
256 +
257 +@@ -466,7 +466,7 @@ struct kvm_vcpu_arch {
258 + bool nmi_injected; /* Trying to inject an NMI this entry */
259 +
260 + struct mtrr_state_type mtrr_state;
261 +- u32 pat;
262 ++ u64 pat;
263 +
264 + unsigned switch_db_regs;
265 + unsigned long db[KVM_NR_DB_REGS];
266 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
267 +index 20316c67b824..5521f7c14a11 100644
268 +--- a/arch/x86/kvm/x86.c
269 ++++ b/arch/x86/kvm/x86.c
270 +@@ -1912,7 +1912,7 @@ static int set_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data)
271 + if (!(data & HV_X64_MSR_TSC_REFERENCE_ENABLE))
272 + break;
273 + gfn = data >> HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT;
274 +- if (kvm_write_guest(kvm, data,
275 ++ if (kvm_write_guest(kvm, gfn << HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT,
276 + &tsc_ref, sizeof(tsc_ref)))
277 + return 1;
278 + mark_page_dirty(kvm, gfn);
279 +diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
280 +index 1039fb9ff5f5..95ee425bf7c6 100644
281 +--- a/block/blk-cgroup.c
282 ++++ b/block/blk-cgroup.c
283 +@@ -80,7 +80,7 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q,
284 + blkg->q = q;
285 + INIT_LIST_HEAD(&blkg->q_node);
286 + blkg->blkcg = blkcg;
287 +- blkg->refcnt = 1;
288 ++ atomic_set(&blkg->refcnt, 1);
289 +
290 + /* root blkg uses @q->root_rl, init rl only for !root blkgs */
291 + if (blkcg != &blkcg_root) {
292 +@@ -399,11 +399,8 @@ void __blkg_release_rcu(struct rcu_head *rcu_head)
293 +
294 + /* release the blkcg and parent blkg refs this blkg has been holding */
295 + css_put(&blkg->blkcg->css);
296 +- if (blkg->parent) {
297 +- spin_lock_irq(blkg->q->queue_lock);
298 ++ if (blkg->parent)
299 + blkg_put(blkg->parent);
300 +- spin_unlock_irq(blkg->q->queue_lock);
301 +- }
302 +
303 + blkg_free(blkg);
304 + }
305 +diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
306 +index 371fe8e92ab5..75012d8d900c 100644
307 +--- a/block/blk-cgroup.h
308 ++++ b/block/blk-cgroup.h
309 +@@ -18,6 +18,7 @@
310 + #include <linux/seq_file.h>
311 + #include <linux/radix-tree.h>
312 + #include <linux/blkdev.h>
313 ++#include <linux/atomic.h>
314 +
315 + /* Max limits for throttle policy */
316 + #define THROTL_IOPS_MAX UINT_MAX
317 +@@ -104,7 +105,7 @@ struct blkcg_gq {
318 + struct request_list rl;
319 +
320 + /* reference count */
321 +- int refcnt;
322 ++ atomic_t refcnt;
323 +
324 + /* is this blkg online? protected by both blkcg and q locks */
325 + bool online;
326 +@@ -257,13 +258,12 @@ static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
327 + * blkg_get - get a blkg reference
328 + * @blkg: blkg to get
329 + *
330 +- * The caller should be holding queue_lock and an existing reference.
331 ++ * The caller should be holding an existing reference.
332 + */
333 + static inline void blkg_get(struct blkcg_gq *blkg)
334 + {
335 +- lockdep_assert_held(blkg->q->queue_lock);
336 +- WARN_ON_ONCE(!blkg->refcnt);
337 +- blkg->refcnt++;
338 ++ WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
339 ++ atomic_inc(&blkg->refcnt);
340 + }
341 +
342 + void __blkg_release_rcu(struct rcu_head *rcu);
343 +@@ -271,14 +271,11 @@ void __blkg_release_rcu(struct rcu_head *rcu);
344 + /**
345 + * blkg_put - put a blkg reference
346 + * @blkg: blkg to put
347 +- *
348 +- * The caller should be holding queue_lock.
349 + */
350 + static inline void blkg_put(struct blkcg_gq *blkg)
351 + {
352 +- lockdep_assert_held(blkg->q->queue_lock);
353 +- WARN_ON_ONCE(blkg->refcnt <= 0);
354 +- if (!--blkg->refcnt)
355 ++ WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
356 ++ if (atomic_dec_and_test(&blkg->refcnt))
357 + call_rcu(&blkg->rcu_head, __blkg_release_rcu);
358 + }
359 +
360 +diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
361 +index 4c95b503b09e..684806c14f84 100644
362 +--- a/drivers/block/rbd.c
363 ++++ b/drivers/block/rbd.c
364 +@@ -1366,6 +1366,14 @@ static bool obj_request_exists_test(struct rbd_obj_request *obj_request)
365 + return test_bit(OBJ_REQ_EXISTS, &obj_request->flags) != 0;
366 + }
367 +
368 ++static bool obj_request_overlaps_parent(struct rbd_obj_request *obj_request)
369 ++{
370 ++ struct rbd_device *rbd_dev = obj_request->img_request->rbd_dev;
371 ++
372 ++ return obj_request->img_offset <
373 ++ round_up(rbd_dev->parent_overlap, rbd_obj_bytes(&rbd_dev->header));
374 ++}
375 ++
376 + static void rbd_obj_request_get(struct rbd_obj_request *obj_request)
377 + {
378 + dout("%s: obj %p (was %d)\n", __func__, obj_request,
379 +@@ -1382,6 +1390,13 @@ static void rbd_obj_request_put(struct rbd_obj_request *obj_request)
380 + kref_put(&obj_request->kref, rbd_obj_request_destroy);
381 + }
382 +
383 ++static void rbd_img_request_get(struct rbd_img_request *img_request)
384 ++{
385 ++ dout("%s: img %p (was %d)\n", __func__, img_request,
386 ++ atomic_read(&img_request->kref.refcount));
387 ++ kref_get(&img_request->kref);
388 ++}
389 ++
390 + static bool img_request_child_test(struct rbd_img_request *img_request);
391 + static void rbd_parent_request_destroy(struct kref *kref);
392 + static void rbd_img_request_destroy(struct kref *kref);
393 +@@ -2142,6 +2157,7 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
394 + img_request->next_completion = which;
395 + out:
396 + spin_unlock_irq(&img_request->completion_lock);
397 ++ rbd_img_request_put(img_request);
398 +
399 + if (!more)
400 + rbd_img_request_complete(img_request);
401 +@@ -2242,6 +2258,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
402 + goto out_unwind;
403 + obj_request->osd_req = osd_req;
404 + obj_request->callback = rbd_img_obj_callback;
405 ++ rbd_img_request_get(img_request);
406 +
407 + if (write_request) {
408 + osd_req_op_alloc_hint_init(osd_req, which,
409 +@@ -2674,7 +2691,7 @@ static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request)
410 + */
411 + if (!img_request_write_test(img_request) ||
412 + !img_request_layered_test(img_request) ||
413 +- rbd_dev->parent_overlap <= obj_request->img_offset ||
414 ++ !obj_request_overlaps_parent(obj_request) ||
415 + ((known = obj_request_known_test(obj_request)) &&
416 + obj_request_exists_test(obj_request))) {
417 +
418 +diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
419 +index 48eccb350180..089e72cd37be 100644
420 +--- a/drivers/block/zram/zram_drv.c
421 ++++ b/drivers/block/zram/zram_drv.c
422 +@@ -622,8 +622,10 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity)
423 + memset(&zram->stats, 0, sizeof(zram->stats));
424 +
425 + zram->disksize = 0;
426 +- if (reset_capacity)
427 ++ if (reset_capacity) {
428 + set_capacity(zram->disk, 0);
429 ++ revalidate_disk(zram->disk);
430 ++ }
431 + up_write(&zram->init_lock);
432 + }
433 +
434 +@@ -664,6 +666,7 @@ static ssize_t disksize_store(struct device *dev,
435 + zram->comp = comp;
436 + zram->disksize = disksize;
437 + set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
438 ++ revalidate_disk(zram->disk);
439 + up_write(&zram->init_lock);
440 + return len;
441 +
442 +diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
443 +index 00f878a04d3f..0996a3a39855 100644
444 +--- a/drivers/clk/qcom/clk-rcg2.c
445 ++++ b/drivers/clk/qcom/clk-rcg2.c
446 +@@ -55,7 +55,7 @@ static int clk_rcg2_is_enabled(struct clk_hw *hw)
447 + if (ret)
448 + return ret;
449 +
450 +- return (cmd & CMD_ROOT_OFF) != 0;
451 ++ return (cmd & CMD_ROOT_OFF) == 0;
452 + }
453 +
454 + static u8 clk_rcg2_get_parent(struct clk_hw *hw)
455 +diff --git a/drivers/clk/qcom/mmcc-msm8974.c b/drivers/clk/qcom/mmcc-msm8974.c
456 +index c95774514b81..6a0ae77d1939 100644
457 +--- a/drivers/clk/qcom/mmcc-msm8974.c
458 ++++ b/drivers/clk/qcom/mmcc-msm8974.c
459 +@@ -169,6 +169,7 @@ static struct clk_pll mmpll0 = {
460 + .config_reg = 0x0014,
461 + .mode_reg = 0x0000,
462 + .status_reg = 0x001c,
463 ++ .status_bit = 17,
464 + .clkr.hw.init = &(struct clk_init_data){
465 + .name = "mmpll0",
466 + .parent_names = (const char *[]){ "xo" },
467 +@@ -192,9 +193,10 @@ static struct clk_pll mmpll1 = {
468 + .l_reg = 0x0044,
469 + .m_reg = 0x0048,
470 + .n_reg = 0x004c,
471 +- .config_reg = 0x0054,
472 ++ .config_reg = 0x0050,
473 + .mode_reg = 0x0040,
474 + .status_reg = 0x005c,
475 ++ .status_bit = 17,
476 + .clkr.hw.init = &(struct clk_init_data){
477 + .name = "mmpll1",
478 + .parent_names = (const char *[]){ "xo" },
479 +@@ -218,7 +220,7 @@ static struct clk_pll mmpll2 = {
480 + .l_reg = 0x4104,
481 + .m_reg = 0x4108,
482 + .n_reg = 0x410c,
483 +- .config_reg = 0x4114,
484 ++ .config_reg = 0x4110,
485 + .mode_reg = 0x4100,
486 + .status_reg = 0x411c,
487 + .clkr.hw.init = &(struct clk_init_data){
488 +@@ -233,9 +235,10 @@ static struct clk_pll mmpll3 = {
489 + .l_reg = 0x0084,
490 + .m_reg = 0x0088,
491 + .n_reg = 0x008c,
492 +- .config_reg = 0x0094,
493 ++ .config_reg = 0x0090,
494 + .mode_reg = 0x0080,
495 + .status_reg = 0x009c,
496 ++ .status_bit = 17,
497 + .clkr.hw.init = &(struct clk_init_data){
498 + .name = "mmpll3",
499 + .parent_names = (const char *[]){ "xo" },
500 +@@ -2318,7 +2321,7 @@ static const struct pll_config mmpll1_config = {
501 + .vco_val = 0x0,
502 + .vco_mask = 0x3 << 20,
503 + .pre_div_val = 0x0,
504 +- .pre_div_mask = 0x3 << 12,
505 ++ .pre_div_mask = 0x7 << 12,
506 + .post_div_val = 0x0,
507 + .post_div_mask = 0x3 << 8,
508 + .mn_ena_mask = BIT(24),
509 +@@ -2332,7 +2335,7 @@ static struct pll_config mmpll3_config = {
510 + .vco_val = 0x0,
511 + .vco_mask = 0x3 << 20,
512 + .pre_div_val = 0x0,
513 +- .pre_div_mask = 0x3 << 12,
514 ++ .pre_div_mask = 0x7 << 12,
515 + .post_div_val = 0x0,
516 + .post_div_mask = 0x3 << 8,
517 + .mn_ena_mask = BIT(24),
518 +diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
519 +index db2e45b4808e..fcd0c9208e98 100644
520 +--- a/drivers/cpufreq/intel_pstate.c
521 ++++ b/drivers/cpufreq/intel_pstate.c
522 +@@ -200,10 +200,7 @@ static signed int pid_calc(struct _pid *pid, int32_t busy)
523 + pid->last_err = fp_error;
524 +
525 + result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm;
526 +- if (result >= 0)
527 +- result = result + (1 << (FRAC_BITS-1));
528 +- else
529 +- result = result - (1 << (FRAC_BITS-1));
530 ++ result = result + (1 << (FRAC_BITS-1));
531 + return (signed int)fp_toint(result);
532 + }
533 +
534 +diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
535 +index 03711d00aaae..8218078b6133 100644
536 +--- a/drivers/gpu/drm/drm_drv.c
537 ++++ b/drivers/gpu/drm/drm_drv.c
538 +@@ -419,8 +419,9 @@ long drm_ioctl(struct file *filp,
539 + retcode = -EFAULT;
540 + goto err_i1;
541 + }
542 +- } else
543 ++ } else if (cmd & IOC_OUT) {
544 + memset(kdata, 0, usize);
545 ++ }
546 +
547 + if (ioctl->flags & DRM_UNLOCKED)
548 + retcode = func(dev, kdata, file_priv);
549 +diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
550 +index 48af5cac1902..b98c969aeffa 100644
551 +--- a/drivers/gpu/drm/i2c/tda998x_drv.c
552 ++++ b/drivers/gpu/drm/i2c/tda998x_drv.c
553 +@@ -1183,7 +1183,6 @@ static void
554 + tda998x_encoder_destroy(struct drm_encoder *encoder)
555 + {
556 + struct tda998x_priv *priv = to_tda998x_priv(encoder);
557 +- drm_i2c_encoder_destroy(encoder);
558 +
559 + /* disable all IRQs and free the IRQ handler */
560 + cec_write(priv, REG_CEC_RXSHPDINTENA, 0);
561 +@@ -1193,6 +1192,7 @@ tda998x_encoder_destroy(struct drm_encoder *encoder)
562 +
563 + if (priv->cec)
564 + i2c_unregister_device(priv->cec);
565 ++ drm_i2c_encoder_destroy(encoder);
566 + kfree(priv);
567 + }
568 +
569 +diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
570 +index 195fe5bc0aac..332259c42a50 100644
571 +--- a/drivers/gpu/drm/i915/i915_debugfs.c
572 ++++ b/drivers/gpu/drm/i915/i915_debugfs.c
573 +@@ -446,7 +446,9 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
574 +
575 + memset(&stats, 0, sizeof(stats));
576 + stats.file_priv = file->driver_priv;
577 ++ spin_lock(&file->table_lock);
578 + idr_for_each(&file->object_idr, per_file_stats, &stats);
579 ++ spin_unlock(&file->table_lock);
580 + /*
581 + * Although we have a valid reference on file->pid, that does
582 + * not guarantee that the task_struct who called get_pid() is
583 +diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
584 +index 5deb22864c52..cc245429781f 100644
585 +--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
586 ++++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
587 +@@ -1811,6 +1811,13 @@ static inline unsigned int gen8_get_total_gtt_size(u16 bdw_gmch_ctl)
588 + bdw_gmch_ctl &= BDW_GMCH_GGMS_MASK;
589 + if (bdw_gmch_ctl)
590 + bdw_gmch_ctl = 1 << bdw_gmch_ctl;
591 ++
592 ++#ifdef CONFIG_X86_32
593 ++ /* Limit 32b platforms to a 2GB GGTT: 4 << 20 / pte size * PAGE_SIZE */
594 ++ if (bdw_gmch_ctl > 4)
595 ++ bdw_gmch_ctl = 4;
596 ++#endif
597 ++
598 + return bdw_gmch_ctl << 20;
599 + }
600 +
601 +diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
602 +index 12f1d43b2d68..8c7a7d891ff9 100644
603 +--- a/drivers/gpu/drm/i915/i915_gpu_error.c
604 ++++ b/drivers/gpu/drm/i915/i915_gpu_error.c
605 +@@ -894,6 +894,8 @@ static void i915_gem_record_rings(struct drm_device *dev,
606 + for (i = 0; i < I915_NUM_RINGS; i++) {
607 + struct intel_ring_buffer *ring = &dev_priv->ring[i];
608 +
609 ++ error->ring[i].pid = -1;
610 ++
611 + if (ring->dev == NULL)
612 + continue;
613 +
614 +@@ -901,7 +903,6 @@ static void i915_gem_record_rings(struct drm_device *dev,
615 +
616 + i915_record_ring_state(dev, ring, &error->ring[i]);
617 +
618 +- error->ring[i].pid = -1;
619 + request = i915_gem_find_active_request(ring);
620 + if (request) {
621 + /* We need to copy these to an anonymous buffer
622 +diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
623 +index f98ba4e6e70b..e9830cd52d22 100644
624 +--- a/drivers/gpu/drm/i915/i915_irq.c
625 ++++ b/drivers/gpu/drm/i915/i915_irq.c
626 +@@ -2561,10 +2561,14 @@ static int semaphore_passed(struct intel_ring_buffer *ring)
627 + struct intel_ring_buffer *signaller;
628 + u32 seqno, ctl;
629 +
630 +- ring->hangcheck.deadlock = true;
631 ++ ring->hangcheck.deadlock++;
632 +
633 + signaller = semaphore_waits_for(ring, &seqno);
634 +- if (signaller == NULL || signaller->hangcheck.deadlock)
635 ++ if (signaller == NULL)
636 ++ return -1;
637 ++
638 ++ /* Prevent pathological recursion due to driver bugs */
639 ++ if (signaller->hangcheck.deadlock >= I915_NUM_RINGS)
640 + return -1;
641 +
642 + /* cursory check for an unkickable deadlock */
643 +@@ -2572,7 +2576,13 @@ static int semaphore_passed(struct intel_ring_buffer *ring)
644 + if (ctl & RING_WAIT_SEMAPHORE && semaphore_passed(signaller) < 0)
645 + return -1;
646 +
647 +- return i915_seqno_passed(signaller->get_seqno(signaller, false), seqno);
648 ++ if (i915_seqno_passed(signaller->get_seqno(signaller, false), seqno))
649 ++ return 1;
650 ++
651 ++ if (signaller->hangcheck.deadlock)
652 ++ return -1;
653 ++
654 ++ return 0;
655 + }
656 +
657 + static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
658 +@@ -2581,7 +2591,7 @@ static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
659 + int i;
660 +
661 + for_each_ring(ring, dev_priv, i)
662 +- ring->hangcheck.deadlock = false;
663 ++ ring->hangcheck.deadlock = 0;
664 + }
665 +
666 + static enum intel_ring_hangcheck_action
667 +diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
668 +index aff4a113cda3..7eda7440d776 100644
669 +--- a/drivers/gpu/drm/i915/intel_bios.c
670 ++++ b/drivers/gpu/drm/i915/intel_bios.c
671 +@@ -287,9 +287,6 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
672 + const struct bdb_lfp_backlight_data *backlight_data;
673 + const struct bdb_lfp_backlight_data_entry *entry;
674 +
675 +- /* Err to enabling backlight if no backlight block. */
676 +- dev_priv->vbt.backlight.present = true;
677 +-
678 + backlight_data = find_section(bdb, BDB_LVDS_BACKLIGHT);
679 + if (!backlight_data)
680 + return;
681 +@@ -839,6 +836,9 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
682 +
683 + dev_priv->vbt.crt_ddc_pin = GMBUS_PORT_VGADDC;
684 +
685 ++ /* Default to having backlight */
686 ++ dev_priv->vbt.backlight.present = true;
687 ++
688 + /* LFP panel data */
689 + dev_priv->vbt.lvds_dither = 1;
690 + dev_priv->vbt.lvds_vbt = 0;
691 +diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
692 +index cb8cfb7e0974..8b2538356371 100644
693 +--- a/drivers/gpu/drm/i915/intel_panel.c
694 ++++ b/drivers/gpu/drm/i915/intel_panel.c
695 +@@ -723,9 +723,6 @@ static void i965_enable_backlight(struct intel_connector *connector)
696 + ctl = freq << 16;
697 + I915_WRITE(BLC_PWM_CTL, ctl);
698 +
699 +- /* XXX: combine this into above write? */
700 +- intel_panel_actually_set_backlight(connector, panel->backlight.level);
701 +-
702 + ctl2 = BLM_PIPE(pipe);
703 + if (panel->backlight.combination_mode)
704 + ctl2 |= BLM_COMBINATION_MODE;
705 +@@ -734,6 +731,8 @@ static void i965_enable_backlight(struct intel_connector *connector)
706 + I915_WRITE(BLC_PWM_CTL2, ctl2);
707 + POSTING_READ(BLC_PWM_CTL2);
708 + I915_WRITE(BLC_PWM_CTL2, ctl2 | BLM_PWM_ENABLE);
709 ++
710 ++ intel_panel_actually_set_backlight(connector, panel->backlight.level);
711 + }
712 +
713 + static void vlv_enable_backlight(struct intel_connector *connector)
714 +diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
715 +index d93dcf683e8c..2b68c35eec15 100644
716 +--- a/drivers/gpu/drm/i915/intel_pm.c
717 ++++ b/drivers/gpu/drm/i915/intel_pm.c
718 +@@ -511,8 +511,7 @@ void intel_update_fbc(struct drm_device *dev)
719 + obj = intel_fb->obj;
720 + adjusted_mode = &intel_crtc->config.adjusted_mode;
721 +
722 +- if (i915.enable_fbc < 0 &&
723 +- INTEL_INFO(dev)->gen <= 7 && !IS_HASWELL(dev)) {
724 ++ if (i915.enable_fbc < 0) {
725 + if (set_no_fbc_reason(dev_priv, FBC_CHIP_DEFAULT))
726 + DRM_DEBUG_KMS("disabled per chip default\n");
727 + goto out_disable;
728 +@@ -5314,10 +5313,25 @@ bool intel_display_power_enabled_sw(struct drm_i915_private *dev_priv,
729 + enum intel_display_power_domain domain)
730 + {
731 + struct i915_power_domains *power_domains;
732 ++ struct i915_power_well *power_well;
733 ++ bool is_enabled;
734 ++ int i;
735 ++
736 ++ if (dev_priv->pm.suspended)
737 ++ return false;
738 +
739 + power_domains = &dev_priv->power_domains;
740 ++ is_enabled = true;
741 ++ for_each_power_well_rev(i, power_well, BIT(domain), power_domains) {
742 ++ if (power_well->always_on)
743 ++ continue;
744 +
745 +- return power_domains->domain_use_count[domain];
746 ++ if (!power_well->count) {
747 ++ is_enabled = false;
748 ++ break;
749 ++ }
750 ++ }
751 ++ return is_enabled;
752 + }
753 +
754 + bool intel_display_power_enabled(struct drm_i915_private *dev_priv,
755 +@@ -5706,33 +5720,56 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
756 + static struct i915_power_domains *hsw_pwr;
757 +
758 + /* Display audio driver power well request */
759 +-void i915_request_power_well(void)
760 ++int i915_request_power_well(void)
761 + {
762 + struct drm_i915_private *dev_priv;
763 +
764 +- if (WARN_ON(!hsw_pwr))
765 +- return;
766 ++ if (!hsw_pwr)
767 ++ return -ENODEV;
768 +
769 + dev_priv = container_of(hsw_pwr, struct drm_i915_private,
770 + power_domains);
771 + intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO);
772 ++ return 0;
773 + }
774 + EXPORT_SYMBOL_GPL(i915_request_power_well);
775 +
776 + /* Display audio driver power well release */
777 +-void i915_release_power_well(void)
778 ++int i915_release_power_well(void)
779 + {
780 + struct drm_i915_private *dev_priv;
781 +
782 +- if (WARN_ON(!hsw_pwr))
783 +- return;
784 ++ if (!hsw_pwr)
785 ++ return -ENODEV;
786 +
787 + dev_priv = container_of(hsw_pwr, struct drm_i915_private,
788 + power_domains);
789 + intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
790 ++ return 0;
791 + }
792 + EXPORT_SYMBOL_GPL(i915_release_power_well);
793 +
794 ++/*
795 ++ * Private interface for the audio driver to get CDCLK in kHz.
796 ++ *
797 ++ * Caller must request power well using i915_request_power_well() prior to
798 ++ * making the call.
799 ++ */
800 ++int i915_get_cdclk_freq(void)
801 ++{
802 ++ struct drm_i915_private *dev_priv;
803 ++
804 ++ if (!hsw_pwr)
805 ++ return -ENODEV;
806 ++
807 ++ dev_priv = container_of(hsw_pwr, struct drm_i915_private,
808 ++ power_domains);
809 ++
810 ++ return intel_ddi_get_cdclk_freq(dev_priv);
811 ++}
812 ++EXPORT_SYMBOL_GPL(i915_get_cdclk_freq);
813 ++
814 ++
815 + #define POWER_DOMAIN_MASK (BIT(POWER_DOMAIN_NUM) - 1)
816 +
817 + #define HSW_ALWAYS_ON_POWER_DOMAINS ( \
818 +diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
819 +index 2b91c4b4d34b..4a978b97b47d 100644
820 +--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
821 ++++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
822 +@@ -51,7 +51,7 @@ struct intel_ring_hangcheck {
823 + u32 seqno;
824 + int score;
825 + enum intel_ring_hangcheck_action action;
826 +- bool deadlock;
827 ++ int deadlock;
828 + };
829 +
830 + struct intel_ring_buffer {
831 +diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
832 +index 46be00d66df3..6317953d5773 100644
833 +--- a/drivers/gpu/drm/i915/intel_sdvo.c
834 ++++ b/drivers/gpu/drm/i915/intel_sdvo.c
835 +@@ -1383,7 +1383,9 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
836 + >> SDVO_PORT_MULTIPLY_SHIFT) + 1;
837 + }
838 +
839 +- dotclock = pipe_config->port_clock / pipe_config->pixel_multiplier;
840 ++ dotclock = pipe_config->port_clock;
841 ++ if (pipe_config->pixel_multiplier)
842 ++ dotclock /= pipe_config->pixel_multiplier;
843 +
844 + if (HAS_PCH_SPLIT(dev))
845 + ironlake_check_encoder_dotclock(pipe_config, dotclock);
846 +diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv04.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv04.c
847 +index 6c89af792889..94a2cc69ec2c 100644
848 +--- a/drivers/gpu/drm/nouveau/core/engine/disp/nv04.c
849 ++++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv04.c
850 +@@ -51,6 +51,14 @@ nv04_disp_scanoutpos(struct nouveau_object *object, u32 mthd,
851 + args->htotal = nv_rd32(priv, 0x680824 + (head * 0x2000)) & 0xffff;
852 + args->hblanke = args->htotal - 1;
853 +
854 ++ /*
855 ++ * If output is vga instead of digital then vtotal/htotal is invalid
856 ++ * so we have to give up and trigger the timestamping fallback in the
857 ++ * drm core.
858 ++ */
859 ++ if (!args->vtotal || !args->htotal)
860 ++ return -ENOTSUPP;
861 ++
862 + args->time[0] = ktime_to_ns(ktime_get());
863 + line = nv_rd32(priv, 0x600868 + (head * 0x2000));
864 + args->time[1] = ktime_to_ns(ktime_get());
865 +diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c
866 +index 48351b4d6d6b..8de4a4291548 100644
867 +--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c
868 ++++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c
869 +@@ -545,10 +545,12 @@ nv108_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
870 + mmio_list(0x408010, 0x80000000, 0, 0);
871 + mmio_list(0x419004, 0x00000000, 8, 1);
872 + mmio_list(0x419008, 0x00000000, 0, 0);
873 ++ mmio_list(0x4064cc, 0x80000000, 0, 0);
874 + mmio_list(0x408004, 0x00000000, 8, 0);
875 + mmio_list(0x408008, 0x80000030, 0, 0);
876 + mmio_list(0x418808, 0x00000000, 8, 0);
877 + mmio_list(0x41880c, 0x80000030, 0, 0);
878 ++ mmio_list(0x4064c8, 0x00c20200, 0, 0);
879 + mmio_list(0x418810, 0x80000000, 12, 2);
880 + mmio_list(0x419848, 0x10000000, 12, 2);
881 +
882 +diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c
883 +index e8822a934c48..90d8bf8ce0dc 100644
884 +--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c
885 ++++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c
886 +@@ -26,6 +26,7 @@
887 +
888 + const struct nouveau_mc_intr
889 + nv50_mc_intr[] = {
890 ++ { 0x04000000, NVDEV_ENGINE_DISP }, /* DISP before FIFO, so pageflip-timestamping works! */
891 + { 0x00000001, NVDEV_ENGINE_MPEG },
892 + { 0x00000100, NVDEV_ENGINE_FIFO },
893 + { 0x00001000, NVDEV_ENGINE_GR },
894 +@@ -34,7 +35,6 @@ nv50_mc_intr[] = {
895 + { 0x00020000, NVDEV_ENGINE_VP }, /* NV84- */
896 + { 0x00100000, NVDEV_SUBDEV_TIMER },
897 + { 0x00200000, NVDEV_SUBDEV_GPIO },
898 +- { 0x04000000, NVDEV_ENGINE_DISP },
899 + { 0x10000000, NVDEV_SUBDEV_BUS },
900 + { 0x80000000, NVDEV_ENGINE_SW },
901 + { 0x0002d101, NVDEV_SUBDEV_FB },
902 +diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c
903 +index f8a6f18e2d34..95b3d35388a8 100644
904 +--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c
905 ++++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c
906 +@@ -26,6 +26,7 @@
907 +
908 + static const struct nouveau_mc_intr
909 + nv98_mc_intr[] = {
910 ++ { 0x04000000, NVDEV_ENGINE_DISP }, /* DISP first, so pageflip timestamps work */
911 + { 0x00000001, NVDEV_ENGINE_PPP },
912 + { 0x00000100, NVDEV_ENGINE_FIFO },
913 + { 0x00001000, NVDEV_ENGINE_GR },
914 +@@ -37,7 +38,6 @@ nv98_mc_intr[] = {
915 + { 0x00100000, NVDEV_SUBDEV_TIMER },
916 + { 0x00200000, NVDEV_SUBDEV_GPIO },
917 + { 0x00400000, NVDEV_ENGINE_COPY0 }, /* NVA3- */
918 +- { 0x04000000, NVDEV_ENGINE_DISP },
919 + { 0x10000000, NVDEV_SUBDEV_BUS },
920 + { 0x80000000, NVDEV_ENGINE_SW },
921 + { 0x0042d101, NVDEV_SUBDEV_FB },
922 +diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c
923 +index 34472d317097..ac7f99a15fa7 100644
924 +--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c
925 ++++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c
926 +@@ -26,6 +26,7 @@
927 +
928 + const struct nouveau_mc_intr
929 + nvc0_mc_intr[] = {
930 ++ { 0x04000000, NVDEV_ENGINE_DISP }, /* DISP first, so pageflip timestamps work. */
931 + { 0x00000001, NVDEV_ENGINE_PPP },
932 + { 0x00000020, NVDEV_ENGINE_COPY0 },
933 + { 0x00000040, NVDEV_ENGINE_COPY1 },
934 +@@ -40,7 +41,6 @@ nvc0_mc_intr[] = {
935 + { 0x00200000, NVDEV_SUBDEV_GPIO },
936 + { 0x01000000, NVDEV_SUBDEV_PWR },
937 + { 0x02000000, NVDEV_SUBDEV_LTCG },
938 +- { 0x04000000, NVDEV_ENGINE_DISP },
939 + { 0x08000000, NVDEV_SUBDEV_FB },
940 + { 0x10000000, NVDEV_SUBDEV_BUS },
941 + { 0x40000000, NVDEV_SUBDEV_IBUS },
942 +diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
943 +index da764a4ed958..64938b77b38c 100644
944 +--- a/drivers/gpu/drm/nouveau/nouveau_display.c
945 ++++ b/drivers/gpu/drm/nouveau/nouveau_display.c
946 +@@ -736,6 +736,9 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
947 + fb->bits_per_pixel, fb->pitches[0], crtc->x, crtc->y,
948 + new_bo->bo.offset };
949 +
950 ++ /* Keep vblanks on during flip, for the target crtc of this flip */
951 ++ drm_vblank_get(dev, nouveau_crtc(crtc)->index);
952 ++
953 + /* Emit a page flip */
954 + if (nv_device(drm->device)->card_type >= NV_50) {
955 + ret = nv50_display_flip_next(crtc, fb, chan, swap_interval);
956 +@@ -779,6 +782,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
957 + return 0;
958 +
959 + fail_unreserve:
960 ++ drm_vblank_put(dev, nouveau_crtc(crtc)->index);
961 + ttm_bo_unreserve(&old_bo->bo);
962 + fail_unpin:
963 + mutex_unlock(&chan->cli->mutex);
964 +@@ -798,6 +802,7 @@ nouveau_finish_page_flip(struct nouveau_channel *chan,
965 + struct drm_device *dev = drm->dev;
966 + struct nouveau_page_flip_state *s;
967 + unsigned long flags;
968 ++ int crtcid = -1;
969 +
970 + spin_lock_irqsave(&dev->event_lock, flags);
971 +
972 +@@ -808,8 +813,16 @@ nouveau_finish_page_flip(struct nouveau_channel *chan,
973 + }
974 +
975 + s = list_first_entry(&fctx->flip, struct nouveau_page_flip_state, head);
976 +- if (s->event)
977 +- drm_send_vblank_event(dev, s->crtc, s->event);
978 ++ if (s->event) {
979 ++ /* Vblank timestamps/counts are only correct on >= NV-50 */
980 ++ if (nv_device(drm->device)->card_type >= NV_50)
981 ++ crtcid = s->crtc;
982 ++
983 ++ drm_send_vblank_event(dev, crtcid, s->event);
984 ++ }
985 ++
986 ++ /* Give up ownership of vblank for page-flipped crtc */
987 ++ drm_vblank_put(dev, s->crtc);
988 +
989 + list_del(&s->head);
990 + if (ps)
991 +diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
992 +index e911898348f8..c5f35b0d2983 100644
993 +--- a/drivers/gpu/drm/radeon/atombios_crtc.c
994 ++++ b/drivers/gpu/drm/radeon/atombios_crtc.c
995 +@@ -862,14 +862,16 @@ static void atombios_crtc_program_pll(struct drm_crtc *crtc,
996 + args.v5.ucMiscInfo = 0; /* HDMI depth, etc. */
997 + if (ss_enabled && (ss->type & ATOM_EXTERNAL_SS_MASK))
998 + args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_REF_DIV_SRC;
999 +- switch (bpc) {
1000 +- case 8:
1001 +- default:
1002 +- args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_24BPP;
1003 +- break;
1004 +- case 10:
1005 +- args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_30BPP;
1006 +- break;
1007 ++ if (encoder_mode == ATOM_ENCODER_MODE_HDMI) {
1008 ++ switch (bpc) {
1009 ++ case 8:
1010 ++ default:
1011 ++ args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_24BPP;
1012 ++ break;
1013 ++ case 10:
1014 ++ args.v5.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_30BPP;
1015 ++ break;
1016 ++ }
1017 + }
1018 + args.v5.ucTransmitterID = encoder_id;
1019 + args.v5.ucEncoderMode = encoder_mode;
1020 +@@ -884,20 +886,22 @@ static void atombios_crtc_program_pll(struct drm_crtc *crtc,
1021 + args.v6.ucMiscInfo = 0; /* HDMI depth, etc. */
1022 + if (ss_enabled && (ss->type & ATOM_EXTERNAL_SS_MASK))
1023 + args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_REF_DIV_SRC;
1024 +- switch (bpc) {
1025 +- case 8:
1026 +- default:
1027 +- args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_24BPP;
1028 +- break;
1029 +- case 10:
1030 +- args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_30BPP;
1031 +- break;
1032 +- case 12:
1033 +- args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_36BPP;
1034 +- break;
1035 +- case 16:
1036 +- args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_48BPP;
1037 +- break;
1038 ++ if (encoder_mode == ATOM_ENCODER_MODE_HDMI) {
1039 ++ switch (bpc) {
1040 ++ case 8:
1041 ++ default:
1042 ++ args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_24BPP;
1043 ++ break;
1044 ++ case 10:
1045 ++ args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_30BPP;
1046 ++ break;
1047 ++ case 12:
1048 ++ args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_36BPP;
1049 ++ break;
1050 ++ case 16:
1051 ++ args.v6.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_48BPP;
1052 ++ break;
1053 ++ }
1054 + }
1055 + args.v6.ucTransmitterID = encoder_id;
1056 + args.v6.ucEncoderMode = encoder_mode;
1057 +diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
1058 +index 54e4f52549af..87afe966a307 100644
1059 +--- a/drivers/gpu/drm/radeon/atombios_dp.c
1060 ++++ b/drivers/gpu/drm/radeon/atombios_dp.c
1061 +@@ -281,6 +281,19 @@ static int dp_get_max_dp_pix_clock(int link_rate,
1062 +
1063 + /***** radeon specific DP functions *****/
1064 +
1065 ++static int radeon_dp_get_max_link_rate(struct drm_connector *connector,
1066 ++ u8 dpcd[DP_DPCD_SIZE])
1067 ++{
1068 ++ int max_link_rate;
1069 ++
1070 ++ if (radeon_connector_is_dp12_capable(connector))
1071 ++ max_link_rate = min(drm_dp_max_link_rate(dpcd), 540000);
1072 ++ else
1073 ++ max_link_rate = min(drm_dp_max_link_rate(dpcd), 270000);
1074 ++
1075 ++ return max_link_rate;
1076 ++}
1077 ++
1078 + /* First get the min lane# when low rate is used according to pixel clock
1079 + * (prefer low rate), second check max lane# supported by DP panel,
1080 + * if the max lane# < low rate lane# then use max lane# instead.
1081 +@@ -290,7 +303,7 @@ static int radeon_dp_get_dp_lane_number(struct drm_connector *connector,
1082 + int pix_clock)
1083 + {
1084 + int bpp = convert_bpc_to_bpp(radeon_get_monitor_bpc(connector));
1085 +- int max_link_rate = drm_dp_max_link_rate(dpcd);
1086 ++ int max_link_rate = radeon_dp_get_max_link_rate(connector, dpcd);
1087 + int max_lane_num = drm_dp_max_lane_count(dpcd);
1088 + int lane_num;
1089 + int max_dp_pix_clock;
1090 +@@ -328,7 +341,7 @@ static int radeon_dp_get_dp_link_clock(struct drm_connector *connector,
1091 + return 540000;
1092 + }
1093 +
1094 +- return drm_dp_max_link_rate(dpcd);
1095 ++ return radeon_dp_get_max_link_rate(connector, dpcd);
1096 + }
1097 +
1098 + static u8 radeon_dp_encoder_service(struct radeon_device *rdev,
1099 +diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
1100 +index e6eb5097597f..2b2908440644 100644
1101 +--- a/drivers/gpu/drm/radeon/atombios_encoders.c
1102 ++++ b/drivers/gpu/drm/radeon/atombios_encoders.c
1103 +@@ -1884,8 +1884,11 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
1104 + args.v2.ucEncodeMode = ATOM_ENCODER_MODE_CRT;
1105 + else
1106 + args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder);
1107 +- } else
1108 ++ } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
1109 ++ args.v2.ucEncodeMode = ATOM_ENCODER_MODE_LVDS;
1110 ++ } else {
1111 + args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder);
1112 ++ }
1113 + switch (radeon_encoder->encoder_id) {
1114 + case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1115 + case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1116 +diff --git a/drivers/gpu/drm/radeon/cikd.h b/drivers/gpu/drm/radeon/cikd.h
1117 +index dd7926394a8f..e6d2dbbe4f6e 100644
1118 +--- a/drivers/gpu/drm/radeon/cikd.h
1119 ++++ b/drivers/gpu/drm/radeon/cikd.h
1120 +@@ -1751,12 +1751,12 @@
1121 + #define EOP_TC_WB_ACTION_EN (1 << 15) /* L2 */
1122 + #define EOP_TCL1_ACTION_EN (1 << 16)
1123 + #define EOP_TC_ACTION_EN (1 << 17) /* L2 */
1124 ++#define EOP_TCL2_VOLATILE (1 << 24)
1125 + #define EOP_CACHE_POLICY(x) ((x) << 25)
1126 + /* 0 - LRU
1127 + * 1 - Stream
1128 + * 2 - Bypass
1129 + */
1130 +-#define EOP_TCL2_VOLATILE (1 << 27)
1131 + #define DATA_SEL(x) ((x) << 29)
1132 + /* 0 - discard
1133 + * 1 - send low 32bit data
1134 +diff --git a/drivers/gpu/drm/radeon/cypress_dpm.c b/drivers/gpu/drm/radeon/cypress_dpm.c
1135 +index 5a9a5f4d7888..47d31e915758 100644
1136 +--- a/drivers/gpu/drm/radeon/cypress_dpm.c
1137 ++++ b/drivers/gpu/drm/radeon/cypress_dpm.c
1138 +@@ -1551,7 +1551,7 @@ int cypress_populate_smc_voltage_tables(struct radeon_device *rdev,
1139 +
1140 + table->voltageMaskTable.highMask[RV770_SMC_VOLTAGEMASK_VDDCI] = 0;
1141 + table->voltageMaskTable.lowMask[RV770_SMC_VOLTAGEMASK_VDDCI] =
1142 +- cpu_to_be32(eg_pi->vddc_voltage_table.mask_low);
1143 ++ cpu_to_be32(eg_pi->vddci_voltage_table.mask_low);
1144 + }
1145 +
1146 + return 0;
1147 +diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
1148 +index 004c931606c4..01fc4888e6fe 100644
1149 +--- a/drivers/gpu/drm/radeon/ni_dpm.c
1150 ++++ b/drivers/gpu/drm/radeon/ni_dpm.c
1151 +@@ -1315,7 +1315,7 @@ static void ni_populate_smc_voltage_tables(struct radeon_device *rdev,
1152 +
1153 + table->voltageMaskTable.highMask[NISLANDS_SMC_VOLTAGEMASK_VDDCI] = 0;
1154 + table->voltageMaskTable.lowMask[NISLANDS_SMC_VOLTAGEMASK_VDDCI] =
1155 +- cpu_to_be32(eg_pi->vddc_voltage_table.mask_low);
1156 ++ cpu_to_be32(eg_pi->vddci_voltage_table.mask_low);
1157 + }
1158 + }
1159 +
1160 +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
1161 +index ea50e0ae7bf7..bf73a04791ed 100644
1162 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c
1163 ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
1164 +@@ -1387,7 +1387,7 @@ bool radeon_connector_is_dp12_capable(struct drm_connector *connector)
1165 + struct radeon_device *rdev = dev->dev_private;
1166 +
1167 + if (ASIC_IS_DCE5(rdev) &&
1168 +- (rdev->clock.dp_extclk >= 53900) &&
1169 ++ (rdev->clock.default_dispclk >= 53900) &&
1170 + radeon_connector_encoder_is_hbr2(connector)) {
1171 + return true;
1172 + }
1173 +diff --git a/drivers/gpu/drm/radeon/radeon_vce.c b/drivers/gpu/drm/radeon/radeon_vce.c
1174 +index 3971d968af6c..aa21c31a846c 100644
1175 +--- a/drivers/gpu/drm/radeon/radeon_vce.c
1176 ++++ b/drivers/gpu/drm/radeon/radeon_vce.c
1177 +@@ -66,6 +66,7 @@ int radeon_vce_init(struct radeon_device *rdev)
1178 + case CHIP_BONAIRE:
1179 + case CHIP_KAVERI:
1180 + case CHIP_KABINI:
1181 ++ case CHIP_HAWAII:
1182 + case CHIP_MULLINS:
1183 + fw_name = FIRMWARE_BONAIRE;
1184 + break;
1185 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1186 +index a89ad938eacf..b031b48dbb3c 100644
1187 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1188 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1189 +@@ -179,7 +179,6 @@ static int vmw_fb_set_par(struct fb_info *info)
1190 + vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_Y, info->var.yoffset);
1191 + vmw_write(vmw_priv, SVGA_REG_DISPLAY_WIDTH, info->var.xres);
1192 + vmw_write(vmw_priv, SVGA_REG_DISPLAY_HEIGHT, info->var.yres);
1193 +- vmw_write(vmw_priv, SVGA_REG_BYTES_PER_LINE, info->fix.line_length);
1194 + vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
1195 + }
1196 +
1197 +diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
1198 +index ec0ae2d1686a..6866448083b2 100644
1199 +--- a/drivers/gpu/vga/vga_switcheroo.c
1200 ++++ b/drivers/gpu/vga/vga_switcheroo.c
1201 +@@ -623,7 +623,8 @@ static int vga_switcheroo_runtime_suspend(struct device *dev)
1202 + ret = dev->bus->pm->runtime_suspend(dev);
1203 + if (ret)
1204 + return ret;
1205 +-
1206 ++ if (vgasr_priv.handler->switchto)
1207 ++ vgasr_priv.handler->switchto(VGA_SWITCHEROO_IGD);
1208 + vga_switcheroo_power_switch(pdev, VGA_SWITCHEROO_OFF);
1209 + return 0;
1210 + }
1211 +diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
1212 +index 93d26e8af3e2..bfd3f3eeabcd 100644
1213 +--- a/drivers/hwmon/ina2xx.c
1214 ++++ b/drivers/hwmon/ina2xx.c
1215 +@@ -148,7 +148,8 @@ static int ina2xx_get_value(struct ina2xx_data *data, u8 reg)
1216 +
1217 + switch (reg) {
1218 + case INA2XX_SHUNT_VOLTAGE:
1219 +- val = DIV_ROUND_CLOSEST(data->regs[reg],
1220 ++ /* signed register */
1221 ++ val = DIV_ROUND_CLOSEST((s16)data->regs[reg],
1222 + data->config->shunt_div);
1223 + break;
1224 + case INA2XX_BUS_VOLTAGE:
1225 +@@ -160,8 +161,8 @@ static int ina2xx_get_value(struct ina2xx_data *data, u8 reg)
1226 + val = data->regs[reg] * data->config->power_lsb;
1227 + break;
1228 + case INA2XX_CURRENT:
1229 +- /* LSB=1mA (selected). Is in mA */
1230 +- val = data->regs[reg];
1231 ++ /* signed register, LSB=1mA (selected), in mA */
1232 ++ val = (s16)data->regs[reg];
1233 + break;
1234 + default:
1235 + /* programmer goofed */
1236 +diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
1237 +index 7de1c4c87942..eb86786e698e 100644
1238 +--- a/drivers/iio/adc/twl4030-madc.c
1239 ++++ b/drivers/iio/adc/twl4030-madc.c
1240 +@@ -645,6 +645,7 @@ int twl4030_get_madc_conversion(int channel_no)
1241 + req.channels = (1 << channel_no);
1242 + req.method = TWL4030_MADC_SW2;
1243 + req.active = 0;
1244 ++ req.raw = 0;
1245 + req.func_cb = NULL;
1246 + ret = twl4030_madc_conversion(&req);
1247 + if (ret < 0)
1248 +diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
1249 +index 0cf5f8e06cfc..1e8e94d4db7d 100644
1250 +--- a/drivers/iio/inkern.c
1251 ++++ b/drivers/iio/inkern.c
1252 +@@ -183,7 +183,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
1253 + else if (name && index >= 0) {
1254 + pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
1255 + np->full_name, name ? name : "", index);
1256 +- return chan;
1257 ++ return NULL;
1258 + }
1259 +
1260 + /*
1261 +@@ -193,8 +193,9 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
1262 + */
1263 + np = np->parent;
1264 + if (np && !of_get_property(np, "io-channel-ranges", NULL))
1265 +- break;
1266 ++ return NULL;
1267 + }
1268 ++
1269 + return chan;
1270 + }
1271 +
1272 +@@ -317,6 +318,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
1273 + if (channel != NULL)
1274 + return channel;
1275 + }
1276 ++
1277 + return iio_channel_get_sys(name, channel_name);
1278 + }
1279 + EXPORT_SYMBOL_GPL(iio_channel_get);
1280 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
1281 +index f256ffc02e29..7119079719e4 100644
1282 +--- a/drivers/iommu/intel-iommu.c
1283 ++++ b/drivers/iommu/intel-iommu.c
1284 +@@ -3799,14 +3799,11 @@ int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info)
1285 + ((void *)rmrr) + rmrr->header.length,
1286 + rmrr->segment, rmrru->devices,
1287 + rmrru->devices_cnt);
1288 +- if (ret > 0)
1289 +- break;
1290 +- else if(ret < 0)
1291 ++ if(ret < 0)
1292 + return ret;
1293 + } else if (info->event == BUS_NOTIFY_DEL_DEVICE) {
1294 +- if (dmar_remove_dev_scope(info, rmrr->segment,
1295 +- rmrru->devices, rmrru->devices_cnt))
1296 +- break;
1297 ++ dmar_remove_dev_scope(info, rmrr->segment,
1298 ++ rmrru->devices, rmrru->devices_cnt);
1299 + }
1300 + }
1301 +
1302 +diff --git a/drivers/irqchip/spear-shirq.c b/drivers/irqchip/spear-shirq.c
1303 +index 3fdda3a40269..6ce6bd3441bf 100644
1304 +--- a/drivers/irqchip/spear-shirq.c
1305 ++++ b/drivers/irqchip/spear-shirq.c
1306 +@@ -125,7 +125,7 @@ static struct spear_shirq spear320_shirq_ras2 = {
1307 + };
1308 +
1309 + static struct spear_shirq spear320_shirq_ras3 = {
1310 +- .irq_nr = 3,
1311 ++ .irq_nr = 7,
1312 + .irq_bit_off = 0,
1313 + .invalid_irq = 1,
1314 + .regs = {
1315 +diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
1316 +index 414dad4cb49b..ad913cd4aded 100644
1317 +--- a/drivers/md/dm-era-target.c
1318 ++++ b/drivers/md/dm-era-target.c
1319 +@@ -1391,7 +1391,8 @@ static int era_is_congested(struct dm_target_callbacks *cb, int bdi_bits)
1320 +
1321 + static void era_destroy(struct era *era)
1322 + {
1323 +- metadata_close(era->md);
1324 ++ if (era->md)
1325 ++ metadata_close(era->md);
1326 +
1327 + if (era->wq)
1328 + destroy_workqueue(era->wq);
1329 +diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
1330 +index 242ac2ea5f29..6b4793d71fb6 100644
1331 +--- a/drivers/md/dm-thin.c
1332 ++++ b/drivers/md/dm-thin.c
1333 +@@ -3068,7 +3068,8 @@ static void set_discard_limits(struct pool_c *pt, struct queue_limits *limits)
1334 + */
1335 + if (pt->adjusted_pf.discard_passdown) {
1336 + data_limits = &bdev_get_queue(pt->data_dev->bdev)->limits;
1337 +- limits->discard_granularity = data_limits->discard_granularity;
1338 ++ limits->discard_granularity = max(data_limits->discard_granularity,
1339 ++ pool->sectors_per_block << SECTOR_SHIFT);
1340 + } else
1341 + limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
1342 + }
1343 +diff --git a/drivers/md/md.c b/drivers/md/md.c
1344 +index 2382cfc9bb3f..9a182092f4a8 100644
1345 +--- a/drivers/md/md.c
1346 ++++ b/drivers/md/md.c
1347 +@@ -7491,6 +7491,19 @@ void md_do_sync(struct md_thread *thread)
1348 + rdev->recovery_offset < j)
1349 + j = rdev->recovery_offset;
1350 + rcu_read_unlock();
1351 ++
1352 ++ /* If there is a bitmap, we need to make sure all
1353 ++ * writes that started before we added a spare
1354 ++ * complete before we start doing a recovery.
1355 ++ * Otherwise the write might complete and (via
1356 ++ * bitmap_endwrite) set a bit in the bitmap after the
1357 ++ * recovery has checked that bit and skipped that
1358 ++ * region.
1359 ++ */
1360 ++ if (mddev->bitmap) {
1361 ++ mddev->pers->quiesce(mddev, 1);
1362 ++ mddev->pers->quiesce(mddev, 0);
1363 ++ }
1364 + }
1365 +
1366 + printk(KERN_INFO "md: %s of RAID array %s\n", desc, mdname(mddev));
1367 +diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
1368 +index 0b9ded13a3ae..1c68e0d2c82d 100644
1369 +--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
1370 ++++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
1371 +@@ -236,6 +236,9 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
1372 + case MMC_RSP_R1:
1373 + rsp_type = SD_RSP_TYPE_R1;
1374 + break;
1375 ++ case MMC_RSP_R1 & ~MMC_RSP_CRC:
1376 ++ rsp_type = SD_RSP_TYPE_R1 | SD_NO_CHECK_CRC7;
1377 ++ break;
1378 + case MMC_RSP_R1B:
1379 + rsp_type = SD_RSP_TYPE_R1b;
1380 + break;
1381 +diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
1382 +index ec549cd9849f..545a5c002f09 100644
1383 +--- a/drivers/mtd/nand/fsl_elbc_nand.c
1384 ++++ b/drivers/mtd/nand/fsl_elbc_nand.c
1385 +@@ -723,6 +723,19 @@ static int fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
1386 + return 0;
1387 + }
1388 +
1389 ++/* ECC will be calculated automatically, and errors will be detected in
1390 ++ * waitfunc.
1391 ++ */
1392 ++static int fsl_elbc_write_subpage(struct mtd_info *mtd, struct nand_chip *chip,
1393 ++ uint32_t offset, uint32_t data_len,
1394 ++ const uint8_t *buf, int oob_required)
1395 ++{
1396 ++ fsl_elbc_write_buf(mtd, buf, mtd->writesize);
1397 ++ fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
1398 ++
1399 ++ return 0;
1400 ++}
1401 ++
1402 + static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
1403 + {
1404 + struct fsl_lbc_ctrl *ctrl = priv->ctrl;
1405 +@@ -761,6 +774,7 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
1406 +
1407 + chip->ecc.read_page = fsl_elbc_read_page;
1408 + chip->ecc.write_page = fsl_elbc_write_page;
1409 ++ chip->ecc.write_subpage = fsl_elbc_write_subpage;
1410 +
1411 + /* If CS Base Register selects full hardware ECC then use it */
1412 + if ((in_be32(&lbc->bank[priv->bank].br) & BR_DECC) ==
1413 +diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
1414 +index 1ff49b80bdaf..0a685089c3fd 100644
1415 +--- a/drivers/mtd/nand/omap2.c
1416 ++++ b/drivers/mtd/nand/omap2.c
1417 +@@ -1382,7 +1382,7 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1418 +
1419 + /* Check if any error reported */
1420 + if (!is_error_reported)
1421 +- return 0;
1422 ++ return stat;
1423 +
1424 + /* Decode BCH error using ELM module */
1425 + elm_decode_bch_error_page(info->elm_dev, ecc_vec, err_vec);
1426 +diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
1427 +index 7588fe2c127f..3003611b6865 100644
1428 +--- a/drivers/mtd/nand/pxa3xx_nand.c
1429 ++++ b/drivers/mtd/nand/pxa3xx_nand.c
1430 +@@ -127,10 +127,10 @@
1431 +
1432 + /* macros for registers read/write */
1433 + #define nand_writel(info, off, val) \
1434 +- __raw_writel((val), (info)->mmio_base + (off))
1435 ++ writel_relaxed((val), (info)->mmio_base + (off))
1436 +
1437 + #define nand_readl(info, off) \
1438 +- __raw_readl((info)->mmio_base + (off))
1439 ++ readl_relaxed((info)->mmio_base + (off))
1440 +
1441 + /* error code and state */
1442 + enum {
1443 +diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
1444 +index 28460676b8ca..d81e7167a8b5 100644
1445 +--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
1446 ++++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
1447 +@@ -736,6 +736,7 @@ static int emac_open(struct net_device *dev)
1448 +
1449 + ret = emac_mdio_probe(dev);
1450 + if (ret < 0) {
1451 ++ free_irq(dev->irq, dev);
1452 + netdev_err(dev, "cannot probe MDIO bus\n");
1453 + return ret;
1454 + }
1455 +diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
1456 +index d16a4d118903..ef242e19766f 100644
1457 +--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
1458 ++++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
1459 +@@ -414,7 +414,7 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u32 gen_or_port,
1460 +
1461 + MLX4_GET(func_cap->flags1, outbox, QUERY_FUNC_CAP_FLAGS1_OFFSET);
1462 + if (dev->caps.port_type[gen_or_port] == MLX4_PORT_TYPE_ETH) {
1463 +- if (func_cap->flags1 & QUERY_FUNC_CAP_FLAGS1_OFFSET) {
1464 ++ if (func_cap->flags1 & QUERY_FUNC_CAP_FLAGS1_FORCE_VLAN) {
1465 + mlx4_err(dev, "VLAN is enforced on this port\n");
1466 + err = -EPROTONOSUPPORT;
1467 + goto out;
1468 +diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
1469 +index c187d748115f..8fa321f39dfd 100644
1470 +--- a/drivers/net/ethernet/mellanox/mlx4/main.c
1471 ++++ b/drivers/net/ethernet/mellanox/mlx4/main.c
1472 +@@ -2800,7 +2800,7 @@ static struct pci_driver mlx4_driver = {
1473 + .name = DRV_NAME,
1474 + .id_table = mlx4_pci_table,
1475 + .probe = mlx4_init_one,
1476 +- .shutdown = mlx4_remove_one,
1477 ++ .shutdown = __mlx4_remove_one,
1478 + .remove = mlx4_remove_one,
1479 + .err_handler = &mlx4_err_handler,
1480 + };
1481 +diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
1482 +index 31adb8cf0291..22d050fc5475 100644
1483 +--- a/drivers/net/wireless/b43/xmit.c
1484 ++++ b/drivers/net/wireless/b43/xmit.c
1485 +@@ -811,9 +811,13 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
1486 + break;
1487 + case B43_PHYTYPE_G:
1488 + status.band = IEEE80211_BAND_2GHZ;
1489 +- /* chanid is the radio channel cookie value as used
1490 +- * to tune the radio. */
1491 +- status.freq = chanid + 2400;
1492 ++ /* Somewhere between 478.104 and 508.1084 firmware for G-PHY
1493 ++ * has been modified to be compatible with N-PHY and others.
1494 ++ */
1495 ++ if (dev->fw.rev >= 508)
1496 ++ status.freq = ieee80211_channel_to_frequency(chanid, status.band);
1497 ++ else
1498 ++ status.freq = chanid + 2400;
1499 + break;
1500 + case B43_PHYTYPE_N:
1501 + case B43_PHYTYPE_LP:
1502 +diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
1503 +index 2365553f1ef7..295b24cefe2d 100644
1504 +--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
1505 ++++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
1506 +@@ -454,6 +454,7 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
1507 + {
1508 + int ret;
1509 + int t = 0;
1510 ++ int iter;
1511 +
1512 + IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n");
1513 +
1514 +@@ -462,18 +463,23 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
1515 + if (ret >= 0)
1516 + return 0;
1517 +
1518 +- /* If HW is not ready, prepare the conditions to check again */
1519 +- iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
1520 +- CSR_HW_IF_CONFIG_REG_PREPARE);
1521 ++ for (iter = 0; iter < 10; iter++) {
1522 ++ /* If HW is not ready, prepare the conditions to check again */
1523 ++ iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
1524 ++ CSR_HW_IF_CONFIG_REG_PREPARE);
1525 ++
1526 ++ do {
1527 ++ ret = iwl_pcie_set_hw_ready(trans);
1528 ++ if (ret >= 0)
1529 ++ return 0;
1530 +
1531 +- do {
1532 +- ret = iwl_pcie_set_hw_ready(trans);
1533 +- if (ret >= 0)
1534 +- return 0;
1535 ++ usleep_range(200, 1000);
1536 ++ t += 200;
1537 ++ } while (t < 150000);
1538 ++ msleep(25);
1539 ++ }
1540 +
1541 +- usleep_range(200, 1000);
1542 +- t += 200;
1543 +- } while (t < 150000);
1544 ++ IWL_DEBUG_INFO(trans, "got NIC after %d iterations\n", iter);
1545 +
1546 + return ret;
1547 + }
1548 +diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
1549 +index 2f1cd929c6f6..a511cccc9f01 100644
1550 +--- a/drivers/net/wireless/rt2x00/rt2500pci.c
1551 ++++ b/drivers/net/wireless/rt2x00/rt2500pci.c
1552 +@@ -1681,8 +1681,13 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
1553 + /*
1554 + * Detect if this device has an hardware controlled radio.
1555 + */
1556 +- if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
1557 ++ if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) {
1558 + __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags);
1559 ++ /*
1560 ++ * On this device RFKILL initialized during probe does not work.
1561 ++ */
1562 ++ __set_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags);
1563 ++ }
1564 +
1565 + /*
1566 + * Check if the BBP tuning should be enabled.
1567 +diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
1568 +index e3b885d8f7db..5d45a1a740a4 100644
1569 +--- a/drivers/net/wireless/rt2x00/rt2x00.h
1570 ++++ b/drivers/net/wireless/rt2x00/rt2x00.h
1571 +@@ -693,6 +693,7 @@ enum rt2x00_capability_flags {
1572 + REQUIRE_SW_SEQNO,
1573 + REQUIRE_HT_TX_DESC,
1574 + REQUIRE_PS_AUTOWAKE,
1575 ++ REQUIRE_DELAYED_RFKILL,
1576 +
1577 + /*
1578 + * Capabilities
1579 +diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
1580 +index 2bde6729f5e6..4fa43a2eeb73 100644
1581 +--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
1582 ++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
1583 +@@ -1126,9 +1126,10 @@ static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
1584 + return;
1585 +
1586 + /*
1587 +- * Unregister extra components.
1588 ++ * Stop rfkill polling.
1589 + */
1590 +- rt2x00rfkill_unregister(rt2x00dev);
1591 ++ if (test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
1592 ++ rt2x00rfkill_unregister(rt2x00dev);
1593 +
1594 + /*
1595 + * Allow the HW to uninitialize.
1596 +@@ -1166,6 +1167,12 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1597 +
1598 + set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags);
1599 +
1600 ++ /*
1601 ++ * Start rfkill polling.
1602 ++ */
1603 ++ if (test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
1604 ++ rt2x00rfkill_register(rt2x00dev);
1605 ++
1606 + return 0;
1607 + }
1608 +
1609 +@@ -1375,7 +1382,12 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1610 + rt2x00link_register(rt2x00dev);
1611 + rt2x00leds_register(rt2x00dev);
1612 + rt2x00debug_register(rt2x00dev);
1613 +- rt2x00rfkill_register(rt2x00dev);
1614 ++
1615 ++ /*
1616 ++ * Start rfkill polling.
1617 ++ */
1618 ++ if (!test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
1619 ++ rt2x00rfkill_register(rt2x00dev);
1620 +
1621 + return 0;
1622 +
1623 +@@ -1391,6 +1403,12 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
1624 + clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
1625 +
1626 + /*
1627 ++ * Stop rfkill polling.
1628 ++ */
1629 ++ if (!test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
1630 ++ rt2x00rfkill_unregister(rt2x00dev);
1631 ++
1632 ++ /*
1633 + * Disable radio.
1634 + */
1635 + rt2x00lib_disable_radio(rt2x00dev);
1636 +diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
1637 +index a87ee9b6585a..87a8ad5d2eb7 100644
1638 +--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
1639 ++++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
1640 +@@ -487,6 +487,8 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1641 + crypto.cipher = rt2x00crypto_key_to_cipher(key);
1642 + if (crypto.cipher == CIPHER_NONE)
1643 + return -EOPNOTSUPP;
1644 ++ if (crypto.cipher == CIPHER_TKIP && rt2x00_is_usb(rt2x00dev))
1645 ++ return -EOPNOTSUPP;
1646 +
1647 + crypto.cmd = cmd;
1648 +
1649 +diff --git a/drivers/regulator/tps65218-regulator.c b/drivers/regulator/tps65218-regulator.c
1650 +index cec72fa71d1d..676e3fb0a0f5 100644
1651 +--- a/drivers/regulator/tps65218-regulator.c
1652 ++++ b/drivers/regulator/tps65218-regulator.c
1653 +@@ -226,7 +226,7 @@ static const struct regulator_desc regulators[] = {
1654 + 1, -1, -1, TPS65218_REG_ENABLE1,
1655 + TPS65218_ENABLE1_DC6_EN, NULL, NULL, 0),
1656 + TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, tps65218_ldo1_dcdc34_ops, 64,
1657 +- TPS65218_REG_CONTROL_DCDC4,
1658 ++ TPS65218_REG_CONTROL_LDO1,
1659 + TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2,
1660 + TPS65218_ENABLE2_LDO1_EN, NULL, ldo1_dcdc3_ranges,
1661 + 2),
1662 +@@ -257,6 +257,7 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
1663 + config.init_data = init_data;
1664 + config.driver_data = tps;
1665 + config.regmap = tps->regmap;
1666 ++ config.of_node = pdev->dev.of_node;
1667 +
1668 + rdev = devm_regulator_register(&pdev->dev, &regulators[id], &config);
1669 + if (IS_ERR(rdev)) {
1670 +diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
1671 +index fa764406df68..c5bb0e0a36b9 100644
1672 +--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
1673 ++++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
1674 +@@ -185,6 +185,11 @@ static struct viosrp_crq *crq_queue_next_crq(struct crq_queue *queue)
1675 + if (crq->valid & 0x80) {
1676 + if (++queue->cur == queue->size)
1677 + queue->cur = 0;
1678 ++
1679 ++ /* Ensure the read of the valid bit occurs before reading any
1680 ++ * other bits of the CRQ entry
1681 ++ */
1682 ++ rmb();
1683 + } else
1684 + crq = NULL;
1685 + spin_unlock_irqrestore(&queue->lock, flags);
1686 +@@ -203,6 +208,11 @@ static int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata,
1687 + {
1688 + struct vio_dev *vdev = to_vio_dev(hostdata->dev);
1689 +
1690 ++ /*
1691 ++ * Ensure the command buffer is flushed to memory before handing it
1692 ++ * over to the VIOS to prevent it from fetching any stale data.
1693 ++ */
1694 ++ mb();
1695 + return plpar_hcall_norets(H_SEND_CRQ, vdev->unit_address, word1, word2);
1696 + }
1697 +
1698 +@@ -797,7 +807,8 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code)
1699 + evt->hostdata->dev);
1700 + if (evt->cmnd_done)
1701 + evt->cmnd_done(evt->cmnd);
1702 +- } else if (evt->done)
1703 ++ } else if (evt->done && evt->crq.format != VIOSRP_MAD_FORMAT &&
1704 ++ evt->iu.srp.login_req.opcode != SRP_LOGIN_REQ)
1705 + evt->done(evt);
1706 + free_event_struct(&evt->hostdata->pool, evt);
1707 + spin_lock_irqsave(hostdata->host->host_lock, flags);
1708 +diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
1709 +index f17aa7aa7879..d941f25fa999 100644
1710 +--- a/drivers/scsi/scsi_error.c
1711 ++++ b/drivers/scsi/scsi_error.c
1712 +@@ -131,7 +131,7 @@ scmd_eh_abort_handler(struct work_struct *work)
1713 + "aborting command %p\n", scmd));
1714 + rtn = scsi_try_to_abort_cmd(sdev->host->hostt, scmd);
1715 + if (rtn == SUCCESS) {
1716 +- scmd->result |= DID_TIME_OUT << 16;
1717 ++ set_host_byte(scmd, DID_TIME_OUT);
1718 + if (scsi_host_eh_past_deadline(sdev->host)) {
1719 + SCSI_LOG_ERROR_RECOVERY(3,
1720 + scmd_printk(KERN_INFO, scmd,
1721 +@@ -167,7 +167,7 @@ scmd_eh_abort_handler(struct work_struct *work)
1722 + scmd_printk(KERN_WARNING, scmd,
1723 + "scmd %p terminate "
1724 + "aborted command\n", scmd));
1725 +- scmd->result |= DID_TIME_OUT << 16;
1726 ++ set_host_byte(scmd, DID_TIME_OUT);
1727 + scsi_finish_command(scmd);
1728 + }
1729 + }
1730 +@@ -291,7 +291,7 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
1731 + if (scsi_abort_command(scmd) == SUCCESS)
1732 + return BLK_EH_NOT_HANDLED;
1733 +
1734 +- scmd->result |= DID_TIME_OUT << 16;
1735 ++ set_host_byte(scmd, DID_TIME_OUT);
1736 +
1737 + if (unlikely(rtn == BLK_EH_NOT_HANDLED &&
1738 + !scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD)))
1739 +@@ -1776,7 +1776,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
1740 + break;
1741 + case DID_ABORT:
1742 + if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) {
1743 +- scmd->result |= DID_TIME_OUT << 16;
1744 ++ set_host_byte(scmd, DID_TIME_OUT);
1745 + return SUCCESS;
1746 + }
1747 + case DID_NO_CONNECT:
1748 +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
1749 +index efcbcd182863..bffbd4b42111 100644
1750 +--- a/drivers/scsi/sd.c
1751 ++++ b/drivers/scsi/sd.c
1752 +@@ -2455,7 +2455,10 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
1753 + }
1754 +
1755 + sdkp->DPOFUA = (data.device_specific & 0x10) != 0;
1756 +- if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) {
1757 ++ if (sdp->broken_fua) {
1758 ++ sd_first_printk(KERN_NOTICE, sdkp, "Disabling FUA\n");
1759 ++ sdkp->DPOFUA = 0;
1760 ++ } else if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) {
1761 + sd_first_printk(KERN_NOTICE, sdkp,
1762 + "Uses READ/WRITE(6), disabling FUA\n");
1763 + sdkp->DPOFUA = 0;
1764 +diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
1765 +index db3b494e5926..8490aa411739 100644
1766 +--- a/drivers/scsi/virtio_scsi.c
1767 ++++ b/drivers/scsi/virtio_scsi.c
1768 +@@ -273,6 +273,16 @@ static void virtscsi_req_done(struct virtqueue *vq)
1769 + virtscsi_vq_done(vscsi, req_vq, virtscsi_complete_cmd);
1770 + };
1771 +
1772 ++static void virtscsi_poll_requests(struct virtio_scsi *vscsi)
1773 ++{
1774 ++ int i, num_vqs;
1775 ++
1776 ++ num_vqs = vscsi->num_queues;
1777 ++ for (i = 0; i < num_vqs; i++)
1778 ++ virtscsi_vq_done(vscsi, &vscsi->req_vqs[i],
1779 ++ virtscsi_complete_cmd);
1780 ++}
1781 ++
1782 + static void virtscsi_complete_free(struct virtio_scsi *vscsi, void *buf)
1783 + {
1784 + struct virtio_scsi_cmd *cmd = buf;
1785 +@@ -291,6 +301,8 @@ static void virtscsi_ctrl_done(struct virtqueue *vq)
1786 + virtscsi_vq_done(vscsi, &vscsi->ctrl_vq, virtscsi_complete_free);
1787 + };
1788 +
1789 ++static void virtscsi_handle_event(struct work_struct *work);
1790 ++
1791 + static int virtscsi_kick_event(struct virtio_scsi *vscsi,
1792 + struct virtio_scsi_event_node *event_node)
1793 + {
1794 +@@ -298,6 +310,7 @@ static int virtscsi_kick_event(struct virtio_scsi *vscsi,
1795 + struct scatterlist sg;
1796 + unsigned long flags;
1797 +
1798 ++ INIT_WORK(&event_node->work, virtscsi_handle_event);
1799 + sg_init_one(&sg, &event_node->event, sizeof(struct virtio_scsi_event));
1800 +
1801 + spin_lock_irqsave(&vscsi->event_vq.vq_lock, flags);
1802 +@@ -415,7 +428,6 @@ static void virtscsi_complete_event(struct virtio_scsi *vscsi, void *buf)
1803 + {
1804 + struct virtio_scsi_event_node *event_node = buf;
1805 +
1806 +- INIT_WORK(&event_node->work, virtscsi_handle_event);
1807 + schedule_work(&event_node->work);
1808 + }
1809 +
1810 +@@ -605,6 +617,18 @@ static int virtscsi_tmf(struct virtio_scsi *vscsi, struct virtio_scsi_cmd *cmd)
1811 + cmd->resp.tmf.response == VIRTIO_SCSI_S_FUNCTION_SUCCEEDED)
1812 + ret = SUCCESS;
1813 +
1814 ++ /*
1815 ++ * The spec guarantees that all requests related to the TMF have
1816 ++ * been completed, but the callback might not have run yet if
1817 ++ * we're using independent interrupts (e.g. MSI). Poll the
1818 ++ * virtqueues once.
1819 ++ *
1820 ++ * In the abort case, sc->scsi_done will do nothing, because
1821 ++ * the block layer must have detected a timeout and as a result
1822 ++ * REQ_ATOM_COMPLETE has been set.
1823 ++ */
1824 ++ virtscsi_poll_requests(vscsi);
1825 ++
1826 + out:
1827 + mempool_free(cmd, virtscsi_cmd_pool);
1828 + return ret;
1829 +diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
1830 +index 357cef2a6f4c..7194bd138762 100644
1831 +--- a/drivers/staging/iio/adc/ad7291.c
1832 ++++ b/drivers/staging/iio/adc/ad7291.c
1833 +@@ -465,7 +465,7 @@ static int ad7291_probe(struct i2c_client *client,
1834 + struct ad7291_platform_data *pdata = client->dev.platform_data;
1835 + struct ad7291_chip_info *chip;
1836 + struct iio_dev *indio_dev;
1837 +- int ret = 0;
1838 ++ int ret;
1839 +
1840 + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
1841 + if (!indio_dev)
1842 +@@ -475,7 +475,7 @@ static int ad7291_probe(struct i2c_client *client,
1843 + if (pdata && pdata->use_external_ref) {
1844 + chip->reg = devm_regulator_get(&client->dev, "vref");
1845 + if (IS_ERR(chip->reg))
1846 +- return ret;
1847 ++ return PTR_ERR(chip->reg);
1848 +
1849 + ret = regulator_enable(chip->reg);
1850 + if (ret)
1851 +diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
1852 +index 8945b4e3a2a6..cb50120ed7b5 100644
1853 +--- a/drivers/staging/tidspbridge/core/tiomap3430.c
1854 ++++ b/drivers/staging/tidspbridge/core/tiomap3430.c
1855 +@@ -280,8 +280,10 @@ static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt)
1856 + OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL);
1857 +
1858 + /* Wait until the state has moved to ON */
1859 +- while (*pdata->dsp_prm_read(OMAP3430_IVA2_MOD, OMAP2_PM_PWSTST)&
1860 +- OMAP_INTRANSITION_MASK);
1861 ++ while ((*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD,
1862 ++ OMAP2_PM_PWSTST) &
1863 ++ OMAP_INTRANSITION_MASK)
1864 ++ ;
1865 + /* Disable Automatic transition */
1866 + (*pdata->dsp_cm_write)(OMAP34XX_CLKSTCTRL_DISABLE_AUTO,
1867 + OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL);
1868 +diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
1869 +index fe9d129c8735..0391f17020f6 100644
1870 +--- a/drivers/tty/n_tty.c
1871 ++++ b/drivers/tty/n_tty.c
1872 +@@ -1214,15 +1214,16 @@ static void n_tty_receive_parity_error(struct tty_struct *tty, unsigned char c)
1873 + {
1874 + struct n_tty_data *ldata = tty->disc_data;
1875 +
1876 +- if (I_IGNPAR(tty))
1877 +- return;
1878 +- if (I_PARMRK(tty)) {
1879 +- put_tty_queue('\377', ldata);
1880 +- put_tty_queue('\0', ldata);
1881 +- put_tty_queue(c, ldata);
1882 +- } else if (I_INPCK(tty))
1883 +- put_tty_queue('\0', ldata);
1884 +- else
1885 ++ if (I_INPCK(tty)) {
1886 ++ if (I_IGNPAR(tty))
1887 ++ return;
1888 ++ if (I_PARMRK(tty)) {
1889 ++ put_tty_queue('\377', ldata);
1890 ++ put_tty_queue('\0', ldata);
1891 ++ put_tty_queue(c, ldata);
1892 ++ } else
1893 ++ put_tty_queue('\0', ldata);
1894 ++ } else
1895 + put_tty_queue(c, ldata);
1896 + if (waitqueue_active(&tty->read_wait))
1897 + wake_up_interruptible(&tty->read_wait);
1898 +diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
1899 +index 2d4bd3929e50..1c17ab591444 100644
1900 +--- a/drivers/tty/serial/8250/8250_core.c
1901 ++++ b/drivers/tty/serial/8250/8250_core.c
1902 +@@ -2360,7 +2360,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
1903 + port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
1904 + if (termios->c_iflag & INPCK)
1905 + port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
1906 +- if (termios->c_iflag & (BRKINT | PARMRK))
1907 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
1908 + port->read_status_mask |= UART_LSR_BI;
1909 +
1910 + /*
1911 +diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
1912 +index 501667e3e3f5..323376668b72 100644
1913 +--- a/drivers/tty/serial/altera_uart.c
1914 ++++ b/drivers/tty/serial/altera_uart.c
1915 +@@ -185,6 +185,12 @@ static void altera_uart_set_termios(struct uart_port *port,
1916 + uart_update_timeout(port, termios->c_cflag, baud);
1917 + altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG);
1918 + spin_unlock_irqrestore(&port->lock, flags);
1919 ++
1920 ++ /*
1921 ++ * FIXME: port->read_status_mask and port->ignore_status_mask
1922 ++ * need to be initialized based on termios settings for
1923 ++ * INPCK, IGNBRK, IGNPAR, PARMRK, BRKINT
1924 ++ */
1925 + }
1926 +
1927 + static void altera_uart_rx_chars(struct altera_uart *pp)
1928 +diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
1929 +index 01c9e72433e1..971af1e22d0f 100644
1930 +--- a/drivers/tty/serial/amba-pl010.c
1931 ++++ b/drivers/tty/serial/amba-pl010.c
1932 +@@ -420,7 +420,7 @@ pl010_set_termios(struct uart_port *port, struct ktermios *termios,
1933 + uap->port.read_status_mask = UART01x_RSR_OE;
1934 + if (termios->c_iflag & INPCK)
1935 + uap->port.read_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE;
1936 +- if (termios->c_iflag & (BRKINT | PARMRK))
1937 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
1938 + uap->port.read_status_mask |= UART01x_RSR_BE;
1939 +
1940 + /*
1941 +diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
1942 +index dacf0a09ab24..c2ee793aedae 100644
1943 +--- a/drivers/tty/serial/amba-pl011.c
1944 ++++ b/drivers/tty/serial/amba-pl011.c
1945 +@@ -1744,7 +1744,7 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
1946 + port->read_status_mask = UART011_DR_OE | 255;
1947 + if (termios->c_iflag & INPCK)
1948 + port->read_status_mask |= UART011_DR_FE | UART011_DR_PE;
1949 +- if (termios->c_iflag & (BRKINT | PARMRK))
1950 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
1951 + port->read_status_mask |= UART011_DR_BE;
1952 +
1953 + /*
1954 +diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
1955 +index 53eeea13ff16..372212956f6c 100644
1956 +--- a/drivers/tty/serial/atmel_serial.c
1957 ++++ b/drivers/tty/serial/atmel_serial.c
1958 +@@ -1784,7 +1784,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
1959 + port->read_status_mask = ATMEL_US_OVRE;
1960 + if (termios->c_iflag & INPCK)
1961 + port->read_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE);
1962 +- if (termios->c_iflag & (BRKINT | PARMRK))
1963 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
1964 + port->read_status_mask |= ATMEL_US_RXBRK;
1965 +
1966 + if (atmel_use_pdc_rx(port))
1967 +diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
1968 +index a47421e4627c..231519022b73 100644
1969 +--- a/drivers/tty/serial/bcm63xx_uart.c
1970 ++++ b/drivers/tty/serial/bcm63xx_uart.c
1971 +@@ -567,7 +567,7 @@ static void bcm_uart_set_termios(struct uart_port *port,
1972 + port->read_status_mask |= UART_FIFO_FRAMEERR_MASK;
1973 + port->read_status_mask |= UART_FIFO_PARERR_MASK;
1974 + }
1975 +- if (new->c_iflag & (BRKINT))
1976 ++ if (new->c_iflag & (IGNBRK | BRKINT))
1977 + port->read_status_mask |= UART_FIFO_BRKDET_MASK;
1978 +
1979 + port->ignore_status_mask = 0;
1980 +diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
1981 +index 869ceba2ec57..ac86a20992e9 100644
1982 +--- a/drivers/tty/serial/bfin_uart.c
1983 ++++ b/drivers/tty/serial/bfin_uart.c
1984 +@@ -833,7 +833,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
1985 + port->read_status_mask = OE;
1986 + if (termios->c_iflag & INPCK)
1987 + port->read_status_mask |= (FE | PE);
1988 +- if (termios->c_iflag & (BRKINT | PARMRK))
1989 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
1990 + port->read_status_mask |= BI;
1991 +
1992 + /*
1993 +diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
1994 +index 2f2b2e538a54..cdbbc788230a 100644
1995 +--- a/drivers/tty/serial/dz.c
1996 ++++ b/drivers/tty/serial/dz.c
1997 +@@ -625,7 +625,7 @@ static void dz_set_termios(struct uart_port *uport, struct ktermios *termios,
1998 + dport->port.read_status_mask = DZ_OERR;
1999 + if (termios->c_iflag & INPCK)
2000 + dport->port.read_status_mask |= DZ_FERR | DZ_PERR;
2001 +- if (termios->c_iflag & (BRKINT | PARMRK))
2002 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2003 + dport->port.read_status_mask |= DZ_BREAK;
2004 +
2005 + /* characters to ignore */
2006 +diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c
2007 +index c167a710dc39..e65f4c840ab4 100644
2008 +--- a/drivers/tty/serial/efm32-uart.c
2009 ++++ b/drivers/tty/serial/efm32-uart.c
2010 +@@ -407,7 +407,7 @@ static void efm32_uart_set_termios(struct uart_port *port,
2011 + if (new->c_iflag & INPCK)
2012 + port->read_status_mask |=
2013 + UARTn_RXDATAX_FERR | UARTn_RXDATAX_PERR;
2014 +- if (new->c_iflag & (BRKINT | PARMRK))
2015 ++ if (new->c_iflag & (IGNBRK | BRKINT | PARMRK))
2016 + port->read_status_mask |= SW_UARTn_RXDATAX_BERR;
2017 +
2018 + port->ignore_status_mask = 0;
2019 +diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
2020 +index c5eb897de9de..49385c86cfba 100644
2021 +--- a/drivers/tty/serial/fsl_lpuart.c
2022 ++++ b/drivers/tty/serial/fsl_lpuart.c
2023 +@@ -902,7 +902,7 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios,
2024 + sport->port.read_status_mask = 0;
2025 + if (termios->c_iflag & INPCK)
2026 + sport->port.read_status_mask |= (UARTSR1_FE | UARTSR1_PE);
2027 +- if (termios->c_iflag & (BRKINT | PARMRK))
2028 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2029 + sport->port.read_status_mask |= UARTSR1_FE;
2030 +
2031 + /* characters to ignore */
2032 +diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
2033 +index 1d9420548e16..1efd4c36ba0c 100644
2034 +--- a/drivers/tty/serial/ip22zilog.c
2035 ++++ b/drivers/tty/serial/ip22zilog.c
2036 +@@ -850,7 +850,7 @@ ip22zilog_convert_to_zs(struct uart_ip22zilog_port *up, unsigned int cflag,
2037 + up->port.read_status_mask = Rx_OVR;
2038 + if (iflag & INPCK)
2039 + up->port.read_status_mask |= CRC_ERR | PAR_ERR;
2040 +- if (iflag & (BRKINT | PARMRK))
2041 ++ if (iflag & (IGNBRK | BRKINT | PARMRK))
2042 + up->port.read_status_mask |= BRK_ABRT;
2043 +
2044 + up->port.ignore_status_mask = 0;
2045 +diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
2046 +index 9cd9b4eba9fc..68f2c53e0b54 100644
2047 +--- a/drivers/tty/serial/m32r_sio.c
2048 ++++ b/drivers/tty/serial/m32r_sio.c
2049 +@@ -737,7 +737,7 @@ static void m32r_sio_set_termios(struct uart_port *port,
2050 + up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
2051 + if (termios->c_iflag & INPCK)
2052 + up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
2053 +- if (termios->c_iflag & (BRKINT | PARMRK))
2054 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2055 + up->port.read_status_mask |= UART_LSR_BI;
2056 +
2057 + /*
2058 +diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
2059 +index 2a99d0c61b9e..ba285cd45b59 100644
2060 +--- a/drivers/tty/serial/max310x.c
2061 ++++ b/drivers/tty/serial/max310x.c
2062 +@@ -835,7 +835,7 @@ static void max310x_set_termios(struct uart_port *port,
2063 + if (termios->c_iflag & INPCK)
2064 + port->read_status_mask |= MAX310X_LSR_RXPAR_BIT |
2065 + MAX310X_LSR_FRERR_BIT;
2066 +- if (termios->c_iflag & (BRKINT | PARMRK))
2067 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2068 + port->read_status_mask |= MAX310X_LSR_RXBRK_BIT;
2069 +
2070 + /* Set status ignore mask */
2071 +diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
2072 +index 0edfaf8cd269..a6f085717f94 100644
2073 +--- a/drivers/tty/serial/mcf.c
2074 ++++ b/drivers/tty/serial/mcf.c
2075 +@@ -248,6 +248,12 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
2076 + mr1 |= MCFUART_MR1_PARITYNONE;
2077 + }
2078 +
2079 ++ /*
2080 ++ * FIXME: port->read_status_mask and port->ignore_status_mask
2081 ++ * need to be initialized based on termios settings for
2082 ++ * INPCK, IGNBRK, IGNPAR, PARMRK, BRKINT
2083 ++ */
2084 ++
2085 + if (termios->c_cflag & CSTOPB)
2086 + mr2 |= MCFUART_MR2_STOP2;
2087 + else
2088 +diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c
2089 +index 52c930fac210..445799dc9846 100644
2090 +--- a/drivers/tty/serial/mfd.c
2091 ++++ b/drivers/tty/serial/mfd.c
2092 +@@ -977,7 +977,7 @@ serial_hsu_set_termios(struct uart_port *port, struct ktermios *termios,
2093 + up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
2094 + if (termios->c_iflag & INPCK)
2095 + up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
2096 +- if (termios->c_iflag & (BRKINT | PARMRK))
2097 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2098 + up->port.read_status_mask |= UART_LSR_BI;
2099 +
2100 + /* Characters to ignore */
2101 +diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
2102 +index e30a3ca3cea3..759c6a6fa74a 100644
2103 +--- a/drivers/tty/serial/mpsc.c
2104 ++++ b/drivers/tty/serial/mpsc.c
2105 +@@ -1458,7 +1458,7 @@ static void mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
2106 + pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_PE
2107 + | SDMA_DESC_CMDSTAT_FR;
2108 +
2109 +- if (termios->c_iflag & (BRKINT | PARMRK))
2110 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2111 + pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_BR;
2112 +
2113 + /* Characters/events to ignore */
2114 +diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
2115 +index 053b98eb46c8..7307dc4145ec 100644
2116 +--- a/drivers/tty/serial/msm_serial.c
2117 ++++ b/drivers/tty/serial/msm_serial.c
2118 +@@ -583,7 +583,7 @@ static void msm_set_termios(struct uart_port *port, struct ktermios *termios,
2119 + port->read_status_mask = 0;
2120 + if (termios->c_iflag & INPCK)
2121 + port->read_status_mask |= UART_SR_PAR_FRAME_ERR;
2122 +- if (termios->c_iflag & (BRKINT | PARMRK))
2123 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2124 + port->read_status_mask |= UART_SR_RX_BREAK;
2125 +
2126 + uart_update_timeout(port, termios->c_cflag, baud);
2127 +diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
2128 +index aa97fd845b4d..d98f1d4a9bd3 100644
2129 +--- a/drivers/tty/serial/mxs-auart.c
2130 ++++ b/drivers/tty/serial/mxs-auart.c
2131 +@@ -604,7 +604,7 @@ static void mxs_auart_settermios(struct uart_port *u,
2132 +
2133 + if (termios->c_iflag & INPCK)
2134 + u->read_status_mask |= AUART_STAT_PERR;
2135 +- if (termios->c_iflag & (BRKINT | PARMRK))
2136 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2137 + u->read_status_mask |= AUART_STAT_BERR;
2138 +
2139 + /*
2140 +diff --git a/drivers/tty/serial/netx-serial.c b/drivers/tty/serial/netx-serial.c
2141 +index 0a4dd70d29eb..7a6745601d4e 100644
2142 +--- a/drivers/tty/serial/netx-serial.c
2143 ++++ b/drivers/tty/serial/netx-serial.c
2144 +@@ -419,7 +419,7 @@ netx_set_termios(struct uart_port *port, struct ktermios *termios,
2145 + }
2146 +
2147 + port->read_status_mask = 0;
2148 +- if (termios->c_iflag & (BRKINT | PARMRK))
2149 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2150 + port->read_status_mask |= SR_BE;
2151 + if (termios->c_iflag & INPCK)
2152 + port->read_status_mask |= SR_PE | SR_FE;
2153 +diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
2154 +index e9d420ff3931..8193635103ee 100644
2155 +--- a/drivers/tty/serial/pmac_zilog.c
2156 ++++ b/drivers/tty/serial/pmac_zilog.c
2157 +@@ -1092,7 +1092,7 @@ static void pmz_convert_to_zs(struct uart_pmac_port *uap, unsigned int cflag,
2158 + uap->port.read_status_mask = Rx_OVR;
2159 + if (iflag & INPCK)
2160 + uap->port.read_status_mask |= CRC_ERR | PAR_ERR;
2161 +- if (iflag & (BRKINT | PARMRK))
2162 ++ if (iflag & (IGNBRK | BRKINT | PARMRK))
2163 + uap->port.read_status_mask |= BRK_ABRT;
2164 +
2165 + uap->port.ignore_status_mask = 0;
2166 +diff --git a/drivers/tty/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c
2167 +index de6c05c63683..2ba24a45c97f 100644
2168 +--- a/drivers/tty/serial/pnx8xxx_uart.c
2169 ++++ b/drivers/tty/serial/pnx8xxx_uart.c
2170 +@@ -477,7 +477,7 @@ pnx8xxx_set_termios(struct uart_port *port, struct ktermios *termios,
2171 + sport->port.read_status_mask |=
2172 + FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) |
2173 + FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR);
2174 +- if (termios->c_iflag & (BRKINT | PARMRK))
2175 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2176 + sport->port.read_status_mask |=
2177 + ISTAT_TO_SM(PNX8XXX_UART_INT_BREAK);
2178 +
2179 +diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
2180 +index f9f20f383760..fc3f308cd6c1 100644
2181 +--- a/drivers/tty/serial/pxa.c
2182 ++++ b/drivers/tty/serial/pxa.c
2183 +@@ -492,7 +492,7 @@ serial_pxa_set_termios(struct uart_port *port, struct ktermios *termios,
2184 + up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
2185 + if (termios->c_iflag & INPCK)
2186 + up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
2187 +- if (termios->c_iflag & (BRKINT | PARMRK))
2188 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2189 + up->port.read_status_mask |= UART_LSR_BI;
2190 +
2191 + /*
2192 +diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c
2193 +index a7cdec2962dd..771f361c47ea 100644
2194 +--- a/drivers/tty/serial/sb1250-duart.c
2195 ++++ b/drivers/tty/serial/sb1250-duart.c
2196 +@@ -596,7 +596,7 @@ static void sbd_set_termios(struct uart_port *uport, struct ktermios *termios,
2197 + if (termios->c_iflag & INPCK)
2198 + uport->read_status_mask |= M_DUART_FRM_ERR |
2199 + M_DUART_PARITY_ERR;
2200 +- if (termios->c_iflag & (BRKINT | PARMRK))
2201 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2202 + uport->read_status_mask |= M_DUART_RCVD_BRK;
2203 +
2204 + uport->ignore_status_mask = 0;
2205 +diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
2206 +index a447f71538ef..75ea83278ba4 100644
2207 +--- a/drivers/tty/serial/sccnxp.c
2208 ++++ b/drivers/tty/serial/sccnxp.c
2209 +@@ -667,7 +667,7 @@ static void sccnxp_set_termios(struct uart_port *port,
2210 + port->read_status_mask = SR_OVR;
2211 + if (termios->c_iflag & INPCK)
2212 + port->read_status_mask |= SR_PE | SR_FE;
2213 +- if (termios->c_iflag & (BRKINT | PARMRK))
2214 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2215 + port->read_status_mask |= SR_BRK;
2216 +
2217 + /* Set status ignore mask */
2218 +diff --git a/drivers/tty/serial/serial_ks8695.c b/drivers/tty/serial/serial_ks8695.c
2219 +index e1caa99e3d3b..5c79bdab985d 100644
2220 +--- a/drivers/tty/serial/serial_ks8695.c
2221 ++++ b/drivers/tty/serial/serial_ks8695.c
2222 +@@ -437,7 +437,7 @@ static void ks8695uart_set_termios(struct uart_port *port, struct ktermios *term
2223 + port->read_status_mask = URLS_URROE;
2224 + if (termios->c_iflag & INPCK)
2225 + port->read_status_mask |= (URLS_URFE | URLS_URPE);
2226 +- if (termios->c_iflag & (BRKINT | PARMRK))
2227 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2228 + port->read_status_mask |= URLS_URBI;
2229 +
2230 + /*
2231 +diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
2232 +index 90a080b1f9ee..cbf501da5df3 100644
2233 +--- a/drivers/tty/serial/serial_txx9.c
2234 ++++ b/drivers/tty/serial/serial_txx9.c
2235 +@@ -702,7 +702,7 @@ serial_txx9_set_termios(struct uart_port *port, struct ktermios *termios,
2236 + TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS;
2237 + if (termios->c_iflag & INPCK)
2238 + up->port.read_status_mask |= TXX9_SIDISR_UFER | TXX9_SIDISR_UPER;
2239 +- if (termios->c_iflag & (BRKINT | PARMRK))
2240 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2241 + up->port.read_status_mask |= TXX9_SIDISR_UBRK;
2242 +
2243 + /*
2244 +diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c
2245 +index 68b0fd4b9a6a..3146feb15255 100644
2246 +--- a/drivers/tty/serial/sirfsoc_uart.c
2247 ++++ b/drivers/tty/serial/sirfsoc_uart.c
2248 +@@ -907,7 +907,7 @@ static void sirfsoc_uart_set_termios(struct uart_port *port,
2249 + if (termios->c_iflag & INPCK)
2250 + port->read_status_mask |= uint_en->sirfsoc_frm_err_en;
2251 + }
2252 +- if (termios->c_iflag & (BRKINT | PARMRK))
2253 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2254 + port->read_status_mask |= uint_en->sirfsoc_rxd_brk_en;
2255 + if (sirfport->uart_reg->uart_type == SIRF_REAL_UART) {
2256 + if (termios->c_iflag & IGNPAR)
2257 +diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
2258 +index dd3a96e07026..3e707ba5bab9 100644
2259 +--- a/drivers/tty/serial/st-asc.c
2260 ++++ b/drivers/tty/serial/st-asc.c
2261 +@@ -547,7 +547,7 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios,
2262 + ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE;
2263 + if (termios->c_iflag & INPCK)
2264 + ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE;
2265 +- if (termios->c_iflag & (BRKINT | PARMRK))
2266 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2267 + ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE;
2268 +
2269 + /*
2270 +diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
2271 +index 5faa8e905e98..80a58eca785b 100644
2272 +--- a/drivers/tty/serial/sunsab.c
2273 ++++ b/drivers/tty/serial/sunsab.c
2274 +@@ -719,7 +719,7 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
2275 + if (iflag & INPCK)
2276 + up->port.read_status_mask |= (SAB82532_ISR0_PERR |
2277 + SAB82532_ISR0_FERR);
2278 +- if (iflag & (BRKINT | PARMRK))
2279 ++ if (iflag & (IGNBRK | BRKINT | PARMRK))
2280 + up->port.read_status_mask |= (SAB82532_ISR1_BRK << 8);
2281 +
2282 + /*
2283 +diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
2284 +index 9a0f24f83720..5326ae195e5f 100644
2285 +--- a/drivers/tty/serial/sunsu.c
2286 ++++ b/drivers/tty/serial/sunsu.c
2287 +@@ -834,7 +834,7 @@ sunsu_change_speed(struct uart_port *port, unsigned int cflag,
2288 + up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
2289 + if (iflag & INPCK)
2290 + up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
2291 +- if (iflag & (BRKINT | PARMRK))
2292 ++ if (iflag & (IGNBRK | BRKINT | PARMRK))
2293 + up->port.read_status_mask |= UART_LSR_BI;
2294 +
2295 + /*
2296 +diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
2297 +index a2c40ed287d2..a85db8b87156 100644
2298 +--- a/drivers/tty/serial/sunzilog.c
2299 ++++ b/drivers/tty/serial/sunzilog.c
2300 +@@ -915,7 +915,7 @@ sunzilog_convert_to_zs(struct uart_sunzilog_port *up, unsigned int cflag,
2301 + up->port.read_status_mask = Rx_OVR;
2302 + if (iflag & INPCK)
2303 + up->port.read_status_mask |= CRC_ERR | PAR_ERR;
2304 +- if (iflag & (BRKINT | PARMRK))
2305 ++ if (iflag & (IGNBRK | BRKINT | PARMRK))
2306 + up->port.read_status_mask |= BRK_ABRT;
2307 +
2308 + up->port.ignore_status_mask = 0;
2309 +diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
2310 +index d569ca58bab6..1c52074c38df 100644
2311 +--- a/drivers/tty/serial/ucc_uart.c
2312 ++++ b/drivers/tty/serial/ucc_uart.c
2313 +@@ -936,7 +936,7 @@ static void qe_uart_set_termios(struct uart_port *port,
2314 + port->read_status_mask = BD_SC_EMPTY | BD_SC_OV;
2315 + if (termios->c_iflag & INPCK)
2316 + port->read_status_mask |= BD_SC_FR | BD_SC_PR;
2317 +- if (termios->c_iflag & (BRKINT | PARMRK))
2318 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2319 + port->read_status_mask |= BD_SC_BR;
2320 +
2321 + /*
2322 +diff --git a/drivers/tty/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_siu.c
2323 +index a63c14bc9a24..db0c8a4ab03e 100644
2324 +--- a/drivers/tty/serial/vr41xx_siu.c
2325 ++++ b/drivers/tty/serial/vr41xx_siu.c
2326 +@@ -559,7 +559,7 @@ static void siu_set_termios(struct uart_port *port, struct ktermios *new,
2327 + port->read_status_mask = UART_LSR_THRE | UART_LSR_OE | UART_LSR_DR;
2328 + if (c_iflag & INPCK)
2329 + port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
2330 +- if (c_iflag & (BRKINT | PARMRK))
2331 ++ if (c_iflag & (IGNBRK | BRKINT | PARMRK))
2332 + port->read_status_mask |= UART_LSR_BI;
2333 +
2334 + port->ignore_status_mask = 0;
2335 +diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c
2336 +index 6a169877109b..2b65bb7ffb8a 100644
2337 +--- a/drivers/tty/serial/zs.c
2338 ++++ b/drivers/tty/serial/zs.c
2339 +@@ -923,7 +923,7 @@ static void zs_set_termios(struct uart_port *uport, struct ktermios *termios,
2340 + uport->read_status_mask = Rx_OVR;
2341 + if (termios->c_iflag & INPCK)
2342 + uport->read_status_mask |= FRM_ERR | PAR_ERR;
2343 +- if (termios->c_iflag & (BRKINT | PARMRK))
2344 ++ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2345 + uport->read_status_mask |= Rx_BRK;
2346 +
2347 + uport->ignore_status_mask = 0;
2348 +diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
2349 +index 7739c64ef259..482c45b777d3 100644
2350 +--- a/drivers/usb/chipidea/udc.c
2351 ++++ b/drivers/usb/chipidea/udc.c
2352 +@@ -1328,6 +1328,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
2353 + struct ci_hw_ep *hwep = container_of(ep, struct ci_hw_ep, ep);
2354 + struct ci_hw_req *hwreq = container_of(req, struct ci_hw_req, req);
2355 + unsigned long flags;
2356 ++ struct td_node *node, *tmpnode;
2357 +
2358 + if (ep == NULL || req == NULL || hwreq->req.status != -EALREADY ||
2359 + hwep->ep.desc == NULL || list_empty(&hwreq->queue) ||
2360 +@@ -1338,6 +1339,12 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
2361 +
2362 + hw_ep_flush(hwep->ci, hwep->num, hwep->dir);
2363 +
2364 ++ list_for_each_entry_safe(node, tmpnode, &hwreq->tds, td) {
2365 ++ dma_pool_free(hwep->td_pool, node->ptr, node->dma);
2366 ++ list_del(&node->td);
2367 ++ kfree(node);
2368 ++ }
2369 ++
2370 + /* pop request */
2371 + list_del_init(&hwreq->queue);
2372 +
2373 +diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
2374 +index 1e12b3ee56fd..ddb54ee4ca73 100644
2375 +--- a/drivers/usb/gadget/f_fs.c
2376 ++++ b/drivers/usb/gadget/f_fs.c
2377 +@@ -1508,11 +1508,13 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
2378 + ffs->ep0req->context = ffs;
2379 +
2380 + lang = ffs->stringtabs;
2381 +- for (lang = ffs->stringtabs; *lang; ++lang) {
2382 +- struct usb_string *str = (*lang)->strings;
2383 +- int id = first_id;
2384 +- for (; str->s; ++id, ++str)
2385 +- str->id = id;
2386 ++ if (lang) {
2387 ++ for (; *lang; ++lang) {
2388 ++ struct usb_string *str = (*lang)->strings;
2389 ++ int id = first_id;
2390 ++ for (; str->s; ++id, ++str)
2391 ++ str->id = id;
2392 ++ }
2393 + }
2394 +
2395 + ffs->gadget = cdev->gadget;
2396 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
2397 +index 7a0e3c720c00..d0c65d6faf93 100644
2398 +--- a/drivers/usb/host/xhci-ring.c
2399 ++++ b/drivers/usb/host/xhci-ring.c
2400 +@@ -1611,8 +1611,11 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
2401 + xhci_handle_cmd_reset_ep(xhci, slot_id, cmd_trb, cmd_comp_code);
2402 + break;
2403 + case TRB_RESET_DEV:
2404 +- WARN_ON(slot_id != TRB_TO_SLOT_ID(
2405 +- le32_to_cpu(cmd_trb->generic.field[3])));
2406 ++ /* SLOT_ID field in reset device cmd completion event TRB is 0.
2407 ++ * Use the SLOT_ID from the command TRB instead (xhci 4.6.11)
2408 ++ */
2409 ++ slot_id = TRB_TO_SLOT_ID(
2410 ++ le32_to_cpu(cmd_trb->generic.field[3]));
2411 + xhci_handle_cmd_reset_dev(xhci, slot_id, event);
2412 + break;
2413 + case TRB_NEC_GET_FW:
2414 +@@ -3696,7 +3699,7 @@ static unsigned int xhci_get_burst_count(struct xhci_hcd *xhci,
2415 + return 0;
2416 +
2417 + max_burst = urb->ep->ss_ep_comp.bMaxBurst;
2418 +- return roundup(total_packet_count, max_burst + 1) - 1;
2419 ++ return DIV_ROUND_UP(total_packet_count, max_burst + 1) - 1;
2420 + }
2421 +
2422 + /*
2423 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
2424 +index 300836972faa..3f8e2c18962f 100644
2425 +--- a/drivers/usb/host/xhci.c
2426 ++++ b/drivers/usb/host/xhci.c
2427 +@@ -932,7 +932,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
2428 + */
2429 + int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
2430 + {
2431 +- u32 command, temp = 0;
2432 ++ u32 command, temp = 0, status;
2433 + struct usb_hcd *hcd = xhci_to_hcd(xhci);
2434 + struct usb_hcd *secondary_hcd;
2435 + int retval = 0;
2436 +@@ -1050,8 +1050,12 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
2437 +
2438 + done:
2439 + if (retval == 0) {
2440 +- usb_hcd_resume_root_hub(hcd);
2441 +- usb_hcd_resume_root_hub(xhci->shared_hcd);
2442 ++ /* Resume root hubs only when have pending events. */
2443 ++ status = readl(&xhci->op_regs->status);
2444 ++ if (status & STS_EINT) {
2445 ++ usb_hcd_resume_root_hub(hcd);
2446 ++ usb_hcd_resume_root_hub(xhci->shared_hcd);
2447 ++ }
2448 + }
2449 +
2450 + /*
2451 +diff --git a/drivers/usb/musb/musb_am335x.c b/drivers/usb/musb/musb_am335x.c
2452 +index d2353781bd2d..1e58ed2361cc 100644
2453 +--- a/drivers/usb/musb/musb_am335x.c
2454 ++++ b/drivers/usb/musb/musb_am335x.c
2455 +@@ -19,21 +19,6 @@ err:
2456 + return ret;
2457 + }
2458 +
2459 +-static int of_remove_populated_child(struct device *dev, void *d)
2460 +-{
2461 +- struct platform_device *pdev = to_platform_device(dev);
2462 +-
2463 +- of_device_unregister(pdev);
2464 +- return 0;
2465 +-}
2466 +-
2467 +-static int am335x_child_remove(struct platform_device *pdev)
2468 +-{
2469 +- device_for_each_child(&pdev->dev, NULL, of_remove_populated_child);
2470 +- pm_runtime_disable(&pdev->dev);
2471 +- return 0;
2472 +-}
2473 +-
2474 + static const struct of_device_id am335x_child_of_match[] = {
2475 + { .compatible = "ti,am33xx-usb" },
2476 + { },
2477 +@@ -42,13 +27,17 @@ MODULE_DEVICE_TABLE(of, am335x_child_of_match);
2478 +
2479 + static struct platform_driver am335x_child_driver = {
2480 + .probe = am335x_child_probe,
2481 +- .remove = am335x_child_remove,
2482 + .driver = {
2483 + .name = "am335x-usb-childs",
2484 + .of_match_table = am335x_child_of_match,
2485 + },
2486 + };
2487 +
2488 +-module_platform_driver(am335x_child_driver);
2489 ++static int __init am335x_child_init(void)
2490 ++{
2491 ++ return platform_driver_register(&am335x_child_driver);
2492 ++}
2493 ++module_init(am335x_child_init);
2494 ++
2495 + MODULE_DESCRIPTION("AM33xx child devices");
2496 + MODULE_LICENSE("GPL v2");
2497 +diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
2498 +index 7b8bbf53127e..5341bb223b7c 100644
2499 +--- a/drivers/usb/musb/musb_cppi41.c
2500 ++++ b/drivers/usb/musb/musb_cppi41.c
2501 +@@ -318,7 +318,7 @@ static void cppi41_dma_callback(void *private_data)
2502 + }
2503 + list_add_tail(&cppi41_channel->tx_check,
2504 + &controller->early_tx_list);
2505 +- if (!hrtimer_active(&controller->early_tx)) {
2506 ++ if (!hrtimer_is_queued(&controller->early_tx)) {
2507 + hrtimer_start_range_ns(&controller->early_tx,
2508 + ktime_set(0, 140 * NSEC_PER_USEC),
2509 + 40 * NSEC_PER_USEC,
2510 +diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
2511 +index c2e45e632723..f202e5088461 100644
2512 +--- a/drivers/usb/musb/ux500.c
2513 ++++ b/drivers/usb/musb/ux500.c
2514 +@@ -274,7 +274,6 @@ static int ux500_probe(struct platform_device *pdev)
2515 + musb->dev.parent = &pdev->dev;
2516 + musb->dev.dma_mask = &pdev->dev.coherent_dma_mask;
2517 + musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
2518 +- musb->dev.of_node = pdev->dev.of_node;
2519 +
2520 + glue->dev = &pdev->dev;
2521 + glue->musb = musb;
2522 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
2523 +index edf3b124583c..115662c16dcc 100644
2524 +--- a/drivers/usb/serial/ftdi_sio.c
2525 ++++ b/drivers/usb/serial/ftdi_sio.c
2526 +@@ -1566,14 +1566,17 @@ static void ftdi_set_max_packet_size(struct usb_serial_port *port)
2527 + struct usb_device *udev = serial->dev;
2528 +
2529 + struct usb_interface *interface = serial->interface;
2530 +- struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc;
2531 ++ struct usb_endpoint_descriptor *ep_desc;
2532 +
2533 + unsigned num_endpoints;
2534 +- int i;
2535 ++ unsigned i;
2536 +
2537 + num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
2538 + dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
2539 +
2540 ++ if (!num_endpoints)
2541 ++ return;
2542 ++
2543 + /* NOTE: some customers have programmed FT232R/FT245R devices
2544 + * with an endpoint size of 0 - not good. In this case, we
2545 + * want to override the endpoint descriptor setting and use a
2546 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2547 +index 70ede84f4f6b..e25e8ca09fe2 100644
2548 +--- a/drivers/usb/serial/option.c
2549 ++++ b/drivers/usb/serial/option.c
2550 +@@ -352,6 +352,9 @@ static void option_instat_callback(struct urb *urb);
2551 + /* Zoom */
2552 + #define ZOOM_PRODUCT_4597 0x9607
2553 +
2554 ++/* SpeedUp SU9800 usb 3g modem */
2555 ++#define SPEEDUP_PRODUCT_SU9800 0x9800
2556 ++
2557 + /* Haier products */
2558 + #define HAIER_VENDOR_ID 0x201e
2559 + #define HAIER_PRODUCT_CE100 0x2009
2560 +@@ -372,8 +375,12 @@ static void option_instat_callback(struct urb *urb);
2561 + /* Olivetti products */
2562 + #define OLIVETTI_VENDOR_ID 0x0b3c
2563 + #define OLIVETTI_PRODUCT_OLICARD100 0xc000
2564 ++#define OLIVETTI_PRODUCT_OLICARD120 0xc001
2565 ++#define OLIVETTI_PRODUCT_OLICARD140 0xc002
2566 + #define OLIVETTI_PRODUCT_OLICARD145 0xc003
2567 ++#define OLIVETTI_PRODUCT_OLICARD155 0xc004
2568 + #define OLIVETTI_PRODUCT_OLICARD200 0xc005
2569 ++#define OLIVETTI_PRODUCT_OLICARD160 0xc00a
2570 + #define OLIVETTI_PRODUCT_OLICARD500 0xc00b
2571 +
2572 + /* Celot products */
2573 +@@ -1577,6 +1584,7 @@ static const struct usb_device_id option_ids[] = {
2574 + { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14),
2575 + .driver_info = (kernel_ulong_t)&four_g_w14_blacklist
2576 + },
2577 ++ { USB_DEVICE_INTERFACE_CLASS(LONGCHEER_VENDOR_ID, SPEEDUP_PRODUCT_SU9800, 0xff) },
2578 + { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) },
2579 + { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) },
2580 + { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
2581 +@@ -1611,15 +1619,21 @@ static const struct usb_device_id option_ids[] = {
2582 + { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) },
2583 + { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, /* HC28 enumerates with Siemens or Cinterion VID depending on FW revision */
2584 + { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
2585 +-
2586 +- { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
2587 ++ { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100),
2588 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2589 ++ { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD120),
2590 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2591 ++ { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD140),
2592 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2593 + { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) },
2594 ++ { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD155),
2595 ++ .driver_info = (kernel_ulong_t)&net_intf6_blacklist },
2596 + { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200),
2597 +- .driver_info = (kernel_ulong_t)&net_intf6_blacklist
2598 +- },
2599 ++ .driver_info = (kernel_ulong_t)&net_intf6_blacklist },
2600 ++ { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD160),
2601 ++ .driver_info = (kernel_ulong_t)&net_intf6_blacklist },
2602 + { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD500),
2603 +- .driver_info = (kernel_ulong_t)&net_intf4_blacklist
2604 +- },
2605 ++ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2606 + { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
2607 + { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
2608 + { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) },
2609 +diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
2610 +index 9d38ddc8da49..866b5df36ed1 100644
2611 +--- a/drivers/usb/storage/scsiglue.c
2612 ++++ b/drivers/usb/storage/scsiglue.c
2613 +@@ -256,6 +256,10 @@ static int slave_configure(struct scsi_device *sdev)
2614 + if (us->fflags & US_FL_WRITE_CACHE)
2615 + sdev->wce_default_on = 1;
2616 +
2617 ++ /* A few buggy USB-ATA bridges don't understand FUA */
2618 ++ if (us->fflags & US_FL_BROKEN_FUA)
2619 ++ sdev->broken_fua = 1;
2620 ++
2621 + } else {
2622 +
2623 + /* Non-disk-type devices don't need to blacklist any pages
2624 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
2625 +index 174a447868cd..80a5b366255f 100644
2626 +--- a/drivers/usb/storage/unusual_devs.h
2627 ++++ b/drivers/usb/storage/unusual_devs.h
2628 +@@ -1936,6 +1936,13 @@ UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201,
2629 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2630 + US_FL_IGNORE_RESIDUE ),
2631 +
2632 ++/* Reported by Michael Büsch <m@××××.ch> */
2633 ++UNUSUAL_DEV( 0x152d, 0x0567, 0x0114, 0x0114,
2634 ++ "JMicron",
2635 ++ "USB to ATA/ATAPI Bridge",
2636 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2637 ++ US_FL_BROKEN_FUA ),
2638 ++
2639 + /* Reported by Alexandre Oliva <oliva@××××××××××××××.br>
2640 + * JMicron responds to USN and several other SCSI ioctls with a
2641 + * residue that causes subsequent I/O requests to fail. */
2642 +diff --git a/drivers/video/fbdev/fb-puv3.c b/drivers/video/fbdev/fb-puv3.c
2643 +index 6db9ebd042a3..88fa2e70a0bb 100644
2644 +--- a/drivers/video/fbdev/fb-puv3.c
2645 ++++ b/drivers/video/fbdev/fb-puv3.c
2646 +@@ -18,8 +18,10 @@
2647 + #include <linux/fb.h>
2648 + #include <linux/init.h>
2649 + #include <linux/console.h>
2650 ++#include <linux/mm.h>
2651 +
2652 + #include <asm/sizes.h>
2653 ++#include <asm/pgtable.h>
2654 + #include <mach/hardware.h>
2655 +
2656 + /* Platform_data reserved for unifb registers. */
2657 +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
2658 +index a62a5bdc0502..10f3c5c8783d 100644
2659 +--- a/fs/btrfs/disk-io.c
2660 ++++ b/fs/btrfs/disk-io.c
2661 +@@ -368,7 +368,8 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
2662 + out:
2663 + unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1,
2664 + &cached_state, GFP_NOFS);
2665 +- btrfs_tree_read_unlock_blocking(eb);
2666 ++ if (need_lock)
2667 ++ btrfs_tree_read_unlock_blocking(eb);
2668 + return ret;
2669 + }
2670 +
2671 +diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
2672 +index 0227b45ef00a..15e9505aa35f 100644
2673 +--- a/fs/cifs/cifs_unicode.c
2674 ++++ b/fs/cifs/cifs_unicode.c
2675 +@@ -290,7 +290,8 @@ int
2676 + cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
2677 + const struct nls_table *cp, int mapChars)
2678 + {
2679 +- int i, j, charlen;
2680 ++ int i, charlen;
2681 ++ int j = 0;
2682 + char src_char;
2683 + __le16 dst_char;
2684 + wchar_t tmp;
2685 +@@ -298,12 +299,11 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
2686 + if (!mapChars)
2687 + return cifs_strtoUTF16(target, source, PATH_MAX, cp);
2688 +
2689 +- for (i = 0, j = 0; i < srclen; j++) {
2690 ++ for (i = 0; i < srclen; j++) {
2691 + src_char = source[i];
2692 + charlen = 1;
2693 + switch (src_char) {
2694 + case 0:
2695 +- put_unaligned(0, &target[j]);
2696 + goto ctoUTF16_out;
2697 + case ':':
2698 + dst_char = cpu_to_le16(UNI_COLON);
2699 +@@ -350,6 +350,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
2700 + }
2701 +
2702 + ctoUTF16_out:
2703 ++ put_unaligned(0, &target[j]); /* Null terminate target unicode string */
2704 + return j;
2705 + }
2706 +
2707 +diff --git a/fs/cifs/link.c b/fs/cifs/link.c
2708 +index 264ece71bdb2..68559fd557fb 100644
2709 +--- a/fs/cifs/link.c
2710 ++++ b/fs/cifs/link.c
2711 +@@ -374,7 +374,7 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
2712 + oparms.cifs_sb = cifs_sb;
2713 + oparms.desired_access = GENERIC_WRITE;
2714 + oparms.create_options = create_options;
2715 +- oparms.disposition = FILE_OPEN;
2716 ++ oparms.disposition = FILE_CREATE;
2717 + oparms.path = path;
2718 + oparms.fid = &fid;
2719 + oparms.reconnect = false;
2720 +diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
2721 +index 594009f5f523..e6574d7b6642 100644
2722 +--- a/fs/ext4/indirect.c
2723 ++++ b/fs/ext4/indirect.c
2724 +@@ -389,7 +389,13 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
2725 + return 0;
2726 + failed:
2727 + for (; i >= 0; i--) {
2728 +- if (i != indirect_blks && branch[i].bh)
2729 ++ /*
2730 ++ * We want to ext4_forget() only freshly allocated indirect
2731 ++ * blocks. Buffer for new_blocks[i-1] is at branch[i].bh and
2732 ++ * buffer at branch[0].bh is indirect block / inode already
2733 ++ * existing before ext4_alloc_branch() was called.
2734 ++ */
2735 ++ if (i > 0 && i != indirect_blks && branch[i].bh)
2736 + ext4_forget(handle, 1, inode, branch[i].bh,
2737 + branch[i].bh->b_blocknr);
2738 + ext4_free_blocks(handle, inode, NULL, new_blocks[i],
2739 +@@ -1312,16 +1318,24 @@ static int free_hole_blocks(handle_t *handle, struct inode *inode,
2740 + blk = *i_data;
2741 + if (level > 0) {
2742 + ext4_lblk_t first2;
2743 ++ ext4_lblk_t count2;
2744 ++
2745 + bh = sb_bread(inode->i_sb, le32_to_cpu(blk));
2746 + if (!bh) {
2747 + EXT4_ERROR_INODE_BLOCK(inode, le32_to_cpu(blk),
2748 + "Read failure");
2749 + return -EIO;
2750 + }
2751 +- first2 = (first > offset) ? first - offset : 0;
2752 ++ if (first > offset) {
2753 ++ first2 = first - offset;
2754 ++ count2 = count;
2755 ++ } else {
2756 ++ first2 = 0;
2757 ++ count2 = count - (offset - first);
2758 ++ }
2759 + ret = free_hole_blocks(handle, inode, bh,
2760 + (__le32 *)bh->b_data, level - 1,
2761 +- first2, count - offset,
2762 ++ first2, count2,
2763 + inode->i_sb->s_blocksize >> 2);
2764 + if (ret) {
2765 + brelse(bh);
2766 +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
2767 +index d543222babf3..95e3720d1452 100644
2768 +--- a/fs/nfsd/nfs4proc.c
2769 ++++ b/fs/nfsd/nfs4proc.c
2770 +@@ -618,15 +618,6 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2771 +
2772 + switch (create->cr_type) {
2773 + case NF4LNK:
2774 +- /* ugh! we have to null-terminate the linktext, or
2775 +- * vfs_symlink() will choke. it is always safe to
2776 +- * null-terminate by brute force, since at worst we
2777 +- * will overwrite the first byte of the create namelen
2778 +- * in the XDR buffer, which has already been extracted
2779 +- * during XDR decode.
2780 +- */
2781 +- create->cr_linkname[create->cr_linklen] = 0;
2782 +-
2783 + status = nfsd_symlink(rqstp, &cstate->current_fh,
2784 + create->cr_name, create->cr_namelen,
2785 + create->cr_linkname, create->cr_linklen,
2786 +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
2787 +index b4c49588eada..3297158241e5 100644
2788 +--- a/fs/nfsd/nfs4xdr.c
2789 ++++ b/fs/nfsd/nfs4xdr.c
2790 +@@ -602,7 +602,18 @@ nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create
2791 + READ_BUF(4);
2792 + READ32(create->cr_linklen);
2793 + READ_BUF(create->cr_linklen);
2794 +- SAVEMEM(create->cr_linkname, create->cr_linklen);
2795 ++ /*
2796 ++ * The VFS will want a null-terminated string, and
2797 ++ * null-terminating in place isn't safe since this might
2798 ++ * end on a page boundary:
2799 ++ */
2800 ++ create->cr_linkname =
2801 ++ kmalloc(create->cr_linklen + 1, GFP_KERNEL);
2802 ++ if (!create->cr_linkname)
2803 ++ return nfserr_jukebox;
2804 ++ memcpy(create->cr_linkname, p, create->cr_linklen);
2805 ++ create->cr_linkname[create->cr_linklen] = '\0';
2806 ++ defer_free(argp, kfree, create->cr_linkname);
2807 + break;
2808 + case NF4BLK:
2809 + case NF4CHR:
2810 +diff --git a/include/drm/i915_powerwell.h b/include/drm/i915_powerwell.h
2811 +index cfdc884405b7..baa6f11b1837 100644
2812 +--- a/include/drm/i915_powerwell.h
2813 ++++ b/include/drm/i915_powerwell.h
2814 +@@ -30,7 +30,8 @@
2815 + #define _I915_POWERWELL_H_
2816 +
2817 + /* For use by hda_i915 driver */
2818 +-extern void i915_request_power_well(void);
2819 +-extern void i915_release_power_well(void);
2820 ++extern int i915_request_power_well(void);
2821 ++extern int i915_release_power_well(void);
2822 ++extern int i915_get_cdclk_freq(void);
2823 +
2824 + #endif /* _I915_POWERWELL_H_ */
2825 +diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
2826 +index 1a64b26046ed..9b7de1b46437 100644
2827 +--- a/include/linux/usb_usual.h
2828 ++++ b/include/linux/usb_usual.h
2829 +@@ -70,7 +70,9 @@
2830 + US_FLAG(NEEDS_CAP16, 0x00400000) \
2831 + /* cannot handle READ_CAPACITY_10 */ \
2832 + US_FLAG(IGNORE_UAS, 0x00800000) \
2833 +- /* Device advertises UAS but it is broken */
2834 ++ /* Device advertises UAS but it is broken */ \
2835 ++ US_FLAG(BROKEN_FUA, 0x01000000) \
2836 ++ /* Cannot handle FUA in WRITE or READ CDBs */ \
2837 +
2838 + #define US_FLAG(name, value) US_FL_##name = value ,
2839 + enum { US_DO_ALL_FLAGS };
2840 +diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
2841 +index a100c6e266c7..c95c0774a863 100644
2842 +--- a/include/scsi/scsi_cmnd.h
2843 ++++ b/include/scsi/scsi_cmnd.h
2844 +@@ -309,7 +309,7 @@ static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)
2845 +
2846 + static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
2847 + {
2848 +- unsigned int xfer_len = blk_rq_bytes(scmd->request);
2849 ++ unsigned int xfer_len = scsi_out(scmd)->length;
2850 + unsigned int prot_op = scsi_get_prot_op(scmd);
2851 + unsigned int sector_size = scmd->device->sector_size;
2852 +
2853 +diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
2854 +index 5853c913d2b0..27ab31017f09 100644
2855 +--- a/include/scsi/scsi_device.h
2856 ++++ b/include/scsi/scsi_device.h
2857 +@@ -173,6 +173,7 @@ struct scsi_device {
2858 + unsigned is_visible:1; /* is the device visible in sysfs */
2859 + unsigned wce_default_on:1; /* Cache is ON by default */
2860 + unsigned no_dif:1; /* T10 PI (DIF) should be disabled */
2861 ++ unsigned broken_fua:1; /* Don't set FUA bit */
2862 +
2863 + atomic_t disk_events_disable_depth; /* disable depth for disk events */
2864 +
2865 +diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
2866 +index 2a4b4a72a4f9..24b68c59dcf8 100644
2867 +--- a/include/uapi/linux/usb/functionfs.h
2868 ++++ b/include/uapi/linux/usb/functionfs.h
2869 +@@ -33,6 +33,13 @@ struct usb_endpoint_descriptor_no_audio {
2870 + __u8 bInterval;
2871 + } __attribute__((packed));
2872 +
2873 ++/* Legacy format, deprecated as of 3.14. */
2874 ++struct usb_functionfs_descs_head {
2875 ++ __le32 magic;
2876 ++ __le32 length;
2877 ++ __le32 fs_count;
2878 ++ __le32 hs_count;
2879 ++} __attribute__((packed, deprecated));
2880 +
2881 + /*
2882 + * Descriptors format:
2883 +diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2884 +index 74f5b580fe34..0e0373f51c58 100644
2885 +--- a/kernel/sysctl.c
2886 ++++ b/kernel/sysctl.c
2887 +@@ -136,7 +136,6 @@ static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
2888 + /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
2889 + static int maxolduid = 65535;
2890 + static int minolduid;
2891 +-static int min_percpu_pagelist_fract = 8;
2892 +
2893 + static int ngroups_max = NGROUPS_MAX;
2894 + static const int cap_last_cap = CAP_LAST_CAP;
2895 +@@ -1305,7 +1304,7 @@ static struct ctl_table vm_table[] = {
2896 + .maxlen = sizeof(percpu_pagelist_fraction),
2897 + .mode = 0644,
2898 + .proc_handler = percpu_pagelist_fraction_sysctl_handler,
2899 +- .extra1 = &min_percpu_pagelist_fract,
2900 ++ .extra1 = &zero,
2901 + },
2902 + #ifdef CONFIG_MMU
2903 + {
2904 +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
2905 +index e916972c6d87..1848dc6278b7 100644
2906 +--- a/kernel/trace/trace.c
2907 ++++ b/kernel/trace/trace.c
2908 +@@ -1367,7 +1367,6 @@ void tracing_start(void)
2909 +
2910 + arch_spin_unlock(&ftrace_max_lock);
2911 +
2912 +- ftrace_start();
2913 + out:
2914 + raw_spin_unlock_irqrestore(&global_trace.start_lock, flags);
2915 + }
2916 +@@ -1414,7 +1413,6 @@ void tracing_stop(void)
2917 + struct ring_buffer *buffer;
2918 + unsigned long flags;
2919 +
2920 +- ftrace_stop();
2921 + raw_spin_lock_irqsave(&global_trace.start_lock, flags);
2922 + if (global_trace.stop_count++)
2923 + goto out;
2924 +diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
2925 +index c082a7441345..da9d2614e82e 100644
2926 +--- a/kernel/trace/trace_uprobe.c
2927 ++++ b/kernel/trace/trace_uprobe.c
2928 +@@ -893,6 +893,9 @@ probe_event_enable(struct trace_uprobe *tu, struct ftrace_event_file *file,
2929 + int ret;
2930 +
2931 + if (file) {
2932 ++ if (tu->tp.flags & TP_FLAG_PROFILE)
2933 ++ return -EINTR;
2934 ++
2935 + link = kmalloc(sizeof(*link), GFP_KERNEL);
2936 + if (!link)
2937 + return -ENOMEM;
2938 +@@ -901,29 +904,40 @@ probe_event_enable(struct trace_uprobe *tu, struct ftrace_event_file *file,
2939 + list_add_tail_rcu(&link->list, &tu->tp.files);
2940 +
2941 + tu->tp.flags |= TP_FLAG_TRACE;
2942 +- } else
2943 +- tu->tp.flags |= TP_FLAG_PROFILE;
2944 ++ } else {
2945 ++ if (tu->tp.flags & TP_FLAG_TRACE)
2946 ++ return -EINTR;
2947 +
2948 +- ret = uprobe_buffer_enable();
2949 +- if (ret < 0)
2950 +- return ret;
2951 ++ tu->tp.flags |= TP_FLAG_PROFILE;
2952 ++ }
2953 +
2954 + WARN_ON(!uprobe_filter_is_empty(&tu->filter));
2955 +
2956 + if (enabled)
2957 + return 0;
2958 +
2959 ++ ret = uprobe_buffer_enable();
2960 ++ if (ret)
2961 ++ goto err_flags;
2962 ++
2963 + tu->consumer.filter = filter;
2964 + ret = uprobe_register(tu->inode, tu->offset, &tu->consumer);
2965 +- if (ret) {
2966 +- if (file) {
2967 +- list_del(&link->list);
2968 +- kfree(link);
2969 +- tu->tp.flags &= ~TP_FLAG_TRACE;
2970 +- } else
2971 +- tu->tp.flags &= ~TP_FLAG_PROFILE;
2972 +- }
2973 ++ if (ret)
2974 ++ goto err_buffer;
2975 ++
2976 ++ return 0;
2977 ++
2978 ++ err_buffer:
2979 ++ uprobe_buffer_disable();
2980 +
2981 ++ err_flags:
2982 ++ if (file) {
2983 ++ list_del(&link->list);
2984 ++ kfree(link);
2985 ++ tu->tp.flags &= ~TP_FLAG_TRACE;
2986 ++ } else {
2987 ++ tu->tp.flags &= ~TP_FLAG_PROFILE;
2988 ++ }
2989 + return ret;
2990 + }
2991 +
2992 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
2993 +index c82290b9c1fc..a646f1598d58 100644
2994 +--- a/mm/hugetlb.c
2995 ++++ b/mm/hugetlb.c
2996 +@@ -2377,6 +2377,31 @@ static void set_huge_ptep_writable(struct vm_area_struct *vma,
2997 + update_mmu_cache(vma, address, ptep);
2998 + }
2999 +
3000 ++static int is_hugetlb_entry_migration(pte_t pte)
3001 ++{
3002 ++ swp_entry_t swp;
3003 ++
3004 ++ if (huge_pte_none(pte) || pte_present(pte))
3005 ++ return 0;
3006 ++ swp = pte_to_swp_entry(pte);
3007 ++ if (non_swap_entry(swp) && is_migration_entry(swp))
3008 ++ return 1;
3009 ++ else
3010 ++ return 0;
3011 ++}
3012 ++
3013 ++static int is_hugetlb_entry_hwpoisoned(pte_t pte)
3014 ++{
3015 ++ swp_entry_t swp;
3016 ++
3017 ++ if (huge_pte_none(pte) || pte_present(pte))
3018 ++ return 0;
3019 ++ swp = pte_to_swp_entry(pte);
3020 ++ if (non_swap_entry(swp) && is_hwpoison_entry(swp))
3021 ++ return 1;
3022 ++ else
3023 ++ return 0;
3024 ++}
3025 +
3026 + int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
3027 + struct vm_area_struct *vma)
3028 +@@ -2416,10 +2441,26 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
3029 + dst_ptl = huge_pte_lock(h, dst, dst_pte);
3030 + src_ptl = huge_pte_lockptr(h, src, src_pte);
3031 + spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING);
3032 +- if (!huge_pte_none(huge_ptep_get(src_pte))) {
3033 ++ entry = huge_ptep_get(src_pte);
3034 ++ if (huge_pte_none(entry)) { /* skip none entry */
3035 ++ ;
3036 ++ } else if (unlikely(is_hugetlb_entry_migration(entry) ||
3037 ++ is_hugetlb_entry_hwpoisoned(entry))) {
3038 ++ swp_entry_t swp_entry = pte_to_swp_entry(entry);
3039 ++
3040 ++ if (is_write_migration_entry(swp_entry) && cow) {
3041 ++ /*
3042 ++ * COW mappings require pages in both
3043 ++ * parent and child to be set to read.
3044 ++ */
3045 ++ make_migration_entry_read(&swp_entry);
3046 ++ entry = swp_entry_to_pte(swp_entry);
3047 ++ set_huge_pte_at(src, addr, src_pte, entry);
3048 ++ }
3049 ++ set_huge_pte_at(dst, addr, dst_pte, entry);
3050 ++ } else {
3051 + if (cow)
3052 + huge_ptep_set_wrprotect(src, addr, src_pte);
3053 +- entry = huge_ptep_get(src_pte);
3054 + ptepage = pte_page(entry);
3055 + get_page(ptepage);
3056 + page_dup_rmap(ptepage);
3057 +@@ -2435,32 +2476,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
3058 + return ret;
3059 + }
3060 +
3061 +-static int is_hugetlb_entry_migration(pte_t pte)
3062 +-{
3063 +- swp_entry_t swp;
3064 +-
3065 +- if (huge_pte_none(pte) || pte_present(pte))
3066 +- return 0;
3067 +- swp = pte_to_swp_entry(pte);
3068 +- if (non_swap_entry(swp) && is_migration_entry(swp))
3069 +- return 1;
3070 +- else
3071 +- return 0;
3072 +-}
3073 +-
3074 +-static int is_hugetlb_entry_hwpoisoned(pte_t pte)
3075 +-{
3076 +- swp_entry_t swp;
3077 +-
3078 +- if (huge_pte_none(pte) || pte_present(pte))
3079 +- return 0;
3080 +- swp = pte_to_swp_entry(pte);
3081 +- if (non_swap_entry(swp) && is_hwpoison_entry(swp))
3082 +- return 1;
3083 +- else
3084 +- return 0;
3085 +-}
3086 +-
3087 + void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
3088 + unsigned long start, unsigned long end,
3089 + struct page *ref_page)
3090 +diff --git a/mm/memory.c b/mm/memory.c
3091 +index 037b812a9531..e302ae1dcce0 100644
3092 +--- a/mm/memory.c
3093 ++++ b/mm/memory.c
3094 +@@ -3920,9 +3920,6 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
3095 + }
3096 + }
3097 +
3098 +- /* THP should already have been handled */
3099 +- BUG_ON(pmd_numa(*pmd));
3100 +-
3101 + /*
3102 + * Use __pte_alloc instead of pte_alloc_map, because we can't
3103 + * run pte_offset_map on the pmd, if an huge pmd could
3104 +diff --git a/mm/mempolicy.c b/mm/mempolicy.c
3105 +index 30cc47f8ffa0..35f9f91278fd 100644
3106 +--- a/mm/mempolicy.c
3107 ++++ b/mm/mempolicy.c
3108 +@@ -653,19 +653,18 @@ static unsigned long change_prot_numa(struct vm_area_struct *vma,
3109 + * @nodes and @flags,) it's isolated and queued to the pagelist which is
3110 + * passed via @private.)
3111 + */
3112 +-static struct vm_area_struct *
3113 ++static int
3114 + queue_pages_range(struct mm_struct *mm, unsigned long start, unsigned long end,
3115 + const nodemask_t *nodes, unsigned long flags, void *private)
3116 + {
3117 +- int err;
3118 +- struct vm_area_struct *first, *vma, *prev;
3119 +-
3120 ++ int err = 0;
3121 ++ struct vm_area_struct *vma, *prev;
3122 +
3123 +- first = find_vma(mm, start);
3124 +- if (!first)
3125 +- return ERR_PTR(-EFAULT);
3126 ++ vma = find_vma(mm, start);
3127 ++ if (!vma)
3128 ++ return -EFAULT;
3129 + prev = NULL;
3130 +- for (vma = first; vma && vma->vm_start < end; vma = vma->vm_next) {
3131 ++ for (; vma && vma->vm_start < end; vma = vma->vm_next) {
3132 + unsigned long endvma = vma->vm_end;
3133 +
3134 + if (endvma > end)
3135 +@@ -675,9 +674,9 @@ queue_pages_range(struct mm_struct *mm, unsigned long start, unsigned long end,
3136 +
3137 + if (!(flags & MPOL_MF_DISCONTIG_OK)) {
3138 + if (!vma->vm_next && vma->vm_end < end)
3139 +- return ERR_PTR(-EFAULT);
3140 ++ return -EFAULT;
3141 + if (prev && prev->vm_end < vma->vm_start)
3142 +- return ERR_PTR(-EFAULT);
3143 ++ return -EFAULT;
3144 + }
3145 +
3146 + if (flags & MPOL_MF_LAZY) {
3147 +@@ -691,15 +690,13 @@ queue_pages_range(struct mm_struct *mm, unsigned long start, unsigned long end,
3148 +
3149 + err = queue_pages_pgd_range(vma, start, endvma, nodes,
3150 + flags, private);
3151 +- if (err) {
3152 +- first = ERR_PTR(err);
3153 ++ if (err)
3154 + break;
3155 +- }
3156 + }
3157 + next:
3158 + prev = vma;
3159 + }
3160 +- return first;
3161 ++ return err;
3162 + }
3163 +
3164 + /*
3165 +@@ -1153,16 +1150,17 @@ out:
3166 +
3167 + /*
3168 + * Allocate a new page for page migration based on vma policy.
3169 +- * Start assuming that page is mapped by vma pointed to by @private.
3170 ++ * Start by assuming the page is mapped by the same vma as contains @start.
3171 + * Search forward from there, if not. N.B., this assumes that the
3172 + * list of pages handed to migrate_pages()--which is how we get here--
3173 + * is in virtual address order.
3174 + */
3175 +-static struct page *new_vma_page(struct page *page, unsigned long private, int **x)
3176 ++static struct page *new_page(struct page *page, unsigned long start, int **x)
3177 + {
3178 +- struct vm_area_struct *vma = (struct vm_area_struct *)private;
3179 ++ struct vm_area_struct *vma;
3180 + unsigned long uninitialized_var(address);
3181 +
3182 ++ vma = find_vma(current->mm, start);
3183 + while (vma) {
3184 + address = page_address_in_vma(page, vma);
3185 + if (address != -EFAULT)
3186 +@@ -1192,7 +1190,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from,
3187 + return -ENOSYS;
3188 + }
3189 +
3190 +-static struct page *new_vma_page(struct page *page, unsigned long private, int **x)
3191 ++static struct page *new_page(struct page *page, unsigned long start, int **x)
3192 + {
3193 + return NULL;
3194 + }
3195 +@@ -1202,7 +1200,6 @@ static long do_mbind(unsigned long start, unsigned long len,
3196 + unsigned short mode, unsigned short mode_flags,
3197 + nodemask_t *nmask, unsigned long flags)
3198 + {
3199 +- struct vm_area_struct *vma;
3200 + struct mm_struct *mm = current->mm;
3201 + struct mempolicy *new;
3202 + unsigned long end;
3203 +@@ -1268,11 +1265,9 @@ static long do_mbind(unsigned long start, unsigned long len,
3204 + if (err)
3205 + goto mpol_out;
3206 +
3207 +- vma = queue_pages_range(mm, start, end, nmask,
3208 ++ err = queue_pages_range(mm, start, end, nmask,
3209 + flags | MPOL_MF_INVERT, &pagelist);
3210 +-
3211 +- err = PTR_ERR(vma); /* maybe ... */
3212 +- if (!IS_ERR(vma))
3213 ++ if (!err)
3214 + err = mbind_range(mm, start, end, new);
3215 +
3216 + if (!err) {
3217 +@@ -1280,9 +1275,8 @@ static long do_mbind(unsigned long start, unsigned long len,
3218 +
3219 + if (!list_empty(&pagelist)) {
3220 + WARN_ON_ONCE(flags & MPOL_MF_LAZY);
3221 +- nr_failed = migrate_pages(&pagelist, new_vma_page,
3222 +- (unsigned long)vma,
3223 +- MIGRATE_SYNC, MR_MEMPOLICY_MBIND);
3224 ++ nr_failed = migrate_pages(&pagelist, new_page,
3225 ++ start, MIGRATE_SYNC, MR_MEMPOLICY_MBIND);
3226 + if (nr_failed)
3227 + putback_movable_pages(&pagelist);
3228 + }
3229 +diff --git a/mm/nommu.c b/mm/nommu.c
3230 +index 85f8d6698d48..431fd7c277cc 100644
3231 +--- a/mm/nommu.c
3232 ++++ b/mm/nommu.c
3233 +@@ -783,7 +783,7 @@ static void delete_vma_from_mm(struct vm_area_struct *vma)
3234 + for (i = 0; i < VMACACHE_SIZE; i++) {
3235 + /* if the vma is cached, invalidate the entire cache */
3236 + if (curr->vmacache[i] == vma) {
3237 +- vmacache_invalidate(curr->mm);
3238 ++ vmacache_invalidate(mm);
3239 + break;
3240 + }
3241 + }
3242 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
3243 +index 56eb0eb382b1..d64f5f90000c 100644
3244 +--- a/mm/page_alloc.c
3245 ++++ b/mm/page_alloc.c
3246 +@@ -69,6 +69,7 @@
3247 +
3248 + /* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */
3249 + static DEFINE_MUTEX(pcp_batch_high_lock);
3250 ++#define MIN_PERCPU_PAGELIST_FRACTION (8)
3251 +
3252 + #ifdef CONFIG_USE_PERCPU_NUMA_NODE_ID
3253 + DEFINE_PER_CPU(int, numa_node);
3254 +@@ -799,9 +800,21 @@ void __init init_cma_reserved_pageblock(struct page *page)
3255 + set_page_count(p, 0);
3256 + } while (++p, --i);
3257 +
3258 +- set_page_refcounted(page);
3259 + set_pageblock_migratetype(page, MIGRATE_CMA);
3260 +- __free_pages(page, pageblock_order);
3261 ++
3262 ++ if (pageblock_order >= MAX_ORDER) {
3263 ++ i = pageblock_nr_pages;
3264 ++ p = page;
3265 ++ do {
3266 ++ set_page_refcounted(p);
3267 ++ __free_pages(p, MAX_ORDER - 1);
3268 ++ p += MAX_ORDER_NR_PAGES;
3269 ++ } while (i -= MAX_ORDER_NR_PAGES);
3270 ++ } else {
3271 ++ set_page_refcounted(page);
3272 ++ __free_pages(page, pageblock_order);
3273 ++ }
3274 ++
3275 + adjust_managed_page_count(page, pageblock_nr_pages);
3276 + }
3277 + #endif
3278 +@@ -4107,7 +4120,7 @@ static void __meminit zone_init_free_lists(struct zone *zone)
3279 + memmap_init_zone((size), (nid), (zone), (start_pfn), MEMMAP_EARLY)
3280 + #endif
3281 +
3282 +-static int __meminit zone_batchsize(struct zone *zone)
3283 ++static int zone_batchsize(struct zone *zone)
3284 + {
3285 + #ifdef CONFIG_MMU
3286 + int batch;
3287 +@@ -4223,8 +4236,8 @@ static void pageset_set_high(struct per_cpu_pageset *p,
3288 + pageset_update(&p->pcp, high, batch);
3289 + }
3290 +
3291 +-static void __meminit pageset_set_high_and_batch(struct zone *zone,
3292 +- struct per_cpu_pageset *pcp)
3293 ++static void pageset_set_high_and_batch(struct zone *zone,
3294 ++ struct per_cpu_pageset *pcp)
3295 + {
3296 + if (percpu_pagelist_fraction)
3297 + pageset_set_high(pcp,
3298 +@@ -5850,23 +5863,38 @@ int percpu_pagelist_fraction_sysctl_handler(ctl_table *table, int write,
3299 + void __user *buffer, size_t *length, loff_t *ppos)
3300 + {
3301 + struct zone *zone;
3302 +- unsigned int cpu;
3303 ++ int old_percpu_pagelist_fraction;
3304 + int ret;
3305 +
3306 ++ mutex_lock(&pcp_batch_high_lock);
3307 ++ old_percpu_pagelist_fraction = percpu_pagelist_fraction;
3308 ++
3309 + ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
3310 +- if (!write || (ret < 0))
3311 +- return ret;
3312 ++ if (!write || ret < 0)
3313 ++ goto out;
3314 ++
3315 ++ /* Sanity checking to avoid pcp imbalance */
3316 ++ if (percpu_pagelist_fraction &&
3317 ++ percpu_pagelist_fraction < MIN_PERCPU_PAGELIST_FRACTION) {
3318 ++ percpu_pagelist_fraction = old_percpu_pagelist_fraction;
3319 ++ ret = -EINVAL;
3320 ++ goto out;
3321 ++ }
3322 ++
3323 ++ /* No change? */
3324 ++ if (percpu_pagelist_fraction == old_percpu_pagelist_fraction)
3325 ++ goto out;
3326 +
3327 +- mutex_lock(&pcp_batch_high_lock);
3328 + for_each_populated_zone(zone) {
3329 +- unsigned long high;
3330 +- high = zone->managed_pages / percpu_pagelist_fraction;
3331 ++ unsigned int cpu;
3332 ++
3333 + for_each_possible_cpu(cpu)
3334 +- pageset_set_high(per_cpu_ptr(zone->pageset, cpu),
3335 +- high);
3336 ++ pageset_set_high_and_batch(zone,
3337 ++ per_cpu_ptr(zone->pageset, cpu));
3338 + }
3339 ++out:
3340 + mutex_unlock(&pcp_batch_high_lock);
3341 +- return 0;
3342 ++ return ret;
3343 + }
3344 +
3345 + int hashdist = HASHDIST_DEFAULT;
3346 +diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
3347 +index 521fd4f3985e..ea72cc0de9b7 100644
3348 +--- a/net/bluetooth/hci_conn.c
3349 ++++ b/net/bluetooth/hci_conn.c
3350 +@@ -584,11 +584,6 @@ static void hci_req_add_le_create_conn(struct hci_request *req,
3351 + if (hci_update_random_address(req, false, &own_addr_type))
3352 + return;
3353 +
3354 +- /* Save the address type used for this connnection attempt so we able
3355 +- * to retrieve this information if we need it.
3356 +- */
3357 +- conn->src_type = own_addr_type;
3358 +-
3359 + cp.scan_interval = cpu_to_le16(hdev->le_scan_interval);
3360 + cp.scan_window = cpu_to_le16(hdev->le_scan_window);
3361 + bacpy(&cp.peer_addr, &conn->dst);
3362 +@@ -826,7 +821,7 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
3363 + /* If we're already encrypted set the REAUTH_PEND flag,
3364 + * otherwise set the ENCRYPT_PEND.
3365 + */
3366 +- if (conn->key_type != 0xff)
3367 ++ if (conn->link_mode & HCI_LM_ENCRYPT)
3368 + set_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
3369 + else
3370 + set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
3371 +diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
3372 +index 0381d55f995d..40357c8e3d27 100644
3373 +--- a/net/bluetooth/hci_event.c
3374 ++++ b/net/bluetooth/hci_event.c
3375 +@@ -48,6 +48,10 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
3376 + smp_mb__after_clear_bit(); /* wake_up_bit advises about this barrier */
3377 + wake_up_bit(&hdev->flags, HCI_INQUIRY);
3378 +
3379 ++ hci_dev_lock(hdev);
3380 ++ hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
3381 ++ hci_dev_unlock(hdev);
3382 ++
3383 + hci_conn_check_pending(hdev);
3384 + }
3385 +
3386 +@@ -3503,8 +3507,11 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev,
3387 +
3388 + /* If we're not the initiators request authorization to
3389 + * proceed from user space (mgmt_user_confirm with
3390 +- * confirm_hint set to 1). */
3391 +- if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
3392 ++ * confirm_hint set to 1). The exception is if neither
3393 ++ * side had MITM in which case we do auto-accept.
3394 ++ */
3395 ++ if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) &&
3396 ++ (loc_mitm || rem_mitm)) {
3397 + BT_DBG("Confirming auto-accept as acceptor");
3398 + confirm_hint = 1;
3399 + goto confirm;
3400 +diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
3401 +index dc4d301d3a72..1c97b7a4f170 100644
3402 +--- a/net/bluetooth/l2cap_core.c
3403 ++++ b/net/bluetooth/l2cap_core.c
3404 +@@ -1657,7 +1657,13 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
3405 + kfree_skb(conn->rx_skb);
3406 +
3407 + skb_queue_purge(&conn->pending_rx);
3408 +- flush_work(&conn->pending_rx_work);
3409 ++
3410 ++ /* We can not call flush_work(&conn->pending_rx_work) here since we
3411 ++ * might block if we are running on a worker from the same workqueue
3412 ++ * pending_rx_work is waiting on.
3413 ++ */
3414 ++ if (work_pending(&conn->pending_rx_work))
3415 ++ cancel_work_sync(&conn->pending_rx_work);
3416 +
3417 + l2cap_unregister_all_users(conn);
3418 +
3419 +diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
3420 +index ade3fb4c23bc..e1378693cc90 100644
3421 +--- a/net/bluetooth/l2cap_sock.c
3422 ++++ b/net/bluetooth/l2cap_sock.c
3423 +@@ -787,11 +787,6 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
3424 +
3425 + /*change security for LE channels */
3426 + if (chan->scid == L2CAP_CID_ATT) {
3427 +- if (!conn->hcon->out) {
3428 +- err = -EINVAL;
3429 +- break;
3430 +- }
3431 +-
3432 + if (smp_conn_security(conn->hcon, sec.level))
3433 + break;
3434 + sk->sk_state = BT_CONFIG;
3435 +diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
3436 +index c88b2b671849..a88cb3321361 100644
3437 +--- a/net/bluetooth/mgmt.c
3438 ++++ b/net/bluetooth/mgmt.c
3439 +@@ -1045,6 +1045,43 @@ static void clean_up_hci_complete(struct hci_dev *hdev, u8 status)
3440 + }
3441 + }
3442 +
3443 ++static void hci_stop_discovery(struct hci_request *req)
3444 ++{
3445 ++ struct hci_dev *hdev = req->hdev;
3446 ++ struct hci_cp_remote_name_req_cancel cp;
3447 ++ struct inquiry_entry *e;
3448 ++
3449 ++ switch (hdev->discovery.state) {
3450 ++ case DISCOVERY_FINDING:
3451 ++ if (test_bit(HCI_INQUIRY, &hdev->flags)) {
3452 ++ hci_req_add(req, HCI_OP_INQUIRY_CANCEL, 0, NULL);
3453 ++ } else {
3454 ++ cancel_delayed_work(&hdev->le_scan_disable);
3455 ++ hci_req_add_le_scan_disable(req);
3456 ++ }
3457 ++
3458 ++ break;
3459 ++
3460 ++ case DISCOVERY_RESOLVING:
3461 ++ e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY,
3462 ++ NAME_PENDING);
3463 ++ if (!e)
3464 ++ return;
3465 ++
3466 ++ bacpy(&cp.bdaddr, &e->data.bdaddr);
3467 ++ hci_req_add(req, HCI_OP_REMOTE_NAME_REQ_CANCEL, sizeof(cp),
3468 ++ &cp);
3469 ++
3470 ++ break;
3471 ++
3472 ++ default:
3473 ++ /* Passive scanning */
3474 ++ if (test_bit(HCI_LE_SCAN, &hdev->dev_flags))
3475 ++ hci_req_add_le_scan_disable(req);
3476 ++ break;
3477 ++ }
3478 ++}
3479 ++
3480 + static int clean_up_hci_state(struct hci_dev *hdev)
3481 + {
3482 + struct hci_request req;
3483 +@@ -1061,9 +1098,7 @@ static int clean_up_hci_state(struct hci_dev *hdev)
3484 + if (test_bit(HCI_ADVERTISING, &hdev->dev_flags))
3485 + disable_advertising(&req);
3486 +
3487 +- if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) {
3488 +- hci_req_add_le_scan_disable(&req);
3489 +- }
3490 ++ hci_stop_discovery(&req);
3491 +
3492 + list_for_each_entry(conn, &hdev->conn_hash.list, list) {
3493 + struct hci_cp_disconnect dc;
3494 +@@ -2997,8 +3032,13 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev,
3495 + }
3496 +
3497 + if (addr->type == BDADDR_LE_PUBLIC || addr->type == BDADDR_LE_RANDOM) {
3498 +- /* Continue with pairing via SMP */
3499 ++ /* Continue with pairing via SMP. The hdev lock must be
3500 ++ * released as SMP may try to recquire it for crypto
3501 ++ * purposes.
3502 ++ */
3503 ++ hci_dev_unlock(hdev);
3504 + err = smp_user_confirm_reply(conn, mgmt_op, passkey);
3505 ++ hci_dev_lock(hdev);
3506 +
3507 + if (!err)
3508 + err = cmd_complete(sk, hdev->id, mgmt_op,
3509 +@@ -3570,8 +3610,6 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
3510 + {
3511 + struct mgmt_cp_stop_discovery *mgmt_cp = data;
3512 + struct pending_cmd *cmd;
3513 +- struct hci_cp_remote_name_req_cancel cp;
3514 +- struct inquiry_entry *e;
3515 + struct hci_request req;
3516 + int err;
3517 +
3518 +@@ -3601,52 +3639,22 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
3519 +
3520 + hci_req_init(&req, hdev);
3521 +
3522 +- switch (hdev->discovery.state) {
3523 +- case DISCOVERY_FINDING:
3524 +- if (test_bit(HCI_INQUIRY, &hdev->flags)) {
3525 +- hci_req_add(&req, HCI_OP_INQUIRY_CANCEL, 0, NULL);
3526 +- } else {
3527 +- cancel_delayed_work(&hdev->le_scan_disable);
3528 +-
3529 +- hci_req_add_le_scan_disable(&req);
3530 +- }
3531 +-
3532 +- break;
3533 ++ hci_stop_discovery(&req);
3534 +
3535 +- case DISCOVERY_RESOLVING:
3536 +- e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY,
3537 +- NAME_PENDING);
3538 +- if (!e) {
3539 +- mgmt_pending_remove(cmd);
3540 +- err = cmd_complete(sk, hdev->id,
3541 +- MGMT_OP_STOP_DISCOVERY, 0,
3542 +- &mgmt_cp->type,
3543 +- sizeof(mgmt_cp->type));
3544 +- hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
3545 +- goto unlock;
3546 +- }
3547 +-
3548 +- bacpy(&cp.bdaddr, &e->data.bdaddr);
3549 +- hci_req_add(&req, HCI_OP_REMOTE_NAME_REQ_CANCEL, sizeof(cp),
3550 +- &cp);
3551 +-
3552 +- break;
3553 +-
3554 +- default:
3555 +- BT_DBG("unknown discovery state %u", hdev->discovery.state);
3556 +-
3557 +- mgmt_pending_remove(cmd);
3558 +- err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY,
3559 +- MGMT_STATUS_FAILED, &mgmt_cp->type,
3560 +- sizeof(mgmt_cp->type));
3561 ++ err = hci_req_run(&req, stop_discovery_complete);
3562 ++ if (!err) {
3563 ++ hci_discovery_set_state(hdev, DISCOVERY_STOPPING);
3564 + goto unlock;
3565 + }
3566 +
3567 +- err = hci_req_run(&req, stop_discovery_complete);
3568 +- if (err < 0)
3569 +- mgmt_pending_remove(cmd);
3570 +- else
3571 +- hci_discovery_set_state(hdev, DISCOVERY_STOPPING);
3572 ++ mgmt_pending_remove(cmd);
3573 ++
3574 ++ /* If no HCI commands were sent we're done */
3575 ++ if (err == -ENODATA) {
3576 ++ err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, 0,
3577 ++ &mgmt_cp->type, sizeof(mgmt_cp->type));
3578 ++ hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
3579 ++ }
3580 +
3581 + unlock:
3582 + hci_dev_unlock(hdev);
3583 +diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
3584 +index 956d127528cb..863425a5886e 100644
3585 +--- a/net/bluetooth/smp.c
3586 ++++ b/net/bluetooth/smp.c
3587 +@@ -533,7 +533,7 @@ static void random_work(struct work_struct *work)
3588 + hci_le_start_enc(hcon, ediv, rand, stk);
3589 + hcon->enc_key_size = smp->enc_key_size;
3590 + } else {
3591 +- u8 stk[16];
3592 ++ u8 stk[16], auth;
3593 + __le64 rand = 0;
3594 + __le16 ediv = 0;
3595 +
3596 +@@ -545,8 +545,13 @@ static void random_work(struct work_struct *work)
3597 + memset(stk + smp->enc_key_size, 0,
3598 + SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size);
3599 +
3600 ++ if (hcon->pending_sec_level == BT_SECURITY_HIGH)
3601 ++ auth = 1;
3602 ++ else
3603 ++ auth = 0;
3604 ++
3605 + hci_add_ltk(hcon->hdev, &hcon->dst, hcon->dst_type,
3606 +- HCI_SMP_STK_SLAVE, 0, stk, smp->enc_key_size,
3607 ++ HCI_SMP_STK_SLAVE, auth, stk, smp->enc_key_size,
3608 + ediv, rand);
3609 + }
3610 +
3611 +diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
3612 +index 40a648938985..e205ebabfa50 100644
3613 +--- a/net/mac80211/debugfs_netdev.c
3614 ++++ b/net/mac80211/debugfs_netdev.c
3615 +@@ -34,8 +34,7 @@ static ssize_t ieee80211_if_read(
3616 + ssize_t ret = -EINVAL;
3617 +
3618 + read_lock(&dev_base_lock);
3619 +- if (sdata->dev->reg_state == NETREG_REGISTERED)
3620 +- ret = (*format)(sdata, buf, sizeof(buf));
3621 ++ ret = (*format)(sdata, buf, sizeof(buf));
3622 + read_unlock(&dev_base_lock);
3623 +
3624 + if (ret >= 0)
3625 +@@ -62,8 +61,7 @@ static ssize_t ieee80211_if_write(
3626 +
3627 + ret = -ENODEV;
3628 + rtnl_lock();
3629 +- if (sdata->dev->reg_state == NETREG_REGISTERED)
3630 +- ret = (*write)(sdata, buf, count);
3631 ++ ret = (*write)(sdata, buf, count);
3632 + rtnl_unlock();
3633 +
3634 + return ret;
3635 +diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
3636 +index 06d28787945b..53cf876b97b2 100644
3637 +--- a/net/mac80211/ibss.c
3638 ++++ b/net/mac80211/ibss.c
3639 +@@ -1648,6 +1648,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
3640 + sdata->u.ibss.control_port = params->control_port;
3641 + sdata->u.ibss.userspace_handles_dfs = params->userspace_handles_dfs;
3642 + sdata->u.ibss.basic_rates = params->basic_rates;
3643 ++ sdata->u.ibss.last_scan_completed = jiffies;
3644 +
3645 + /* fix basic_rates if channel does not support these rates */
3646 + rate_flags = ieee80211_chandef_rate_flags(&params->chandef);
3647 +diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
3648 +index 847d92f6bef6..8f8c11583630 100644
3649 +--- a/net/mac80211/sta_info.c
3650 ++++ b/net/mac80211/sta_info.c
3651 +@@ -240,6 +240,7 @@ void sta_info_free(struct ieee80211_local *local, struct sta_info *sta)
3652 +
3653 + sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr);
3654 +
3655 ++ kfree(rcu_dereference_raw(sta->sta.rates));
3656 + kfree(sta);
3657 + }
3658 +
3659 +diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
3660 +index 58579634427d..70123f48b6c9 100644
3661 +--- a/net/netfilter/nf_conntrack_netlink.c
3662 ++++ b/net/netfilter/nf_conntrack_netlink.c
3663 +@@ -1150,7 +1150,7 @@ static int ctnetlink_done_list(struct netlink_callback *cb)
3664 + static int
3665 + ctnetlink_dump_list(struct sk_buff *skb, struct netlink_callback *cb, bool dying)
3666 + {
3667 +- struct nf_conn *ct, *last = NULL;
3668 ++ struct nf_conn *ct, *last;
3669 + struct nf_conntrack_tuple_hash *h;
3670 + struct hlist_nulls_node *n;
3671 + struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
3672 +@@ -1163,8 +1163,7 @@ ctnetlink_dump_list(struct sk_buff *skb, struct netlink_callback *cb, bool dying
3673 + if (cb->args[2])
3674 + return 0;
3675 +
3676 +- if (cb->args[0] == nr_cpu_ids)
3677 +- return 0;
3678 ++ last = (struct nf_conn *)cb->args[1];
3679 +
3680 + for (cpu = cb->args[0]; cpu < nr_cpu_ids; cpu++) {
3681 + struct ct_pcpu *pcpu;
3682 +@@ -1174,7 +1173,6 @@ ctnetlink_dump_list(struct sk_buff *skb, struct netlink_callback *cb, bool dying
3683 +
3684 + pcpu = per_cpu_ptr(net->ct.pcpu_lists, cpu);
3685 + spin_lock_bh(&pcpu->lock);
3686 +- last = (struct nf_conn *)cb->args[1];
3687 + list = dying ? &pcpu->dying : &pcpu->unconfirmed;
3688 + restart:
3689 + hlist_nulls_for_each_entry(h, n, list, hnnode) {
3690 +@@ -1193,7 +1191,9 @@ restart:
3691 + ct);
3692 + rcu_read_unlock();
3693 + if (res < 0) {
3694 +- nf_conntrack_get(&ct->ct_general);
3695 ++ if (!atomic_inc_not_zero(&ct->ct_general.use))
3696 ++ continue;
3697 ++ cb->args[0] = cpu;
3698 + cb->args[1] = (unsigned long)ct;
3699 + spin_unlock_bh(&pcpu->lock);
3700 + goto out;
3701 +@@ -1202,10 +1202,10 @@ restart:
3702 + if (cb->args[1]) {
3703 + cb->args[1] = 0;
3704 + goto restart;
3705 +- } else
3706 +- cb->args[2] = 1;
3707 ++ }
3708 + spin_unlock_bh(&pcpu->lock);
3709 + }
3710 ++ cb->args[2] = 1;
3711 + out:
3712 + if (last)
3713 + nf_ct_put(last);
3714 +diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
3715 +index 52ca952b802c..23247a0d2b69 100644
3716 +--- a/net/netfilter/nf_nat_core.c
3717 ++++ b/net/netfilter/nf_nat_core.c
3718 +@@ -517,6 +517,39 @@ static int nf_nat_proto_remove(struct nf_conn *i, void *data)
3719 + return i->status & IPS_NAT_MASK ? 1 : 0;
3720 + }
3721 +
3722 ++static int nf_nat_proto_clean(struct nf_conn *ct, void *data)
3723 ++{
3724 ++ struct nf_conn_nat *nat = nfct_nat(ct);
3725 ++
3726 ++ if (nf_nat_proto_remove(ct, data))
3727 ++ return 1;
3728 ++
3729 ++ if (!nat || !nat->ct)
3730 ++ return 0;
3731 ++
3732 ++ /* This netns is being destroyed, and conntrack has nat null binding.
3733 ++ * Remove it from bysource hash, as the table will be freed soon.
3734 ++ *
3735 ++ * Else, when the conntrack is destoyed, nf_nat_cleanup_conntrack()
3736 ++ * will delete entry from already-freed table.
3737 ++ */
3738 ++ if (!del_timer(&ct->timeout))
3739 ++ return 1;
3740 ++
3741 ++ spin_lock_bh(&nf_nat_lock);
3742 ++ hlist_del_rcu(&nat->bysource);
3743 ++ ct->status &= ~IPS_NAT_DONE_MASK;
3744 ++ nat->ct = NULL;
3745 ++ spin_unlock_bh(&nf_nat_lock);
3746 ++
3747 ++ add_timer(&ct->timeout);
3748 ++
3749 ++ /* don't delete conntrack. Although that would make things a lot
3750 ++ * simpler, we'd end up flushing all conntracks on nat rmmod.
3751 ++ */
3752 ++ return 0;
3753 ++}
3754 ++
3755 + static void nf_nat_l4proto_clean(u8 l3proto, u8 l4proto)
3756 + {
3757 + struct nf_nat_proto_clean clean = {
3758 +@@ -787,7 +820,7 @@ static void __net_exit nf_nat_net_exit(struct net *net)
3759 + {
3760 + struct nf_nat_proto_clean clean = {};
3761 +
3762 +- nf_ct_iterate_cleanup(net, &nf_nat_proto_remove, &clean, 0, 0);
3763 ++ nf_ct_iterate_cleanup(net, nf_nat_proto_clean, &clean, 0, 0);
3764 + synchronize_rcu();
3765 + nf_ct_free_hashtable(net->ct.nat_bysource, net->ct.nat_htable_size);
3766 + }
3767 +diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
3768 +index 9d07e4edacdb..8b4940ba33d6 100644
3769 +--- a/sound/pci/hda/hda_i915.c
3770 ++++ b/sound/pci/hda/hda_i915.c
3771 +@@ -20,24 +20,71 @@
3772 + #include <linux/module.h>
3773 + #include <sound/core.h>
3774 + #include <drm/i915_powerwell.h>
3775 ++#include "hda_priv.h"
3776 + #include "hda_i915.h"
3777 +
3778 +-static void (*get_power)(void);
3779 +-static void (*put_power)(void);
3780 ++/* Intel HSW/BDW display HDA controller Extended Mode registers.
3781 ++ * EM4 (M value) and EM5 (N Value) are used to convert CDClk (Core Display
3782 ++ * Clock) to 24MHz BCLK: BCLK = CDCLK * M / N
3783 ++ * The values will be lost when the display power well is disabled.
3784 ++ */
3785 ++#define ICH6_REG_EM4 0x100c
3786 ++#define ICH6_REG_EM5 0x1010
3787 ++
3788 ++static int (*get_power)(void);
3789 ++static int (*put_power)(void);
3790 ++static int (*get_cdclk)(void);
3791 +
3792 +-void hda_display_power(bool enable)
3793 ++int hda_display_power(bool enable)
3794 + {
3795 + if (!get_power || !put_power)
3796 +- return;
3797 ++ return -ENODEV;
3798 +
3799 + pr_debug("HDA display power %s \n",
3800 + enable ? "Enable" : "Disable");
3801 + if (enable)
3802 +- get_power();
3803 ++ return get_power();
3804 + else
3805 +- put_power();
3806 ++ return put_power();
3807 ++}
3808 ++
3809 ++void haswell_set_bclk(struct azx *chip)
3810 ++{
3811 ++ int cdclk_freq;
3812 ++ unsigned int bclk_m, bclk_n;
3813 ++
3814 ++ if (!get_cdclk)
3815 ++ return;
3816 ++
3817 ++ cdclk_freq = get_cdclk();
3818 ++ switch (cdclk_freq) {
3819 ++ case 337500:
3820 ++ bclk_m = 16;
3821 ++ bclk_n = 225;
3822 ++ break;
3823 ++
3824 ++ case 450000:
3825 ++ default: /* default CDCLK 450MHz */
3826 ++ bclk_m = 4;
3827 ++ bclk_n = 75;
3828 ++ break;
3829 ++
3830 ++ case 540000:
3831 ++ bclk_m = 4;
3832 ++ bclk_n = 90;
3833 ++ break;
3834 ++
3835 ++ case 675000:
3836 ++ bclk_m = 8;
3837 ++ bclk_n = 225;
3838 ++ break;
3839 ++ }
3840 ++
3841 ++ azx_writew(chip, EM4, bclk_m);
3842 ++ azx_writew(chip, EM5, bclk_n);
3843 + }
3844 +
3845 ++
3846 + int hda_i915_init(void)
3847 + {
3848 + int err = 0;
3849 +@@ -55,6 +102,10 @@ int hda_i915_init(void)
3850 + return -ENODEV;
3851 + }
3852 +
3853 ++ get_cdclk = symbol_request(i915_get_cdclk_freq);
3854 ++ if (!get_cdclk) /* may have abnormal BCLK and audio playback rate */
3855 ++ pr_warn("hda-i915: get_cdclk symbol get fail\n");
3856 ++
3857 + pr_debug("HDA driver get symbol successfully from i915 module\n");
3858 +
3859 + return err;
3860 +@@ -70,6 +121,10 @@ int hda_i915_exit(void)
3861 + symbol_put(i915_release_power_well);
3862 + put_power = NULL;
3863 + }
3864 ++ if (get_cdclk) {
3865 ++ symbol_put(i915_get_cdclk_freq);
3866 ++ get_cdclk = NULL;
3867 ++ }
3868 +
3869 + return 0;
3870 + }
3871 +diff --git a/sound/pci/hda/hda_i915.h b/sound/pci/hda/hda_i915.h
3872 +index 5a63da2c53e5..e6072c627583 100644
3873 +--- a/sound/pci/hda/hda_i915.h
3874 ++++ b/sound/pci/hda/hda_i915.h
3875 +@@ -17,11 +17,13 @@
3876 + #define __SOUND_HDA_I915_H
3877 +
3878 + #ifdef CONFIG_SND_HDA_I915
3879 +-void hda_display_power(bool enable);
3880 ++int hda_display_power(bool enable);
3881 ++void haswell_set_bclk(struct azx *chip);
3882 + int hda_i915_init(void);
3883 + int hda_i915_exit(void);
3884 + #else
3885 +-static inline void hda_display_power(bool enable) {}
3886 ++static inline int hda_display_power(bool enable) { return 0; }
3887 ++static inline void haswell_set_bclk(struct azx *chip) { return; }
3888 + static inline int hda_i915_init(void)
3889 + {
3890 + return -ENODEV;
3891 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
3892 +index 0176cf0e01d9..bc36f9cdd9d2 100644
3893 +--- a/sound/pci/hda/hda_intel.c
3894 ++++ b/sound/pci/hda/hda_intel.c
3895 +@@ -62,9 +62,9 @@
3896 + #include <linux/vga_switcheroo.h>
3897 + #include <linux/firmware.h>
3898 + #include "hda_codec.h"
3899 +-#include "hda_i915.h"
3900 + #include "hda_controller.h"
3901 + #include "hda_priv.h"
3902 ++#include "hda_i915.h"
3903 +
3904 +
3905 + static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
3906 +@@ -282,21 +282,8 @@ static char *driver_short_names[] = {
3907 + [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
3908 + };
3909 +
3910 +-
3911 +-/* Intel HSW/BDW display HDA controller Extended Mode registers.
3912 +- * EM4 (M value) and EM5 (N Value) are used to convert CDClk (Core Display
3913 +- * Clock) to 24MHz BCLK: BCLK = CDCLK * M / N
3914 +- * The values will be lost when the display power well is disabled.
3915 +- */
3916 +-#define ICH6_REG_EM4 0x100c
3917 +-#define ICH6_REG_EM5 0x1010
3918 +-
3919 + struct hda_intel {
3920 + struct azx chip;
3921 +-
3922 +- /* HSW/BDW display HDA controller to restore BCLK from CDCLK */
3923 +- unsigned int bclk_m;
3924 +- unsigned int bclk_n;
3925 + };
3926 +
3927 +
3928 +@@ -592,22 +579,6 @@ static int param_set_xint(const char *val, const struct kernel_param *kp)
3929 + #define azx_del_card_list(chip) /* NOP */
3930 + #endif /* CONFIG_PM */
3931 +
3932 +-static void haswell_save_bclk(struct azx *chip)
3933 +-{
3934 +- struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
3935 +-
3936 +- hda->bclk_m = azx_readw(chip, EM4);
3937 +- hda->bclk_n = azx_readw(chip, EM5);
3938 +-}
3939 +-
3940 +-static void haswell_restore_bclk(struct azx *chip)
3941 +-{
3942 +- struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
3943 +-
3944 +- azx_writew(chip, EM4, hda->bclk_m);
3945 +- azx_writew(chip, EM5, hda->bclk_n);
3946 +-}
3947 +-
3948 + #if defined(CONFIG_PM_SLEEP) || defined(SUPPORT_VGA_SWITCHEROO)
3949 + /*
3950 + * power management
3951 +@@ -635,12 +606,6 @@ static int azx_suspend(struct device *dev)
3952 + chip->irq = -1;
3953 + }
3954 +
3955 +- /* Save BCLK M/N values before they become invalid in D3.
3956 +- * Will test if display power well can be released now.
3957 +- */
3958 +- if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
3959 +- haswell_save_bclk(chip);
3960 +-
3961 + if (chip->msi)
3962 + pci_disable_msi(chip->pci);
3963 + pci_disable_device(pci);
3964 +@@ -662,7 +627,7 @@ static int azx_resume(struct device *dev)
3965 +
3966 + if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
3967 + hda_display_power(true);
3968 +- haswell_restore_bclk(chip);
3969 ++ haswell_set_bclk(chip);
3970 + }
3971 + pci_set_power_state(pci, PCI_D0);
3972 + pci_restore_state(pci);
3973 +@@ -707,10 +672,9 @@ static int azx_runtime_suspend(struct device *dev)
3974 + azx_stop_chip(chip);
3975 + azx_enter_link_reset(chip);
3976 + azx_clear_irq_pending(chip);
3977 +- if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
3978 +- haswell_save_bclk(chip);
3979 ++ if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
3980 + hda_display_power(false);
3981 +- }
3982 ++
3983 + return 0;
3984 + }
3985 +
3986 +@@ -730,7 +694,7 @@ static int azx_runtime_resume(struct device *dev)
3987 +
3988 + if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
3989 + hda_display_power(true);
3990 +- haswell_restore_bclk(chip);
3991 ++ haswell_set_bclk(chip);
3992 + }
3993 +
3994 + /* Read STATESTS before controller reset */
3995 +@@ -1426,6 +1390,10 @@ static int azx_first_init(struct azx *chip)
3996 +
3997 + /* initialize chip */
3998 + azx_init_pci(chip);
3999 ++
4000 ++ if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
4001 ++ haswell_set_bclk(chip);
4002 ++
4003 + azx_init_chip(chip, (probe_only[dev] & 2) == 0);
4004 +
4005 + /* codec detection */
4006 +@@ -1707,8 +1675,13 @@ static int azx_probe_continue(struct azx *chip)
4007 + "Error request power-well from i915\n");
4008 + goto out_free;
4009 + }
4010 ++ err = hda_display_power(true);
4011 ++ if (err < 0) {
4012 ++ dev_err(chip->card->dev,
4013 ++ "Cannot turn on display power on i915\n");
4014 ++ goto out_free;
4015 ++ }
4016 + #endif
4017 +- hda_display_power(true);
4018 + }
4019 +
4020 + err = azx_first_init(chip);
4021 +diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
4022 +index fe1e66b6ef40..a87e99f37c52 100644
4023 +--- a/tools/usb/ffs-test.c
4024 ++++ b/tools/usb/ffs-test.c
4025 +@@ -116,8 +116,8 @@ static const struct {
4026 + .header = {
4027 + .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC),
4028 + .length = cpu_to_le32(sizeof descriptors),
4029 +- .fs_count = 3,
4030 +- .hs_count = 3,
4031 ++ .fs_count = cpu_to_le32(3),
4032 ++ .hs_count = cpu_to_le32(3),
4033 + },
4034 + .fs_descs = {
4035 + .intf = {
4036
4037 diff --git a/2405_G-PHY-freq-fix.patch b/2405_G-PHY-freq-fix.patch
4038 deleted file mode 100644
4039 index 2777ced..0000000
4040 --- a/2405_G-PHY-freq-fix.patch
4041 +++ /dev/null
4042 @@ -1,19 +0,0 @@
4043 ---- a/drivers/net/wireless/b43/xmit.c 2014-07-05 18:58:29.992935369 -0400
4044 -+++ b/drivers/net/wireless/b43/xmit.c 2014-07-05 19:01:16.654933780 -0400
4045 -@@ -811,9 +811,13 @@ void b43_rx(struct b43_wldev *dev, struc
4046 - break;
4047 - case B43_PHYTYPE_G:
4048 - status.band = IEEE80211_BAND_2GHZ;
4049 -- /* chanid is the radio channel cookie value as used
4050 -- * to tune the radio. */
4051 -- status.freq = chanid + 2400;
4052 -+ /* Somewhere between 478.104 and 508.1084 firmware for G-PHY
4053 -+ * has been modified to be compatible with N-PHY and others.
4054 -+ */
4055 -+ if (dev->fw.rev >= 508)
4056 -+ status.freq = ieee80211_channel_to_frequency(chanid, status.band);
4057 -+ else
4058 -+ status.freq = chanid + 2400;
4059 - break;
4060 - case B43_PHYTYPE_N:
4061 - case B43_PHYTYPE_LP: