Magellan Linux

Contents of /trunk/kernel-alx/patches-3.10/0114-3.10.15-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2342 - (show annotations) (download)
Mon Dec 16 10:04:20 2013 UTC (10 years, 4 months ago) by niro
File size: 56226 byte(s)
-linux-3.10.15
1 diff --git a/Makefile b/Makefile
2 index 129c49f..9a77179 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 3
7 PATCHLEVEL = 10
8 -SUBLEVEL = 14
9 +SUBLEVEL = 15
10 EXTRAVERSION =
11 NAME = TOSSUG Baby Fish
12
13 diff --git a/arch/arm/crypto/aes-armv4.S b/arch/arm/crypto/aes-armv4.S
14 index 19d6cd6..3a14ea8 100644
15 --- a/arch/arm/crypto/aes-armv4.S
16 +++ b/arch/arm/crypto/aes-armv4.S
17 @@ -148,7 +148,7 @@ AES_Te:
18 @ const AES_KEY *key) {
19 .align 5
20 ENTRY(AES_encrypt)
21 - sub r3,pc,#8 @ AES_encrypt
22 + adr r3,AES_encrypt
23 stmdb sp!,{r1,r4-r12,lr}
24 mov r12,r0 @ inp
25 mov r11,r2
26 @@ -381,7 +381,7 @@ _armv4_AES_encrypt:
27 .align 5
28 ENTRY(private_AES_set_encrypt_key)
29 _armv4_AES_set_encrypt_key:
30 - sub r3,pc,#8 @ AES_set_encrypt_key
31 + adr r3,_armv4_AES_set_encrypt_key
32 teq r0,#0
33 moveq r0,#-1
34 beq .Labrt
35 @@ -843,7 +843,7 @@ AES_Td:
36 @ const AES_KEY *key) {
37 .align 5
38 ENTRY(AES_decrypt)
39 - sub r3,pc,#8 @ AES_decrypt
40 + adr r3,AES_decrypt
41 stmdb sp!,{r1,r4-r12,lr}
42 mov r12,r0 @ inp
43 mov r11,r2
44 diff --git a/arch/arm/mach-mxs/pm.h b/arch/arm/mach-mxs/pm.h
45 index f57e7cd..09d77b0 100644
46 --- a/arch/arm/mach-mxs/pm.h
47 +++ b/arch/arm/mach-mxs/pm.h
48 @@ -9,6 +9,10 @@
49 #ifndef __ARCH_MXS_PM_H
50 #define __ARCH_MXS_PM_H
51
52 +#ifdef CONFIG_PM
53 void mxs_pm_init(void);
54 +#else
55 +#define mxs_pm_init NULL
56 +#endif
57
58 #endif
59 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
60 index 76fa1e9..90fd119 100644
61 --- a/arch/x86/kernel/reboot.c
62 +++ b/arch/x86/kernel/reboot.c
63 @@ -447,6 +447,22 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
64 DMI_MATCH(DMI_PRODUCT_NAME, "Precision M6600"),
65 },
66 },
67 + { /* Handle problems with rebooting on the Dell PowerEdge C6100. */
68 + .callback = set_pci_reboot,
69 + .ident = "Dell PowerEdge C6100",
70 + .matches = {
71 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
72 + DMI_MATCH(DMI_PRODUCT_NAME, "C6100"),
73 + },
74 + },
75 + { /* Some C6100 machines were shipped with vendor being 'Dell'. */
76 + .callback = set_pci_reboot,
77 + .ident = "Dell PowerEdge C6100",
78 + .matches = {
79 + DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
80 + DMI_MATCH(DMI_PRODUCT_NAME, "C6100"),
81 + },
82 + },
83 { }
84 };
85
86 diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
87 index d2fbced..91ac654 100644
88 --- a/arch/x86/platform/efi/efi.c
89 +++ b/arch/x86/platform/efi/efi.c
90 @@ -910,10 +910,13 @@ void __init efi_enter_virtual_mode(void)
91
92 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
93 md = p;
94 - if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
95 - md->type != EFI_BOOT_SERVICES_CODE &&
96 - md->type != EFI_BOOT_SERVICES_DATA)
97 - continue;
98 + if (!(md->attribute & EFI_MEMORY_RUNTIME)) {
99 +#ifdef CONFIG_X86_64
100 + if (md->type != EFI_BOOT_SERVICES_CODE &&
101 + md->type != EFI_BOOT_SERVICES_DATA)
102 +#endif
103 + continue;
104 + }
105
106 size = md->num_pages << EFI_PAGE_SHIFT;
107 end = md->phys_addr + size;
108 diff --git a/drivers/base/core.c b/drivers/base/core.c
109 index 2499cef..ca4bcb8 100644
110 --- a/drivers/base/core.c
111 +++ b/drivers/base/core.c
112 @@ -1839,7 +1839,7 @@ EXPORT_SYMBOL_GPL(device_move);
113 */
114 void device_shutdown(void)
115 {
116 - struct device *dev;
117 + struct device *dev, *parent;
118
119 spin_lock(&devices_kset->list_lock);
120 /*
121 @@ -1856,7 +1856,7 @@ void device_shutdown(void)
122 * prevent it from being freed because parent's
123 * lock is to be held
124 */
125 - get_device(dev->parent);
126 + parent = get_device(dev->parent);
127 get_device(dev);
128 /*
129 * Make sure the device is off the kset list, in the
130 @@ -1866,8 +1866,8 @@ void device_shutdown(void)
131 spin_unlock(&devices_kset->list_lock);
132
133 /* hold lock to avoid race with probe/release */
134 - if (dev->parent)
135 - device_lock(dev->parent);
136 + if (parent)
137 + device_lock(parent);
138 device_lock(dev);
139
140 /* Don't allow any more runtime suspends */
141 @@ -1885,11 +1885,11 @@ void device_shutdown(void)
142 }
143
144 device_unlock(dev);
145 - if (dev->parent)
146 - device_unlock(dev->parent);
147 + if (parent)
148 + device_unlock(parent);
149
150 put_device(dev);
151 - put_device(dev->parent);
152 + put_device(parent);
153
154 spin_lock(&devices_kset->list_lock);
155 }
156 diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
157 index a365780..b1a0cdb 100644
158 --- a/drivers/gpu/drm/i915/i915_reg.h
159 +++ b/drivers/gpu/drm/i915/i915_reg.h
160 @@ -1675,10 +1675,16 @@
161 #define CRT_HOTPLUG_DETECT_VOLTAGE_475MV (1 << 2)
162
163 #define PORT_HOTPLUG_STAT (dev_priv->info->display_mmio_offset + 0x61114)
164 -/* HDMI/DP bits are gen4+ */
165 -#define PORTB_HOTPLUG_LIVE_STATUS (1 << 29)
166 +/*
167 + * HDMI/DP bits are gen4+
168 + *
169 + * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused.
170 + * Please check the detailed lore in the commit message for for experimental
171 + * evidence.
172 + */
173 +#define PORTD_HOTPLUG_LIVE_STATUS (1 << 29)
174 #define PORTC_HOTPLUG_LIVE_STATUS (1 << 28)
175 -#define PORTD_HOTPLUG_LIVE_STATUS (1 << 27)
176 +#define PORTB_HOTPLUG_LIVE_STATUS (1 << 27)
177 #define PORTD_HOTPLUG_INT_STATUS (3 << 21)
178 #define PORTC_HOTPLUG_INT_STATUS (3 << 19)
179 #define PORTB_HOTPLUG_INT_STATUS (3 << 17)
180 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
181 index eea5982..2667d6d 100644
182 --- a/drivers/gpu/drm/i915/intel_display.c
183 +++ b/drivers/gpu/drm/i915/intel_display.c
184 @@ -4564,6 +4564,10 @@ static void i9xx_set_pipeconf(struct intel_crtc *intel_crtc)
185
186 pipeconf = I915_READ(PIPECONF(intel_crtc->pipe));
187
188 + if (dev_priv->quirks & QUIRK_PIPEA_FORCE &&
189 + I915_READ(PIPECONF(intel_crtc->pipe)) & PIPECONF_ENABLE)
190 + pipeconf |= PIPECONF_ENABLE;
191 +
192 if (intel_crtc->pipe == 0 && INTEL_INFO(dev)->gen < 4) {
193 /* Enable pixel doubling when the dot clock is > 90% of the (display)
194 * core speed.
195 diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
196 index 70789b1..80feaec 100644
197 --- a/drivers/gpu/drm/i915/intel_dp.c
198 +++ b/drivers/gpu/drm/i915/intel_dp.c
199 @@ -604,7 +604,18 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
200 DRM_DEBUG_KMS("aux_ch native nack\n");
201 return -EREMOTEIO;
202 case AUX_NATIVE_REPLY_DEFER:
203 - udelay(100);
204 + /*
205 + * For now, just give more slack to branch devices. We
206 + * could check the DPCD for I2C bit rate capabilities,
207 + * and if available, adjust the interval. We could also
208 + * be more careful with DP-to-Legacy adapters where a
209 + * long legacy cable may force very low I2C bit rates.
210 + */
211 + if (intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
212 + DP_DWN_STRM_PORT_PRESENT)
213 + usleep_range(500, 600);
214 + else
215 + usleep_range(300, 400);
216 continue;
217 default:
218 DRM_ERROR("aux_ch invalid native reply 0x%02x\n",
219 diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
220 index b945bc5..a202d8d 100644
221 --- a/drivers/gpu/drm/i915/intel_tv.c
222 +++ b/drivers/gpu/drm/i915/intel_tv.c
223 @@ -921,6 +921,14 @@ intel_tv_compute_config(struct intel_encoder *encoder,
224 DRM_DEBUG_KMS("forcing bpc to 8 for TV\n");
225 pipe_config->pipe_bpp = 8*3;
226
227 + /* TV has it's own notion of sync and other mode flags, so clear them. */
228 + pipe_config->adjusted_mode.flags = 0;
229 +
230 + /*
231 + * FIXME: We don't check whether the input mode is actually what we want
232 + * or whether userspace is doing something stupid.
233 + */
234 +
235 return true;
236 }
237
238 diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
239 index d0314ec..46470dd 100644
240 --- a/drivers/gpu/drm/radeon/r100.c
241 +++ b/drivers/gpu/drm/radeon/r100.c
242 @@ -2935,9 +2935,11 @@ static int r100_debugfs_cp_ring_info(struct seq_file *m, void *data)
243 seq_printf(m, "CP_RB_RPTR 0x%08x\n", rdp);
244 seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw);
245 seq_printf(m, "%u dwords in ring\n", count);
246 - for (j = 0; j <= count; j++) {
247 - i = (rdp + j) & ring->ptr_mask;
248 - seq_printf(m, "r[%04d]=0x%08x\n", i, ring->ring[i]);
249 + if (ring->ready) {
250 + for (j = 0; j <= count; j++) {
251 + i = (rdp + j) & ring->ptr_mask;
252 + seq_printf(m, "r[%04d]=0x%08x\n", i, ring->ring[i]);
253 + }
254 }
255 return 0;
256 }
257 diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
258 index b9b1139..0efe2a9 100644
259 --- a/drivers/gpu/drm/radeon/r600_hdmi.c
260 +++ b/drivers/gpu/drm/radeon/r600_hdmi.c
261 @@ -238,9 +238,19 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
262 * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE
263 * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator
264 */
265 - if (ASIC_IS_DCE3(rdev)) {
266 + if (ASIC_IS_DCE32(rdev)) {
267 + if (dig->dig_encoder == 0) {
268 + WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100);
269 + WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100);
270 + WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */
271 + } else {
272 + WREG32(DCCG_AUDIO_DTO1_PHASE, base_rate * 100);
273 + WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100);
274 + WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
275 + }
276 + } else if (ASIC_IS_DCE3(rdev)) {
277 /* according to the reg specs, this should DCE3.2 only, but in
278 - * practice it seems to cover DCE3.0 as well.
279 + * practice it seems to cover DCE3.0/3.1 as well.
280 */
281 if (dig->dig_encoder == 0) {
282 WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100);
283 @@ -252,7 +262,7 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
284 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
285 }
286 } else {
287 - /* according to the reg specs, this should be DCE2.0 and DCE3.0 */
288 + /* according to the reg specs, this should be DCE2.0 and DCE3.0/3.1 */
289 WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) |
290 AUDIO_DTO_MODULE(clock / 10));
291 }
292 diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
293 index de36c47..7fadfd5 100644
294 --- a/drivers/gpu/drm/radeon/radeon_asic.c
295 +++ b/drivers/gpu/drm/radeon/radeon_asic.c
296 @@ -892,6 +892,8 @@ static struct radeon_asic r520_asic = {
297 .wait_for_vblank = &avivo_wait_for_vblank,
298 .set_backlight_level = &atombios_set_backlight_level,
299 .get_backlight_level = &atombios_get_backlight_level,
300 + .hdmi_enable = &r600_hdmi_enable,
301 + .hdmi_setmode = &r600_hdmi_setmode,
302 },
303 .copy = {
304 .blit = &r100_copy_blit,
305 diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
306 index 6337f67..fe36f1d 100644
307 --- a/drivers/gpu/drm/radeon/radeon_cs.c
308 +++ b/drivers/gpu/drm/radeon/radeon_cs.c
309 @@ -84,7 +84,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
310 VRAM, also but everything into VRAM on AGP cards to avoid
311 image corruptions */
312 if (p->ring == R600_RING_TYPE_UVD_INDEX &&
313 - (i == 0 || p->rdev->flags & RADEON_IS_AGP)) {
314 + (i == 0 || drm_pci_device_is_agp(p->rdev->ddev))) {
315 /* TODO: is this still needed for NI+ ? */
316 p->relocs[i].lobj.domain =
317 RADEON_GEM_DOMAIN_VRAM;
318 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
319 index b0dc0b6..8df1525 100644
320 --- a/drivers/gpu/drm/radeon/radeon_device.c
321 +++ b/drivers/gpu/drm/radeon/radeon_device.c
322 @@ -1196,13 +1196,22 @@ int radeon_device_init(struct radeon_device *rdev,
323 return r;
324 }
325 if ((radeon_testing & 1)) {
326 - radeon_test_moves(rdev);
327 + if (rdev->accel_working)
328 + radeon_test_moves(rdev);
329 + else
330 + DRM_INFO("radeon: acceleration disabled, skipping move tests\n");
331 }
332 if ((radeon_testing & 2)) {
333 - radeon_test_syncing(rdev);
334 + if (rdev->accel_working)
335 + radeon_test_syncing(rdev);
336 + else
337 + DRM_INFO("radeon: acceleration disabled, skipping sync tests\n");
338 }
339 if (radeon_benchmarking) {
340 - radeon_benchmark(rdev, radeon_benchmarking);
341 + if (rdev->accel_working)
342 + radeon_benchmark(rdev, radeon_benchmarking);
343 + else
344 + DRM_INFO("radeon: acceleration disabled, skipping benchmarks\n");
345 }
346 return 0;
347 }
348 diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
349 index 83f6295..6e0f480 100644
350 --- a/drivers/gpu/drm/radeon/radeon_ring.c
351 +++ b/drivers/gpu/drm/radeon/radeon_ring.c
352 @@ -823,9 +823,11 @@ static int radeon_debugfs_ring_info(struct seq_file *m, void *data)
353 * packet that is the root issue
354 */
355 i = (ring->rptr + ring->ptr_mask + 1 - 32) & ring->ptr_mask;
356 - for (j = 0; j <= (count + 32); j++) {
357 - seq_printf(m, "r[%5d]=0x%08x\n", i, ring->ring[i]);
358 - i = (i + 1) & ring->ptr_mask;
359 + if (ring->ready) {
360 + for (j = 0; j <= (count + 32); j++) {
361 + seq_printf(m, "r[%5d]=0x%08x\n", i, ring->ring[i]);
362 + i = (i + 1) & ring->ptr_mask;
363 + }
364 }
365 return 0;
366 }
367 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
368 index 62c2e32..98814d1 100644
369 --- a/drivers/hwmon/applesmc.c
370 +++ b/drivers/hwmon/applesmc.c
371 @@ -525,16 +525,25 @@ static int applesmc_init_smcreg_try(void)
372 {
373 struct applesmc_registers *s = &smcreg;
374 bool left_light_sensor, right_light_sensor;
375 + unsigned int count;
376 u8 tmp[1];
377 int ret;
378
379 if (s->init_complete)
380 return 0;
381
382 - ret = read_register_count(&s->key_count);
383 + ret = read_register_count(&count);
384 if (ret)
385 return ret;
386
387 + if (s->cache && s->key_count != count) {
388 + pr_warn("key count changed from %d to %d\n",
389 + s->key_count, count);
390 + kfree(s->cache);
391 + s->cache = NULL;
392 + }
393 + s->key_count = count;
394 +
395 if (!s->cache)
396 s->cache = kcalloc(s->key_count, sizeof(*s->cache), GFP_KERNEL);
397 if (!s->cache)
398 diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
399 index c42b14b..6bc016e 100644
400 --- a/drivers/md/bcache/bcache.h
401 +++ b/drivers/md/bcache/bcache.h
402 @@ -499,7 +499,7 @@ struct cached_dev {
403 */
404 atomic_t has_dirty;
405
406 - struct ratelimit writeback_rate;
407 + struct bch_ratelimit writeback_rate;
408 struct delayed_work writeback_rate_update;
409
410 /*
411 @@ -508,10 +508,9 @@ struct cached_dev {
412 */
413 sector_t last_read;
414
415 - /* Number of writeback bios in flight */
416 - atomic_t in_flight;
417 + /* Limit number of writeback bios in flight */
418 + struct semaphore in_flight;
419 struct closure_with_timer writeback;
420 - struct closure_waitlist writeback_wait;
421
422 struct keybuf writeback_keys;
423
424 diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
425 index cb4578a..14032e8 100644
426 --- a/drivers/md/bcache/bset.c
427 +++ b/drivers/md/bcache/bset.c
428 @@ -918,28 +918,45 @@ struct bkey *bch_next_recurse_key(struct btree *b, struct bkey *search)
429
430 /* Mergesort */
431
432 +static void sort_key_next(struct btree_iter *iter,
433 + struct btree_iter_set *i)
434 +{
435 + i->k = bkey_next(i->k);
436 +
437 + if (i->k == i->end)
438 + *i = iter->data[--iter->used];
439 +}
440 +
441 static void btree_sort_fixup(struct btree_iter *iter)
442 {
443 while (iter->used > 1) {
444 struct btree_iter_set *top = iter->data, *i = top + 1;
445 - struct bkey *k;
446
447 if (iter->used > 2 &&
448 btree_iter_cmp(i[0], i[1]))
449 i++;
450
451 - for (k = i->k;
452 - k != i->end && bkey_cmp(top->k, &START_KEY(k)) > 0;
453 - k = bkey_next(k))
454 - if (top->k > i->k)
455 - __bch_cut_front(top->k, k);
456 - else if (KEY_SIZE(k))
457 - bch_cut_back(&START_KEY(k), top->k);
458 -
459 - if (top->k < i->k || k == i->k)
460 + if (bkey_cmp(top->k, &START_KEY(i->k)) <= 0)
461 break;
462
463 - heap_sift(iter, i - top, btree_iter_cmp);
464 + if (!KEY_SIZE(i->k)) {
465 + sort_key_next(iter, i);
466 + heap_sift(iter, i - top, btree_iter_cmp);
467 + continue;
468 + }
469 +
470 + if (top->k > i->k) {
471 + if (bkey_cmp(top->k, i->k) >= 0)
472 + sort_key_next(iter, i);
473 + else
474 + bch_cut_front(top->k, i->k);
475 +
476 + heap_sift(iter, i - top, btree_iter_cmp);
477 + } else {
478 + /* can't happen because of comparison func */
479 + BUG_ON(!bkey_cmp(&START_KEY(top->k), &START_KEY(i->k)));
480 + bch_cut_back(&START_KEY(i->k), top->k);
481 + }
482 }
483 }
484
485 diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
486 index 833c590..7d3deab 100644
487 --- a/drivers/md/bcache/btree.c
488 +++ b/drivers/md/bcache/btree.c
489 @@ -633,7 +633,7 @@ static int bch_mca_shrink(struct shrinker *shrink, struct shrink_control *sc)
490 return mca_can_free(c) * c->btree_pages;
491
492 /* Return -1 if we can't do anything right now */
493 - if (sc->gfp_mask & __GFP_WAIT)
494 + if (sc->gfp_mask & __GFP_IO)
495 mutex_lock(&c->bucket_lock);
496 else if (!mutex_trylock(&c->bucket_lock))
497 return -1;
498 diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
499 index b49abb2..151a4ab 100644
500 --- a/drivers/md/bcache/journal.c
501 +++ b/drivers/md/bcache/journal.c
502 @@ -151,7 +151,8 @@ int bch_journal_read(struct cache_set *c, struct list_head *list,
503 bitmap_zero(bitmap, SB_JOURNAL_BUCKETS);
504 pr_debug("%u journal buckets", ca->sb.njournal_buckets);
505
506 - /* Read journal buckets ordered by golden ratio hash to quickly
507 + /*
508 + * Read journal buckets ordered by golden ratio hash to quickly
509 * find a sequence of buckets with valid journal entries
510 */
511 for (i = 0; i < ca->sb.njournal_buckets; i++) {
512 @@ -164,18 +165,20 @@ int bch_journal_read(struct cache_set *c, struct list_head *list,
513 goto bsearch;
514 }
515
516 - /* If that fails, check all the buckets we haven't checked
517 + /*
518 + * If that fails, check all the buckets we haven't checked
519 * already
520 */
521 pr_debug("falling back to linear search");
522
523 - for (l = 0; l < ca->sb.njournal_buckets; l++) {
524 - if (test_bit(l, bitmap))
525 - continue;
526 -
527 + for (l = find_first_zero_bit(bitmap, ca->sb.njournal_buckets);
528 + l < ca->sb.njournal_buckets;
529 + l = find_next_zero_bit(bitmap, ca->sb.njournal_buckets, l + 1))
530 if (read_bucket(l))
531 goto bsearch;
532 - }
533 +
534 + if (list_empty(list))
535 + continue;
536 bsearch:
537 /* Binary search */
538 m = r = find_next_bit(bitmap, ca->sb.njournal_buckets, l + 1);
539 @@ -195,10 +198,12 @@ bsearch:
540 r = m;
541 }
542
543 - /* Read buckets in reverse order until we stop finding more
544 + /*
545 + * Read buckets in reverse order until we stop finding more
546 * journal entries
547 */
548 - pr_debug("finishing up");
549 + pr_debug("finishing up: m %u njournal_buckets %u",
550 + m, ca->sb.njournal_buckets);
551 l = m;
552
553 while (1) {
554 @@ -226,9 +231,10 @@ bsearch:
555 }
556 }
557
558 - c->journal.seq = list_entry(list->prev,
559 - struct journal_replay,
560 - list)->j.seq;
561 + if (!list_empty(list))
562 + c->journal.seq = list_entry(list->prev,
563 + struct journal_replay,
564 + list)->j.seq;
565
566 return 0;
567 #undef read_bucket
568 @@ -425,7 +431,7 @@ static void do_journal_discard(struct cache *ca)
569 return;
570 }
571
572 - switch (atomic_read(&ja->discard_in_flight) == DISCARD_IN_FLIGHT) {
573 + switch (atomic_read(&ja->discard_in_flight)) {
574 case DISCARD_IN_FLIGHT:
575 return;
576
577 @@ -686,6 +692,7 @@ void bch_journal_meta(struct cache_set *c, struct closure *cl)
578 if (cl)
579 BUG_ON(!closure_wait(&w->wait, cl));
580
581 + closure_flush(&c->journal.io);
582 __journal_try_write(c, true);
583 }
584 }
585 diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
586 index afb9a99..2fe37fa 100644
587 --- a/drivers/md/bcache/request.c
588 +++ b/drivers/md/bcache/request.c
589 @@ -1056,14 +1056,17 @@ static void request_write(struct cached_dev *dc, struct search *s)
590 trace_bcache_writeback(s->orig_bio);
591 bch_writeback_add(dc, bio_sectors(bio));
592
593 - if (s->op.flush_journal) {
594 + if (bio->bi_rw & REQ_FLUSH) {
595 /* Also need to send a flush to the backing device */
596 - s->op.cache_bio = bio_clone_bioset(bio, GFP_NOIO,
597 - dc->disk.bio_split);
598 + struct bio *flush = bio_alloc_bioset(0, GFP_NOIO,
599 + dc->disk.bio_split);
600
601 - bio->bi_size = 0;
602 - bio->bi_vcnt = 0;
603 - closure_bio_submit(bio, cl, s->d);
604 + flush->bi_rw = WRITE_FLUSH;
605 + flush->bi_bdev = bio->bi_bdev;
606 + flush->bi_end_io = request_endio;
607 + flush->bi_private = cl;
608 +
609 + closure_bio_submit(flush, cl, s->d);
610 } else {
611 s->op.cache_bio = bio;
612 }
613 diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
614 index 4d9cca4..e9bd6c0 100644
615 --- a/drivers/md/bcache/sysfs.c
616 +++ b/drivers/md/bcache/sysfs.c
617 @@ -214,7 +214,13 @@ STORE(__cached_dev)
618 }
619
620 if (attr == &sysfs_label) {
621 - memcpy(dc->sb.label, buf, SB_LABEL_SIZE);
622 + if (size > SB_LABEL_SIZE)
623 + return -EINVAL;
624 + memcpy(dc->sb.label, buf, size);
625 + if (size < SB_LABEL_SIZE)
626 + dc->sb.label[size] = '\0';
627 + if (size && dc->sb.label[size - 1] == '\n')
628 + dc->sb.label[size - 1] = '\0';
629 bch_write_bdev_super(dc, NULL);
630 if (dc->disk.c) {
631 memcpy(dc->disk.c->uuids[dc->disk.id].label,
632 diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
633 index da3a99e..38a43f8 100644
634 --- a/drivers/md/bcache/util.c
635 +++ b/drivers/md/bcache/util.c
636 @@ -190,7 +190,16 @@ void bch_time_stats_update(struct time_stats *stats, uint64_t start_time)
637 stats->last = now ?: 1;
638 }
639
640 -unsigned bch_next_delay(struct ratelimit *d, uint64_t done)
641 +/**
642 + * bch_next_delay() - increment @d by the amount of work done, and return how
643 + * long to delay until the next time to do some work.
644 + *
645 + * @d - the struct bch_ratelimit to update
646 + * @done - the amount of work done, in arbitrary units
647 + *
648 + * Returns the amount of time to delay by, in jiffies
649 + */
650 +uint64_t bch_next_delay(struct bch_ratelimit *d, uint64_t done)
651 {
652 uint64_t now = local_clock();
653
654 diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
655 index 577393e..43fd78a 100644
656 --- a/drivers/md/bcache/util.h
657 +++ b/drivers/md/bcache/util.h
658 @@ -452,17 +452,23 @@ read_attribute(name ## _last_ ## frequency_units)
659 (ewma) >> factor; \
660 })
661
662 -struct ratelimit {
663 +struct bch_ratelimit {
664 + /* Next time we want to do some work, in nanoseconds */
665 uint64_t next;
666 +
667 + /*
668 + * Rate at which we want to do work, in units per nanosecond
669 + * The units here correspond to the units passed to bch_next_delay()
670 + */
671 unsigned rate;
672 };
673
674 -static inline void ratelimit_reset(struct ratelimit *d)
675 +static inline void bch_ratelimit_reset(struct bch_ratelimit *d)
676 {
677 d->next = local_clock();
678 }
679
680 -unsigned bch_next_delay(struct ratelimit *d, uint64_t done);
681 +uint64_t bch_next_delay(struct bch_ratelimit *d, uint64_t done);
682
683 #define __DIV_SAFE(n, d, zero) \
684 ({ \
685 diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
686 index 2714ed3..841f049 100644
687 --- a/drivers/md/bcache/writeback.c
688 +++ b/drivers/md/bcache/writeback.c
689 @@ -91,11 +91,15 @@ static void update_writeback_rate(struct work_struct *work)
690
691 static unsigned writeback_delay(struct cached_dev *dc, unsigned sectors)
692 {
693 + uint64_t ret;
694 +
695 if (atomic_read(&dc->disk.detaching) ||
696 !dc->writeback_percent)
697 return 0;
698
699 - return bch_next_delay(&dc->writeback_rate, sectors * 10000000ULL);
700 + ret = bch_next_delay(&dc->writeback_rate, sectors * 10000000ULL);
701 +
702 + return min_t(uint64_t, ret, HZ);
703 }
704
705 /* Background writeback */
706 @@ -165,7 +169,7 @@ static void refill_dirty(struct closure *cl)
707
708 up_write(&dc->writeback_lock);
709
710 - ratelimit_reset(&dc->writeback_rate);
711 + bch_ratelimit_reset(&dc->writeback_rate);
712
713 /* Punt to workqueue only so we don't recurse and blow the stack */
714 continue_at(cl, read_dirty, dirty_wq);
715 @@ -246,9 +250,7 @@ static void write_dirty_finish(struct closure *cl)
716 }
717
718 bch_keybuf_del(&dc->writeback_keys, w);
719 - atomic_dec_bug(&dc->in_flight);
720 -
721 - closure_wake_up(&dc->writeback_wait);
722 + up(&dc->in_flight);
723
724 closure_return_with_destructor(cl, dirty_io_destructor);
725 }
726 @@ -278,7 +280,7 @@ static void write_dirty(struct closure *cl)
727 trace_bcache_write_dirty(&io->bio);
728 closure_bio_submit(&io->bio, cl, &io->dc->disk);
729
730 - continue_at(cl, write_dirty_finish, dirty_wq);
731 + continue_at(cl, write_dirty_finish, system_wq);
732 }
733
734 static void read_dirty_endio(struct bio *bio, int error)
735 @@ -299,7 +301,7 @@ static void read_dirty_submit(struct closure *cl)
736 trace_bcache_read_dirty(&io->bio);
737 closure_bio_submit(&io->bio, cl, &io->dc->disk);
738
739 - continue_at(cl, write_dirty, dirty_wq);
740 + continue_at(cl, write_dirty, system_wq);
741 }
742
743 static void read_dirty(struct closure *cl)
744 @@ -324,12 +326,8 @@ static void read_dirty(struct closure *cl)
745
746 if (delay > 0 &&
747 (KEY_START(&w->key) != dc->last_read ||
748 - jiffies_to_msecs(delay) > 50)) {
749 - w->private = NULL;
750 -
751 - closure_delay(&dc->writeback, delay);
752 - continue_at(cl, read_dirty, dirty_wq);
753 - }
754 + jiffies_to_msecs(delay) > 50))
755 + delay = schedule_timeout_uninterruptible(delay);
756
757 dc->last_read = KEY_OFFSET(&w->key);
758
759 @@ -354,15 +352,10 @@ static void read_dirty(struct closure *cl)
760
761 pr_debug("%s", pkey(&w->key));
762
763 - closure_call(&io->cl, read_dirty_submit, NULL, &dc->disk.cl);
764 + down(&dc->in_flight);
765 + closure_call(&io->cl, read_dirty_submit, NULL, cl);
766
767 delay = writeback_delay(dc, KEY_SIZE(&w->key));
768 -
769 - atomic_inc(&dc->in_flight);
770 -
771 - if (!closure_wait_event(&dc->writeback_wait, cl,
772 - atomic_read(&dc->in_flight) < 64))
773 - continue_at(cl, read_dirty, dirty_wq);
774 }
775
776 if (0) {
777 @@ -372,11 +365,16 @@ err:
778 bch_keybuf_del(&dc->writeback_keys, w);
779 }
780
781 - refill_dirty(cl);
782 + /*
783 + * Wait for outstanding writeback IOs to finish (and keybuf slots to be
784 + * freed) before refilling again
785 + */
786 + continue_at(cl, refill_dirty, dirty_wq);
787 }
788
789 void bch_cached_dev_writeback_init(struct cached_dev *dc)
790 {
791 + sema_init(&dc->in_flight, 64);
792 closure_init_unlocked(&dc->writeback);
793 init_rwsem(&dc->writeback_lock);
794
795 @@ -406,7 +404,7 @@ void bch_writeback_exit(void)
796
797 int __init bch_writeback_init(void)
798 {
799 - dirty_wq = create_singlethread_workqueue("bcache_writeback");
800 + dirty_wq = create_workqueue("bcache_writeback");
801 if (!dirty_wq)
802 return -ENOMEM;
803
804 diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
805 index 5adede1..c5b7b3d 100644
806 --- a/drivers/md/dm-mpath.c
807 +++ b/drivers/md/dm-mpath.c
808 @@ -1284,8 +1284,17 @@ static int do_end_io(struct multipath *m, struct request *clone,
809 if (!error && !clone->errors)
810 return 0; /* I/O complete */
811
812 - if (error == -EOPNOTSUPP || error == -EREMOTEIO || error == -EILSEQ)
813 + if (error == -EOPNOTSUPP || error == -EREMOTEIO || error == -EILSEQ) {
814 + if ((clone->cmd_flags & REQ_WRITE_SAME) &&
815 + !clone->q->limits.max_write_same_sectors) {
816 + struct queue_limits *limits;
817 +
818 + /* device doesn't really support WRITE SAME, disable it */
819 + limits = dm_get_queue_limits(dm_table_get_md(m->ti->table));
820 + limits->max_write_same_sectors = 0;
821 + }
822 return error;
823 + }
824
825 if (mpio->pgpath)
826 fail_path(mpio->pgpath);
827 diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
828 index 1d3fe1a..2dea49c 100644
829 --- a/drivers/md/dm-raid.c
830 +++ b/drivers/md/dm-raid.c
831 @@ -380,7 +380,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
832 static int validate_raid_redundancy(struct raid_set *rs)
833 {
834 unsigned i, rebuild_cnt = 0;
835 - unsigned rebuilds_per_group, copies, d;
836 + unsigned rebuilds_per_group = 0, copies, d;
837 unsigned group_size, last_group_start;
838
839 for (i = 0; i < rs->md.raid_disks; i++)
840 diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
841 index 3ac4156..4caa8e6 100644
842 --- a/drivers/md/dm-snap-persistent.c
843 +++ b/drivers/md/dm-snap-persistent.c
844 @@ -256,7 +256,7 @@ static int chunk_io(struct pstore *ps, void *area, chunk_t chunk, int rw,
845 */
846 INIT_WORK_ONSTACK(&req.work, do_metadata);
847 queue_work(ps->metadata_wq, &req.work);
848 - flush_work(&req.work);
849 + flush_workqueue(ps->metadata_wq);
850
851 return req.result;
852 }
853 diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
854 index c434e5a..aec57d7 100644
855 --- a/drivers/md/dm-snap.c
856 +++ b/drivers/md/dm-snap.c
857 @@ -725,17 +725,16 @@ static int calc_max_buckets(void)
858 */
859 static int init_hash_tables(struct dm_snapshot *s)
860 {
861 - sector_t hash_size, cow_dev_size, origin_dev_size, max_buckets;
862 + sector_t hash_size, cow_dev_size, max_buckets;
863
864 /*
865 * Calculate based on the size of the original volume or
866 * the COW volume...
867 */
868 cow_dev_size = get_dev_size(s->cow->bdev);
869 - origin_dev_size = get_dev_size(s->origin->bdev);
870 max_buckets = calc_max_buckets();
871
872 - hash_size = min(origin_dev_size, cow_dev_size) >> s->store->chunk_shift;
873 + hash_size = cow_dev_size >> s->store->chunk_shift;
874 hash_size = min(hash_size, max_buckets);
875
876 if (hash_size < 64)
877 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
878 index 33f2010..1c13071 100644
879 --- a/drivers/md/dm.c
880 +++ b/drivers/md/dm.c
881 @@ -2219,6 +2219,17 @@ struct target_type *dm_get_immutable_target_type(struct mapped_device *md)
882 }
883
884 /*
885 + * The queue_limits are only valid as long as you have a reference
886 + * count on 'md'.
887 + */
888 +struct queue_limits *dm_get_queue_limits(struct mapped_device *md)
889 +{
890 + BUG_ON(!atomic_read(&md->holders));
891 + return &md->queue->limits;
892 +}
893 +EXPORT_SYMBOL_GPL(dm_get_queue_limits);
894 +
895 +/*
896 * Fully initialize a request-based queue (->elevator, ->request_fn, etc).
897 */
898 static int dm_init_request_based_queue(struct mapped_device *md)
899 diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
900 index b3e5098..3db9291 100644
901 --- a/drivers/misc/mei/amthif.c
902 +++ b/drivers/misc/mei/amthif.c
903 @@ -57,6 +57,7 @@ void mei_amthif_reset_params(struct mei_device *dev)
904 dev->iamthif_ioctl = false;
905 dev->iamthif_state = MEI_IAMTHIF_IDLE;
906 dev->iamthif_timer = 0;
907 + dev->iamthif_stall_timer = 0;
908 }
909
910 /**
911 diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
912 index 9ecd49a..99cc0b0 100644
913 --- a/drivers/misc/mei/bus.c
914 +++ b/drivers/misc/mei/bus.c
915 @@ -295,10 +295,13 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length)
916
917 if (cl->reading_state != MEI_READ_COMPLETE &&
918 !waitqueue_active(&cl->rx_wait)) {
919 +
920 mutex_unlock(&dev->device_lock);
921
922 if (wait_event_interruptible(cl->rx_wait,
923 - (MEI_READ_COMPLETE == cl->reading_state))) {
924 + cl->reading_state == MEI_READ_COMPLETE ||
925 + mei_cl_is_transitioning(cl))) {
926 +
927 if (signal_pending(current))
928 return -EINTR;
929 return -ERESTARTSYS;
930 diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
931 index cfdb144..467d9dd 100644
932 --- a/drivers/misc/mei/client.h
933 +++ b/drivers/misc/mei/client.h
934 @@ -76,6 +76,12 @@ static inline bool mei_cl_cmp_id(const struct mei_cl *cl1,
935 (cl1->host_client_id == cl2->host_client_id) &&
936 (cl1->me_client_id == cl2->me_client_id);
937 }
938 +static inline bool mei_cl_is_transitioning(struct mei_cl *cl)
939 +{
940 + return (MEI_FILE_INITIALIZING == cl->state ||
941 + MEI_FILE_DISCONNECTED == cl->state ||
942 + MEI_FILE_DISCONNECTING == cl->state);
943 +}
944
945
946 int mei_cl_flow_ctrl_creds(struct mei_cl *cl);
947 diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
948 index 6916045..23b5b7b 100644
949 --- a/drivers/misc/mei/hbm.c
950 +++ b/drivers/misc/mei/hbm.c
951 @@ -35,11 +35,15 @@ static void mei_hbm_me_cl_allocate(struct mei_device *dev)
952 struct mei_me_client *clients;
953 int b;
954
955 + dev->me_clients_num = 0;
956 + dev->me_client_presentation_num = 0;
957 + dev->me_client_index = 0;
958 +
959 /* count how many ME clients we have */
960 for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX)
961 dev->me_clients_num++;
962
963 - if (dev->me_clients_num <= 0)
964 + if (dev->me_clients_num == 0)
965 return;
966
967 kfree(dev->me_clients);
968 @@ -221,7 +225,7 @@ static int mei_hbm_prop_req(struct mei_device *dev)
969 struct hbm_props_request *prop_req;
970 const size_t len = sizeof(struct hbm_props_request);
971 unsigned long next_client_index;
972 - u8 client_num;
973 + unsigned long client_num;
974
975
976 client_num = dev->me_client_presentation_num;
977 @@ -650,8 +654,6 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
978 if (dev->dev_state == MEI_DEV_INIT_CLIENTS &&
979 dev->hbm_state == MEI_HBM_ENUM_CLIENTS) {
980 dev->init_clients_timer = 0;
981 - dev->me_client_presentation_num = 0;
982 - dev->me_client_index = 0;
983 mei_hbm_me_cl_allocate(dev);
984 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
985
986 diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
987 index 6eec689..878bc1c 100644
988 --- a/drivers/misc/mei/init.c
989 +++ b/drivers/misc/mei/init.c
990 @@ -164,6 +164,9 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
991 memset(&dev->wr_ext_msg, 0, sizeof(dev->wr_ext_msg));
992 }
993
994 + /* we're already in reset, cancel the init timer */
995 + dev->init_clients_timer = 0;
996 +
997 dev->me_clients_num = 0;
998 dev->rd_msg_hdr = 0;
999 dev->wd_pending = false;
1000 diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
1001 index 053139f..701698d 100644
1002 --- a/drivers/misc/mei/main.c
1003 +++ b/drivers/misc/mei/main.c
1004 @@ -262,19 +262,16 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
1005 mutex_unlock(&dev->device_lock);
1006
1007 if (wait_event_interruptible(cl->rx_wait,
1008 - (MEI_READ_COMPLETE == cl->reading_state ||
1009 - MEI_FILE_INITIALIZING == cl->state ||
1010 - MEI_FILE_DISCONNECTED == cl->state ||
1011 - MEI_FILE_DISCONNECTING == cl->state))) {
1012 + MEI_READ_COMPLETE == cl->reading_state ||
1013 + mei_cl_is_transitioning(cl))) {
1014 +
1015 if (signal_pending(current))
1016 return -EINTR;
1017 return -ERESTARTSYS;
1018 }
1019
1020 mutex_lock(&dev->device_lock);
1021 - if (MEI_FILE_INITIALIZING == cl->state ||
1022 - MEI_FILE_DISCONNECTED == cl->state ||
1023 - MEI_FILE_DISCONNECTING == cl->state) {
1024 + if (mei_cl_is_transitioning(cl)) {
1025 rets = -EBUSY;
1026 goto out;
1027 }
1028 diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
1029 index 4de5140..73c7700 100644
1030 --- a/drivers/misc/mei/mei_dev.h
1031 +++ b/drivers/misc/mei/mei_dev.h
1032 @@ -402,9 +402,9 @@ struct mei_device {
1033 struct mei_me_client *me_clients; /* Note: memory has to be allocated */
1034 DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX);
1035 DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
1036 - u8 me_clients_num;
1037 - u8 me_client_presentation_num;
1038 - u8 me_client_index;
1039 + unsigned long me_clients_num;
1040 + unsigned long me_client_presentation_num;
1041 + unsigned long me_client_index;
1042
1043 struct mei_cl wd_cl;
1044 enum mei_wd_states wd_state;
1045 diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c
1046 index d0cf7d8..8872e0f 100644
1047 --- a/drivers/staging/vt6656/iwctl.c
1048 +++ b/drivers/staging/vt6656/iwctl.c
1049 @@ -1634,6 +1634,9 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,
1050 if (pMgmt == NULL)
1051 return -EFAULT;
1052
1053 + if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
1054 + return -ENODEV;
1055 +
1056 buf = kzalloc(sizeof(struct viawget_wpa_param), GFP_KERNEL);
1057 if (buf == NULL)
1058 return -ENOMEM;
1059 diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
1060 index 3a3fdc5..06b966c 100644
1061 --- a/drivers/staging/vt6656/main_usb.c
1062 +++ b/drivers/staging/vt6656/main_usb.c
1063 @@ -1099,6 +1099,8 @@ static int device_close(struct net_device *dev)
1064 memset(pMgmt->abyCurrBSSID, 0, 6);
1065 pMgmt->eCurrState = WMAC_STATE_IDLE;
1066
1067 + pDevice->flags &= ~DEVICE_FLAGS_OPENED;
1068 +
1069 device_free_tx_bufs(pDevice);
1070 device_free_rx_bufs(pDevice);
1071 device_free_int_bufs(pDevice);
1072 @@ -1110,7 +1112,6 @@ static int device_close(struct net_device *dev)
1073 usb_free_urb(pDevice->pInterruptURB);
1074
1075 BSSvClearNodeDBTable(pDevice, 0);
1076 - pDevice->flags &=(~DEVICE_FLAGS_OPENED);
1077
1078 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close2 \n");
1079
1080 diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
1081 index 572d481..20e4c94 100644
1082 --- a/drivers/tty/serial/pch_uart.c
1083 +++ b/drivers/tty/serial/pch_uart.c
1084 @@ -658,11 +658,12 @@ static int dma_push_rx(struct eg20t_port *priv, int size)
1085 dev_warn(port->dev, "Rx overrun: dropping %u bytes\n",
1086 size - room);
1087 if (!room)
1088 - return room;
1089 + goto out;
1090
1091 tty_insert_flip_string(tport, sg_virt(&priv->sg_rx), size);
1092
1093 port->icount.rx += room;
1094 +out:
1095 tty_kref_put(tty);
1096
1097 return room;
1098 @@ -1071,6 +1072,8 @@ static void pch_uart_err_ir(struct eg20t_port *priv, unsigned int lsr)
1099 if (tty == NULL) {
1100 for (i = 0; error_msg[i] != NULL; i++)
1101 dev_err(&priv->pdev->dev, error_msg[i]);
1102 + } else {
1103 + tty_kref_put(tty);
1104 }
1105 }
1106
1107 diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
1108 index 9799d04..357a837 100644
1109 --- a/drivers/tty/serial/serial-tegra.c
1110 +++ b/drivers/tty/serial/serial-tegra.c
1111 @@ -726,7 +726,7 @@ static irqreturn_t tegra_uart_isr(int irq, void *data)
1112 static void tegra_uart_stop_rx(struct uart_port *u)
1113 {
1114 struct tegra_uart_port *tup = to_tegra_uport(u);
1115 - struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port);
1116 + struct tty_struct *tty;
1117 struct tty_port *port = &u->state->port;
1118 struct dma_tx_state state;
1119 unsigned long ier;
1120 @@ -738,6 +738,8 @@ static void tegra_uart_stop_rx(struct uart_port *u)
1121 if (!tup->rx_in_progress)
1122 return;
1123
1124 + tty = tty_port_tty_get(&tup->uport.state->port);
1125 +
1126 tegra_uart_wait_sym_time(tup, 1); /* wait a character interval */
1127
1128 ier = tup->ier_shadow;
1129 diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
1130 index 3500d41..088b4ca 100644
1131 --- a/drivers/tty/tty_ioctl.c
1132 +++ b/drivers/tty/tty_ioctl.c
1133 @@ -1201,6 +1201,9 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
1134 }
1135 return 0;
1136 case TCFLSH:
1137 + retval = tty_check_change(tty);
1138 + if (retval)
1139 + return retval;
1140 return __tty_perform_flush(tty, arg);
1141 default:
1142 /* Try the mode commands */
1143 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
1144 index c88c4fb..ce773cc 100644
1145 --- a/drivers/usb/core/devio.c
1146 +++ b/drivers/usb/core/devio.c
1147 @@ -742,6 +742,22 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
1148 if ((index & ~USB_DIR_IN) == 0)
1149 return 0;
1150 ret = findintfep(ps->dev, index);
1151 + if (ret < 0) {
1152 + /*
1153 + * Some not fully compliant Win apps seem to get
1154 + * index wrong and have the endpoint number here
1155 + * rather than the endpoint address (with the
1156 + * correct direction). Win does let this through,
1157 + * so we'll not reject it here but leave it to
1158 + * the device to not break KVM. But we warn.
1159 + */
1160 + ret = findintfep(ps->dev, index ^ 0x80);
1161 + if (ret >= 0)
1162 + dev_info(&ps->dev->dev,
1163 + "%s: process %i (%s) requesting ep %02x but needs %02x\n",
1164 + __func__, task_pid_nr(current),
1165 + current->comm, index, index ^ 0x80);
1166 + }
1167 if (ret >= 0)
1168 ret = checkintf(ps, ret);
1169 break;
1170 diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
1171 index eba9e2b..2357c4e 100644
1172 --- a/drivers/usb/dwc3/dwc3-pci.c
1173 +++ b/drivers/usb/dwc3/dwc3-pci.c
1174 @@ -48,6 +48,8 @@
1175 /* FIXME define these in <linux/pci_ids.h> */
1176 #define PCI_VENDOR_ID_SYNOPSYS 0x16c3
1177 #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
1178 +#define PCI_DEVICE_ID_INTEL_BYT 0x0f37
1179 +#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
1180
1181 struct dwc3_pci {
1182 struct device *dev;
1183 @@ -208,6 +210,8 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = {
1184 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
1185 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
1186 },
1187 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
1188 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
1189 { } /* Terminating Entry */
1190 };
1191 MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
1192 diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
1193 index f394f29..b6e9d91 100644
1194 --- a/drivers/usb/gadget/f_fs.c
1195 +++ b/drivers/usb/gadget/f_fs.c
1196 @@ -1034,37 +1034,19 @@ struct ffs_sb_fill_data {
1197 struct ffs_file_perms perms;
1198 umode_t root_mode;
1199 const char *dev_name;
1200 - union {
1201 - /* set by ffs_fs_mount(), read by ffs_sb_fill() */
1202 - void *private_data;
1203 - /* set by ffs_sb_fill(), read by ffs_fs_mount */
1204 - struct ffs_data *ffs_data;
1205 - };
1206 + struct ffs_data *ffs_data;
1207 };
1208
1209 static int ffs_sb_fill(struct super_block *sb, void *_data, int silent)
1210 {
1211 struct ffs_sb_fill_data *data = _data;
1212 struct inode *inode;
1213 - struct ffs_data *ffs;
1214 + struct ffs_data *ffs = data->ffs_data;
1215
1216 ENTER();
1217
1218 - /* Initialise data */
1219 - ffs = ffs_data_new();
1220 - if (unlikely(!ffs))
1221 - goto Enomem;
1222 -
1223 ffs->sb = sb;
1224 - ffs->dev_name = kstrdup(data->dev_name, GFP_KERNEL);
1225 - if (unlikely(!ffs->dev_name))
1226 - goto Enomem;
1227 - ffs->file_perms = data->perms;
1228 - ffs->private_data = data->private_data;
1229 -
1230 - /* used by the caller of this function */
1231 - data->ffs_data = ffs;
1232 -
1233 + data->ffs_data = NULL;
1234 sb->s_fs_info = ffs;
1235 sb->s_blocksize = PAGE_CACHE_SIZE;
1236 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1237 @@ -1080,17 +1062,14 @@ static int ffs_sb_fill(struct super_block *sb, void *_data, int silent)
1238 &data->perms);
1239 sb->s_root = d_make_root(inode);
1240 if (unlikely(!sb->s_root))
1241 - goto Enomem;
1242 + return -ENOMEM;
1243
1244 /* EP0 file */
1245 if (unlikely(!ffs_sb_create_file(sb, "ep0", ffs,
1246 &ffs_ep0_operations, NULL)))
1247 - goto Enomem;
1248 + return -ENOMEM;
1249
1250 return 0;
1251 -
1252 -Enomem:
1253 - return -ENOMEM;
1254 }
1255
1256 static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts)
1257 @@ -1193,6 +1172,7 @@ ffs_fs_mount(struct file_system_type *t, int flags,
1258 struct dentry *rv;
1259 int ret;
1260 void *ffs_dev;
1261 + struct ffs_data *ffs;
1262
1263 ENTER();
1264
1265 @@ -1200,18 +1180,30 @@ ffs_fs_mount(struct file_system_type *t, int flags,
1266 if (unlikely(ret < 0))
1267 return ERR_PTR(ret);
1268
1269 + ffs = ffs_data_new();
1270 + if (unlikely(!ffs))
1271 + return ERR_PTR(-ENOMEM);
1272 + ffs->file_perms = data.perms;
1273 +
1274 + ffs->dev_name = kstrdup(dev_name, GFP_KERNEL);
1275 + if (unlikely(!ffs->dev_name)) {
1276 + ffs_data_put(ffs);
1277 + return ERR_PTR(-ENOMEM);
1278 + }
1279 +
1280 ffs_dev = functionfs_acquire_dev_callback(dev_name);
1281 - if (IS_ERR(ffs_dev))
1282 - return ffs_dev;
1283 + if (IS_ERR(ffs_dev)) {
1284 + ffs_data_put(ffs);
1285 + return ERR_CAST(ffs_dev);
1286 + }
1287 + ffs->private_data = ffs_dev;
1288 + data.ffs_data = ffs;
1289
1290 - data.dev_name = dev_name;
1291 - data.private_data = ffs_dev;
1292 rv = mount_nodev(t, flags, &data, ffs_sb_fill);
1293 -
1294 - /* data.ffs_data is set by ffs_sb_fill */
1295 - if (IS_ERR(rv))
1296 + if (IS_ERR(rv) && data.ffs_data) {
1297 functionfs_release_dev_callback(data.ffs_data);
1298 -
1299 + ffs_data_put(data.ffs_data);
1300 + }
1301 return rv;
1302 }
1303
1304 diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
1305 index 3be3df2..3c0a49a 100644
1306 --- a/drivers/usb/host/ehci-fsl.c
1307 +++ b/drivers/usb/host/ehci-fsl.c
1308 @@ -130,7 +130,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
1309 }
1310
1311 /* Enable USB controller, 83xx or 8536 */
1312 - if (pdata->have_sysif_regs)
1313 + if (pdata->have_sysif_regs && pdata->controller_ver < FSL_USB_VER_1_6)
1314 setbits32(hcd->regs + FSL_SOC_USB_CTRL, 0x4);
1315
1316 /* Don't need to set host mode here. It will be done by tdi_reset() */
1317 @@ -232,15 +232,9 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
1318 case FSL_USB2_PHY_ULPI:
1319 if (pdata->have_sysif_regs && pdata->controller_ver) {
1320 /* controller version 1.6 or above */
1321 + clrbits32(non_ehci + FSL_SOC_USB_CTRL, UTMI_PHY_EN);
1322 setbits32(non_ehci + FSL_SOC_USB_CTRL,
1323 - ULPI_PHY_CLK_SEL);
1324 - /*
1325 - * Due to controller issue of PHY_CLK_VALID in ULPI
1326 - * mode, we set USB_CTRL_USB_EN before checking
1327 - * PHY_CLK_VALID, otherwise PHY_CLK_VALID doesn't work.
1328 - */
1329 - clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL,
1330 - UTMI_PHY_EN, USB_CTRL_USB_EN);
1331 + ULPI_PHY_CLK_SEL | USB_CTRL_USB_EN);
1332 }
1333 portsc |= PORT_PTS_ULPI;
1334 break;
1335 diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
1336 index 595d210..8fe401c 100644
1337 --- a/drivers/usb/host/ehci-pci.c
1338 +++ b/drivers/usb/host/ehci-pci.c
1339 @@ -403,7 +403,7 @@ static struct pci_driver ehci_pci_driver = {
1340 .remove = usb_hcd_pci_remove,
1341 .shutdown = usb_hcd_pci_shutdown,
1342
1343 -#ifdef CONFIG_PM_SLEEP
1344 +#ifdef CONFIG_PM
1345 .driver = {
1346 .pm = &usb_hcd_pci_pm_ops
1347 },
1348 diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
1349 index fc627fd..865946c 100644
1350 --- a/drivers/usb/host/ohci-hcd.c
1351 +++ b/drivers/usb/host/ohci-hcd.c
1352 @@ -231,31 +231,26 @@ static int ohci_urb_enqueue (
1353 frame &= ~(ed->interval - 1);
1354 frame |= ed->branch;
1355 urb->start_frame = frame;
1356 + ed->last_iso = frame + ed->interval * (size - 1);
1357 }
1358 } else if (ed->type == PIPE_ISOCHRONOUS) {
1359 u16 next = ohci_frame_no(ohci) + 1;
1360 u16 frame = ed->last_iso + ed->interval;
1361 + u16 length = ed->interval * (size - 1);
1362
1363 /* Behind the scheduling threshold? */
1364 if (unlikely(tick_before(frame, next))) {
1365
1366 - /* USB_ISO_ASAP: Round up to the first available slot */
1367 + /* URB_ISO_ASAP: Round up to the first available slot */
1368 if (urb->transfer_flags & URB_ISO_ASAP) {
1369 frame += (next - frame + ed->interval - 1) &
1370 -ed->interval;
1371
1372 /*
1373 - * Not ASAP: Use the next slot in the stream. If
1374 - * the entire URB falls before the threshold, fail.
1375 + * Not ASAP: Use the next slot in the stream,
1376 + * no matter what.
1377 */
1378 } else {
1379 - if (tick_before(frame + ed->interval *
1380 - (urb->number_of_packets - 1), next)) {
1381 - retval = -EXDEV;
1382 - usb_hcd_unlink_urb_from_ep(hcd, urb);
1383 - goto fail;
1384 - }
1385 -
1386 /*
1387 * Some OHCI hardware doesn't handle late TDs
1388 * correctly. After retiring them it proceeds
1389 @@ -266,9 +261,16 @@ static int ohci_urb_enqueue (
1390 urb_priv->td_cnt = DIV_ROUND_UP(
1391 (u16) (next - frame),
1392 ed->interval);
1393 + if (urb_priv->td_cnt >= urb_priv->length) {
1394 + ++urb_priv->td_cnt; /* Mark it */
1395 + ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n",
1396 + urb, frame, length,
1397 + next);
1398 + }
1399 }
1400 }
1401 urb->start_frame = frame;
1402 + ed->last_iso = frame + length;
1403 }
1404
1405 /* fill the TDs and link them to the ed; and
1406 diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
1407 index 88731b7..37dc837 100644
1408 --- a/drivers/usb/host/ohci-q.c
1409 +++ b/drivers/usb/host/ohci-q.c
1410 @@ -41,8 +41,12 @@ finish_urb(struct ohci_hcd *ohci, struct urb *urb, int status)
1411 __releases(ohci->lock)
1412 __acquires(ohci->lock)
1413 {
1414 + struct usb_host_endpoint *ep = urb->ep;
1415 + struct urb_priv *urb_priv;
1416 +
1417 // ASSERT (urb->hcpriv != 0);
1418
1419 + restart:
1420 urb_free_priv (ohci, urb->hcpriv);
1421 urb->hcpriv = NULL;
1422 if (likely(status == -EINPROGRESS))
1423 @@ -79,6 +83,21 @@ __acquires(ohci->lock)
1424 ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_IE);
1425 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
1426 }
1427 +
1428 + /*
1429 + * An isochronous URB that is sumitted too late won't have any TDs
1430 + * (marked by the fact that the td_cnt value is larger than the
1431 + * actual number of TDs). If the next URB on this endpoint is like
1432 + * that, give it back now.
1433 + */
1434 + if (!list_empty(&ep->urb_list)) {
1435 + urb = list_first_entry(&ep->urb_list, struct urb, urb_list);
1436 + urb_priv = urb->hcpriv;
1437 + if (urb_priv->td_cnt > urb_priv->length) {
1438 + status = 0;
1439 + goto restart;
1440 + }
1441 + }
1442 }
1443
1444
1445 @@ -545,7 +564,6 @@ td_fill (struct ohci_hcd *ohci, u32 info,
1446 td->hwCBP = cpu_to_hc32 (ohci, data & 0xFFFFF000);
1447 *ohci_hwPSWp(ohci, td, 0) = cpu_to_hc16 (ohci,
1448 (data & 0x0FFF) | 0xE000);
1449 - td->ed->last_iso = info & 0xffff;
1450 } else {
1451 td->hwCBP = cpu_to_hc32 (ohci, data);
1452 }
1453 @@ -994,7 +1012,7 @@ rescan_this:
1454 urb_priv->td_cnt++;
1455
1456 /* if URB is done, clean up */
1457 - if (urb_priv->td_cnt == urb_priv->length) {
1458 + if (urb_priv->td_cnt >= urb_priv->length) {
1459 modified = completed = 1;
1460 finish_urb(ohci, urb, 0);
1461 }
1462 @@ -1084,7 +1102,7 @@ static void takeback_td(struct ohci_hcd *ohci, struct td *td)
1463 urb_priv->td_cnt++;
1464
1465 /* If all this urb's TDs are done, call complete() */
1466 - if (urb_priv->td_cnt == urb_priv->length)
1467 + if (urb_priv->td_cnt >= urb_priv->length)
1468 finish_urb(ohci, urb, status);
1469
1470 /* clean schedule: unlink EDs that are no longer busy */
1471 diff --git a/drivers/usb/host/uhci-pci.c b/drivers/usb/host/uhci-pci.c
1472 index c300bd2f7..0f228c4 100644
1473 --- a/drivers/usb/host/uhci-pci.c
1474 +++ b/drivers/usb/host/uhci-pci.c
1475 @@ -293,7 +293,7 @@ static struct pci_driver uhci_pci_driver = {
1476 .remove = usb_hcd_pci_remove,
1477 .shutdown = uhci_shutdown,
1478
1479 -#ifdef CONFIG_PM_SLEEP
1480 +#ifdef CONFIG_PM
1481 .driver = {
1482 .pm = &usb_hcd_pci_pm_ops
1483 },
1484 diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
1485 index 041c6dd..da6f56d 100644
1486 --- a/drivers/usb/host/uhci-q.c
1487 +++ b/drivers/usb/host/uhci-q.c
1488 @@ -1303,7 +1303,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1489 }
1490
1491 /* Fell behind? */
1492 - if (uhci_frame_before_eq(frame, next)) {
1493 + if (!uhci_frame_before_eq(next, frame)) {
1494
1495 /* USB_ISO_ASAP: Round up to the first available slot */
1496 if (urb->transfer_flags & URB_ISO_ASAP)
1497 @@ -1311,13 +1311,17 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb,
1498 -qh->period;
1499
1500 /*
1501 - * Not ASAP: Use the next slot in the stream. If
1502 - * the entire URB falls before the threshold, fail.
1503 + * Not ASAP: Use the next slot in the stream,
1504 + * no matter what.
1505 */
1506 else if (!uhci_frame_before_eq(next,
1507 frame + (urb->number_of_packets - 1) *
1508 qh->period))
1509 - return -EXDEV;
1510 + dev_dbg(uhci_dev(uhci), "iso underrun %p (%u+%u < %u)\n",
1511 + urb, frame,
1512 + (urb->number_of_packets - 1) *
1513 + qh->period,
1514 + next);
1515 }
1516 }
1517
1518 diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
1519 index 187a3ec..7cdcfd0 100644
1520 --- a/drivers/usb/host/xhci-hub.c
1521 +++ b/drivers/usb/host/xhci-hub.c
1522 @@ -286,7 +286,7 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
1523 if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue)
1524 xhci_queue_stop_endpoint(xhci, slot_id, i, suspend);
1525 }
1526 - cmd->command_trb = xhci->cmd_ring->enqueue;
1527 + cmd->command_trb = xhci_find_next_enqueue(xhci->cmd_ring);
1528 list_add_tail(&cmd->cmd_list, &virt_dev->cmd_list);
1529 xhci_queue_stop_endpoint(xhci, slot_id, 0, suspend);
1530 xhci_ring_cmd_db(xhci);
1531 diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
1532 index f00cb20..159e3c6 100644
1533 --- a/drivers/usb/host/xhci-pci.c
1534 +++ b/drivers/usb/host/xhci-pci.c
1535 @@ -345,7 +345,7 @@ static struct pci_driver xhci_pci_driver = {
1536 /* suspend and resume implemented later */
1537
1538 .shutdown = usb_hcd_pci_shutdown,
1539 -#ifdef CONFIG_PM_SLEEP
1540 +#ifdef CONFIG_PM
1541 .driver = {
1542 .pm = &usb_hcd_pci_pm_ops
1543 },
1544 diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
1545 index cc3bfc5..bcfb08e 100644
1546 --- a/drivers/usb/host/xhci-ring.c
1547 +++ b/drivers/usb/host/xhci-ring.c
1548 @@ -122,6 +122,16 @@ static int enqueue_is_link_trb(struct xhci_ring *ring)
1549 return TRB_TYPE_LINK_LE32(link->control);
1550 }
1551
1552 +union xhci_trb *xhci_find_next_enqueue(struct xhci_ring *ring)
1553 +{
1554 + /* Enqueue pointer can be left pointing to the link TRB,
1555 + * we must handle that
1556 + */
1557 + if (TRB_TYPE_LINK_LE32(ring->enqueue->link.control))
1558 + return ring->enq_seg->next->trbs;
1559 + return ring->enqueue;
1560 +}
1561 +
1562 /* Updates trb to point to the next TRB in the ring, and updates seg if the next
1563 * TRB is in a new segment. This does not skip over link TRBs, and it does not
1564 * effect the ring dequeue or enqueue pointers.
1565 @@ -847,8 +857,12 @@ remove_finished_td:
1566 /* Otherwise ring the doorbell(s) to restart queued transfers */
1567 ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
1568 }
1569 - ep->stopped_td = NULL;
1570 - ep->stopped_trb = NULL;
1571 +
1572 + /* Clear stopped_td and stopped_trb if endpoint is not halted */
1573 + if (!(ep->ep_state & EP_HALTED)) {
1574 + ep->stopped_td = NULL;
1575 + ep->stopped_trb = NULL;
1576 + }
1577
1578 /*
1579 * Drop the lock and complete the URBs in the cancelled TD list.
1580 @@ -1390,6 +1404,12 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1581 inc_deq(xhci, xhci->cmd_ring);
1582 return;
1583 }
1584 + /* There is no command to handle if we get a stop event when the
1585 + * command ring is empty, event->cmd_trb points to the next
1586 + * unset command
1587 + */
1588 + if (xhci->cmd_ring->dequeue == xhci->cmd_ring->enqueue)
1589 + return;
1590 }
1591
1592 switch (le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3])
1593 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
1594 index f4a49c4..4a5251f 100644
1595 --- a/drivers/usb/host/xhci.c
1596 +++ b/drivers/usb/host/xhci.c
1597 @@ -2592,15 +2592,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
1598 if (command) {
1599 cmd_completion = command->completion;
1600 cmd_status = &command->status;
1601 - command->command_trb = xhci->cmd_ring->enqueue;
1602 -
1603 - /* Enqueue pointer can be left pointing to the link TRB,
1604 - * we must handle that
1605 - */
1606 - if (TRB_TYPE_LINK_LE32(command->command_trb->link.control))
1607 - command->command_trb =
1608 - xhci->cmd_ring->enq_seg->next->trbs;
1609 -
1610 + command->command_trb = xhci_find_next_enqueue(xhci->cmd_ring);
1611 list_add_tail(&command->cmd_list, &virt_dev->cmd_list);
1612 } else {
1613 cmd_completion = &virt_dev->cmd_completion;
1614 @@ -2608,7 +2600,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
1615 }
1616 init_completion(cmd_completion);
1617
1618 - cmd_trb = xhci->cmd_ring->dequeue;
1619 + cmd_trb = xhci_find_next_enqueue(xhci->cmd_ring);
1620 if (!ctx_change)
1621 ret = xhci_queue_configure_endpoint(xhci, in_ctx->dma,
1622 udev->slot_id, must_succeed);
1623 @@ -3393,14 +3385,7 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
1624
1625 /* Attempt to submit the Reset Device command to the command ring */
1626 spin_lock_irqsave(&xhci->lock, flags);
1627 - reset_device_cmd->command_trb = xhci->cmd_ring->enqueue;
1628 -
1629 - /* Enqueue pointer can be left pointing to the link TRB,
1630 - * we must handle that
1631 - */
1632 - if (TRB_TYPE_LINK_LE32(reset_device_cmd->command_trb->link.control))
1633 - reset_device_cmd->command_trb =
1634 - xhci->cmd_ring->enq_seg->next->trbs;
1635 + reset_device_cmd->command_trb = xhci_find_next_enqueue(xhci->cmd_ring);
1636
1637 list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list);
1638 ret = xhci_queue_reset_device(xhci, slot_id);
1639 @@ -3604,7 +3589,7 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
1640 union xhci_trb *cmd_trb;
1641
1642 spin_lock_irqsave(&xhci->lock, flags);
1643 - cmd_trb = xhci->cmd_ring->dequeue;
1644 + cmd_trb = xhci_find_next_enqueue(xhci->cmd_ring);
1645 ret = xhci_queue_slot_control(xhci, TRB_ENABLE_SLOT, 0);
1646 if (ret) {
1647 spin_unlock_irqrestore(&xhci->lock, flags);
1648 @@ -3731,7 +3716,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
1649 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
1650
1651 spin_lock_irqsave(&xhci->lock, flags);
1652 - cmd_trb = xhci->cmd_ring->dequeue;
1653 + cmd_trb = xhci_find_next_enqueue(xhci->cmd_ring);
1654 ret = xhci_queue_address_device(xhci, virt_dev->in_ctx->dma,
1655 udev->slot_id);
1656 if (ret) {
1657 diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
1658 index 3638f1d..627fcd9 100644
1659 --- a/drivers/usb/host/xhci.h
1660 +++ b/drivers/usb/host/xhci.h
1661 @@ -1821,6 +1821,7 @@ int xhci_cancel_cmd(struct xhci_hcd *xhci, struct xhci_command *command,
1662 union xhci_trb *cmd_trb);
1663 void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
1664 unsigned int ep_index, unsigned int stream_id);
1665 +union xhci_trb *xhci_find_next_enqueue(struct xhci_ring *ring);
1666
1667 /* xHCI roothub code */
1668 void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array,
1669 diff --git a/fs/bio.c b/fs/bio.c
1670 index c5eae72..5e7507d 100644
1671 --- a/fs/bio.c
1672 +++ b/fs/bio.c
1673 @@ -917,8 +917,8 @@ void bio_copy_data(struct bio *dst, struct bio *src)
1674 src_p = kmap_atomic(src_bv->bv_page);
1675 dst_p = kmap_atomic(dst_bv->bv_page);
1676
1677 - memcpy(dst_p + dst_bv->bv_offset,
1678 - src_p + src_bv->bv_offset,
1679 + memcpy(dst_p + dst_offset,
1680 + src_p + src_offset,
1681 bytes);
1682
1683 kunmap_atomic(dst_p);
1684 diff --git a/fs/sysv/super.c b/fs/sysv/super.c
1685 index d0c6a00..eda1095 100644
1686 --- a/fs/sysv/super.c
1687 +++ b/fs/sysv/super.c
1688 @@ -487,6 +487,7 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
1689 sbi->s_sb = sb;
1690 sbi->s_block_base = 0;
1691 sbi->s_type = FSTYPE_V7;
1692 + mutex_init(&sbi->s_lock);
1693 sb->s_fs_info = sbi;
1694
1695 sb_set_blocksize(sb, 512);
1696 diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
1697 index 3cd3247..ef5bd3f 100644
1698 --- a/include/linux/device-mapper.h
1699 +++ b/include/linux/device-mapper.h
1700 @@ -405,13 +405,14 @@ int dm_noflush_suspending(struct dm_target *ti);
1701 union map_info *dm_get_mapinfo(struct bio *bio);
1702 union map_info *dm_get_rq_mapinfo(struct request *rq);
1703
1704 +struct queue_limits *dm_get_queue_limits(struct mapped_device *md);
1705 +
1706 /*
1707 * Geometry functions.
1708 */
1709 int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo);
1710 int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo);
1711
1712 -
1713 /*-----------------------------------------------------------------
1714 * Functions for manipulating device-mapper tables.
1715 *---------------------------------------------------------------*/
1716 diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
1717 index 9896954..5863ba6 100644
1718 --- a/sound/core/compress_offload.c
1719 +++ b/sound/core/compress_offload.c
1720 @@ -837,7 +837,8 @@ static int snd_compress_dev_disconnect(struct snd_device *device)
1721 struct snd_compr *compr;
1722
1723 compr = device->device_data;
1724 - snd_unregister_device(compr->direction, compr->card, compr->device);
1725 + snd_unregister_device(SNDRV_DEVICE_TYPE_COMPRESS, compr->card,
1726 + compr->device);
1727 return 0;
1728 }
1729
1730 diff --git a/tools/lib/lk/debugfs.c b/tools/lib/lk/debugfs.c
1731 index 099e7cd..7c43479 100644
1732 --- a/tools/lib/lk/debugfs.c
1733 +++ b/tools/lib/lk/debugfs.c
1734 @@ -5,7 +5,6 @@
1735 #include <stdbool.h>
1736 #include <sys/vfs.h>
1737 #include <sys/mount.h>
1738 -#include <linux/magic.h>
1739 #include <linux/kernel.h>
1740
1741 #include "debugfs.h"