Contents of /trunk/kernel-magellan/patches-4.13/0109-4.13.10-all-fixes.patch
Parent Directory | Revision Log
Revision 3018 -
(show annotations)
(download)
Mon Nov 6 09:39:46 2017 UTC (6 years, 10 months ago) by niro
File size: 130011 byte(s)
Mon Nov 6 09:39:46 2017 UTC (6 years, 10 months ago) by niro
File size: 130011 byte(s)
-linux-4.13.10
1 | diff --git a/Makefile b/Makefile |
2 | index aa0267950444..0e30a0d282e8 100644 |
3 | --- a/Makefile |
4 | +++ b/Makefile |
5 | @@ -1,6 +1,6 @@ |
6 | VERSION = 4 |
7 | PATCHLEVEL = 13 |
8 | -SUBLEVEL = 9 |
9 | +SUBLEVEL = 10 |
10 | EXTRAVERSION = |
11 | NAME = Fearless Coyote |
12 | |
13 | diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi |
14 | index aebc3f9dc7b6..fa1bbdca1710 100644 |
15 | --- a/arch/arm/boot/dts/sun6i-a31.dtsi |
16 | +++ b/arch/arm/boot/dts/sun6i-a31.dtsi |
17 | @@ -311,8 +311,8 @@ |
18 | #size-cells = <0>; |
19 | reg = <0>; |
20 | |
21 | - tcon1_in_drc1: endpoint@0 { |
22 | - reg = <0>; |
23 | + tcon1_in_drc1: endpoint@1 { |
24 | + reg = <1>; |
25 | remote-endpoint = <&drc1_out_tcon1>; |
26 | }; |
27 | }; |
28 | @@ -1012,8 +1012,8 @@ |
29 | #size-cells = <0>; |
30 | reg = <1>; |
31 | |
32 | - be1_out_drc1: endpoint@0 { |
33 | - reg = <0>; |
34 | + be1_out_drc1: endpoint@1 { |
35 | + reg = <1>; |
36 | remote-endpoint = <&drc1_in_be1>; |
37 | }; |
38 | }; |
39 | @@ -1042,8 +1042,8 @@ |
40 | #size-cells = <0>; |
41 | reg = <0>; |
42 | |
43 | - drc1_in_be1: endpoint@0 { |
44 | - reg = <0>; |
45 | + drc1_in_be1: endpoint@1 { |
46 | + reg = <1>; |
47 | remote-endpoint = <&be1_out_drc1>; |
48 | }; |
49 | }; |
50 | @@ -1053,8 +1053,8 @@ |
51 | #size-cells = <0>; |
52 | reg = <1>; |
53 | |
54 | - drc1_out_tcon1: endpoint@0 { |
55 | - reg = <0>; |
56 | + drc1_out_tcon1: endpoint@1 { |
57 | + reg = <1>; |
58 | remote-endpoint = <&tcon1_in_drc1>; |
59 | }; |
60 | }; |
61 | diff --git a/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts b/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts |
62 | index ba1d9810ad1e..c27242a7d5e7 100644 |
63 | --- a/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts |
64 | +++ b/arch/arm64/boot/dts/rockchip/rk3399-firefly.dts |
65 | @@ -370,10 +370,10 @@ |
66 | regulator-always-on; |
67 | regulator-boot-on; |
68 | regulator-min-microvolt = <1800000>; |
69 | - regulator-max-microvolt = <3300000>; |
70 | + regulator-max-microvolt = <3000000>; |
71 | regulator-state-mem { |
72 | regulator-on-in-suspend; |
73 | - regulator-suspend-microvolt = <3300000>; |
74 | + regulator-suspend-microvolt = <3000000>; |
75 | }; |
76 | }; |
77 | |
78 | diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S |
79 | index 23de307c3052..41e60a9c7db2 100644 |
80 | --- a/arch/parisc/kernel/syscall.S |
81 | +++ b/arch/parisc/kernel/syscall.S |
82 | @@ -742,7 +742,7 @@ lws_compare_and_swap_2: |
83 | 10: ldd 0(%r25), %r25 |
84 | 11: ldd 0(%r24), %r24 |
85 | #else |
86 | - /* Load new value into r22/r23 - high/low */ |
87 | + /* Load old value into r22/r23 - high/low */ |
88 | 10: ldw 0(%r25), %r22 |
89 | 11: ldw 4(%r25), %r23 |
90 | /* Load new value into fr4 for atomic store later */ |
91 | @@ -834,11 +834,11 @@ cas2_action: |
92 | copy %r0, %r28 |
93 | #else |
94 | /* Compare first word */ |
95 | -19: ldw,ma 0(%r26), %r29 |
96 | +19: ldw 0(%r26), %r29 |
97 | sub,= %r29, %r22, %r0 |
98 | b,n cas2_end |
99 | /* Compare second word */ |
100 | -20: ldw,ma 4(%r26), %r29 |
101 | +20: ldw 4(%r26), %r29 |
102 | sub,= %r29, %r23, %r0 |
103 | b,n cas2_end |
104 | /* Perform the store */ |
105 | diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c |
106 | index 2d956aa0a38a..8c0105a49839 100644 |
107 | --- a/arch/parisc/kernel/time.c |
108 | +++ b/arch/parisc/kernel/time.c |
109 | @@ -253,7 +253,10 @@ static int __init init_cr16_clocksource(void) |
110 | cpu0_loc = per_cpu(cpu_data, 0).cpu_loc; |
111 | |
112 | for_each_online_cpu(cpu) { |
113 | - if (cpu0_loc == per_cpu(cpu_data, cpu).cpu_loc) |
114 | + if (cpu == 0) |
115 | + continue; |
116 | + if ((cpu0_loc != 0) && |
117 | + (cpu0_loc == per_cpu(cpu_data, cpu).cpu_loc)) |
118 | continue; |
119 | |
120 | clocksource_cr16.name = "cr16_unstable"; |
121 | diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c |
122 | index 1020a11a24e5..03895b6db719 100644 |
123 | --- a/arch/s390/kernel/smp.c |
124 | +++ b/arch/s390/kernel/smp.c |
125 | @@ -293,7 +293,10 @@ static void pcpu_attach_task(struct pcpu *pcpu, struct task_struct *tsk) |
126 | lc->lpp = LPP_MAGIC; |
127 | lc->current_pid = tsk->pid; |
128 | lc->user_timer = tsk->thread.user_timer; |
129 | + lc->guest_timer = tsk->thread.guest_timer; |
130 | lc->system_timer = tsk->thread.system_timer; |
131 | + lc->hardirq_timer = tsk->thread.hardirq_timer; |
132 | + lc->softirq_timer = tsk->thread.softirq_timer; |
133 | lc->steal_timer = 0; |
134 | } |
135 | |
136 | diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c |
137 | index 59edbe9d4ccb..636a5fcfdeb7 100644 |
138 | --- a/arch/x86/kernel/cpu/microcode/intel.c |
139 | +++ b/arch/x86/kernel/cpu/microcode/intel.c |
140 | @@ -34,6 +34,7 @@ |
141 | #include <linux/mm.h> |
142 | |
143 | #include <asm/microcode_intel.h> |
144 | +#include <asm/intel-family.h> |
145 | #include <asm/processor.h> |
146 | #include <asm/tlbflush.h> |
147 | #include <asm/setup.h> |
148 | @@ -917,6 +918,18 @@ static int get_ucode_fw(void *to, const void *from, size_t n) |
149 | return 0; |
150 | } |
151 | |
152 | +static bool is_blacklisted(unsigned int cpu) |
153 | +{ |
154 | + struct cpuinfo_x86 *c = &cpu_data(cpu); |
155 | + |
156 | + if (c->x86 == 6 && c->x86_model == INTEL_FAM6_BROADWELL_X) { |
157 | + pr_err_once("late loading on model 79 is disabled.\n"); |
158 | + return true; |
159 | + } |
160 | + |
161 | + return false; |
162 | +} |
163 | + |
164 | static enum ucode_state request_microcode_fw(int cpu, struct device *device, |
165 | bool refresh_fw) |
166 | { |
167 | @@ -925,6 +938,9 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device, |
168 | const struct firmware *firmware; |
169 | enum ucode_state ret; |
170 | |
171 | + if (is_blacklisted(cpu)) |
172 | + return UCODE_NFOUND; |
173 | + |
174 | sprintf(name, "intel-ucode/%02x-%02x-%02x", |
175 | c->x86, c->x86_model, c->x86_mask); |
176 | |
177 | @@ -949,6 +965,9 @@ static int get_ucode_user(void *to, const void *from, size_t n) |
178 | static enum ucode_state |
179 | request_microcode_user(int cpu, const void __user *buf, size_t size) |
180 | { |
181 | + if (is_blacklisted(cpu)) |
182 | + return UCODE_NFOUND; |
183 | + |
184 | return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user); |
185 | } |
186 | |
187 | diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c |
188 | index af4cd8649117..d140d8bb2c96 100644 |
189 | --- a/crypto/asymmetric_keys/pkcs7_parser.c |
190 | +++ b/crypto/asymmetric_keys/pkcs7_parser.c |
191 | @@ -88,6 +88,9 @@ static int pkcs7_check_authattrs(struct pkcs7_message *msg) |
192 | bool want = false; |
193 | |
194 | sinfo = msg->signed_infos; |
195 | + if (!sinfo) |
196 | + goto inconsistent; |
197 | + |
198 | if (sinfo->authattrs) { |
199 | want = true; |
200 | msg->have_authattrs = true; |
201 | diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c |
202 | index 5bdf923294a5..da7043893249 100644 |
203 | --- a/drivers/block/nbd.c |
204 | +++ b/drivers/block/nbd.c |
205 | @@ -243,7 +243,6 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize, |
206 | struct nbd_config *config = nbd->config; |
207 | config->blksize = blocksize; |
208 | config->bytesize = blocksize * nr_blocks; |
209 | - nbd_size_update(nbd); |
210 | } |
211 | |
212 | static void nbd_complete_rq(struct request *req) |
213 | @@ -1090,6 +1089,7 @@ static int nbd_start_device(struct nbd_device *nbd) |
214 | args->index = i; |
215 | queue_work(recv_workqueue, &args->work); |
216 | } |
217 | + nbd_size_update(nbd); |
218 | return error; |
219 | } |
220 | |
221 | diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c |
222 | index c7f396903184..70db4d5638a6 100644 |
223 | --- a/drivers/bus/mvebu-mbus.c |
224 | +++ b/drivers/bus/mvebu-mbus.c |
225 | @@ -720,7 +720,7 @@ mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus) |
226 | if (mbus->hw_io_coherency) |
227 | w->mbus_attr |= ATTR_HW_COHERENCY; |
228 | w->base = base & DDR_BASE_CS_LOW_MASK; |
229 | - w->size = (size | ~DDR_SIZE_MASK) + 1; |
230 | + w->size = (u64)(size | ~DDR_SIZE_MASK) + 1; |
231 | } |
232 | } |
233 | mvebu_mbus_dram_info.num_cs = cs; |
234 | diff --git a/drivers/clocksource/cs5535-clockevt.c b/drivers/clocksource/cs5535-clockevt.c |
235 | index a1df588343f2..1de8cac99a0e 100644 |
236 | --- a/drivers/clocksource/cs5535-clockevt.c |
237 | +++ b/drivers/clocksource/cs5535-clockevt.c |
238 | @@ -117,7 +117,8 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id) |
239 | /* Turn off the clock (and clear the event) */ |
240 | disable_timer(cs5535_event_clock); |
241 | |
242 | - if (clockevent_state_shutdown(&cs5535_clockevent)) |
243 | + if (clockevent_state_detached(&cs5535_clockevent) || |
244 | + clockevent_state_shutdown(&cs5535_clockevent)) |
245 | return IRQ_HANDLED; |
246 | |
247 | /* Clear the counter */ |
248 | diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c |
249 | index d3b3252a8742..384bf4695e99 100644 |
250 | --- a/drivers/gpu/drm/i915/intel_ddi.c |
251 | +++ b/drivers/gpu/drm/i915/intel_ddi.c |
252 | @@ -664,8 +664,8 @@ intel_ddi_get_buf_trans_fdi(struct drm_i915_private *dev_priv, |
253 | int *n_entries) |
254 | { |
255 | if (IS_BROADWELL(dev_priv)) { |
256 | - *n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi); |
257 | - return hsw_ddi_translations_fdi; |
258 | + *n_entries = ARRAY_SIZE(bdw_ddi_translations_fdi); |
259 | + return bdw_ddi_translations_fdi; |
260 | } else if (IS_HASWELL(dev_priv)) { |
261 | *n_entries = ARRAY_SIZE(hsw_ddi_translations_fdi); |
262 | return hsw_ddi_translations_fdi; |
263 | diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c |
264 | index 3d35ea3e95db..92ff3e4ca013 100644 |
265 | --- a/drivers/gpu/drm/nouveau/nv50_display.c |
266 | +++ b/drivers/gpu/drm/nouveau/nv50_display.c |
267 | @@ -3281,11 +3281,14 @@ nv50_mstm = { |
268 | void |
269 | nv50_mstm_service(struct nv50_mstm *mstm) |
270 | { |
271 | - struct drm_dp_aux *aux = mstm->mgr.aux; |
272 | + struct drm_dp_aux *aux = mstm ? mstm->mgr.aux : NULL; |
273 | bool handled = true; |
274 | int ret; |
275 | u8 esi[8] = {}; |
276 | |
277 | + if (!aux) |
278 | + return; |
279 | + |
280 | while (handled) { |
281 | ret = drm_dp_dpcd_read(aux, DP_SINK_COUNT_ESI, esi, 8); |
282 | if (ret != 8) { |
283 | diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c b/drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c |
284 | index 8e2e24a74774..44e116f7880d 100644 |
285 | --- a/drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c |
286 | +++ b/drivers/gpu/drm/nouveau/nvkm/engine/bsp/g84.c |
287 | @@ -39,5 +39,5 @@ int |
288 | g84_bsp_new(struct nvkm_device *device, int index, struct nvkm_engine **pengine) |
289 | { |
290 | return nvkm_xtensa_new_(&g84_bsp, device, index, |
291 | - true, 0x103000, pengine); |
292 | + device->chipset != 0x92, 0x103000, pengine); |
293 | } |
294 | diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c |
295 | index d06ad2c372bf..455da298227f 100644 |
296 | --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c |
297 | +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c |
298 | @@ -241,6 +241,8 @@ nvkm_vm_unmap_pgt(struct nvkm_vm *vm, int big, u32 fpde, u32 lpde) |
299 | mmu->func->map_pgt(vpgd->obj, pde, vpgt->mem); |
300 | } |
301 | |
302 | + mmu->func->flush(vm); |
303 | + |
304 | nvkm_memory_del(&pgt); |
305 | } |
306 | } |
307 | diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c |
308 | index 22ffcb73c185..b51adffa4841 100644 |
309 | --- a/drivers/i2c/busses/i2c-ismt.c |
310 | +++ b/drivers/i2c/busses/i2c-ismt.c |
311 | @@ -340,12 +340,15 @@ static int ismt_process_desc(const struct ismt_desc *desc, |
312 | data->word = dma_buffer[0] | (dma_buffer[1] << 8); |
313 | break; |
314 | case I2C_SMBUS_BLOCK_DATA: |
315 | - case I2C_SMBUS_I2C_BLOCK_DATA: |
316 | if (desc->rxbytes != dma_buffer[0] + 1) |
317 | return -EMSGSIZE; |
318 | |
319 | memcpy(data->block, dma_buffer, desc->rxbytes); |
320 | break; |
321 | + case I2C_SMBUS_I2C_BLOCK_DATA: |
322 | + memcpy(&data->block[1], dma_buffer, desc->rxbytes); |
323 | + data->block[0] = desc->rxbytes; |
324 | + break; |
325 | } |
326 | return 0; |
327 | } |
328 | diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c |
329 | index 0ecdb47a23ab..01f767ee4546 100644 |
330 | --- a/drivers/i2c/busses/i2c-piix4.c |
331 | +++ b/drivers/i2c/busses/i2c-piix4.c |
332 | @@ -94,6 +94,12 @@ |
333 | #define SB800_PIIX4_PORT_IDX_ALT 0x2e |
334 | #define SB800_PIIX4_PORT_IDX_SEL 0x2f |
335 | #define SB800_PIIX4_PORT_IDX_MASK 0x06 |
336 | +#define SB800_PIIX4_PORT_IDX_SHIFT 1 |
337 | + |
338 | +/* On kerncz, SmBus0Sel is at bit 20:19 of PMx00 DecodeEn */ |
339 | +#define SB800_PIIX4_PORT_IDX_KERNCZ 0x02 |
340 | +#define SB800_PIIX4_PORT_IDX_MASK_KERNCZ 0x18 |
341 | +#define SB800_PIIX4_PORT_IDX_SHIFT_KERNCZ 3 |
342 | |
343 | /* insmod parameters */ |
344 | |
345 | @@ -149,6 +155,8 @@ static const struct dmi_system_id piix4_dmi_ibm[] = { |
346 | */ |
347 | static DEFINE_MUTEX(piix4_mutex_sb800); |
348 | static u8 piix4_port_sel_sb800; |
349 | +static u8 piix4_port_mask_sb800; |
350 | +static u8 piix4_port_shift_sb800; |
351 | static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = { |
352 | " port 0", " port 2", " port 3", " port 4" |
353 | }; |
354 | @@ -347,7 +355,19 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, |
355 | |
356 | /* Find which register is used for port selection */ |
357 | if (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD) { |
358 | - piix4_port_sel_sb800 = SB800_PIIX4_PORT_IDX_ALT; |
359 | + switch (PIIX4_dev->device) { |
360 | + case PCI_DEVICE_ID_AMD_KERNCZ_SMBUS: |
361 | + piix4_port_sel_sb800 = SB800_PIIX4_PORT_IDX_KERNCZ; |
362 | + piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK_KERNCZ; |
363 | + piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT_KERNCZ; |
364 | + break; |
365 | + case PCI_DEVICE_ID_AMD_HUDSON2_SMBUS: |
366 | + default: |
367 | + piix4_port_sel_sb800 = SB800_PIIX4_PORT_IDX_ALT; |
368 | + piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK; |
369 | + piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT; |
370 | + break; |
371 | + } |
372 | } else { |
373 | mutex_lock(&piix4_mutex_sb800); |
374 | outb_p(SB800_PIIX4_PORT_IDX_SEL, SB800_PIIX4_SMB_IDX); |
375 | @@ -355,6 +375,8 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, |
376 | piix4_port_sel_sb800 = (port_sel & 0x01) ? |
377 | SB800_PIIX4_PORT_IDX_ALT : |
378 | SB800_PIIX4_PORT_IDX; |
379 | + piix4_port_mask_sb800 = SB800_PIIX4_PORT_IDX_MASK; |
380 | + piix4_port_shift_sb800 = SB800_PIIX4_PORT_IDX_SHIFT; |
381 | mutex_unlock(&piix4_mutex_sb800); |
382 | } |
383 | |
384 | @@ -616,8 +638,8 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, |
385 | smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); |
386 | |
387 | port = adapdata->port; |
388 | - if ((smba_en_lo & SB800_PIIX4_PORT_IDX_MASK) != port) |
389 | - outb_p((smba_en_lo & ~SB800_PIIX4_PORT_IDX_MASK) | port, |
390 | + if ((smba_en_lo & piix4_port_mask_sb800) != port) |
391 | + outb_p((smba_en_lo & ~piix4_port_mask_sb800) | port, |
392 | SB800_PIIX4_SMB_IDX + 1); |
393 | |
394 | retval = piix4_access(adap, addr, flags, read_write, |
395 | @@ -706,7 +728,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, |
396 | |
397 | adapdata->smba = smba; |
398 | adapdata->sb800_main = sb800_main; |
399 | - adapdata->port = port << 1; |
400 | + adapdata->port = port << piix4_port_shift_sb800; |
401 | |
402 | /* set up the sysfs linkage to our parent device */ |
403 | adap->dev.parent = &dev->dev; |
404 | diff --git a/drivers/iio/dummy/iio_simple_dummy_events.c b/drivers/iio/dummy/iio_simple_dummy_events.c |
405 | index ed63ffd849f8..7ec2a0bb0807 100644 |
406 | --- a/drivers/iio/dummy/iio_simple_dummy_events.c |
407 | +++ b/drivers/iio/dummy/iio_simple_dummy_events.c |
408 | @@ -72,6 +72,7 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev, |
409 | st->event_en = state; |
410 | else |
411 | return -EINVAL; |
412 | + break; |
413 | default: |
414 | return -EINVAL; |
415 | } |
416 | diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c |
417 | index 157fdb4bb2e8..8c6c6178ec12 100644 |
418 | --- a/drivers/input/touchscreen/stmfts.c |
419 | +++ b/drivers/input/touchscreen/stmfts.c |
420 | @@ -663,12 +663,10 @@ static int stmfts_probe(struct i2c_client *client, |
421 | sdata->input->open = stmfts_input_open; |
422 | sdata->input->close = stmfts_input_close; |
423 | |
424 | + input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_X); |
425 | + input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_Y); |
426 | touchscreen_parse_properties(sdata->input, true, &sdata->prop); |
427 | |
428 | - input_set_abs_params(sdata->input, ABS_MT_POSITION_X, 0, |
429 | - sdata->prop.max_x, 0, 0); |
430 | - input_set_abs_params(sdata->input, ABS_MT_POSITION_Y, 0, |
431 | - sdata->prop.max_y, 0, 0); |
432 | input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); |
433 | input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); |
434 | input_set_abs_params(sdata->input, ABS_MT_ORIENTATION, 0, 255, 0, 0); |
435 | diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c |
436 | index d596b601ff42..8cfc5e84a129 100644 |
437 | --- a/drivers/media/cec/cec-adap.c |
438 | +++ b/drivers/media/cec/cec-adap.c |
439 | @@ -1726,12 +1726,19 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, |
440 | */ |
441 | switch (msg->msg[1]) { |
442 | case CEC_MSG_GET_CEC_VERSION: |
443 | - case CEC_MSG_GIVE_DEVICE_VENDOR_ID: |
444 | case CEC_MSG_ABORT: |
445 | case CEC_MSG_GIVE_DEVICE_POWER_STATUS: |
446 | - case CEC_MSG_GIVE_PHYSICAL_ADDR: |
447 | case CEC_MSG_GIVE_OSD_NAME: |
448 | + /* |
449 | + * These messages reply with a directed message, so ignore if |
450 | + * the initiator is Unregistered. |
451 | + */ |
452 | + if (!adap->passthrough && from_unregistered) |
453 | + return 0; |
454 | + /* Fall through */ |
455 | + case CEC_MSG_GIVE_DEVICE_VENDOR_ID: |
456 | case CEC_MSG_GIVE_FEATURES: |
457 | + case CEC_MSG_GIVE_PHYSICAL_ADDR: |
458 | /* |
459 | * Skip processing these messages if the passthrough mode |
460 | * is on. |
461 | @@ -1739,7 +1746,7 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, |
462 | if (adap->passthrough) |
463 | goto skip_processing; |
464 | /* Ignore if addressing is wrong */ |
465 | - if (is_broadcast || from_unregistered) |
466 | + if (is_broadcast) |
467 | return 0; |
468 | break; |
469 | |
470 | diff --git a/drivers/media/dvb-frontends/dib3000mc.c b/drivers/media/dvb-frontends/dib3000mc.c |
471 | index 224283fe100a..4d086a7248e9 100644 |
472 | --- a/drivers/media/dvb-frontends/dib3000mc.c |
473 | +++ b/drivers/media/dvb-frontends/dib3000mc.c |
474 | @@ -55,29 +55,57 @@ struct dib3000mc_state { |
475 | |
476 | static u16 dib3000mc_read_word(struct dib3000mc_state *state, u16 reg) |
477 | { |
478 | - u8 wb[2] = { (reg >> 8) | 0x80, reg & 0xff }; |
479 | - u8 rb[2]; |
480 | struct i2c_msg msg[2] = { |
481 | - { .addr = state->i2c_addr >> 1, .flags = 0, .buf = wb, .len = 2 }, |
482 | - { .addr = state->i2c_addr >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2 }, |
483 | + { .addr = state->i2c_addr >> 1, .flags = 0, .len = 2 }, |
484 | + { .addr = state->i2c_addr >> 1, .flags = I2C_M_RD, .len = 2 }, |
485 | }; |
486 | + u16 word; |
487 | + u8 *b; |
488 | + |
489 | + b = kmalloc(4, GFP_KERNEL); |
490 | + if (!b) |
491 | + return 0; |
492 | + |
493 | + b[0] = (reg >> 8) | 0x80; |
494 | + b[1] = reg; |
495 | + b[2] = 0; |
496 | + b[3] = 0; |
497 | + |
498 | + msg[0].buf = b; |
499 | + msg[1].buf = b + 2; |
500 | |
501 | if (i2c_transfer(state->i2c_adap, msg, 2) != 2) |
502 | dprintk("i2c read error on %d\n",reg); |
503 | |
504 | - return (rb[0] << 8) | rb[1]; |
505 | + word = (b[2] << 8) | b[3]; |
506 | + kfree(b); |
507 | + |
508 | + return word; |
509 | } |
510 | |
511 | static int dib3000mc_write_word(struct dib3000mc_state *state, u16 reg, u16 val) |
512 | { |
513 | - u8 b[4] = { |
514 | - (reg >> 8) & 0xff, reg & 0xff, |
515 | - (val >> 8) & 0xff, val & 0xff, |
516 | - }; |
517 | struct i2c_msg msg = { |
518 | - .addr = state->i2c_addr >> 1, .flags = 0, .buf = b, .len = 4 |
519 | + .addr = state->i2c_addr >> 1, .flags = 0, .len = 4 |
520 | }; |
521 | - return i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; |
522 | + int rc; |
523 | + u8 *b; |
524 | + |
525 | + b = kmalloc(4, GFP_KERNEL); |
526 | + if (!b) |
527 | + return -ENOMEM; |
528 | + |
529 | + b[0] = reg >> 8; |
530 | + b[1] = reg; |
531 | + b[2] = val >> 8; |
532 | + b[3] = val; |
533 | + |
534 | + msg.buf = b; |
535 | + |
536 | + rc = i2c_transfer(state->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0; |
537 | + kfree(b); |
538 | + |
539 | + return rc; |
540 | } |
541 | |
542 | static int dib3000mc_identify(struct dib3000mc_state *state) |
543 | diff --git a/drivers/media/dvb-frontends/dvb-pll.c b/drivers/media/dvb-frontends/dvb-pll.c |
544 | index 7bec3e028bee..5553b89b804e 100644 |
545 | --- a/drivers/media/dvb-frontends/dvb-pll.c |
546 | +++ b/drivers/media/dvb-frontends/dvb-pll.c |
547 | @@ -753,13 +753,19 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, |
548 | struct i2c_adapter *i2c, |
549 | unsigned int pll_desc_id) |
550 | { |
551 | - u8 b1 [] = { 0 }; |
552 | - struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, |
553 | - .buf = b1, .len = 1 }; |
554 | + u8 *b1; |
555 | + struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, .len = 1 }; |
556 | struct dvb_pll_priv *priv = NULL; |
557 | int ret; |
558 | const struct dvb_pll_desc *desc; |
559 | |
560 | + b1 = kmalloc(1, GFP_KERNEL); |
561 | + if (!b1) |
562 | + return NULL; |
563 | + |
564 | + b1[0] = 0; |
565 | + msg.buf = b1; |
566 | + |
567 | if ((id[dvb_pll_devcount] > DVB_PLL_UNDEFINED) && |
568 | (id[dvb_pll_devcount] < ARRAY_SIZE(pll_list))) |
569 | pll_desc_id = id[dvb_pll_devcount]; |
570 | @@ -773,15 +779,19 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, |
571 | fe->ops.i2c_gate_ctrl(fe, 1); |
572 | |
573 | ret = i2c_transfer (i2c, &msg, 1); |
574 | - if (ret != 1) |
575 | + if (ret != 1) { |
576 | + kfree(b1); |
577 | return NULL; |
578 | + } |
579 | if (fe->ops.i2c_gate_ctrl) |
580 | fe->ops.i2c_gate_ctrl(fe, 0); |
581 | } |
582 | |
583 | priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL); |
584 | - if (priv == NULL) |
585 | + if (!priv) { |
586 | + kfree(b1); |
587 | return NULL; |
588 | + } |
589 | |
590 | priv->pll_i2c_address = pll_addr; |
591 | priv->i2c = i2c; |
592 | @@ -811,6 +821,8 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, |
593 | "insmod option" : "autodetected"); |
594 | } |
595 | |
596 | + kfree(b1); |
597 | + |
598 | return fe; |
599 | } |
600 | EXPORT_SYMBOL(dvb_pll_attach); |
601 | diff --git a/drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c b/drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c |
602 | index 1edf667d562a..146ae6f25cdb 100644 |
603 | --- a/drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c |
604 | +++ b/drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c |
605 | @@ -172,7 +172,8 @@ u32 s5p_cec_get_status(struct s5p_cec_dev *cec) |
606 | { |
607 | u32 status = 0; |
608 | |
609 | - status = readb(cec->reg + S5P_CEC_STATUS_0); |
610 | + status = readb(cec->reg + S5P_CEC_STATUS_0) & 0xf; |
611 | + status |= (readb(cec->reg + S5P_CEC_TX_STAT1) & 0xf) << 4; |
612 | status |= readb(cec->reg + S5P_CEC_STATUS_1) << 8; |
613 | status |= readb(cec->reg + S5P_CEC_STATUS_2) << 16; |
614 | status |= readb(cec->reg + S5P_CEC_STATUS_3) << 24; |
615 | diff --git a/drivers/media/platform/s5p-cec/s5p_cec.c b/drivers/media/platform/s5p-cec/s5p_cec.c |
616 | index 8e06071a7977..7d8d67e5448f 100644 |
617 | --- a/drivers/media/platform/s5p-cec/s5p_cec.c |
618 | +++ b/drivers/media/platform/s5p-cec/s5p_cec.c |
619 | @@ -92,7 +92,10 @@ static irqreturn_t s5p_cec_irq_handler(int irq, void *priv) |
620 | dev_dbg(cec->dev, "irq received\n"); |
621 | |
622 | if (status & CEC_STATUS_TX_DONE) { |
623 | - if (status & CEC_STATUS_TX_ERROR) { |
624 | + if (status & CEC_STATUS_TX_NACK) { |
625 | + dev_dbg(cec->dev, "CEC_STATUS_TX_NACK set\n"); |
626 | + cec->tx = STATE_NACK; |
627 | + } else if (status & CEC_STATUS_TX_ERROR) { |
628 | dev_dbg(cec->dev, "CEC_STATUS_TX_ERROR set\n"); |
629 | cec->tx = STATE_ERROR; |
630 | } else { |
631 | @@ -135,6 +138,12 @@ static irqreturn_t s5p_cec_irq_handler_thread(int irq, void *priv) |
632 | cec_transmit_done(cec->adap, CEC_TX_STATUS_OK, 0, 0, 0, 0); |
633 | cec->tx = STATE_IDLE; |
634 | break; |
635 | + case STATE_NACK: |
636 | + cec_transmit_done(cec->adap, |
637 | + CEC_TX_STATUS_MAX_RETRIES | CEC_TX_STATUS_NACK, |
638 | + 0, 1, 0, 0); |
639 | + cec->tx = STATE_IDLE; |
640 | + break; |
641 | case STATE_ERROR: |
642 | cec_transmit_done(cec->adap, |
643 | CEC_TX_STATUS_MAX_RETRIES | CEC_TX_STATUS_ERROR, |
644 | diff --git a/drivers/media/platform/s5p-cec/s5p_cec.h b/drivers/media/platform/s5p-cec/s5p_cec.h |
645 | index 8bcd8dc1aeb9..86ded522ef27 100644 |
646 | --- a/drivers/media/platform/s5p-cec/s5p_cec.h |
647 | +++ b/drivers/media/platform/s5p-cec/s5p_cec.h |
648 | @@ -35,6 +35,7 @@ |
649 | #define CEC_STATUS_TX_TRANSFERRING (1 << 1) |
650 | #define CEC_STATUS_TX_DONE (1 << 2) |
651 | #define CEC_STATUS_TX_ERROR (1 << 3) |
652 | +#define CEC_STATUS_TX_NACK (1 << 4) |
653 | #define CEC_STATUS_TX_BYTES (0xFF << 8) |
654 | #define CEC_STATUS_RX_RUNNING (1 << 16) |
655 | #define CEC_STATUS_RX_RECEIVING (1 << 17) |
656 | @@ -55,6 +56,7 @@ enum cec_state { |
657 | STATE_IDLE, |
658 | STATE_BUSY, |
659 | STATE_DONE, |
660 | + STATE_NACK, |
661 | STATE_ERROR |
662 | }; |
663 | |
664 | diff --git a/drivers/media/tuners/mt2060.c b/drivers/media/tuners/mt2060.c |
665 | index 2e487f9a2cc3..4983eeb39f36 100644 |
666 | --- a/drivers/media/tuners/mt2060.c |
667 | +++ b/drivers/media/tuners/mt2060.c |
668 | @@ -38,41 +38,74 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); |
669 | static int mt2060_readreg(struct mt2060_priv *priv, u8 reg, u8 *val) |
670 | { |
671 | struct i2c_msg msg[2] = { |
672 | - { .addr = priv->cfg->i2c_address, .flags = 0, .buf = ®, .len = 1 }, |
673 | - { .addr = priv->cfg->i2c_address, .flags = I2C_M_RD, .buf = val, .len = 1 }, |
674 | + { .addr = priv->cfg->i2c_address, .flags = 0, .len = 1 }, |
675 | + { .addr = priv->cfg->i2c_address, .flags = I2C_M_RD, .len = 1 }, |
676 | }; |
677 | + int rc = 0; |
678 | + u8 *b; |
679 | + |
680 | + b = kmalloc(2, GFP_KERNEL); |
681 | + if (!b) |
682 | + return -ENOMEM; |
683 | + |
684 | + b[0] = reg; |
685 | + b[1] = 0; |
686 | + |
687 | + msg[0].buf = b; |
688 | + msg[1].buf = b + 1; |
689 | |
690 | if (i2c_transfer(priv->i2c, msg, 2) != 2) { |
691 | printk(KERN_WARNING "mt2060 I2C read failed\n"); |
692 | - return -EREMOTEIO; |
693 | + rc = -EREMOTEIO; |
694 | } |
695 | - return 0; |
696 | + *val = b[1]; |
697 | + kfree(b); |
698 | + |
699 | + return rc; |
700 | } |
701 | |
702 | // Writes a single register |
703 | static int mt2060_writereg(struct mt2060_priv *priv, u8 reg, u8 val) |
704 | { |
705 | - u8 buf[2] = { reg, val }; |
706 | struct i2c_msg msg = { |
707 | - .addr = priv->cfg->i2c_address, .flags = 0, .buf = buf, .len = 2 |
708 | + .addr = priv->cfg->i2c_address, .flags = 0, .len = 2 |
709 | }; |
710 | + u8 *buf; |
711 | + int rc = 0; |
712 | + |
713 | + buf = kmalloc(2, GFP_KERNEL); |
714 | + if (!buf) |
715 | + return -ENOMEM; |
716 | + |
717 | + buf[0] = reg; |
718 | + buf[1] = val; |
719 | + |
720 | + msg.buf = buf; |
721 | |
722 | if (i2c_transfer(priv->i2c, &msg, 1) != 1) { |
723 | printk(KERN_WARNING "mt2060 I2C write failed\n"); |
724 | - return -EREMOTEIO; |
725 | + rc = -EREMOTEIO; |
726 | } |
727 | - return 0; |
728 | + kfree(buf); |
729 | + return rc; |
730 | } |
731 | |
732 | // Writes a set of consecutive registers |
733 | static int mt2060_writeregs(struct mt2060_priv *priv,u8 *buf, u8 len) |
734 | { |
735 | int rem, val_len; |
736 | - u8 xfer_buf[16]; |
737 | + u8 *xfer_buf; |
738 | + int rc = 0; |
739 | struct i2c_msg msg = { |
740 | - .addr = priv->cfg->i2c_address, .flags = 0, .buf = xfer_buf |
741 | + .addr = priv->cfg->i2c_address, .flags = 0 |
742 | }; |
743 | |
744 | + xfer_buf = kmalloc(16, GFP_KERNEL); |
745 | + if (!xfer_buf) |
746 | + return -ENOMEM; |
747 | + |
748 | + msg.buf = xfer_buf; |
749 | + |
750 | for (rem = len - 1; rem > 0; rem -= priv->i2c_max_regs) { |
751 | val_len = min_t(int, rem, priv->i2c_max_regs); |
752 | msg.len = 1 + val_len; |
753 | @@ -81,11 +114,13 @@ static int mt2060_writeregs(struct mt2060_priv *priv,u8 *buf, u8 len) |
754 | |
755 | if (i2c_transfer(priv->i2c, &msg, 1) != 1) { |
756 | printk(KERN_WARNING "mt2060 I2C write failed (len=%i)\n", val_len); |
757 | - return -EREMOTEIO; |
758 | + rc = -EREMOTEIO; |
759 | + break; |
760 | } |
761 | } |
762 | |
763 | - return 0; |
764 | + kfree(xfer_buf); |
765 | + return rc; |
766 | } |
767 | |
768 | // Initialisation sequences |
769 | diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c |
770 | index ba8a0f58fe08..b2d0ee0be8c3 100644 |
771 | --- a/drivers/mmc/host/sdhci-pci-core.c |
772 | +++ b/drivers/mmc/host/sdhci-pci-core.c |
773 | @@ -449,6 +449,8 @@ static void intel_dsm_init(struct intel_host *intel_host, struct device *dev, |
774 | int err; |
775 | u32 val; |
776 | |
777 | + intel_host->d3_retune = true; |
778 | + |
779 | err = __intel_dsm(intel_host, dev, INTEL_DSM_FNS, &intel_host->dsm_fns); |
780 | if (err) { |
781 | pr_debug("%s: DSM not supported, error %d\n", |
782 | diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c |
783 | index 13f0f219d8aa..a13a4896a8bd 100644 |
784 | --- a/drivers/net/can/flexcan.c |
785 | +++ b/drivers/net/can/flexcan.c |
786 | @@ -182,22 +182,23 @@ |
787 | /* FLEXCAN hardware feature flags |
788 | * |
789 | * Below is some version info we got: |
790 | - * SOC Version IP-Version Glitch- [TR]WRN_INT Memory err RTR re- |
791 | - * Filter? connected? detection ception in MB |
792 | - * MX25 FlexCAN2 03.00.00.00 no no no no |
793 | - * MX28 FlexCAN2 03.00.04.00 yes yes no no |
794 | - * MX35 FlexCAN2 03.00.00.00 no no no no |
795 | - * MX53 FlexCAN2 03.00.00.00 yes no no no |
796 | - * MX6s FlexCAN3 10.00.12.00 yes yes no yes |
797 | - * VF610 FlexCAN3 ? no yes yes yes? |
798 | + * SOC Version IP-Version Glitch- [TR]WRN_INT IRQ Err Memory err RTR re- |
799 | + * Filter? connected? Passive detection ception in MB |
800 | + * MX25 FlexCAN2 03.00.00.00 no no ? no no |
801 | + * MX28 FlexCAN2 03.00.04.00 yes yes no no no |
802 | + * MX35 FlexCAN2 03.00.00.00 no no ? no no |
803 | + * MX53 FlexCAN2 03.00.00.00 yes no no no no |
804 | + * MX6s FlexCAN3 10.00.12.00 yes yes no no yes |
805 | + * VF610 FlexCAN3 ? no yes ? yes yes? |
806 | * |
807 | * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected. |
808 | */ |
809 | -#define FLEXCAN_QUIRK_BROKEN_ERR_STATE BIT(1) /* [TR]WRN_INT not connected */ |
810 | +#define FLEXCAN_QUIRK_BROKEN_WERR_STATE BIT(1) /* [TR]WRN_INT not connected */ |
811 | #define FLEXCAN_QUIRK_DISABLE_RXFG BIT(2) /* Disable RX FIFO Global mask */ |
812 | #define FLEXCAN_QUIRK_ENABLE_EACEN_RRS BIT(3) /* Enable EACEN and RRS bit in ctrl2 */ |
813 | #define FLEXCAN_QUIRK_DISABLE_MECR BIT(4) /* Disable Memory error detection */ |
814 | #define FLEXCAN_QUIRK_USE_OFF_TIMESTAMP BIT(5) /* Use timestamp based offloading */ |
815 | +#define FLEXCAN_QUIRK_BROKEN_PERR_STATE BIT(6) /* No interrupt for error passive */ |
816 | |
817 | /* Structure of the message buffer */ |
818 | struct flexcan_mb { |
819 | @@ -281,14 +282,17 @@ struct flexcan_priv { |
820 | }; |
821 | |
822 | static const struct flexcan_devtype_data fsl_p1010_devtype_data = { |
823 | - .quirks = FLEXCAN_QUIRK_BROKEN_ERR_STATE, |
824 | + .quirks = FLEXCAN_QUIRK_BROKEN_WERR_STATE | |
825 | + FLEXCAN_QUIRK_BROKEN_PERR_STATE, |
826 | }; |
827 | |
828 | -static const struct flexcan_devtype_data fsl_imx28_devtype_data; |
829 | +static const struct flexcan_devtype_data fsl_imx28_devtype_data = { |
830 | + .quirks = FLEXCAN_QUIRK_BROKEN_PERR_STATE, |
831 | +}; |
832 | |
833 | static const struct flexcan_devtype_data fsl_imx6q_devtype_data = { |
834 | .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS | |
835 | - FLEXCAN_QUIRK_USE_OFF_TIMESTAMP, |
836 | + FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_BROKEN_PERR_STATE, |
837 | }; |
838 | |
839 | static const struct flexcan_devtype_data fsl_vf610_devtype_data = { |
840 | @@ -335,6 +339,22 @@ static inline void flexcan_write(u32 val, void __iomem *addr) |
841 | } |
842 | #endif |
843 | |
844 | +static inline void flexcan_error_irq_enable(const struct flexcan_priv *priv) |
845 | +{ |
846 | + struct flexcan_regs __iomem *regs = priv->regs; |
847 | + u32 reg_ctrl = (priv->reg_ctrl_default | FLEXCAN_CTRL_ERR_MSK); |
848 | + |
849 | + flexcan_write(reg_ctrl, ®s->ctrl); |
850 | +} |
851 | + |
852 | +static inline void flexcan_error_irq_disable(const struct flexcan_priv *priv) |
853 | +{ |
854 | + struct flexcan_regs __iomem *regs = priv->regs; |
855 | + u32 reg_ctrl = (priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_MSK); |
856 | + |
857 | + flexcan_write(reg_ctrl, ®s->ctrl); |
858 | +} |
859 | + |
860 | static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv) |
861 | { |
862 | if (!priv->reg_xceiver) |
863 | @@ -713,6 +733,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) |
864 | struct flexcan_regs __iomem *regs = priv->regs; |
865 | irqreturn_t handled = IRQ_NONE; |
866 | u32 reg_iflag1, reg_esr; |
867 | + enum can_state last_state = priv->can.state; |
868 | |
869 | reg_iflag1 = flexcan_read(®s->iflag1); |
870 | |
871 | @@ -765,8 +786,10 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) |
872 | flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, ®s->esr); |
873 | } |
874 | |
875 | - /* state change interrupt */ |
876 | - if (reg_esr & FLEXCAN_ESR_ERR_STATE) |
877 | + /* state change interrupt or broken error state quirk fix is enabled */ |
878 | + if ((reg_esr & FLEXCAN_ESR_ERR_STATE) || |
879 | + (priv->devtype_data->quirks & (FLEXCAN_QUIRK_BROKEN_WERR_STATE | |
880 | + FLEXCAN_QUIRK_BROKEN_PERR_STATE))) |
881 | flexcan_irq_state(dev, reg_esr); |
882 | |
883 | /* bus error IRQ - handle if bus error reporting is activated */ |
884 | @@ -774,6 +797,44 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) |
885 | (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) |
886 | flexcan_irq_bus_err(dev, reg_esr); |
887 | |
888 | + /* availability of error interrupt among state transitions in case |
889 | + * bus error reporting is de-activated and |
890 | + * FLEXCAN_QUIRK_BROKEN_PERR_STATE is enabled: |
891 | + * +--------------------------------------------------------------+ |
892 | + * | +----------------------------------------------+ [stopped / | |
893 | + * | | | sleeping] -+ |
894 | + * +-+-> active <-> warning <-> passive -> bus off -+ |
895 | + * ___________^^^^^^^^^^^^_______________________________ |
896 | + * disabled(1) enabled disabled |
897 | + * |
898 | + * (1): enabled if FLEXCAN_QUIRK_BROKEN_WERR_STATE is enabled |
899 | + */ |
900 | + if ((last_state != priv->can.state) && |
901 | + (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_PERR_STATE) && |
902 | + !(priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) { |
903 | + switch (priv->can.state) { |
904 | + case CAN_STATE_ERROR_ACTIVE: |
905 | + if (priv->devtype_data->quirks & |
906 | + FLEXCAN_QUIRK_BROKEN_WERR_STATE) |
907 | + flexcan_error_irq_enable(priv); |
908 | + else |
909 | + flexcan_error_irq_disable(priv); |
910 | + break; |
911 | + |
912 | + case CAN_STATE_ERROR_WARNING: |
913 | + flexcan_error_irq_enable(priv); |
914 | + break; |
915 | + |
916 | + case CAN_STATE_ERROR_PASSIVE: |
917 | + case CAN_STATE_BUS_OFF: |
918 | + flexcan_error_irq_disable(priv); |
919 | + break; |
920 | + |
921 | + default: |
922 | + break; |
923 | + } |
924 | + } |
925 | + |
926 | return handled; |
927 | } |
928 | |
929 | @@ -887,7 +948,7 @@ static int flexcan_chip_start(struct net_device *dev) |
930 | * on most Flexcan cores, too. Otherwise we don't get |
931 | * any error warning or passive interrupts. |
932 | */ |
933 | - if (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_ERR_STATE || |
934 | + if (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_WERR_STATE || |
935 | priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) |
936 | reg_ctrl |= FLEXCAN_CTRL_ERR_MSK; |
937 | else |
938 | diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c |
939 | index be928ce62d32..9fdb0f0bfa06 100644 |
940 | --- a/drivers/net/can/usb/esd_usb2.c |
941 | +++ b/drivers/net/can/usb/esd_usb2.c |
942 | @@ -333,7 +333,7 @@ static void esd_usb2_rx_can_msg(struct esd_usb2_net_priv *priv, |
943 | } |
944 | |
945 | cf->can_id = id & ESD_IDMASK; |
946 | - cf->can_dlc = get_can_dlc(msg->msg.rx.dlc); |
947 | + cf->can_dlc = get_can_dlc(msg->msg.rx.dlc & ~ESD_RTR); |
948 | |
949 | if (id & ESD_EXTID) |
950 | cf->can_id |= CAN_EFF_FLAG; |
951 | diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c |
952 | index afcc1312dbaf..68ac3e88a8ce 100644 |
953 | --- a/drivers/net/can/usb/gs_usb.c |
954 | +++ b/drivers/net/can/usb/gs_usb.c |
955 | @@ -375,6 +375,8 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) |
956 | |
957 | gs_free_tx_context(txc); |
958 | |
959 | + atomic_dec(&dev->active_tx_urbs); |
960 | + |
961 | netif_wake_queue(netdev); |
962 | } |
963 | |
964 | @@ -463,14 +465,6 @@ static void gs_usb_xmit_callback(struct urb *urb) |
965 | urb->transfer_buffer_length, |
966 | urb->transfer_buffer, |
967 | urb->transfer_dma); |
968 | - |
969 | - atomic_dec(&dev->active_tx_urbs); |
970 | - |
971 | - if (!netif_device_present(netdev)) |
972 | - return; |
973 | - |
974 | - if (netif_queue_stopped(netdev)) |
975 | - netif_wake_queue(netdev); |
976 | } |
977 | |
978 | static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb, |
979 | diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c |
980 | index 4eb1e1ce9ace..ef72baf6dd96 100644 |
981 | --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c |
982 | +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c |
983 | @@ -429,7 +429,8 @@ void brcmf_fweh_process_event(struct brcmf_pub *drvr, |
984 | if (code != BRCMF_E_IF && !fweh->evt_handler[code]) |
985 | return; |
986 | |
987 | - if (datalen > BRCMF_DCMD_MAXLEN) |
988 | + if (datalen > BRCMF_DCMD_MAXLEN || |
989 | + datalen + sizeof(*event_packet) > packet_len) |
990 | return; |
991 | |
992 | if (in_interrupt()) |
993 | diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c |
994 | index b3aab2fe96eb..ef685465f80a 100644 |
995 | --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c |
996 | +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c |
997 | @@ -14764,8 +14764,8 @@ static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi) |
998 | } |
999 | |
1000 | static void |
1001 | -wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys, |
1002 | - u8 len) |
1003 | +wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, const u8 *events, |
1004 | + const u8 *dlys, u8 len) |
1005 | { |
1006 | u32 t1_offset, t2_offset; |
1007 | u8 ctr; |
1008 | @@ -15240,16 +15240,16 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi) |
1009 | static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) |
1010 | { |
1011 | u16 currband; |
1012 | - s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 }; |
1013 | - s8 *lna1_gain_db = NULL; |
1014 | - s8 *lna1_gain_db_2 = NULL; |
1015 | - s8 *lna2_gain_db = NULL; |
1016 | - s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 }; |
1017 | - s8 *tia_gain_db; |
1018 | - s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 }; |
1019 | - s8 *tia_gainbits; |
1020 | - u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f }; |
1021 | - u16 *rfseq_init_gain; |
1022 | + static const s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 }; |
1023 | + const s8 *lna1_gain_db = NULL; |
1024 | + const s8 *lna1_gain_db_2 = NULL; |
1025 | + const s8 *lna2_gain_db = NULL; |
1026 | + static const s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 }; |
1027 | + const s8 *tia_gain_db; |
1028 | + static const s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 }; |
1029 | + const s8 *tia_gainbits; |
1030 | + static const u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f }; |
1031 | + const u16 *rfseq_init_gain; |
1032 | u16 init_gaincode; |
1033 | u16 clip1hi_gaincode; |
1034 | u16 clip1md_gaincode = 0; |
1035 | @@ -15310,10 +15310,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) |
1036 | |
1037 | if ((freq <= 5080) || (freq == 5825)) { |
1038 | |
1039 | - s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; |
1040 | - s8 lna1A_gain_db_2_rev7[] = { |
1041 | - 11, 17, 22, 25}; |
1042 | - s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; |
1043 | + static const s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 }; |
1044 | + static const s8 lna1A_gain_db_2_rev7[] = { 11, 17, 22, 25}; |
1045 | + static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; |
1046 | |
1047 | crsminu_th = 0x3e; |
1048 | lna1_gain_db = lna1A_gain_db_rev7; |
1049 | @@ -15321,10 +15320,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) |
1050 | lna2_gain_db = lna2A_gain_db_rev7; |
1051 | } else if ((freq >= 5500) && (freq <= 5700)) { |
1052 | |
1053 | - s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; |
1054 | - s8 lna1A_gain_db_2_rev7[] = { |
1055 | - 12, 18, 22, 26}; |
1056 | - s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 }; |
1057 | + static const s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 }; |
1058 | + static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26}; |
1059 | + static const s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 }; |
1060 | |
1061 | crsminu_th = 0x45; |
1062 | clip1md_gaincode_B = 0x14; |
1063 | @@ -15335,10 +15333,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) |
1064 | lna2_gain_db = lna2A_gain_db_rev7; |
1065 | } else { |
1066 | |
1067 | - s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; |
1068 | - s8 lna1A_gain_db_2_rev7[] = { |
1069 | - 12, 18, 22, 26}; |
1070 | - s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; |
1071 | + static const s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 }; |
1072 | + static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26}; |
1073 | + static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 }; |
1074 | |
1075 | crsminu_th = 0x41; |
1076 | lna1_gain_db = lna1A_gain_db_rev7; |
1077 | @@ -15450,65 +15447,65 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) |
1078 | NPHY_RFSEQ_CMD_CLR_HIQ_DIS, |
1079 | NPHY_RFSEQ_CMD_SET_HPF_BW |
1080 | }; |
1081 | - u8 rfseq_updategainu_dlys[] = { 10, 30, 1 }; |
1082 | - s8 lna1G_gain_db[] = { 7, 11, 16, 23 }; |
1083 | - s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 }; |
1084 | - s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 }; |
1085 | - s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 }; |
1086 | - s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 }; |
1087 | - s8 lna1A_gain_db[] = { 7, 11, 17, 23 }; |
1088 | - s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 }; |
1089 | - s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 }; |
1090 | - s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 }; |
1091 | - s8 *lna1_gain_db = NULL; |
1092 | - s8 lna2G_gain_db[] = { -5, 6, 10, 14 }; |
1093 | - s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 }; |
1094 | - s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 }; |
1095 | - s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 }; |
1096 | - s8 lna2A_gain_db[] = { -6, 2, 6, 10 }; |
1097 | - s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 }; |
1098 | - s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 }; |
1099 | - s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 }; |
1100 | - s8 *lna2_gain_db = NULL; |
1101 | - s8 tiaG_gain_db[] = { |
1102 | + static const u8 rfseq_updategainu_dlys[] = { 10, 30, 1 }; |
1103 | + static const s8 lna1G_gain_db[] = { 7, 11, 16, 23 }; |
1104 | + static const s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 }; |
1105 | + static const s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 }; |
1106 | + static const s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 }; |
1107 | + static const s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 }; |
1108 | + static const s8 lna1A_gain_db[] = { 7, 11, 17, 23 }; |
1109 | + static const s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 }; |
1110 | + static const s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 }; |
1111 | + static const s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 }; |
1112 | + const s8 *lna1_gain_db = NULL; |
1113 | + static const s8 lna2G_gain_db[] = { -5, 6, 10, 14 }; |
1114 | + static const s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 }; |
1115 | + static const s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 }; |
1116 | + static const s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 }; |
1117 | + static const s8 lna2A_gain_db[] = { -6, 2, 6, 10 }; |
1118 | + static const s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 }; |
1119 | + static const s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 }; |
1120 | + static const s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 }; |
1121 | + const s8 *lna2_gain_db = NULL; |
1122 | + static const s8 tiaG_gain_db[] = { |
1123 | 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A }; |
1124 | - s8 tiaA_gain_db[] = { |
1125 | + static const s8 tiaA_gain_db[] = { |
1126 | 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }; |
1127 | - s8 tiaA_gain_db_rev4[] = { |
1128 | + static const s8 tiaA_gain_db_rev4[] = { |
1129 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; |
1130 | - s8 tiaA_gain_db_rev5[] = { |
1131 | + static const s8 tiaA_gain_db_rev5[] = { |
1132 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; |
1133 | - s8 tiaA_gain_db_rev6[] = { |
1134 | + static const s8 tiaA_gain_db_rev6[] = { |
1135 | 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d }; |
1136 | - s8 *tia_gain_db; |
1137 | - s8 tiaG_gainbits[] = { |
1138 | + const s8 *tia_gain_db; |
1139 | + static const s8 tiaG_gainbits[] = { |
1140 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; |
1141 | - s8 tiaA_gainbits[] = { |
1142 | + static const s8 tiaA_gainbits[] = { |
1143 | 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 }; |
1144 | - s8 tiaA_gainbits_rev4[] = { |
1145 | + static const s8 tiaA_gainbits_rev4[] = { |
1146 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; |
1147 | - s8 tiaA_gainbits_rev5[] = { |
1148 | + static const s8 tiaA_gainbits_rev5[] = { |
1149 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; |
1150 | - s8 tiaA_gainbits_rev6[] = { |
1151 | + static const s8 tiaA_gainbits_rev6[] = { |
1152 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }; |
1153 | - s8 *tia_gainbits; |
1154 | - s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 }; |
1155 | - s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 }; |
1156 | - u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f }; |
1157 | - u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f }; |
1158 | - u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f }; |
1159 | - u16 rfseqG_init_gain_rev5_elna[] = { |
1160 | + const s8 *tia_gainbits; |
1161 | + static const s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 }; |
1162 | + static const s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 }; |
1163 | + static const u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f }; |
1164 | + static const u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f }; |
1165 | + static const u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f }; |
1166 | + static const u16 rfseqG_init_gain_rev5_elna[] = { |
1167 | 0x013f, 0x013f, 0x013f, 0x013f }; |
1168 | - u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f }; |
1169 | - u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f }; |
1170 | - u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f }; |
1171 | - u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f }; |
1172 | - u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f }; |
1173 | - u16 rfseqA_init_gain_rev4_elna[] = { |
1174 | + static const u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f }; |
1175 | + static const u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f }; |
1176 | + static const u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f }; |
1177 | + static const u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f }; |
1178 | + static const u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f }; |
1179 | + static const u16 rfseqA_init_gain_rev4_elna[] = { |
1180 | 0x314f, 0x314f, 0x314f, 0x314f }; |
1181 | - u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f }; |
1182 | - u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f }; |
1183 | - u16 *rfseq_init_gain; |
1184 | + static const u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f }; |
1185 | + static const u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f }; |
1186 | + const u16 *rfseq_init_gain; |
1187 | u16 initG_gaincode = 0x627e; |
1188 | u16 initG_gaincode_rev4 = 0x527e; |
1189 | u16 initG_gaincode_rev5 = 0x427e; |
1190 | @@ -15538,10 +15535,10 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) |
1191 | u16 clip1mdA_gaincode_rev6 = 0x2084; |
1192 | u16 clip1md_gaincode = 0; |
1193 | u16 clip1loG_gaincode = 0x0074; |
1194 | - u16 clip1loG_gaincode_rev5[] = { |
1195 | + static const u16 clip1loG_gaincode_rev5[] = { |
1196 | 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c |
1197 | }; |
1198 | - u16 clip1loG_gaincode_rev6[] = { |
1199 | + static const u16 clip1loG_gaincode_rev6[] = { |
1200 | 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e |
1201 | }; |
1202 | u16 clip1loG_gaincode_rev6_224B0 = 0x1074; |
1203 | @@ -16066,7 +16063,7 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) |
1204 | |
1205 | static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) |
1206 | { |
1207 | - u8 rfseq_rx2tx_events[] = { |
1208 | + static const u8 rfseq_rx2tx_events[] = { |
1209 | NPHY_RFSEQ_CMD_NOP, |
1210 | NPHY_RFSEQ_CMD_RXG_FBW, |
1211 | NPHY_RFSEQ_CMD_TR_SWITCH, |
1212 | @@ -16076,7 +16073,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) |
1213 | NPHY_RFSEQ_CMD_EXT_PA |
1214 | }; |
1215 | u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 }; |
1216 | - u8 rfseq_tx2rx_events[] = { |
1217 | + static const u8 rfseq_tx2rx_events[] = { |
1218 | NPHY_RFSEQ_CMD_NOP, |
1219 | NPHY_RFSEQ_CMD_EXT_PA, |
1220 | NPHY_RFSEQ_CMD_TX_GAIN, |
1221 | @@ -16085,8 +16082,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) |
1222 | NPHY_RFSEQ_CMD_RXG_FBW, |
1223 | NPHY_RFSEQ_CMD_CLR_HIQ_DIS |
1224 | }; |
1225 | - u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 }; |
1226 | - u8 rfseq_tx2rx_events_rev3[] = { |
1227 | + static const u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 }; |
1228 | + static const u8 rfseq_tx2rx_events_rev3[] = { |
1229 | NPHY_REV3_RFSEQ_CMD_EXT_PA, |
1230 | NPHY_REV3_RFSEQ_CMD_INT_PA_PU, |
1231 | NPHY_REV3_RFSEQ_CMD_TX_GAIN, |
1232 | @@ -16096,7 +16093,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) |
1233 | NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS, |
1234 | NPHY_REV3_RFSEQ_CMD_END |
1235 | }; |
1236 | - u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 }; |
1237 | + static const u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 }; |
1238 | u8 rfseq_rx2tx_events_rev3[] = { |
1239 | NPHY_REV3_RFSEQ_CMD_NOP, |
1240 | NPHY_REV3_RFSEQ_CMD_RXG_FBW, |
1241 | @@ -16110,7 +16107,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) |
1242 | }; |
1243 | u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 }; |
1244 | |
1245 | - u8 rfseq_rx2tx_events_rev3_ipa[] = { |
1246 | + static const u8 rfseq_rx2tx_events_rev3_ipa[] = { |
1247 | NPHY_REV3_RFSEQ_CMD_NOP, |
1248 | NPHY_REV3_RFSEQ_CMD_RXG_FBW, |
1249 | NPHY_REV3_RFSEQ_CMD_TR_SWITCH, |
1250 | @@ -16121,15 +16118,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) |
1251 | NPHY_REV3_RFSEQ_CMD_INT_PA_PU, |
1252 | NPHY_REV3_RFSEQ_CMD_END |
1253 | }; |
1254 | - u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; |
1255 | - u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f }; |
1256 | + static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; |
1257 | + static const u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f }; |
1258 | |
1259 | s16 alpha0, alpha1, alpha2; |
1260 | s16 beta0, beta1, beta2; |
1261 | u32 leg_data_weights, ht_data_weights, nss1_data_weights, |
1262 | stbc_data_weights; |
1263 | u8 chan_freq_range = 0; |
1264 | - u16 dac_control = 0x0002; |
1265 | + static const u16 dac_control = 0x0002; |
1266 | u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 }; |
1267 | u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 }; |
1268 | u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 }; |
1269 | @@ -16139,8 +16136,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) |
1270 | u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 }; |
1271 | u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 }; |
1272 | u16 *aux_adc_gain; |
1273 | - u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 }; |
1274 | - u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 }; |
1275 | + static const u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 }; |
1276 | + static const u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 }; |
1277 | s32 min_nvar_val = 0x18d; |
1278 | s32 min_nvar_offset_6mbps = 20; |
1279 | u8 pdetrange; |
1280 | @@ -16151,9 +16148,9 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) |
1281 | u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77; |
1282 | u16 rfseq_tx2rx_lpf_h_hpc_rev7 = 0x77; |
1283 | u16 rfseq_pktgn_lpf_h_hpc_rev7 = 0x77; |
1284 | - u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 }; |
1285 | - u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; |
1286 | - u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; |
1287 | + static const u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 }; |
1288 | + static const u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; |
1289 | + static const u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 }; |
1290 | u16 ipalvlshift_3p3_war_en = 0; |
1291 | u16 rccal_bcap_val, rccal_scap_val; |
1292 | u16 rccal_tx20_11b_bcap = 0; |
1293 | @@ -24291,13 +24288,13 @@ static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core) |
1294 | u16 bbmult; |
1295 | u16 tblentry; |
1296 | |
1297 | - struct nphy_txiqcal_ladder ladder_lo[] = { |
1298 | + static const struct nphy_txiqcal_ladder ladder_lo[] = { |
1299 | {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0}, |
1300 | {25, 0}, {25, 1}, {25, 2}, {25, 3}, {25, 4}, {25, 5}, |
1301 | {25, 6}, {25, 7}, {35, 7}, {50, 7}, {71, 7}, {100, 7} |
1302 | }; |
1303 | |
1304 | - struct nphy_txiqcal_ladder ladder_iq[] = { |
1305 | + static const struct nphy_txiqcal_ladder ladder_iq[] = { |
1306 | {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0}, |
1307 | {25, 0}, {35, 0}, {50, 0}, {71, 0}, {100, 0}, {100, 1}, |
1308 | {100, 2}, {100, 3}, {100, 4}, {100, 5}, {100, 6}, {100, 7} |
1309 | @@ -25773,67 +25770,67 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, |
1310 | u16 cal_gain[2]; |
1311 | struct nphy_iqcal_params cal_params[2]; |
1312 | u32 tbl_len; |
1313 | - void *tbl_ptr; |
1314 | + const void *tbl_ptr; |
1315 | bool ladder_updated[2]; |
1316 | u8 mphase_cal_lastphase = 0; |
1317 | int bcmerror = 0; |
1318 | bool phyhang_avoid_state = false; |
1319 | |
1320 | - u16 tbl_tx_iqlo_cal_loft_ladder_20[] = { |
1321 | + static const u16 tbl_tx_iqlo_cal_loft_ladder_20[] = { |
1322 | 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901, |
1323 | 0x1902, |
1324 | 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607, |
1325 | 0x6407 |
1326 | }; |
1327 | |
1328 | - u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = { |
1329 | + static const u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = { |
1330 | 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400, |
1331 | 0x3200, |
1332 | 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406, |
1333 | 0x6407 |
1334 | }; |
1335 | |
1336 | - u16 tbl_tx_iqlo_cal_loft_ladder_40[] = { |
1337 | + static const u16 tbl_tx_iqlo_cal_loft_ladder_40[] = { |
1338 | 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201, |
1339 | 0x1202, |
1340 | 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207, |
1341 | 0x4707 |
1342 | }; |
1343 | |
1344 | - u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = { |
1345 | + static const u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = { |
1346 | 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900, |
1347 | 0x2300, |
1348 | 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706, |
1349 | 0x4707 |
1350 | }; |
1351 | |
1352 | - u16 tbl_tx_iqlo_cal_startcoefs[] = { |
1353 | + static const u16 tbl_tx_iqlo_cal_startcoefs[] = { |
1354 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
1355 | 0x0000 |
1356 | }; |
1357 | |
1358 | - u16 tbl_tx_iqlo_cal_cmds_fullcal[] = { |
1359 | + static const u16 tbl_tx_iqlo_cal_cmds_fullcal[] = { |
1360 | 0x8123, 0x8264, 0x8086, 0x8245, 0x8056, |
1361 | 0x9123, 0x9264, 0x9086, 0x9245, 0x9056 |
1362 | }; |
1363 | |
1364 | - u16 tbl_tx_iqlo_cal_cmds_recal[] = { |
1365 | + static const u16 tbl_tx_iqlo_cal_cmds_recal[] = { |
1366 | 0x8101, 0x8253, 0x8053, 0x8234, 0x8034, |
1367 | 0x9101, 0x9253, 0x9053, 0x9234, 0x9034 |
1368 | }; |
1369 | |
1370 | - u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = { |
1371 | + static const u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = { |
1372 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
1373 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
1374 | 0x0000 |
1375 | }; |
1376 | |
1377 | - u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = { |
1378 | + static const u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = { |
1379 | 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234, |
1380 | 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x9234 |
1381 | }; |
1382 | |
1383 | - u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = { |
1384 | + static const u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = { |
1385 | 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223, |
1386 | 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x9223 |
1387 | }; |
1388 | diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c |
1389 | index 2bc6bace069c..b4302f41493c 100644 |
1390 | --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c |
1391 | +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c |
1392 | @@ -1122,7 +1122,7 @@ static u8 _rtl8821ae_dbi_read(struct rtl_priv *rtlpriv, u16 addr) |
1393 | } |
1394 | if (0 == tmp) { |
1395 | read_addr = REG_DBI_RDATA + addr % 4; |
1396 | - ret = rtl_read_byte(rtlpriv, read_addr); |
1397 | + ret = rtl_read_word(rtlpriv, read_addr); |
1398 | } |
1399 | return ret; |
1400 | } |
1401 | diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c |
1402 | index df57655779ed..5da006d81900 100644 |
1403 | --- a/drivers/scsi/qla2xxx/qla_os.c |
1404 | +++ b/drivers/scsi/qla2xxx/qla_os.c |
1405 | @@ -3165,6 +3165,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) |
1406 | host->can_queue, base_vha->req, |
1407 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
1408 | |
1409 | + INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); |
1410 | + |
1411 | if (ha->mqenable) { |
1412 | bool mq = false; |
1413 | bool startit = false; |
1414 | @@ -3213,7 +3215,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) |
1415 | */ |
1416 | qla2xxx_wake_dpc(base_vha); |
1417 | |
1418 | - INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn); |
1419 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
1420 | |
1421 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
1422 | diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c |
1423 | index 5f3d8f2339e3..4be864dbd41c 100644 |
1424 | --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c |
1425 | +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c |
1426 | @@ -390,8 +390,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream |
1427 | __func__, instance); |
1428 | instance->alsa_stream = alsa_stream; |
1429 | alsa_stream->instance = instance; |
1430 | - ret = 0; // xxx todo -1; |
1431 | - goto err_free_mem; |
1432 | + return 0; |
1433 | } |
1434 | |
1435 | /* Initialize and create a VCHI connection */ |
1436 | @@ -401,16 +400,15 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream |
1437 | LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n", |
1438 | __func__, ret); |
1439 | |
1440 | - ret = -EIO; |
1441 | - goto err_free_mem; |
1442 | + return -EIO; |
1443 | } |
1444 | ret = vchi_connect(NULL, 0, vchi_instance); |
1445 | if (ret) { |
1446 | LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n", |
1447 | __func__, ret); |
1448 | |
1449 | - ret = -EIO; |
1450 | - goto err_free_mem; |
1451 | + kfree(vchi_instance); |
1452 | + return -EIO; |
1453 | } |
1454 | initted = 1; |
1455 | } |
1456 | @@ -421,19 +419,16 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream |
1457 | if (IS_ERR(instance)) { |
1458 | LOG_ERR("%s: failed to initialize audio service\n", __func__); |
1459 | |
1460 | - ret = PTR_ERR(instance); |
1461 | - goto err_free_mem; |
1462 | + /* vchi_instance is retained for use the next time. */ |
1463 | + return PTR_ERR(instance); |
1464 | } |
1465 | |
1466 | instance->alsa_stream = alsa_stream; |
1467 | alsa_stream->instance = instance; |
1468 | |
1469 | LOG_DBG(" success !\n"); |
1470 | - ret = 0; |
1471 | -err_free_mem: |
1472 | - kfree(vchi_instance); |
1473 | |
1474 | - return ret; |
1475 | + return 0; |
1476 | } |
1477 | |
1478 | int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) |
1479 | diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c |
1480 | index 5e056064259c..18c923a4c16e 100644 |
1481 | --- a/drivers/usb/class/cdc-acm.c |
1482 | +++ b/drivers/usb/class/cdc-acm.c |
1483 | @@ -1832,6 +1832,9 @@ static const struct usb_device_id acm_ids[] = { |
1484 | { USB_DEVICE(0xfff0, 0x0100), /* DATECS FP-2000 */ |
1485 | .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ |
1486 | }, |
1487 | + { USB_DEVICE(0x09d8, 0x0320), /* Elatec GmbH TWN3 */ |
1488 | + .driver_info = NO_UNION_NORMAL, /* has misplaced union descriptor */ |
1489 | + }, |
1490 | |
1491 | { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */ |
1492 | .driver_info = CLEAR_HALT_CONDITIONS, |
1493 | diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c |
1494 | index 68b54bd88d1e..883549ee946c 100644 |
1495 | --- a/drivers/usb/core/config.c |
1496 | +++ b/drivers/usb/core/config.c |
1497 | @@ -960,10 +960,12 @@ int usb_get_bos_descriptor(struct usb_device *dev) |
1498 | for (i = 0; i < num; i++) { |
1499 | buffer += length; |
1500 | cap = (struct usb_dev_cap_header *)buffer; |
1501 | - length = cap->bLength; |
1502 | |
1503 | - if (total_len < length) |
1504 | + if (total_len < sizeof(*cap) || total_len < cap->bLength) { |
1505 | + dev->bos->desc->bNumDeviceCaps = i; |
1506 | break; |
1507 | + } |
1508 | + length = cap->bLength; |
1509 | total_len -= length; |
1510 | |
1511 | if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) { |
1512 | diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c |
1513 | index 1d4dfdeb61c1..066b58cb6c98 100644 |
1514 | --- a/drivers/usb/core/devio.c |
1515 | +++ b/drivers/usb/core/devio.c |
1516 | @@ -1576,11 +1576,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb |
1517 | totlen += isopkt[u].length; |
1518 | } |
1519 | u *= sizeof(struct usb_iso_packet_descriptor); |
1520 | - if (totlen <= uurb->buffer_length) |
1521 | - uurb->buffer_length = totlen; |
1522 | - else |
1523 | - WARN_ONCE(1, "uurb->buffer_length is too short %d vs %d", |
1524 | - totlen, uurb->buffer_length); |
1525 | + uurb->buffer_length = totlen; |
1526 | break; |
1527 | |
1528 | default: |
1529 | diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c |
1530 | index 78c2aca5b0fc..3f44341259d8 100644 |
1531 | --- a/drivers/usb/core/hub.c |
1532 | +++ b/drivers/usb/core/hub.c |
1533 | @@ -2710,13 +2710,16 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1, |
1534 | if (!(portstatus & USB_PORT_STAT_CONNECTION)) |
1535 | return -ENOTCONN; |
1536 | |
1537 | - /* bomb out completely if the connection bounced. A USB 3.0 |
1538 | - * connection may bounce if multiple warm resets were issued, |
1539 | + /* Retry if connect change is set but status is still connected. |
1540 | + * A USB 3.0 connection may bounce if multiple warm resets were issued, |
1541 | * but the device may have successfully re-connected. Ignore it. |
1542 | */ |
1543 | if (!hub_is_superspeed(hub->hdev) && |
1544 | - (portchange & USB_PORT_STAT_C_CONNECTION)) |
1545 | - return -ENOTCONN; |
1546 | + (portchange & USB_PORT_STAT_C_CONNECTION)) { |
1547 | + usb_clear_port_feature(hub->hdev, port1, |
1548 | + USB_PORT_FEAT_C_CONNECTION); |
1549 | + return -EAGAIN; |
1550 | + } |
1551 | |
1552 | if (!(portstatus & USB_PORT_STAT_ENABLE)) |
1553 | return -EBUSY; |
1554 | diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c |
1555 | index 82806e311202..a6aaf2f193a4 100644 |
1556 | --- a/drivers/usb/core/quirks.c |
1557 | +++ b/drivers/usb/core/quirks.c |
1558 | @@ -221,6 +221,10 @@ static const struct usb_device_id usb_quirk_list[] = { |
1559 | /* Corsair Strafe RGB */ |
1560 | { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, |
1561 | |
1562 | + /* MIDI keyboard WORLDE MINI */ |
1563 | + { USB_DEVICE(0x1c75, 0x0204), .driver_info = |
1564 | + USB_QUIRK_CONFIG_INTF_STRINGS }, |
1565 | + |
1566 | /* Acer C120 LED Projector */ |
1567 | { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM }, |
1568 | |
1569 | diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c |
1570 | index 950dee33bfcc..ad4c697cf30e 100644 |
1571 | --- a/drivers/usb/host/xhci-hub.c |
1572 | +++ b/drivers/usb/host/xhci-hub.c |
1573 | @@ -420,14 +420,25 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) |
1574 | GFP_NOWAIT); |
1575 | if (!command) { |
1576 | spin_unlock_irqrestore(&xhci->lock, flags); |
1577 | - xhci_free_command(xhci, cmd); |
1578 | - return -ENOMEM; |
1579 | + ret = -ENOMEM; |
1580 | + goto cmd_cleanup; |
1581 | + } |
1582 | + |
1583 | + ret = xhci_queue_stop_endpoint(xhci, command, slot_id, |
1584 | + i, suspend); |
1585 | + if (ret) { |
1586 | + spin_unlock_irqrestore(&xhci->lock, flags); |
1587 | + xhci_free_command(xhci, command); |
1588 | + goto cmd_cleanup; |
1589 | } |
1590 | - xhci_queue_stop_endpoint(xhci, command, slot_id, i, |
1591 | - suspend); |
1592 | } |
1593 | } |
1594 | - xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend); |
1595 | + ret = xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend); |
1596 | + if (ret) { |
1597 | + spin_unlock_irqrestore(&xhci->lock, flags); |
1598 | + goto cmd_cleanup; |
1599 | + } |
1600 | + |
1601 | xhci_ring_cmd_db(xhci); |
1602 | spin_unlock_irqrestore(&xhci->lock, flags); |
1603 | |
1604 | @@ -439,6 +450,8 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) |
1605 | xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n"); |
1606 | ret = -ETIME; |
1607 | } |
1608 | + |
1609 | +cmd_cleanup: |
1610 | xhci_free_command(xhci, cmd); |
1611 | return ret; |
1612 | } |
1613 | diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c |
1614 | index cc368ad2b51e..b0f42e1b91ee 100644 |
1615 | --- a/drivers/usb/host/xhci-ring.c |
1616 | +++ b/drivers/usb/host/xhci-ring.c |
1617 | @@ -1309,6 +1309,7 @@ static void xhci_complete_del_and_free_cmd(struct xhci_command *cmd, u32 status) |
1618 | void xhci_cleanup_command_queue(struct xhci_hcd *xhci) |
1619 | { |
1620 | struct xhci_command *cur_cmd, *tmp_cmd; |
1621 | + xhci->current_cmd = NULL; |
1622 | list_for_each_entry_safe(cur_cmd, tmp_cmd, &xhci->cmd_list, cmd_list) |
1623 | xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED); |
1624 | } |
1625 | @@ -2577,15 +2578,21 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
1626 | (struct xhci_generic_trb *) ep_trb); |
1627 | |
1628 | /* |
1629 | - * No-op TRB should not trigger interrupts. |
1630 | - * If ep_trb is a no-op TRB, it means the |
1631 | - * corresponding TD has been cancelled. Just ignore |
1632 | - * the TD. |
1633 | + * No-op TRB could trigger interrupts in a case where |
1634 | + * a URB was killed and a STALL_ERROR happens right |
1635 | + * after the endpoint ring stopped. Reset the halted |
1636 | + * endpoint. Otherwise, the endpoint remains stalled |
1637 | + * indefinitely. |
1638 | */ |
1639 | if (trb_is_noop(ep_trb)) { |
1640 | - xhci_dbg(xhci, |
1641 | - "ep_trb is a no-op TRB. Skip it for slot %u ep %u\n", |
1642 | - slot_id, ep_index); |
1643 | + if (trb_comp_code == COMP_STALL_ERROR || |
1644 | + xhci_requires_manual_halt_cleanup(xhci, ep_ctx, |
1645 | + trb_comp_code)) |
1646 | + xhci_cleanup_halted_endpoint(xhci, slot_id, |
1647 | + ep_index, |
1648 | + ep_ring->stream_id, |
1649 | + td, ep_trb, |
1650 | + EP_HARD_RESET); |
1651 | goto cleanup; |
1652 | } |
1653 | |
1654 | diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c |
1655 | index ee198ea47f49..51535ba2bcd4 100644 |
1656 | --- a/drivers/usb/host/xhci.c |
1657 | +++ b/drivers/usb/host/xhci.c |
1658 | @@ -4805,7 +4805,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) |
1659 | */ |
1660 | hcd->has_tt = 1; |
1661 | } else { |
1662 | - if (xhci->sbrn == 0x31) { |
1663 | + /* Some 3.1 hosts return sbrn 0x30, can't rely on sbrn alone */ |
1664 | + if (xhci->sbrn == 0x31 || xhci->usb3_rhub.min_rev >= 1) { |
1665 | xhci_info(xhci, "Host supports USB 3.1 Enhanced SuperSpeed\n"); |
1666 | hcd->speed = HCD_USB31; |
1667 | hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; |
1668 | diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c |
1669 | index b67692857daf..458957e97fee 100644 |
1670 | --- a/drivers/usb/musb/musb_core.c |
1671 | +++ b/drivers/usb/musb/musb_core.c |
1672 | @@ -906,7 +906,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, |
1673 | */ |
1674 | if (int_usb & MUSB_INTR_RESET) { |
1675 | handled = IRQ_HANDLED; |
1676 | - if (devctl & MUSB_DEVCTL_HM) { |
1677 | + if (is_host_active(musb)) { |
1678 | /* |
1679 | * When BABBLE happens what we can depends on which |
1680 | * platform MUSB is running, because some platforms |
1681 | @@ -916,9 +916,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, |
1682 | * drop the session. |
1683 | */ |
1684 | dev_err(musb->controller, "Babble\n"); |
1685 | - |
1686 | - if (is_host_active(musb)) |
1687 | - musb_recover_from_babble(musb); |
1688 | + musb_recover_from_babble(musb); |
1689 | } else { |
1690 | musb_dbg(musb, "BUS RESET as %s", |
1691 | usb_otg_state_string(musb->xceiv->otg->state)); |
1692 | @@ -1861,22 +1859,22 @@ static void musb_pm_runtime_check_session(struct musb *musb) |
1693 | MUSB_DEVCTL_HR; |
1694 | switch (devctl & ~s) { |
1695 | case MUSB_QUIRK_B_INVALID_VBUS_91: |
1696 | - if (musb->quirk_retries--) { |
1697 | + if (musb->quirk_retries && !musb->flush_irq_work) { |
1698 | musb_dbg(musb, |
1699 | "Poll devctl on invalid vbus, assume no session"); |
1700 | schedule_delayed_work(&musb->irq_work, |
1701 | msecs_to_jiffies(1000)); |
1702 | - |
1703 | + musb->quirk_retries--; |
1704 | return; |
1705 | } |
1706 | /* fall through */ |
1707 | case MUSB_QUIRK_A_DISCONNECT_19: |
1708 | - if (musb->quirk_retries--) { |
1709 | + if (musb->quirk_retries && !musb->flush_irq_work) { |
1710 | musb_dbg(musb, |
1711 | "Poll devctl on possible host mode disconnect"); |
1712 | schedule_delayed_work(&musb->irq_work, |
1713 | msecs_to_jiffies(1000)); |
1714 | - |
1715 | + musb->quirk_retries--; |
1716 | return; |
1717 | } |
1718 | if (!musb->session) |
1719 | @@ -2681,8 +2679,15 @@ static int musb_suspend(struct device *dev) |
1720 | |
1721 | musb_platform_disable(musb); |
1722 | musb_disable_interrupts(musb); |
1723 | + |
1724 | + musb->flush_irq_work = true; |
1725 | + while (flush_delayed_work(&musb->irq_work)) |
1726 | + ; |
1727 | + musb->flush_irq_work = false; |
1728 | + |
1729 | if (!(musb->io.quirks & MUSB_PRESERVE_SESSION)) |
1730 | musb_writeb(musb->mregs, MUSB_DEVCTL, 0); |
1731 | + |
1732 | WARN_ON(!list_empty(&musb->pending_list)); |
1733 | |
1734 | spin_lock_irqsave(&musb->lock, flags); |
1735 | diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h |
1736 | index 9f22c5b8ce37..1830a571d025 100644 |
1737 | --- a/drivers/usb/musb/musb_core.h |
1738 | +++ b/drivers/usb/musb/musb_core.h |
1739 | @@ -428,6 +428,8 @@ struct musb { |
1740 | unsigned test_mode:1; |
1741 | unsigned softconnect:1; |
1742 | |
1743 | + unsigned flush_irq_work:1; |
1744 | + |
1745 | u8 address; |
1746 | u8 test_mode_nr; |
1747 | u16 ackpend; /* ep0 */ |
1748 | diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c |
1749 | index ba255280a624..1ec0a4947b6b 100644 |
1750 | --- a/drivers/usb/musb/musb_cppi41.c |
1751 | +++ b/drivers/usb/musb/musb_cppi41.c |
1752 | @@ -26,15 +26,28 @@ |
1753 | |
1754 | #define MUSB_DMA_NUM_CHANNELS 15 |
1755 | |
1756 | +#define DA8XX_USB_MODE 0x10 |
1757 | +#define DA8XX_USB_AUTOREQ 0x14 |
1758 | +#define DA8XX_USB_TEARDOWN 0x1c |
1759 | + |
1760 | +#define DA8XX_DMA_NUM_CHANNELS 4 |
1761 | + |
1762 | struct cppi41_dma_controller { |
1763 | struct dma_controller controller; |
1764 | - struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS]; |
1765 | - struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS]; |
1766 | + struct cppi41_dma_channel *rx_channel; |
1767 | + struct cppi41_dma_channel *tx_channel; |
1768 | struct hrtimer early_tx; |
1769 | struct list_head early_tx_list; |
1770 | u32 rx_mode; |
1771 | u32 tx_mode; |
1772 | u32 auto_req; |
1773 | + |
1774 | + u32 tdown_reg; |
1775 | + u32 autoreq_reg; |
1776 | + |
1777 | + void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel, |
1778 | + unsigned int mode); |
1779 | + u8 num_channels; |
1780 | }; |
1781 | |
1782 | static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel) |
1783 | @@ -349,6 +362,32 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel *cppi41_channel, |
1784 | } |
1785 | } |
1786 | |
1787 | +static void da8xx_set_dma_mode(struct cppi41_dma_channel *cppi41_channel, |
1788 | + unsigned int mode) |
1789 | +{ |
1790 | + struct cppi41_dma_controller *controller = cppi41_channel->controller; |
1791 | + struct musb *musb = controller->controller.musb; |
1792 | + unsigned int shift; |
1793 | + u32 port; |
1794 | + u32 new_mode; |
1795 | + u32 old_mode; |
1796 | + |
1797 | + old_mode = controller->tx_mode; |
1798 | + port = cppi41_channel->port_num; |
1799 | + |
1800 | + shift = (port - 1) * 4; |
1801 | + if (!cppi41_channel->is_tx) |
1802 | + shift += 16; |
1803 | + new_mode = old_mode & ~(3 << shift); |
1804 | + new_mode |= mode << shift; |
1805 | + |
1806 | + if (new_mode == old_mode) |
1807 | + return; |
1808 | + controller->tx_mode = new_mode; |
1809 | + musb_writel(musb->ctrl_base, DA8XX_USB_MODE, new_mode); |
1810 | +} |
1811 | + |
1812 | + |
1813 | static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel, |
1814 | unsigned mode) |
1815 | { |
1816 | @@ -364,8 +403,8 @@ static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel, |
1817 | if (new_mode == old_mode) |
1818 | return; |
1819 | controller->auto_req = new_mode; |
1820 | - musb_writel(controller->controller.musb->ctrl_base, USB_CTRL_AUTOREQ, |
1821 | - new_mode); |
1822 | + musb_writel(controller->controller.musb->ctrl_base, |
1823 | + controller->autoreq_reg, new_mode); |
1824 | } |
1825 | |
1826 | static bool cppi41_configure_channel(struct dma_channel *channel, |
1827 | @@ -373,6 +412,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel, |
1828 | dma_addr_t dma_addr, u32 len) |
1829 | { |
1830 | struct cppi41_dma_channel *cppi41_channel = channel->private_data; |
1831 | + struct cppi41_dma_controller *controller = cppi41_channel->controller; |
1832 | struct dma_chan *dc = cppi41_channel->dc; |
1833 | struct dma_async_tx_descriptor *dma_desc; |
1834 | enum dma_transfer_direction direction; |
1835 | @@ -398,7 +438,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel, |
1836 | musb_writel(musb->ctrl_base, |
1837 | RNDIS_REG(cppi41_channel->port_num), len); |
1838 | /* gen rndis */ |
1839 | - cppi41_set_dma_mode(cppi41_channel, |
1840 | + controller->set_dma_mode(cppi41_channel, |
1841 | EP_MODE_DMA_GEN_RNDIS); |
1842 | |
1843 | /* auto req */ |
1844 | @@ -407,14 +447,15 @@ static bool cppi41_configure_channel(struct dma_channel *channel, |
1845 | } else { |
1846 | musb_writel(musb->ctrl_base, |
1847 | RNDIS_REG(cppi41_channel->port_num), 0); |
1848 | - cppi41_set_dma_mode(cppi41_channel, |
1849 | + controller->set_dma_mode(cppi41_channel, |
1850 | EP_MODE_DMA_TRANSPARENT); |
1851 | cppi41_set_autoreq_mode(cppi41_channel, |
1852 | EP_MODE_AUTOREQ_NONE); |
1853 | } |
1854 | } else { |
1855 | /* fallback mode */ |
1856 | - cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT); |
1857 | + controller->set_dma_mode(cppi41_channel, |
1858 | + EP_MODE_DMA_TRANSPARENT); |
1859 | cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE); |
1860 | len = min_t(u32, packet_sz, len); |
1861 | } |
1862 | @@ -445,7 +486,7 @@ static struct dma_channel *cppi41_dma_channel_allocate(struct dma_controller *c, |
1863 | struct cppi41_dma_channel *cppi41_channel = NULL; |
1864 | u8 ch_num = hw_ep->epnum - 1; |
1865 | |
1866 | - if (ch_num >= MUSB_DMA_NUM_CHANNELS) |
1867 | + if (ch_num >= controller->num_channels) |
1868 | return NULL; |
1869 | |
1870 | if (is_tx) |
1871 | @@ -581,12 +622,13 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel) |
1872 | |
1873 | do { |
1874 | if (is_tx) |
1875 | - musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); |
1876 | + musb_writel(musb->ctrl_base, controller->tdown_reg, |
1877 | + tdbit); |
1878 | ret = dmaengine_terminate_all(cppi41_channel->dc); |
1879 | } while (ret == -EAGAIN); |
1880 | |
1881 | if (is_tx) { |
1882 | - musb_writel(musb->ctrl_base, USB_TDOWN, tdbit); |
1883 | + musb_writel(musb->ctrl_base, controller->tdown_reg, tdbit); |
1884 | |
1885 | csr = musb_readw(epio, MUSB_TXCSR); |
1886 | if (csr & MUSB_TXCSR_TXPKTRDY) { |
1887 | @@ -604,7 +646,7 @@ static void cppi41_release_all_dma_chans(struct cppi41_dma_controller *ctrl) |
1888 | struct dma_chan *dc; |
1889 | int i; |
1890 | |
1891 | - for (i = 0; i < MUSB_DMA_NUM_CHANNELS; i++) { |
1892 | + for (i = 0; i < ctrl->num_channels; i++) { |
1893 | dc = ctrl->tx_channel[i].dc; |
1894 | if (dc) |
1895 | dma_release_channel(dc); |
1896 | @@ -656,7 +698,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller) |
1897 | goto err; |
1898 | |
1899 | ret = -EINVAL; |
1900 | - if (port > MUSB_DMA_NUM_CHANNELS || !port) |
1901 | + if (port > controller->num_channels || !port) |
1902 | goto err; |
1903 | if (is_tx) |
1904 | cppi41_channel = &controller->tx_channel[port - 1]; |
1905 | @@ -697,6 +739,8 @@ void cppi41_dma_controller_destroy(struct dma_controller *c) |
1906 | |
1907 | hrtimer_cancel(&controller->early_tx); |
1908 | cppi41_dma_controller_stop(controller); |
1909 | + kfree(controller->rx_channel); |
1910 | + kfree(controller->tx_channel); |
1911 | kfree(controller); |
1912 | } |
1913 | EXPORT_SYMBOL_GPL(cppi41_dma_controller_destroy); |
1914 | @@ -705,6 +749,7 @@ struct dma_controller * |
1915 | cppi41_dma_controller_create(struct musb *musb, void __iomem *base) |
1916 | { |
1917 | struct cppi41_dma_controller *controller; |
1918 | + int channel_size; |
1919 | int ret = 0; |
1920 | |
1921 | if (!musb->controller->parent->of_node) { |
1922 | @@ -727,12 +772,37 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) |
1923 | controller->controller.is_compatible = cppi41_is_compatible; |
1924 | controller->controller.musb = musb; |
1925 | |
1926 | + if (musb->io.quirks & MUSB_DA8XX) { |
1927 | + controller->tdown_reg = DA8XX_USB_TEARDOWN; |
1928 | + controller->autoreq_reg = DA8XX_USB_AUTOREQ; |
1929 | + controller->set_dma_mode = da8xx_set_dma_mode; |
1930 | + controller->num_channels = DA8XX_DMA_NUM_CHANNELS; |
1931 | + } else { |
1932 | + controller->tdown_reg = USB_TDOWN; |
1933 | + controller->autoreq_reg = USB_CTRL_AUTOREQ; |
1934 | + controller->set_dma_mode = cppi41_set_dma_mode; |
1935 | + controller->num_channels = MUSB_DMA_NUM_CHANNELS; |
1936 | + } |
1937 | + |
1938 | + channel_size = controller->num_channels * |
1939 | + sizeof(struct cppi41_dma_channel); |
1940 | + controller->rx_channel = kzalloc(channel_size, GFP_KERNEL); |
1941 | + if (!controller->rx_channel) |
1942 | + goto rx_channel_alloc_fail; |
1943 | + controller->tx_channel = kzalloc(channel_size, GFP_KERNEL); |
1944 | + if (!controller->tx_channel) |
1945 | + goto tx_channel_alloc_fail; |
1946 | + |
1947 | ret = cppi41_dma_controller_start(controller); |
1948 | if (ret) |
1949 | goto plat_get_fail; |
1950 | return &controller->controller; |
1951 | |
1952 | plat_get_fail: |
1953 | + kfree(controller->tx_channel); |
1954 | +tx_channel_alloc_fail: |
1955 | + kfree(controller->rx_channel); |
1956 | +rx_channel_alloc_fail: |
1957 | kfree(controller); |
1958 | kzalloc_fail: |
1959 | if (ret == -EPROBE_DEFER) |
1960 | diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c |
1961 | index c9a09b5bb6e5..dc353e24d53c 100644 |
1962 | --- a/drivers/usb/musb/sunxi.c |
1963 | +++ b/drivers/usb/musb/sunxi.c |
1964 | @@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb) |
1965 | if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags)) |
1966 | sunxi_sram_release(musb->controller->parent); |
1967 | |
1968 | + devm_usb_put_phy(glue->dev, glue->xceiv); |
1969 | + |
1970 | return 0; |
1971 | } |
1972 | |
1973 | diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c |
1974 | index cc84da8dbb84..14511d6a7d44 100644 |
1975 | --- a/drivers/usb/serial/metro-usb.c |
1976 | +++ b/drivers/usb/serial/metro-usb.c |
1977 | @@ -45,6 +45,7 @@ struct metrousb_private { |
1978 | static const struct usb_device_id id_table[] = { |
1979 | { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_BI) }, |
1980 | { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_UNI) }, |
1981 | + { USB_DEVICE_INTERFACE_CLASS(0x0c2e, 0x0730, 0xff) }, /* MS7820 */ |
1982 | { }, /* Terminating entry. */ |
1983 | }; |
1984 | MODULE_DEVICE_TABLE(usb, id_table); |
1985 | diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c |
1986 | index 018c588c7ac3..8e704d12a1cf 100644 |
1987 | --- a/fs/crypto/keyinfo.c |
1988 | +++ b/fs/crypto/keyinfo.c |
1989 | @@ -109,6 +109,11 @@ static int validate_user_key(struct fscrypt_info *crypt_info, |
1990 | goto out; |
1991 | } |
1992 | ukp = user_key_payload_locked(keyring_key); |
1993 | + if (!ukp) { |
1994 | + /* key was revoked before we acquired its semaphore */ |
1995 | + res = -EKEYREVOKED; |
1996 | + goto out; |
1997 | + } |
1998 | if (ukp->datalen != sizeof(struct fscrypt_key)) { |
1999 | res = -EINVAL; |
2000 | goto out; |
2001 | diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h |
2002 | index 9c351bf757b2..3fbc0ff79699 100644 |
2003 | --- a/fs/ecryptfs/ecryptfs_kernel.h |
2004 | +++ b/fs/ecryptfs/ecryptfs_kernel.h |
2005 | @@ -84,11 +84,16 @@ struct ecryptfs_page_crypt_context { |
2006 | static inline struct ecryptfs_auth_tok * |
2007 | ecryptfs_get_encrypted_key_payload_data(struct key *key) |
2008 | { |
2009 | - if (key->type == &key_type_encrypted) |
2010 | - return (struct ecryptfs_auth_tok *) |
2011 | - (&((struct encrypted_key_payload *)key->payload.data[0])->payload_data); |
2012 | - else |
2013 | + struct encrypted_key_payload *payload; |
2014 | + |
2015 | + if (key->type != &key_type_encrypted) |
2016 | return NULL; |
2017 | + |
2018 | + payload = key->payload.data[0]; |
2019 | + if (!payload) |
2020 | + return ERR_PTR(-EKEYREVOKED); |
2021 | + |
2022 | + return (struct ecryptfs_auth_tok *)payload->payload_data; |
2023 | } |
2024 | |
2025 | static inline struct key *ecryptfs_get_encrypted_key(char *sig) |
2026 | @@ -114,12 +119,17 @@ static inline struct ecryptfs_auth_tok * |
2027 | ecryptfs_get_key_payload_data(struct key *key) |
2028 | { |
2029 | struct ecryptfs_auth_tok *auth_tok; |
2030 | + struct user_key_payload *ukp; |
2031 | |
2032 | auth_tok = ecryptfs_get_encrypted_key_payload_data(key); |
2033 | - if (!auth_tok) |
2034 | - return (struct ecryptfs_auth_tok *)user_key_payload_locked(key)->data; |
2035 | - else |
2036 | + if (auth_tok) |
2037 | return auth_tok; |
2038 | + |
2039 | + ukp = user_key_payload_locked(key); |
2040 | + if (!ukp) |
2041 | + return ERR_PTR(-EKEYREVOKED); |
2042 | + |
2043 | + return (struct ecryptfs_auth_tok *)ukp->data; |
2044 | } |
2045 | |
2046 | #define ECRYPTFS_MAX_KEYSET_SIZE 1024 |
2047 | diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c |
2048 | index 3cf1546dca82..fa218cd64f74 100644 |
2049 | --- a/fs/ecryptfs/keystore.c |
2050 | +++ b/fs/ecryptfs/keystore.c |
2051 | @@ -459,7 +459,8 @@ static int ecryptfs_verify_version(u16 version) |
2052 | * @auth_tok_key: key containing the authentication token |
2053 | * @auth_tok: authentication token |
2054 | * |
2055 | - * Returns zero on valid auth tok; -EINVAL otherwise |
2056 | + * Returns zero on valid auth tok; -EINVAL if the payload is invalid; or |
2057 | + * -EKEYREVOKED if the key was revoked before we acquired its semaphore. |
2058 | */ |
2059 | static int |
2060 | ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key, |
2061 | @@ -468,6 +469,12 @@ ecryptfs_verify_auth_tok_from_key(struct key *auth_tok_key, |
2062 | int rc = 0; |
2063 | |
2064 | (*auth_tok) = ecryptfs_get_key_payload_data(auth_tok_key); |
2065 | + if (IS_ERR(*auth_tok)) { |
2066 | + rc = PTR_ERR(*auth_tok); |
2067 | + *auth_tok = NULL; |
2068 | + goto out; |
2069 | + } |
2070 | + |
2071 | if (ecryptfs_verify_version((*auth_tok)->version)) { |
2072 | printk(KERN_ERR "Data structure version mismatch. Userspace " |
2073 | "tools must match eCryptfs kernel module with major " |
2074 | diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c |
2075 | index 67f940892ef8..5eb2e24ce790 100644 |
2076 | --- a/fs/fscache/object-list.c |
2077 | +++ b/fs/fscache/object-list.c |
2078 | @@ -330,6 +330,13 @@ static void fscache_objlist_config(struct fscache_objlist_data *data) |
2079 | rcu_read_lock(); |
2080 | |
2081 | confkey = user_key_payload_rcu(key); |
2082 | + if (!confkey) { |
2083 | + /* key was revoked */ |
2084 | + rcu_read_unlock(); |
2085 | + key_put(key); |
2086 | + goto no_config; |
2087 | + } |
2088 | + |
2089 | buf = confkey->data; |
2090 | |
2091 | for (len = confkey->datalen - 1; len >= 0; len--) { |
2092 | diff --git a/fs/iomap.c b/fs/iomap.c |
2093 | index 59cc98ad7577..b8a91064abc6 100644 |
2094 | --- a/fs/iomap.c |
2095 | +++ b/fs/iomap.c |
2096 | @@ -993,6 +993,13 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, |
2097 | WARN_ON_ONCE(ret); |
2098 | ret = 0; |
2099 | |
2100 | + if (iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) && |
2101 | + !inode->i_sb->s_dio_done_wq) { |
2102 | + ret = sb_init_dio_done_wq(inode->i_sb); |
2103 | + if (ret < 0) |
2104 | + goto out_free_dio; |
2105 | + } |
2106 | + |
2107 | inode_dio_begin(inode); |
2108 | |
2109 | blk_start_plug(&plug); |
2110 | @@ -1015,13 +1022,6 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, |
2111 | if (ret < 0) |
2112 | iomap_dio_set_error(dio, ret); |
2113 | |
2114 | - if (ret >= 0 && iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) && |
2115 | - !inode->i_sb->s_dio_done_wq) { |
2116 | - ret = sb_init_dio_done_wq(inode->i_sb); |
2117 | - if (ret < 0) |
2118 | - iomap_dio_set_error(dio, ret); |
2119 | - } |
2120 | - |
2121 | if (!atomic_dec_and_test(&dio->ref)) { |
2122 | if (!is_sync_kiocb(iocb)) |
2123 | return -EIOCBQUEUED; |
2124 | diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c |
2125 | index b008ff3250eb..df3e600835e8 100644 |
2126 | --- a/fs/xfs/libxfs/xfs_ag_resv.c |
2127 | +++ b/fs/xfs/libxfs/xfs_ag_resv.c |
2128 | @@ -156,7 +156,8 @@ __xfs_ag_resv_free( |
2129 | trace_xfs_ag_resv_free(pag, type, 0); |
2130 | |
2131 | resv = xfs_perag_resv(pag, type); |
2132 | - pag->pag_mount->m_ag_max_usable += resv->ar_asked; |
2133 | + if (pag->pag_agno == 0) |
2134 | + pag->pag_mount->m_ag_max_usable += resv->ar_asked; |
2135 | /* |
2136 | * AGFL blocks are always considered "free", so whatever |
2137 | * was reserved at mount time must be given back at umount. |
2138 | @@ -216,7 +217,14 @@ __xfs_ag_resv_init( |
2139 | return error; |
2140 | } |
2141 | |
2142 | - mp->m_ag_max_usable -= ask; |
2143 | + /* |
2144 | + * Reduce the maximum per-AG allocation length by however much we're |
2145 | + * trying to reserve for an AG. Since this is a filesystem-wide |
2146 | + * counter, we only make the adjustment for AG 0. This assumes that |
2147 | + * there aren't any AGs hungrier for per-AG reservation than AG 0. |
2148 | + */ |
2149 | + if (pag->pag_agno == 0) |
2150 | + mp->m_ag_max_usable -= ask; |
2151 | |
2152 | resv = xfs_perag_resv(pag, type); |
2153 | resv->ar_asked = ask; |
2154 | diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c |
2155 | index 744dcaec34cc..f965ce832bc0 100644 |
2156 | --- a/fs/xfs/libxfs/xfs_alloc.c |
2157 | +++ b/fs/xfs/libxfs/xfs_alloc.c |
2158 | @@ -1584,6 +1584,10 @@ xfs_alloc_ag_vextent_small( |
2159 | |
2160 | bp = xfs_btree_get_bufs(args->mp, args->tp, |
2161 | args->agno, fbno, 0); |
2162 | + if (!bp) { |
2163 | + error = -EFSCORRUPTED; |
2164 | + goto error0; |
2165 | + } |
2166 | xfs_trans_binval(args->tp, bp); |
2167 | } |
2168 | args->len = 1; |
2169 | @@ -2141,6 +2145,10 @@ xfs_alloc_fix_freelist( |
2170 | if (error) |
2171 | goto out_agbp_relse; |
2172 | bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0); |
2173 | + if (!bp) { |
2174 | + error = -EFSCORRUPTED; |
2175 | + goto out_agbp_relse; |
2176 | + } |
2177 | xfs_trans_binval(tp, bp); |
2178 | } |
2179 | |
2180 | diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c |
2181 | index 6f2a5baded76..5c6eb19664f2 100644 |
2182 | --- a/fs/xfs/libxfs/xfs_bmap.c |
2183 | +++ b/fs/xfs/libxfs/xfs_bmap.c |
2184 | @@ -3860,6 +3860,17 @@ xfs_trim_extent( |
2185 | } |
2186 | } |
2187 | |
2188 | +/* trim extent to within eof */ |
2189 | +void |
2190 | +xfs_trim_extent_eof( |
2191 | + struct xfs_bmbt_irec *irec, |
2192 | + struct xfs_inode *ip) |
2193 | + |
2194 | +{ |
2195 | + xfs_trim_extent(irec, 0, XFS_B_TO_FSB(ip->i_mount, |
2196 | + i_size_read(VFS_I(ip)))); |
2197 | +} |
2198 | + |
2199 | /* |
2200 | * Trim the returned map to the required bounds |
2201 | */ |
2202 | diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h |
2203 | index 851982a5dfbc..502e0d8fb4ff 100644 |
2204 | --- a/fs/xfs/libxfs/xfs_bmap.h |
2205 | +++ b/fs/xfs/libxfs/xfs_bmap.h |
2206 | @@ -208,6 +208,7 @@ void xfs_bmap_trace_exlist(struct xfs_inode *ip, xfs_extnum_t cnt, |
2207 | |
2208 | void xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno, |
2209 | xfs_filblks_t len); |
2210 | +void xfs_trim_extent_eof(struct xfs_bmbt_irec *, struct xfs_inode *); |
2211 | int xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd); |
2212 | void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); |
2213 | void xfs_bmap_add_free(struct xfs_mount *mp, struct xfs_defer_ops *dfops, |
2214 | diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h |
2215 | index 8372e9bcd7b6..71de185735e0 100644 |
2216 | --- a/fs/xfs/libxfs/xfs_log_format.h |
2217 | +++ b/fs/xfs/libxfs/xfs_log_format.h |
2218 | @@ -270,6 +270,7 @@ typedef struct xfs_inode_log_format { |
2219 | uint32_t ilf_fields; /* flags for fields logged */ |
2220 | uint16_t ilf_asize; /* size of attr d/ext/root */ |
2221 | uint16_t ilf_dsize; /* size of data/ext/root */ |
2222 | + uint32_t ilf_pad; /* pad for 64 bit boundary */ |
2223 | uint64_t ilf_ino; /* inode number */ |
2224 | union { |
2225 | uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
2226 | @@ -280,29 +281,17 @@ typedef struct xfs_inode_log_format { |
2227 | int32_t ilf_boffset; /* off of inode in buffer */ |
2228 | } xfs_inode_log_format_t; |
2229 | |
2230 | -typedef struct xfs_inode_log_format_32 { |
2231 | - uint16_t ilf_type; /* inode log item type */ |
2232 | - uint16_t ilf_size; /* size of this item */ |
2233 | - uint32_t ilf_fields; /* flags for fields logged */ |
2234 | - uint16_t ilf_asize; /* size of attr d/ext/root */ |
2235 | - uint16_t ilf_dsize; /* size of data/ext/root */ |
2236 | - uint64_t ilf_ino; /* inode number */ |
2237 | - union { |
2238 | - uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
2239 | - uuid_t ilfu_uuid; /* mount point value */ |
2240 | - } ilf_u; |
2241 | - int64_t ilf_blkno; /* blkno of inode buffer */ |
2242 | - int32_t ilf_len; /* len of inode buffer */ |
2243 | - int32_t ilf_boffset; /* off of inode in buffer */ |
2244 | -} __attribute__((packed)) xfs_inode_log_format_32_t; |
2245 | - |
2246 | -typedef struct xfs_inode_log_format_64 { |
2247 | +/* |
2248 | + * Old 32 bit systems will log in this format without the 64 bit |
2249 | + * alignment padding. Recovery will detect this and convert it to the |
2250 | + * correct format. |
2251 | + */ |
2252 | +struct xfs_inode_log_format_32 { |
2253 | uint16_t ilf_type; /* inode log item type */ |
2254 | uint16_t ilf_size; /* size of this item */ |
2255 | uint32_t ilf_fields; /* flags for fields logged */ |
2256 | uint16_t ilf_asize; /* size of attr d/ext/root */ |
2257 | uint16_t ilf_dsize; /* size of data/ext/root */ |
2258 | - uint32_t ilf_pad; /* pad for 64 bit boundary */ |
2259 | uint64_t ilf_ino; /* inode number */ |
2260 | union { |
2261 | uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
2262 | @@ -311,7 +300,7 @@ typedef struct xfs_inode_log_format_64 { |
2263 | int64_t ilf_blkno; /* blkno of inode buffer */ |
2264 | int32_t ilf_len; /* len of inode buffer */ |
2265 | int32_t ilf_boffset; /* off of inode in buffer */ |
2266 | -} xfs_inode_log_format_64_t; |
2267 | +} __attribute__((packed)); |
2268 | |
2269 | |
2270 | /* |
2271 | diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c |
2272 | index 7034e17535de..3354140de07e 100644 |
2273 | --- a/fs/xfs/xfs_acl.c |
2274 | +++ b/fs/xfs/xfs_acl.c |
2275 | @@ -247,6 +247,8 @@ xfs_set_mode(struct inode *inode, umode_t mode) |
2276 | int |
2277 | xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
2278 | { |
2279 | + umode_t mode; |
2280 | + bool set_mode = false; |
2281 | int error = 0; |
2282 | |
2283 | if (!acl) |
2284 | @@ -257,16 +259,24 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
2285 | return error; |
2286 | |
2287 | if (type == ACL_TYPE_ACCESS) { |
2288 | - umode_t mode; |
2289 | - |
2290 | error = posix_acl_update_mode(inode, &mode, &acl); |
2291 | if (error) |
2292 | return error; |
2293 | - error = xfs_set_mode(inode, mode); |
2294 | - if (error) |
2295 | - return error; |
2296 | + set_mode = true; |
2297 | } |
2298 | |
2299 | set_acl: |
2300 | - return __xfs_set_acl(inode, acl, type); |
2301 | + error = __xfs_set_acl(inode, acl, type); |
2302 | + if (error) |
2303 | + return error; |
2304 | + |
2305 | + /* |
2306 | + * We set the mode after successfully updating the ACL xattr because the |
2307 | + * xattr update can fail at ENOSPC and we don't want to change the mode |
2308 | + * if the ACL update hasn't been applied. |
2309 | + */ |
2310 | + if (set_mode) |
2311 | + error = xfs_set_mode(inode, mode); |
2312 | + |
2313 | + return error; |
2314 | } |
2315 | diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c |
2316 | index f9efd67f6fa1..41b767ecfe50 100644 |
2317 | --- a/fs/xfs/xfs_aops.c |
2318 | +++ b/fs/xfs/xfs_aops.c |
2319 | @@ -330,7 +330,8 @@ xfs_end_io( |
2320 | error = xfs_reflink_end_cow(ip, offset, size); |
2321 | break; |
2322 | case XFS_IO_UNWRITTEN: |
2323 | - error = xfs_iomap_write_unwritten(ip, offset, size); |
2324 | + /* writeback should never update isize */ |
2325 | + error = xfs_iomap_write_unwritten(ip, offset, size, false); |
2326 | break; |
2327 | default: |
2328 | ASSERT(!xfs_ioend_is_append(ioend) || ioend->io_append_trans); |
2329 | @@ -432,6 +433,19 @@ xfs_imap_valid( |
2330 | { |
2331 | offset >>= inode->i_blkbits; |
2332 | |
2333 | + /* |
2334 | + * We have to make sure the cached mapping is within EOF to protect |
2335 | + * against eofblocks trimming on file release leaving us with a stale |
2336 | + * mapping. Otherwise, a page for a subsequent file extending buffered |
2337 | + * write could get picked up by this writeback cycle and written to the |
2338 | + * wrong blocks. |
2339 | + * |
2340 | + * Note that what we really want here is a generic mapping invalidation |
2341 | + * mechanism to protect us from arbitrary extent modifying contexts, not |
2342 | + * just eofblocks. |
2343 | + */ |
2344 | + xfs_trim_extent_eof(imap, XFS_I(inode)); |
2345 | + |
2346 | return offset >= imap->br_startoff && |
2347 | offset < imap->br_startoff + imap->br_blockcount; |
2348 | } |
2349 | @@ -721,6 +735,14 @@ xfs_vm_invalidatepage( |
2350 | { |
2351 | trace_xfs_invalidatepage(page->mapping->host, page, offset, |
2352 | length); |
2353 | + |
2354 | + /* |
2355 | + * If we are invalidating the entire page, clear the dirty state from it |
2356 | + * so that we can check for attempts to release dirty cached pages in |
2357 | + * xfs_vm_releasepage(). |
2358 | + */ |
2359 | + if (offset == 0 && length >= PAGE_SIZE) |
2360 | + cancel_dirty_page(page); |
2361 | block_invalidatepage(page, offset, length); |
2362 | } |
2363 | |
2364 | @@ -1176,25 +1198,27 @@ xfs_vm_releasepage( |
2365 | * mm accommodates an old ext3 case where clean pages might not have had |
2366 | * the dirty bit cleared. Thus, it can send actual dirty pages to |
2367 | * ->releasepage() via shrink_active_list(). Conversely, |
2368 | - * block_invalidatepage() can send pages that are still marked dirty |
2369 | - * but otherwise have invalidated buffers. |
2370 | + * block_invalidatepage() can send pages that are still marked dirty but |
2371 | + * otherwise have invalidated buffers. |
2372 | * |
2373 | * We want to release the latter to avoid unnecessary buildup of the |
2374 | - * LRU, skip the former and warn if we've left any lingering |
2375 | - * delalloc/unwritten buffers on clean pages. Skip pages with delalloc |
2376 | - * or unwritten buffers and warn if the page is not dirty. Otherwise |
2377 | - * try to release the buffers. |
2378 | + * LRU, so xfs_vm_invalidatepage() clears the page dirty flag on pages |
2379 | + * that are entirely invalidated and need to be released. Hence the |
2380 | + * only time we should get dirty pages here is through |
2381 | + * shrink_active_list() and so we can simply skip those now. |
2382 | + * |
2383 | + * warn if we've left any lingering delalloc/unwritten buffers on clean |
2384 | + * or invalidated pages we are about to release. |
2385 | */ |
2386 | + if (PageDirty(page)) |
2387 | + return 0; |
2388 | + |
2389 | xfs_count_page_state(page, &delalloc, &unwritten); |
2390 | |
2391 | - if (delalloc) { |
2392 | - WARN_ON_ONCE(!PageDirty(page)); |
2393 | + if (WARN_ON_ONCE(delalloc)) |
2394 | return 0; |
2395 | - } |
2396 | - if (unwritten) { |
2397 | - WARN_ON_ONCE(!PageDirty(page)); |
2398 | + if (WARN_ON_ONCE(unwritten)) |
2399 | return 0; |
2400 | - } |
2401 | |
2402 | return try_to_free_buffers(page); |
2403 | } |
2404 | diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c |
2405 | index be0b79d8900f..c6643004e583 100644 |
2406 | --- a/fs/xfs/xfs_attr_inactive.c |
2407 | +++ b/fs/xfs/xfs_attr_inactive.c |
2408 | @@ -302,6 +302,8 @@ xfs_attr3_node_inactive( |
2409 | &bp, XFS_ATTR_FORK); |
2410 | if (error) |
2411 | return error; |
2412 | + node = bp->b_addr; |
2413 | + btree = dp->d_ops->node_tree_p(node); |
2414 | child_fsb = be32_to_cpu(btree[i + 1].before); |
2415 | xfs_trans_brelse(*trans, bp); |
2416 | } |
2417 | diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c |
2418 | index 3e9b7a4fb8fd..799c69a72f2c 100644 |
2419 | --- a/fs/xfs/xfs_bmap_util.c |
2420 | +++ b/fs/xfs/xfs_bmap_util.c |
2421 | @@ -84,6 +84,7 @@ xfs_zero_extent( |
2422 | GFP_NOFS, 0); |
2423 | } |
2424 | |
2425 | +#ifdef CONFIG_XFS_RT |
2426 | int |
2427 | xfs_bmap_rtalloc( |
2428 | struct xfs_bmalloca *ap) /* bmap alloc argument struct */ |
2429 | @@ -190,6 +191,7 @@ xfs_bmap_rtalloc( |
2430 | } |
2431 | return 0; |
2432 | } |
2433 | +#endif /* CONFIG_XFS_RT */ |
2434 | |
2435 | /* |
2436 | * Check if the endoff is outside the last extent. If so the caller will grow |
2437 | @@ -1459,7 +1461,19 @@ xfs_shift_file_space( |
2438 | return error; |
2439 | |
2440 | /* |
2441 | - * The extent shiting code works on extent granularity. So, if |
2442 | + * Clean out anything hanging around in the cow fork now that |
2443 | + * we've flushed all the dirty data out to disk to avoid having |
2444 | + * CoW extents at the wrong offsets. |
2445 | + */ |
2446 | + if (xfs_is_reflink_inode(ip)) { |
2447 | + error = xfs_reflink_cancel_cow_range(ip, offset, NULLFILEOFF, |
2448 | + true); |
2449 | + if (error) |
2450 | + return error; |
2451 | + } |
2452 | + |
2453 | + /* |
2454 | + * The extent shifting code works on extent granularity. So, if |
2455 | * stop_fsb is not the starting block of extent, we need to split |
2456 | * the extent at stop_fsb. |
2457 | */ |
2458 | @@ -2109,11 +2123,31 @@ xfs_swap_extents( |
2459 | ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK; |
2460 | tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; |
2461 | tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK; |
2462 | + } |
2463 | + |
2464 | + /* Swap the cow forks. */ |
2465 | + if (xfs_sb_version_hasreflink(&mp->m_sb)) { |
2466 | + xfs_extnum_t extnum; |
2467 | + |
2468 | + ASSERT(ip->i_cformat == XFS_DINODE_FMT_EXTENTS); |
2469 | + ASSERT(tip->i_cformat == XFS_DINODE_FMT_EXTENTS); |
2470 | + |
2471 | + extnum = ip->i_cnextents; |
2472 | + ip->i_cnextents = tip->i_cnextents; |
2473 | + tip->i_cnextents = extnum; |
2474 | + |
2475 | cowfp = ip->i_cowfp; |
2476 | ip->i_cowfp = tip->i_cowfp; |
2477 | tip->i_cowfp = cowfp; |
2478 | - xfs_inode_set_cowblocks_tag(ip); |
2479 | - xfs_inode_set_cowblocks_tag(tip); |
2480 | + |
2481 | + if (ip->i_cowfp && ip->i_cnextents) |
2482 | + xfs_inode_set_cowblocks_tag(ip); |
2483 | + else |
2484 | + xfs_inode_clear_cowblocks_tag(ip); |
2485 | + if (tip->i_cowfp && tip->i_cnextents) |
2486 | + xfs_inode_set_cowblocks_tag(tip); |
2487 | + else |
2488 | + xfs_inode_clear_cowblocks_tag(tip); |
2489 | } |
2490 | |
2491 | xfs_trans_log_inode(tp, ip, src_log_flags); |
2492 | diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h |
2493 | index 0cede1043571..fb8d0c7d1db8 100644 |
2494 | --- a/fs/xfs/xfs_bmap_util.h |
2495 | +++ b/fs/xfs/xfs_bmap_util.h |
2496 | @@ -28,7 +28,20 @@ struct xfs_mount; |
2497 | struct xfs_trans; |
2498 | struct xfs_bmalloca; |
2499 | |
2500 | +#ifdef CONFIG_XFS_RT |
2501 | int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); |
2502 | +#else /* !CONFIG_XFS_RT */ |
2503 | +/* |
2504 | + * Attempts to allocate RT extents when RT is disable indicates corruption and |
2505 | + * should trigger a shutdown. |
2506 | + */ |
2507 | +static inline int |
2508 | +xfs_bmap_rtalloc(struct xfs_bmalloca *ap) |
2509 | +{ |
2510 | + return -EFSCORRUPTED; |
2511 | +} |
2512 | +#endif /* CONFIG_XFS_RT */ |
2513 | + |
2514 | int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, |
2515 | int whichfork, int *eof); |
2516 | int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip, |
2517 | diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c |
2518 | index 2f4feb959bfb..028e50a36f95 100644 |
2519 | --- a/fs/xfs/xfs_error.c |
2520 | +++ b/fs/xfs/xfs_error.c |
2521 | @@ -344,7 +344,7 @@ xfs_verifier_error( |
2522 | { |
2523 | struct xfs_mount *mp = bp->b_target->bt_mount; |
2524 | |
2525 | - xfs_alert(mp, "Metadata %s detected at %pF, %s block 0x%llx", |
2526 | + xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx", |
2527 | bp->b_error == -EFSBADCRC ? "CRC error" : "corruption", |
2528 | __return_address, bp->b_ops->name, bp->b_bn); |
2529 | |
2530 | diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c |
2531 | index c4893e226fd8..ad5100ce8c44 100644 |
2532 | --- a/fs/xfs/xfs_file.c |
2533 | +++ b/fs/xfs/xfs_file.c |
2534 | @@ -58,7 +58,7 @@ xfs_zero_range( |
2535 | xfs_off_t count, |
2536 | bool *did_zero) |
2537 | { |
2538 | - return iomap_zero_range(VFS_I(ip), pos, count, NULL, &xfs_iomap_ops); |
2539 | + return iomap_zero_range(VFS_I(ip), pos, count, did_zero, &xfs_iomap_ops); |
2540 | } |
2541 | |
2542 | int |
2543 | @@ -432,7 +432,6 @@ xfs_dio_write_end_io( |
2544 | struct inode *inode = file_inode(iocb->ki_filp); |
2545 | struct xfs_inode *ip = XFS_I(inode); |
2546 | loff_t offset = iocb->ki_pos; |
2547 | - bool update_size = false; |
2548 | int error = 0; |
2549 | |
2550 | trace_xfs_end_io_direct_write(ip, offset, size); |
2551 | @@ -443,6 +442,21 @@ xfs_dio_write_end_io( |
2552 | if (size <= 0) |
2553 | return size; |
2554 | |
2555 | + if (flags & IOMAP_DIO_COW) { |
2556 | + error = xfs_reflink_end_cow(ip, offset, size); |
2557 | + if (error) |
2558 | + return error; |
2559 | + } |
2560 | + |
2561 | + /* |
2562 | + * Unwritten conversion updates the in-core isize after extent |
2563 | + * conversion but before updating the on-disk size. Updating isize any |
2564 | + * earlier allows a racing dio read to find unwritten extents before |
2565 | + * they are converted. |
2566 | + */ |
2567 | + if (flags & IOMAP_DIO_UNWRITTEN) |
2568 | + return xfs_iomap_write_unwritten(ip, offset, size, true); |
2569 | + |
2570 | /* |
2571 | * We need to update the in-core inode size here so that we don't end up |
2572 | * with the on-disk inode size being outside the in-core inode size. We |
2573 | @@ -457,20 +471,11 @@ xfs_dio_write_end_io( |
2574 | spin_lock(&ip->i_flags_lock); |
2575 | if (offset + size > i_size_read(inode)) { |
2576 | i_size_write(inode, offset + size); |
2577 | - update_size = true; |
2578 | - } |
2579 | - spin_unlock(&ip->i_flags_lock); |
2580 | - |
2581 | - if (flags & IOMAP_DIO_COW) { |
2582 | - error = xfs_reflink_end_cow(ip, offset, size); |
2583 | - if (error) |
2584 | - return error; |
2585 | - } |
2586 | - |
2587 | - if (flags & IOMAP_DIO_UNWRITTEN) |
2588 | - error = xfs_iomap_write_unwritten(ip, offset, size); |
2589 | - else if (update_size) |
2590 | + spin_unlock(&ip->i_flags_lock); |
2591 | error = xfs_setfilesize(ip, offset, size); |
2592 | + } else { |
2593 | + spin_unlock(&ip->i_flags_lock); |
2594 | + } |
2595 | |
2596 | return error; |
2597 | } |
2598 | diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c |
2599 | index 814ed729881d..43cfc07996a4 100644 |
2600 | --- a/fs/xfs/xfs_fsmap.c |
2601 | +++ b/fs/xfs/xfs_fsmap.c |
2602 | @@ -367,29 +367,6 @@ xfs_getfsmap_datadev_helper( |
2603 | return xfs_getfsmap_helper(cur->bc_tp, info, rec, rec_daddr); |
2604 | } |
2605 | |
2606 | -/* Transform a rtbitmap "record" into a fsmap */ |
2607 | -STATIC int |
2608 | -xfs_getfsmap_rtdev_rtbitmap_helper( |
2609 | - struct xfs_trans *tp, |
2610 | - struct xfs_rtalloc_rec *rec, |
2611 | - void *priv) |
2612 | -{ |
2613 | - struct xfs_mount *mp = tp->t_mountp; |
2614 | - struct xfs_getfsmap_info *info = priv; |
2615 | - struct xfs_rmap_irec irec; |
2616 | - xfs_daddr_t rec_daddr; |
2617 | - |
2618 | - rec_daddr = XFS_FSB_TO_BB(mp, rec->ar_startblock); |
2619 | - |
2620 | - irec.rm_startblock = rec->ar_startblock; |
2621 | - irec.rm_blockcount = rec->ar_blockcount; |
2622 | - irec.rm_owner = XFS_RMAP_OWN_NULL; /* "free" */ |
2623 | - irec.rm_offset = 0; |
2624 | - irec.rm_flags = 0; |
2625 | - |
2626 | - return xfs_getfsmap_helper(tp, info, &irec, rec_daddr); |
2627 | -} |
2628 | - |
2629 | /* Transform a bnobt irec into a fsmap */ |
2630 | STATIC int |
2631 | xfs_getfsmap_datadev_bnobt_helper( |
2632 | @@ -475,6 +452,30 @@ xfs_getfsmap_logdev( |
2633 | return xfs_getfsmap_helper(tp, info, &rmap, 0); |
2634 | } |
2635 | |
2636 | +#ifdef CONFIG_XFS_RT |
2637 | +/* Transform a rtbitmap "record" into a fsmap */ |
2638 | +STATIC int |
2639 | +xfs_getfsmap_rtdev_rtbitmap_helper( |
2640 | + struct xfs_trans *tp, |
2641 | + struct xfs_rtalloc_rec *rec, |
2642 | + void *priv) |
2643 | +{ |
2644 | + struct xfs_mount *mp = tp->t_mountp; |
2645 | + struct xfs_getfsmap_info *info = priv; |
2646 | + struct xfs_rmap_irec irec; |
2647 | + xfs_daddr_t rec_daddr; |
2648 | + |
2649 | + rec_daddr = XFS_FSB_TO_BB(mp, rec->ar_startblock); |
2650 | + |
2651 | + irec.rm_startblock = rec->ar_startblock; |
2652 | + irec.rm_blockcount = rec->ar_blockcount; |
2653 | + irec.rm_owner = XFS_RMAP_OWN_NULL; /* "free" */ |
2654 | + irec.rm_offset = 0; |
2655 | + irec.rm_flags = 0; |
2656 | + |
2657 | + return xfs_getfsmap_helper(tp, info, &irec, rec_daddr); |
2658 | +} |
2659 | + |
2660 | /* Execute a getfsmap query against the realtime device. */ |
2661 | STATIC int |
2662 | __xfs_getfsmap_rtdev( |
2663 | @@ -561,6 +562,7 @@ xfs_getfsmap_rtdev_rtbitmap( |
2664 | return __xfs_getfsmap_rtdev(tp, keys, xfs_getfsmap_rtdev_rtbitmap_query, |
2665 | info); |
2666 | } |
2667 | +#endif /* CONFIG_XFS_RT */ |
2668 | |
2669 | /* Execute a getfsmap query against the regular data device. */ |
2670 | STATIC int |
2671 | @@ -795,7 +797,15 @@ xfs_getfsmap_check_keys( |
2672 | return false; |
2673 | } |
2674 | |
2675 | +/* |
2676 | + * There are only two devices if we didn't configure RT devices at build time. |
2677 | + */ |
2678 | +#ifdef CONFIG_XFS_RT |
2679 | #define XFS_GETFSMAP_DEVS 3 |
2680 | +#else |
2681 | +#define XFS_GETFSMAP_DEVS 2 |
2682 | +#endif /* CONFIG_XFS_RT */ |
2683 | + |
2684 | /* |
2685 | * Get filesystem's extents as described in head, and format for |
2686 | * output. Calls formatter to fill the user's buffer until all |
2687 | @@ -853,10 +863,12 @@ xfs_getfsmap( |
2688 | handlers[1].dev = new_encode_dev(mp->m_logdev_targp->bt_dev); |
2689 | handlers[1].fn = xfs_getfsmap_logdev; |
2690 | } |
2691 | +#ifdef CONFIG_XFS_RT |
2692 | if (mp->m_rtdev_targp) { |
2693 | handlers[2].dev = new_encode_dev(mp->m_rtdev_targp->bt_dev); |
2694 | handlers[2].fn = xfs_getfsmap_rtdev_rtbitmap; |
2695 | } |
2696 | +#endif /* CONFIG_XFS_RT */ |
2697 | |
2698 | xfs_sort(handlers, XFS_GETFSMAP_DEVS, sizeof(struct xfs_getfsmap_dev), |
2699 | xfs_getfsmap_dev_compare); |
2700 | diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c |
2701 | index 97045e8dfed5..cd2e5b122b01 100644 |
2702 | --- a/fs/xfs/xfs_inode.c |
2703 | +++ b/fs/xfs/xfs_inode.c |
2704 | @@ -1623,10 +1623,12 @@ xfs_itruncate_extents( |
2705 | goto out; |
2706 | |
2707 | /* |
2708 | - * Clear the reflink flag if we truncated everything. |
2709 | + * Clear the reflink flag if there are no data fork blocks and |
2710 | + * there are no extents staged in the cow fork. |
2711 | */ |
2712 | - if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) { |
2713 | - ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; |
2714 | + if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) { |
2715 | + if (ip->i_d.di_nblocks == 0) |
2716 | + ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; |
2717 | xfs_inode_clear_cowblocks_tag(ip); |
2718 | } |
2719 | |
2720 | diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c |
2721 | index 6d0f74ec31e8..9bbc2d7cc8cb 100644 |
2722 | --- a/fs/xfs/xfs_inode_item.c |
2723 | +++ b/fs/xfs/xfs_inode_item.c |
2724 | @@ -364,6 +364,9 @@ xfs_inode_to_log_dinode( |
2725 | to->di_dmstate = from->di_dmstate; |
2726 | to->di_flags = from->di_flags; |
2727 | |
2728 | + /* log a dummy value to ensure log structure is fully initialised */ |
2729 | + to->di_next_unlinked = NULLAGINO; |
2730 | + |
2731 | if (from->di_version == 3) { |
2732 | to->di_changecount = inode->i_version; |
2733 | to->di_crtime.t_sec = from->di_crtime.t_sec; |
2734 | @@ -404,6 +407,11 @@ xfs_inode_item_format_core( |
2735 | * the second with the on-disk inode structure, and a possible third and/or |
2736 | * fourth with the inode data/extents/b-tree root and inode attributes |
2737 | * data/extents/b-tree root. |
2738 | + * |
2739 | + * Note: Always use the 64 bit inode log format structure so we don't |
2740 | + * leave an uninitialised hole in the format item on 64 bit systems. Log |
2741 | + * recovery on 32 bit systems handles this just fine, so there's no reason |
2742 | + * for not using an initialising the properly padded structure all the time. |
2743 | */ |
2744 | STATIC void |
2745 | xfs_inode_item_format( |
2746 | @@ -412,8 +420,8 @@ xfs_inode_item_format( |
2747 | { |
2748 | struct xfs_inode_log_item *iip = INODE_ITEM(lip); |
2749 | struct xfs_inode *ip = iip->ili_inode; |
2750 | - struct xfs_inode_log_format *ilf; |
2751 | struct xfs_log_iovec *vecp = NULL; |
2752 | + struct xfs_inode_log_format *ilf; |
2753 | |
2754 | ASSERT(ip->i_d.di_version > 1); |
2755 | |
2756 | @@ -425,7 +433,17 @@ xfs_inode_item_format( |
2757 | ilf->ilf_boffset = ip->i_imap.im_boffset; |
2758 | ilf->ilf_fields = XFS_ILOG_CORE; |
2759 | ilf->ilf_size = 2; /* format + core */ |
2760 | - xlog_finish_iovec(lv, vecp, sizeof(struct xfs_inode_log_format)); |
2761 | + |
2762 | + /* |
2763 | + * make sure we don't leak uninitialised data into the log in the case |
2764 | + * when we don't log every field in the inode. |
2765 | + */ |
2766 | + ilf->ilf_dsize = 0; |
2767 | + ilf->ilf_asize = 0; |
2768 | + ilf->ilf_pad = 0; |
2769 | + uuid_copy(&ilf->ilf_u.ilfu_uuid, &uuid_null); |
2770 | + |
2771 | + xlog_finish_iovec(lv, vecp, sizeof(*ilf)); |
2772 | |
2773 | xfs_inode_item_format_core(ip, lv, &vecp); |
2774 | xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp); |
2775 | @@ -745,7 +763,7 @@ xfs_iflush_done( |
2776 | */ |
2777 | iip = INODE_ITEM(blip); |
2778 | if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) || |
2779 | - lip->li_flags & XFS_LI_FAILED) |
2780 | + (blip->li_flags & XFS_LI_FAILED)) |
2781 | need_ail++; |
2782 | |
2783 | blip = next; |
2784 | @@ -855,44 +873,29 @@ xfs_istale_done( |
2785 | } |
2786 | |
2787 | /* |
2788 | - * convert an xfs_inode_log_format struct from either 32 or 64 bit versions |
2789 | - * (which can have different field alignments) to the native version |
2790 | + * convert an xfs_inode_log_format struct from the old 32 bit version |
2791 | + * (which can have different field alignments) to the native 64 bit version |
2792 | */ |
2793 | int |
2794 | xfs_inode_item_format_convert( |
2795 | - xfs_log_iovec_t *buf, |
2796 | - xfs_inode_log_format_t *in_f) |
2797 | + struct xfs_log_iovec *buf, |
2798 | + struct xfs_inode_log_format *in_f) |
2799 | { |
2800 | - if (buf->i_len == sizeof(xfs_inode_log_format_32_t)) { |
2801 | - xfs_inode_log_format_32_t *in_f32 = buf->i_addr; |
2802 | - |
2803 | - in_f->ilf_type = in_f32->ilf_type; |
2804 | - in_f->ilf_size = in_f32->ilf_size; |
2805 | - in_f->ilf_fields = in_f32->ilf_fields; |
2806 | - in_f->ilf_asize = in_f32->ilf_asize; |
2807 | - in_f->ilf_dsize = in_f32->ilf_dsize; |
2808 | - in_f->ilf_ino = in_f32->ilf_ino; |
2809 | - /* copy biggest field of ilf_u */ |
2810 | - uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid); |
2811 | - in_f->ilf_blkno = in_f32->ilf_blkno; |
2812 | - in_f->ilf_len = in_f32->ilf_len; |
2813 | - in_f->ilf_boffset = in_f32->ilf_boffset; |
2814 | - return 0; |
2815 | - } else if (buf->i_len == sizeof(xfs_inode_log_format_64_t)){ |
2816 | - xfs_inode_log_format_64_t *in_f64 = buf->i_addr; |
2817 | - |
2818 | - in_f->ilf_type = in_f64->ilf_type; |
2819 | - in_f->ilf_size = in_f64->ilf_size; |
2820 | - in_f->ilf_fields = in_f64->ilf_fields; |
2821 | - in_f->ilf_asize = in_f64->ilf_asize; |
2822 | - in_f->ilf_dsize = in_f64->ilf_dsize; |
2823 | - in_f->ilf_ino = in_f64->ilf_ino; |
2824 | - /* copy biggest field of ilf_u */ |
2825 | - uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f64->ilf_u.ilfu_uuid); |
2826 | - in_f->ilf_blkno = in_f64->ilf_blkno; |
2827 | - in_f->ilf_len = in_f64->ilf_len; |
2828 | - in_f->ilf_boffset = in_f64->ilf_boffset; |
2829 | - return 0; |
2830 | - } |
2831 | - return -EFSCORRUPTED; |
2832 | + struct xfs_inode_log_format_32 *in_f32 = buf->i_addr; |
2833 | + |
2834 | + if (buf->i_len != sizeof(*in_f32)) |
2835 | + return -EFSCORRUPTED; |
2836 | + |
2837 | + in_f->ilf_type = in_f32->ilf_type; |
2838 | + in_f->ilf_size = in_f32->ilf_size; |
2839 | + in_f->ilf_fields = in_f32->ilf_fields; |
2840 | + in_f->ilf_asize = in_f32->ilf_asize; |
2841 | + in_f->ilf_dsize = in_f32->ilf_dsize; |
2842 | + in_f->ilf_ino = in_f32->ilf_ino; |
2843 | + /* copy biggest field of ilf_u */ |
2844 | + uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid); |
2845 | + in_f->ilf_blkno = in_f32->ilf_blkno; |
2846 | + in_f->ilf_len = in_f32->ilf_len; |
2847 | + in_f->ilf_boffset = in_f32->ilf_boffset; |
2848 | + return 0; |
2849 | } |
2850 | diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c |
2851 | index 813394c62849..2cef389d8955 100644 |
2852 | --- a/fs/xfs/xfs_iomap.c |
2853 | +++ b/fs/xfs/xfs_iomap.c |
2854 | @@ -829,7 +829,8 @@ int |
2855 | xfs_iomap_write_unwritten( |
2856 | xfs_inode_t *ip, |
2857 | xfs_off_t offset, |
2858 | - xfs_off_t count) |
2859 | + xfs_off_t count, |
2860 | + bool update_isize) |
2861 | { |
2862 | xfs_mount_t *mp = ip->i_mount; |
2863 | xfs_fileoff_t offset_fsb; |
2864 | @@ -840,6 +841,7 @@ xfs_iomap_write_unwritten( |
2865 | xfs_trans_t *tp; |
2866 | xfs_bmbt_irec_t imap; |
2867 | struct xfs_defer_ops dfops; |
2868 | + struct inode *inode = VFS_I(ip); |
2869 | xfs_fsize_t i_size; |
2870 | uint resblks; |
2871 | int error; |
2872 | @@ -899,7 +901,8 @@ xfs_iomap_write_unwritten( |
2873 | i_size = XFS_FSB_TO_B(mp, offset_fsb + count_fsb); |
2874 | if (i_size > offset + count) |
2875 | i_size = offset + count; |
2876 | - |
2877 | + if (update_isize && i_size > i_size_read(inode)) |
2878 | + i_size_write(inode, i_size); |
2879 | i_size = xfs_new_eof(ip, i_size); |
2880 | if (i_size) { |
2881 | ip->i_d.di_size = i_size; |
2882 | diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h |
2883 | index 00db3ecea084..ee535065c5d0 100644 |
2884 | --- a/fs/xfs/xfs_iomap.h |
2885 | +++ b/fs/xfs/xfs_iomap.h |
2886 | @@ -27,7 +27,7 @@ int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t, |
2887 | struct xfs_bmbt_irec *, int); |
2888 | int xfs_iomap_write_allocate(struct xfs_inode *, int, xfs_off_t, |
2889 | struct xfs_bmbt_irec *); |
2890 | -int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t); |
2891 | +int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool); |
2892 | |
2893 | void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *, |
2894 | struct xfs_bmbt_irec *); |
2895 | diff --git a/fs/xfs/xfs_ondisk.h b/fs/xfs/xfs_ondisk.h |
2896 | index 0c381d71b242..0492436a053f 100644 |
2897 | --- a/fs/xfs/xfs_ondisk.h |
2898 | +++ b/fs/xfs/xfs_ondisk.h |
2899 | @@ -134,7 +134,7 @@ xfs_check_ondisk_structs(void) |
2900 | XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28); |
2901 | XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8); |
2902 | XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52); |
2903 | - XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56); |
2904 | + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56); |
2905 | XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20); |
2906 | XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16); |
2907 | } |
2908 | diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c |
2909 | index 2f2dc3c09ad0..4246876df7b7 100644 |
2910 | --- a/fs/xfs/xfs_pnfs.c |
2911 | +++ b/fs/xfs/xfs_pnfs.c |
2912 | @@ -274,7 +274,7 @@ xfs_fs_commit_blocks( |
2913 | (end - 1) >> PAGE_SHIFT); |
2914 | WARN_ON_ONCE(error); |
2915 | |
2916 | - error = xfs_iomap_write_unwritten(ip, start, length); |
2917 | + error = xfs_iomap_write_unwritten(ip, start, length, false); |
2918 | if (error) |
2919 | goto out_drop_iolock; |
2920 | } |
2921 | diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c |
2922 | index f45fbf0db9bb..8c8390a7f121 100644 |
2923 | --- a/fs/xfs/xfs_reflink.c |
2924 | +++ b/fs/xfs/xfs_reflink.c |
2925 | @@ -735,7 +735,13 @@ xfs_reflink_end_cow( |
2926 | /* If there is a hole at end_fsb - 1 go to the previous extent */ |
2927 | if (!xfs_iext_lookup_extent(ip, ifp, end_fsb - 1, &idx, &got) || |
2928 | got.br_startoff > end_fsb) { |
2929 | - ASSERT(idx > 0); |
2930 | + /* |
2931 | + * In case of racing, overlapping AIO writes no COW extents |
2932 | + * might be left by the time I/O completes for the loser of |
2933 | + * the race. In that case we are done. |
2934 | + */ |
2935 | + if (idx <= 0) |
2936 | + goto out_cancel; |
2937 | xfs_iext_get_extent(ifp, --idx, &got); |
2938 | } |
2939 | |
2940 | @@ -807,6 +813,7 @@ xfs_reflink_end_cow( |
2941 | |
2942 | out_defer: |
2943 | xfs_defer_cancel(&dfops); |
2944 | +out_cancel: |
2945 | xfs_trans_cancel(tp); |
2946 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
2947 | out: |
2948 | diff --git a/include/linux/key.h b/include/linux/key.h |
2949 | index e315e16b6ff8..8a15cabe928d 100644 |
2950 | --- a/include/linux/key.h |
2951 | +++ b/include/linux/key.h |
2952 | @@ -138,6 +138,11 @@ struct key_restriction { |
2953 | struct key_type *keytype; |
2954 | }; |
2955 | |
2956 | +enum key_state { |
2957 | + KEY_IS_UNINSTANTIATED, |
2958 | + KEY_IS_POSITIVE, /* Positively instantiated */ |
2959 | +}; |
2960 | + |
2961 | /*****************************************************************************/ |
2962 | /* |
2963 | * authentication token / access credential / keyring |
2964 | @@ -169,6 +174,7 @@ struct key { |
2965 | * - may not match RCU dereferenced payload |
2966 | * - payload should contain own length |
2967 | */ |
2968 | + short state; /* Key state (+) or rejection error (-) */ |
2969 | |
2970 | #ifdef KEY_DEBUGGING |
2971 | unsigned magic; |
2972 | @@ -176,18 +182,16 @@ struct key { |
2973 | #endif |
2974 | |
2975 | unsigned long flags; /* status flags (change with bitops) */ |
2976 | -#define KEY_FLAG_INSTANTIATED 0 /* set if key has been instantiated */ |
2977 | -#define KEY_FLAG_DEAD 1 /* set if key type has been deleted */ |
2978 | -#define KEY_FLAG_REVOKED 2 /* set if key had been revoked */ |
2979 | -#define KEY_FLAG_IN_QUOTA 3 /* set if key consumes quota */ |
2980 | -#define KEY_FLAG_USER_CONSTRUCT 4 /* set if key is being constructed in userspace */ |
2981 | -#define KEY_FLAG_NEGATIVE 5 /* set if key is negative */ |
2982 | -#define KEY_FLAG_ROOT_CAN_CLEAR 6 /* set if key can be cleared by root without permission */ |
2983 | -#define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */ |
2984 | -#define KEY_FLAG_BUILTIN 8 /* set if key is built in to the kernel */ |
2985 | -#define KEY_FLAG_ROOT_CAN_INVAL 9 /* set if key can be invalidated by root without permission */ |
2986 | -#define KEY_FLAG_KEEP 10 /* set if key should not be removed */ |
2987 | -#define KEY_FLAG_UID_KEYRING 11 /* set if key is a user or user session keyring */ |
2988 | +#define KEY_FLAG_DEAD 0 /* set if key type has been deleted */ |
2989 | +#define KEY_FLAG_REVOKED 1 /* set if key had been revoked */ |
2990 | +#define KEY_FLAG_IN_QUOTA 2 /* set if key consumes quota */ |
2991 | +#define KEY_FLAG_USER_CONSTRUCT 3 /* set if key is being constructed in userspace */ |
2992 | +#define KEY_FLAG_ROOT_CAN_CLEAR 4 /* set if key can be cleared by root without permission */ |
2993 | +#define KEY_FLAG_INVALIDATED 5 /* set if key has been invalidated */ |
2994 | +#define KEY_FLAG_BUILTIN 6 /* set if key is built in to the kernel */ |
2995 | +#define KEY_FLAG_ROOT_CAN_INVAL 7 /* set if key can be invalidated by root without permission */ |
2996 | +#define KEY_FLAG_KEEP 8 /* set if key should not be removed */ |
2997 | +#define KEY_FLAG_UID_KEYRING 9 /* set if key is a user or user session keyring */ |
2998 | |
2999 | /* the key type and key description string |
3000 | * - the desc is used to match a key against search criteria |
3001 | @@ -213,7 +217,6 @@ struct key { |
3002 | struct list_head name_link; |
3003 | struct assoc_array keys; |
3004 | }; |
3005 | - int reject_error; |
3006 | }; |
3007 | |
3008 | /* This is set on a keyring to restrict the addition of a link to a key |
3009 | @@ -353,17 +356,27 @@ extern void key_set_timeout(struct key *, unsigned); |
3010 | #define KEY_NEED_SETATTR 0x20 /* Require permission to change attributes */ |
3011 | #define KEY_NEED_ALL 0x3f /* All the above permissions */ |
3012 | |
3013 | +static inline short key_read_state(const struct key *key) |
3014 | +{ |
3015 | + /* Barrier versus mark_key_instantiated(). */ |
3016 | + return smp_load_acquire(&key->state); |
3017 | +} |
3018 | + |
3019 | /** |
3020 | - * key_is_instantiated - Determine if a key has been positively instantiated |
3021 | + * key_is_positive - Determine if a key has been positively instantiated |
3022 | * @key: The key to check. |
3023 | * |
3024 | * Return true if the specified key has been positively instantiated, false |
3025 | * otherwise. |
3026 | */ |
3027 | -static inline bool key_is_instantiated(const struct key *key) |
3028 | +static inline bool key_is_positive(const struct key *key) |
3029 | +{ |
3030 | + return key_read_state(key) == KEY_IS_POSITIVE; |
3031 | +} |
3032 | + |
3033 | +static inline bool key_is_negative(const struct key *key) |
3034 | { |
3035 | - return test_bit(KEY_FLAG_INSTANTIATED, &key->flags) && |
3036 | - !test_bit(KEY_FLAG_NEGATIVE, &key->flags); |
3037 | + return key_read_state(key) < 0; |
3038 | } |
3039 | |
3040 | #define dereference_key_rcu(KEY) \ |
3041 | diff --git a/include/linux/mbus.h b/include/linux/mbus.h |
3042 | index 0d3f14fd2621..4773145246ed 100644 |
3043 | --- a/include/linux/mbus.h |
3044 | +++ b/include/linux/mbus.h |
3045 | @@ -31,8 +31,8 @@ struct mbus_dram_target_info |
3046 | struct mbus_dram_window { |
3047 | u8 cs_index; |
3048 | u8 mbus_attr; |
3049 | - u32 base; |
3050 | - u32 size; |
3051 | + u64 base; |
3052 | + u64 size; |
3053 | } cs[4]; |
3054 | }; |
3055 | |
3056 | diff --git a/include/sound/control.h b/include/sound/control.h |
3057 | index bd7246de58e7..a1f1152bc687 100644 |
3058 | --- a/include/sound/control.h |
3059 | +++ b/include/sound/control.h |
3060 | @@ -248,6 +248,9 @@ int snd_ctl_add_vmaster_hook(struct snd_kcontrol *kctl, |
3061 | void *private_data); |
3062 | void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only); |
3063 | #define snd_ctl_sync_vmaster_hook(kctl) snd_ctl_sync_vmaster(kctl, true) |
3064 | +int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl, |
3065 | + int (*func)(struct snd_kcontrol *, void *), |
3066 | + void *arg); |
3067 | |
3068 | /* |
3069 | * Helper functions for jack-detection controls |
3070 | diff --git a/lib/digsig.c b/lib/digsig.c |
3071 | index 03d7c63837ae..6ba6fcd92dd1 100644 |
3072 | --- a/lib/digsig.c |
3073 | +++ b/lib/digsig.c |
3074 | @@ -87,6 +87,12 @@ static int digsig_verify_rsa(struct key *key, |
3075 | down_read(&key->sem); |
3076 | ukp = user_key_payload_locked(key); |
3077 | |
3078 | + if (!ukp) { |
3079 | + /* key was revoked before we acquired its semaphore */ |
3080 | + err = -EKEYREVOKED; |
3081 | + goto err1; |
3082 | + } |
3083 | + |
3084 | if (ukp->datalen < sizeof(*pkh)) |
3085 | goto err1; |
3086 | |
3087 | diff --git a/net/can/af_can.c b/net/can/af_can.c |
3088 | index 88edac0f3e36..df186cdcc2b4 100644 |
3089 | --- a/net/can/af_can.c |
3090 | +++ b/net/can/af_can.c |
3091 | @@ -875,9 +875,14 @@ static int can_pernet_init(struct net *net) |
3092 | spin_lock_init(&net->can.can_rcvlists_lock); |
3093 | net->can.can_rx_alldev_list = |
3094 | kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL); |
3095 | - |
3096 | + if (!net->can.can_rx_alldev_list) |
3097 | + goto out; |
3098 | net->can.can_stats = kzalloc(sizeof(struct s_stats), GFP_KERNEL); |
3099 | + if (!net->can.can_stats) |
3100 | + goto out_free_alldev_list; |
3101 | net->can.can_pstats = kzalloc(sizeof(struct s_pstats), GFP_KERNEL); |
3102 | + if (!net->can.can_pstats) |
3103 | + goto out_free_can_stats; |
3104 | |
3105 | if (IS_ENABLED(CONFIG_PROC_FS)) { |
3106 | /* the statistics are updated every second (timer triggered) */ |
3107 | @@ -892,6 +897,13 @@ static int can_pernet_init(struct net *net) |
3108 | } |
3109 | |
3110 | return 0; |
3111 | + |
3112 | + out_free_can_stats: |
3113 | + kfree(net->can.can_stats); |
3114 | + out_free_alldev_list: |
3115 | + kfree(net->can.can_rx_alldev_list); |
3116 | + out: |
3117 | + return -ENOMEM; |
3118 | } |
3119 | |
3120 | static void can_pernet_exit(struct net *net) |
3121 | diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c |
3122 | index 8737412c7b27..e1d4d898a007 100644 |
3123 | --- a/net/dns_resolver/dns_key.c |
3124 | +++ b/net/dns_resolver/dns_key.c |
3125 | @@ -224,7 +224,7 @@ static int dns_resolver_match_preparse(struct key_match_data *match_data) |
3126 | static void dns_resolver_describe(const struct key *key, struct seq_file *m) |
3127 | { |
3128 | seq_puts(m, key->description); |
3129 | - if (key_is_instantiated(key)) { |
3130 | + if (key_is_positive(key)) { |
3131 | int err = PTR_ERR(key->payload.data[dns_key_error]); |
3132 | |
3133 | if (err) |
3134 | diff --git a/samples/trace_events/trace-events-sample.c b/samples/trace_events/trace-events-sample.c |
3135 | index bc7fcf010a5b..446beb7ac48d 100644 |
3136 | --- a/samples/trace_events/trace-events-sample.c |
3137 | +++ b/samples/trace_events/trace-events-sample.c |
3138 | @@ -78,29 +78,37 @@ static int simple_thread_fn(void *arg) |
3139 | } |
3140 | |
3141 | static DEFINE_MUTEX(thread_mutex); |
3142 | +static bool simple_thread_cnt; |
3143 | |
3144 | int foo_bar_reg(void) |
3145 | { |
3146 | + mutex_lock(&thread_mutex); |
3147 | + if (simple_thread_cnt++) |
3148 | + goto out; |
3149 | + |
3150 | pr_info("Starting thread for foo_bar_fn\n"); |
3151 | /* |
3152 | * We shouldn't be able to start a trace when the module is |
3153 | * unloading (there's other locks to prevent that). But |
3154 | * for consistency sake, we still take the thread_mutex. |
3155 | */ |
3156 | - mutex_lock(&thread_mutex); |
3157 | simple_tsk_fn = kthread_run(simple_thread_fn, NULL, "event-sample-fn"); |
3158 | + out: |
3159 | mutex_unlock(&thread_mutex); |
3160 | return 0; |
3161 | } |
3162 | |
3163 | void foo_bar_unreg(void) |
3164 | { |
3165 | - pr_info("Killing thread for foo_bar_fn\n"); |
3166 | - /* protect against module unloading */ |
3167 | mutex_lock(&thread_mutex); |
3168 | + if (--simple_thread_cnt) |
3169 | + goto out; |
3170 | + |
3171 | + pr_info("Killing thread for foo_bar_fn\n"); |
3172 | if (simple_tsk_fn) |
3173 | kthread_stop(simple_tsk_fn); |
3174 | simple_tsk_fn = NULL; |
3175 | + out: |
3176 | mutex_unlock(&thread_mutex); |
3177 | } |
3178 | |
3179 | diff --git a/security/keys/big_key.c b/security/keys/big_key.c |
3180 | index 9c3b16ee1768..ad39a0bdf846 100644 |
3181 | --- a/security/keys/big_key.c |
3182 | +++ b/security/keys/big_key.c |
3183 | @@ -247,7 +247,7 @@ void big_key_revoke(struct key *key) |
3184 | |
3185 | /* clear the quota */ |
3186 | key_payload_reserve(key, 0); |
3187 | - if (key_is_instantiated(key) && |
3188 | + if (key_is_positive(key) && |
3189 | (size_t)key->payload.data[big_key_len] > BIG_KEY_FILE_THRESHOLD) |
3190 | vfs_truncate(path, 0); |
3191 | } |
3192 | @@ -279,7 +279,7 @@ void big_key_describe(const struct key *key, struct seq_file *m) |
3193 | |
3194 | seq_puts(m, key->description); |
3195 | |
3196 | - if (key_is_instantiated(key)) |
3197 | + if (key_is_positive(key)) |
3198 | seq_printf(m, ": %zu [%s]", |
3199 | datalen, |
3200 | datalen > BIG_KEY_FILE_THRESHOLD ? "file" : "buff"); |
3201 | diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c |
3202 | index 69855ba0d3b3..d92cbf9687c3 100644 |
3203 | --- a/security/keys/encrypted-keys/encrypted.c |
3204 | +++ b/security/keys/encrypted-keys/encrypted.c |
3205 | @@ -309,6 +309,13 @@ static struct key *request_user_key(const char *master_desc, const u8 **master_k |
3206 | |
3207 | down_read(&ukey->sem); |
3208 | upayload = user_key_payload_locked(ukey); |
3209 | + if (!upayload) { |
3210 | + /* key was revoked before we acquired its semaphore */ |
3211 | + up_read(&ukey->sem); |
3212 | + key_put(ukey); |
3213 | + ukey = ERR_PTR(-EKEYREVOKED); |
3214 | + goto error; |
3215 | + } |
3216 | *master_key = upayload->data; |
3217 | *master_keylen = upayload->datalen; |
3218 | error: |
3219 | @@ -847,7 +854,7 @@ static int encrypted_update(struct key *key, struct key_preparsed_payload *prep) |
3220 | size_t datalen = prep->datalen; |
3221 | int ret = 0; |
3222 | |
3223 | - if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) |
3224 | + if (key_is_negative(key)) |
3225 | return -ENOKEY; |
3226 | if (datalen <= 0 || datalen > 32767 || !prep->data) |
3227 | return -EINVAL; |
3228 | diff --git a/security/keys/gc.c b/security/keys/gc.c |
3229 | index 87cb260e4890..f01d48cb3de1 100644 |
3230 | --- a/security/keys/gc.c |
3231 | +++ b/security/keys/gc.c |
3232 | @@ -129,15 +129,15 @@ static noinline void key_gc_unused_keys(struct list_head *keys) |
3233 | while (!list_empty(keys)) { |
3234 | struct key *key = |
3235 | list_entry(keys->next, struct key, graveyard_link); |
3236 | + short state = key->state; |
3237 | + |
3238 | list_del(&key->graveyard_link); |
3239 | |
3240 | kdebug("- %u", key->serial); |
3241 | key_check(key); |
3242 | |
3243 | /* Throw away the key data if the key is instantiated */ |
3244 | - if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags) && |
3245 | - !test_bit(KEY_FLAG_NEGATIVE, &key->flags) && |
3246 | - key->type->destroy) |
3247 | + if (state == KEY_IS_POSITIVE && key->type->destroy) |
3248 | key->type->destroy(key); |
3249 | |
3250 | security_key_free(key); |
3251 | @@ -151,7 +151,7 @@ static noinline void key_gc_unused_keys(struct list_head *keys) |
3252 | } |
3253 | |
3254 | atomic_dec(&key->user->nkeys); |
3255 | - if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) |
3256 | + if (state != KEY_IS_UNINSTANTIATED) |
3257 | atomic_dec(&key->user->nikeys); |
3258 | |
3259 | key_user_put(key->user); |
3260 | diff --git a/security/keys/key.c b/security/keys/key.c |
3261 | index e5c0896c3a8f..3186c769f300 100644 |
3262 | --- a/security/keys/key.c |
3263 | +++ b/security/keys/key.c |
3264 | @@ -401,6 +401,18 @@ int key_payload_reserve(struct key *key, size_t datalen) |
3265 | } |
3266 | EXPORT_SYMBOL(key_payload_reserve); |
3267 | |
3268 | +/* |
3269 | + * Change the key state to being instantiated. |
3270 | + */ |
3271 | +static void mark_key_instantiated(struct key *key, int reject_error) |
3272 | +{ |
3273 | + /* Commit the payload before setting the state; barrier versus |
3274 | + * key_read_state(). |
3275 | + */ |
3276 | + smp_store_release(&key->state, |
3277 | + (reject_error < 0) ? reject_error : KEY_IS_POSITIVE); |
3278 | +} |
3279 | + |
3280 | /* |
3281 | * Instantiate a key and link it into the target keyring atomically. Must be |
3282 | * called with the target keyring's semaphore writelocked. The target key's |
3283 | @@ -424,14 +436,14 @@ static int __key_instantiate_and_link(struct key *key, |
3284 | mutex_lock(&key_construction_mutex); |
3285 | |
3286 | /* can't instantiate twice */ |
3287 | - if (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { |
3288 | + if (key->state == KEY_IS_UNINSTANTIATED) { |
3289 | /* instantiate the key */ |
3290 | ret = key->type->instantiate(key, prep); |
3291 | |
3292 | if (ret == 0) { |
3293 | /* mark the key as being instantiated */ |
3294 | atomic_inc(&key->user->nikeys); |
3295 | - set_bit(KEY_FLAG_INSTANTIATED, &key->flags); |
3296 | + mark_key_instantiated(key, 0); |
3297 | |
3298 | if (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags)) |
3299 | awaken = 1; |
3300 | @@ -577,13 +589,10 @@ int key_reject_and_link(struct key *key, |
3301 | mutex_lock(&key_construction_mutex); |
3302 | |
3303 | /* can't instantiate twice */ |
3304 | - if (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { |
3305 | + if (key->state == KEY_IS_UNINSTANTIATED) { |
3306 | /* mark the key as being negatively instantiated */ |
3307 | atomic_inc(&key->user->nikeys); |
3308 | - key->reject_error = -error; |
3309 | - smp_wmb(); |
3310 | - set_bit(KEY_FLAG_NEGATIVE, &key->flags); |
3311 | - set_bit(KEY_FLAG_INSTANTIATED, &key->flags); |
3312 | + mark_key_instantiated(key, -error); |
3313 | now = current_kernel_time(); |
3314 | key->expiry = now.tv_sec + timeout; |
3315 | key_schedule_gc(key->expiry + key_gc_delay); |
3316 | @@ -752,8 +761,8 @@ static inline key_ref_t __key_update(key_ref_t key_ref, |
3317 | |
3318 | ret = key->type->update(key, prep); |
3319 | if (ret == 0) |
3320 | - /* updating a negative key instantiates it */ |
3321 | - clear_bit(KEY_FLAG_NEGATIVE, &key->flags); |
3322 | + /* Updating a negative key positively instantiates it */ |
3323 | + mark_key_instantiated(key, 0); |
3324 | |
3325 | up_write(&key->sem); |
3326 | |
3327 | @@ -936,6 +945,16 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, |
3328 | */ |
3329 | __key_link_end(keyring, &index_key, edit); |
3330 | |
3331 | + key = key_ref_to_ptr(key_ref); |
3332 | + if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags)) { |
3333 | + ret = wait_for_key_construction(key, true); |
3334 | + if (ret < 0) { |
3335 | + key_ref_put(key_ref); |
3336 | + key_ref = ERR_PTR(ret); |
3337 | + goto error_free_prep; |
3338 | + } |
3339 | + } |
3340 | + |
3341 | key_ref = __key_update(key_ref, &prep); |
3342 | goto error_free_prep; |
3343 | } |
3344 | @@ -986,8 +1005,8 @@ int key_update(key_ref_t key_ref, const void *payload, size_t plen) |
3345 | |
3346 | ret = key->type->update(key, &prep); |
3347 | if (ret == 0) |
3348 | - /* updating a negative key instantiates it */ |
3349 | - clear_bit(KEY_FLAG_NEGATIVE, &key->flags); |
3350 | + /* Updating a negative key positively instantiates it */ |
3351 | + mark_key_instantiated(key, 0); |
3352 | |
3353 | up_write(&key->sem); |
3354 | |
3355 | diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c |
3356 | index 6a82090c7fc1..2eb624c0aefc 100644 |
3357 | --- a/security/keys/keyctl.c |
3358 | +++ b/security/keys/keyctl.c |
3359 | @@ -766,10 +766,9 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) |
3360 | |
3361 | key = key_ref_to_ptr(key_ref); |
3362 | |
3363 | - if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { |
3364 | - ret = -ENOKEY; |
3365 | - goto error2; |
3366 | - } |
3367 | + ret = key_read_state(key); |
3368 | + if (ret < 0) |
3369 | + goto error2; /* Negatively instantiated */ |
3370 | |
3371 | /* see if we can read it directly */ |
3372 | ret = key_permission(key_ref, KEY_NEED_READ); |
3373 | @@ -901,7 +900,7 @@ long keyctl_chown_key(key_serial_t id, uid_t user, gid_t group) |
3374 | atomic_dec(&key->user->nkeys); |
3375 | atomic_inc(&newowner->nkeys); |
3376 | |
3377 | - if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { |
3378 | + if (key->state != KEY_IS_UNINSTANTIATED) { |
3379 | atomic_dec(&key->user->nikeys); |
3380 | atomic_inc(&newowner->nikeys); |
3381 | } |
3382 | diff --git a/security/keys/keyring.c b/security/keys/keyring.c |
3383 | index 4fa82a8a9c0e..06173b091a74 100644 |
3384 | --- a/security/keys/keyring.c |
3385 | +++ b/security/keys/keyring.c |
3386 | @@ -414,7 +414,7 @@ static void keyring_describe(const struct key *keyring, struct seq_file *m) |
3387 | else |
3388 | seq_puts(m, "[anon]"); |
3389 | |
3390 | - if (key_is_instantiated(keyring)) { |
3391 | + if (key_is_positive(keyring)) { |
3392 | if (keyring->keys.nr_leaves_on_tree != 0) |
3393 | seq_printf(m, ": %lu", keyring->keys.nr_leaves_on_tree); |
3394 | else |
3395 | @@ -553,7 +553,8 @@ static int keyring_search_iterator(const void *object, void *iterator_data) |
3396 | { |
3397 | struct keyring_search_context *ctx = iterator_data; |
3398 | const struct key *key = keyring_ptr_to_key(object); |
3399 | - unsigned long kflags = key->flags; |
3400 | + unsigned long kflags = READ_ONCE(key->flags); |
3401 | + short state = READ_ONCE(key->state); |
3402 | |
3403 | kenter("{%d}", key->serial); |
3404 | |
3405 | @@ -597,9 +598,8 @@ static int keyring_search_iterator(const void *object, void *iterator_data) |
3406 | |
3407 | if (ctx->flags & KEYRING_SEARCH_DO_STATE_CHECK) { |
3408 | /* we set a different error code if we pass a negative key */ |
3409 | - if (kflags & (1 << KEY_FLAG_NEGATIVE)) { |
3410 | - smp_rmb(); |
3411 | - ctx->result = ERR_PTR(key->reject_error); |
3412 | + if (state < 0) { |
3413 | + ctx->result = ERR_PTR(state); |
3414 | kleave(" = %d [neg]", ctx->skipped_ret); |
3415 | goto skipped; |
3416 | } |
3417 | diff --git a/security/keys/proc.c b/security/keys/proc.c |
3418 | index bf08d02b6646..e6aa1b257578 100644 |
3419 | --- a/security/keys/proc.c |
3420 | +++ b/security/keys/proc.c |
3421 | @@ -182,6 +182,7 @@ static int proc_keys_show(struct seq_file *m, void *v) |
3422 | unsigned long timo; |
3423 | key_ref_t key_ref, skey_ref; |
3424 | char xbuf[16]; |
3425 | + short state; |
3426 | int rc; |
3427 | |
3428 | struct keyring_search_context ctx = { |
3429 | @@ -240,17 +241,19 @@ static int proc_keys_show(struct seq_file *m, void *v) |
3430 | sprintf(xbuf, "%luw", timo / (60*60*24*7)); |
3431 | } |
3432 | |
3433 | + state = key_read_state(key); |
3434 | + |
3435 | #define showflag(KEY, LETTER, FLAG) \ |
3436 | (test_bit(FLAG, &(KEY)->flags) ? LETTER : '-') |
3437 | |
3438 | seq_printf(m, "%08x %c%c%c%c%c%c%c %5d %4s %08x %5d %5d %-9.9s ", |
3439 | key->serial, |
3440 | - showflag(key, 'I', KEY_FLAG_INSTANTIATED), |
3441 | + state != KEY_IS_UNINSTANTIATED ? 'I' : '-', |
3442 | showflag(key, 'R', KEY_FLAG_REVOKED), |
3443 | showflag(key, 'D', KEY_FLAG_DEAD), |
3444 | showflag(key, 'Q', KEY_FLAG_IN_QUOTA), |
3445 | showflag(key, 'U', KEY_FLAG_USER_CONSTRUCT), |
3446 | - showflag(key, 'N', KEY_FLAG_NEGATIVE), |
3447 | + state < 0 ? 'N' : '-', |
3448 | showflag(key, 'i', KEY_FLAG_INVALIDATED), |
3449 | refcount_read(&key->usage), |
3450 | xbuf, |
3451 | diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c |
3452 | index 293d3598153b..740affd65ee9 100644 |
3453 | --- a/security/keys/process_keys.c |
3454 | +++ b/security/keys/process_keys.c |
3455 | @@ -730,7 +730,7 @@ key_ref_t lookup_user_key(key_serial_t id, unsigned long lflags, |
3456 | |
3457 | ret = -EIO; |
3458 | if (!(lflags & KEY_LOOKUP_PARTIAL) && |
3459 | - !test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) |
3460 | + key_read_state(key) == KEY_IS_UNINSTANTIATED) |
3461 | goto invalid_key; |
3462 | |
3463 | /* check the permissions */ |
3464 | diff --git a/security/keys/request_key.c b/security/keys/request_key.c |
3465 | index 63e63a42db3c..e8036cd0ad54 100644 |
3466 | --- a/security/keys/request_key.c |
3467 | +++ b/security/keys/request_key.c |
3468 | @@ -595,10 +595,9 @@ int wait_for_key_construction(struct key *key, bool intr) |
3469 | intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); |
3470 | if (ret) |
3471 | return -ERESTARTSYS; |
3472 | - if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { |
3473 | - smp_rmb(); |
3474 | - return key->reject_error; |
3475 | - } |
3476 | + ret = key_read_state(key); |
3477 | + if (ret < 0) |
3478 | + return ret; |
3479 | return key_validate(key); |
3480 | } |
3481 | EXPORT_SYMBOL(wait_for_key_construction); |
3482 | diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c |
3483 | index afe9d22ab361..4a740e50322b 100644 |
3484 | --- a/security/keys/request_key_auth.c |
3485 | +++ b/security/keys/request_key_auth.c |
3486 | @@ -73,7 +73,7 @@ static void request_key_auth_describe(const struct key *key, |
3487 | |
3488 | seq_puts(m, "key:"); |
3489 | seq_puts(m, key->description); |
3490 | - if (key_is_instantiated(key)) |
3491 | + if (key_is_positive(key)) |
3492 | seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len); |
3493 | } |
3494 | |
3495 | diff --git a/security/keys/trusted.c b/security/keys/trusted.c |
3496 | index ddfaebf60fc8..bd85315cbfeb 100644 |
3497 | --- a/security/keys/trusted.c |
3498 | +++ b/security/keys/trusted.c |
3499 | @@ -1066,7 +1066,7 @@ static int trusted_update(struct key *key, struct key_preparsed_payload *prep) |
3500 | char *datablob; |
3501 | int ret = 0; |
3502 | |
3503 | - if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) |
3504 | + if (key_is_negative(key)) |
3505 | return -ENOKEY; |
3506 | p = key->payload.data[0]; |
3507 | if (!p->migratable) |
3508 | diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c |
3509 | index 3d8c68eba516..9f558bedba23 100644 |
3510 | --- a/security/keys/user_defined.c |
3511 | +++ b/security/keys/user_defined.c |
3512 | @@ -114,7 +114,7 @@ int user_update(struct key *key, struct key_preparsed_payload *prep) |
3513 | |
3514 | /* attach the new data, displacing the old */ |
3515 | key->expiry = prep->expiry; |
3516 | - if (!test_bit(KEY_FLAG_NEGATIVE, &key->flags)) |
3517 | + if (key_is_positive(key)) |
3518 | zap = dereference_key_locked(key); |
3519 | rcu_assign_keypointer(key, prep->payload.data[0]); |
3520 | prep->payload.data[0] = NULL; |
3521 | @@ -162,7 +162,7 @@ EXPORT_SYMBOL_GPL(user_destroy); |
3522 | void user_describe(const struct key *key, struct seq_file *m) |
3523 | { |
3524 | seq_puts(m, key->description); |
3525 | - if (key_is_instantiated(key)) |
3526 | + if (key_is_positive(key)) |
3527 | seq_printf(m, ": %u", key->datalen); |
3528 | } |
3529 | |
3530 | diff --git a/sound/core/seq/seq_lock.c b/sound/core/seq/seq_lock.c |
3531 | index 0ff7926a5a69..cda64b489e42 100644 |
3532 | --- a/sound/core/seq/seq_lock.c |
3533 | +++ b/sound/core/seq/seq_lock.c |
3534 | @@ -23,8 +23,6 @@ |
3535 | #include <sound/core.h> |
3536 | #include "seq_lock.h" |
3537 | |
3538 | -#if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG) |
3539 | - |
3540 | /* wait until all locks are released */ |
3541 | void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line) |
3542 | { |
3543 | @@ -41,5 +39,3 @@ void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line) |
3544 | } |
3545 | } |
3546 | EXPORT_SYMBOL(snd_use_lock_sync_helper); |
3547 | - |
3548 | -#endif |
3549 | diff --git a/sound/core/seq/seq_lock.h b/sound/core/seq/seq_lock.h |
3550 | index 54044bc2c9ef..ac38031c370e 100644 |
3551 | --- a/sound/core/seq/seq_lock.h |
3552 | +++ b/sound/core/seq/seq_lock.h |
3553 | @@ -3,8 +3,6 @@ |
3554 | |
3555 | #include <linux/sched.h> |
3556 | |
3557 | -#if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG) |
3558 | - |
3559 | typedef atomic_t snd_use_lock_t; |
3560 | |
3561 | /* initialize lock */ |
3562 | @@ -20,14 +18,4 @@ typedef atomic_t snd_use_lock_t; |
3563 | void snd_use_lock_sync_helper(snd_use_lock_t *lock, const char *file, int line); |
3564 | #define snd_use_lock_sync(lockp) snd_use_lock_sync_helper(lockp, __BASE_FILE__, __LINE__) |
3565 | |
3566 | -#else /* SMP || CONFIG_SND_DEBUG */ |
3567 | - |
3568 | -typedef spinlock_t snd_use_lock_t; /* dummy */ |
3569 | -#define snd_use_lock_init(lockp) /**/ |
3570 | -#define snd_use_lock_use(lockp) /**/ |
3571 | -#define snd_use_lock_free(lockp) /**/ |
3572 | -#define snd_use_lock_sync(lockp) /**/ |
3573 | - |
3574 | -#endif /* SMP || CONFIG_SND_DEBUG */ |
3575 | - |
3576 | #endif /* __SND_SEQ_LOCK_H */ |
3577 | diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c |
3578 | index 6c58e6f73a01..e43af18d4383 100644 |
3579 | --- a/sound/core/vmaster.c |
3580 | +++ b/sound/core/vmaster.c |
3581 | @@ -484,3 +484,34 @@ void snd_ctl_sync_vmaster(struct snd_kcontrol *kcontrol, bool hook_only) |
3582 | master->hook(master->hook_private_data, master->val); |
3583 | } |
3584 | EXPORT_SYMBOL_GPL(snd_ctl_sync_vmaster); |
3585 | + |
3586 | +/** |
3587 | + * snd_ctl_apply_vmaster_slaves - Apply function to each vmaster slave |
3588 | + * @kctl: vmaster kctl element |
3589 | + * @func: function to apply |
3590 | + * @arg: optional function argument |
3591 | + * |
3592 | + * Apply the function @func to each slave kctl of the given vmaster kctl. |
3593 | + * Returns 0 if successful, or a negative error code. |
3594 | + */ |
3595 | +int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl, |
3596 | + int (*func)(struct snd_kcontrol *, void *), |
3597 | + void *arg) |
3598 | +{ |
3599 | + struct link_master *master; |
3600 | + struct link_slave *slave; |
3601 | + int err; |
3602 | + |
3603 | + master = snd_kcontrol_chip(kctl); |
3604 | + err = master_init(master); |
3605 | + if (err < 0) |
3606 | + return err; |
3607 | + list_for_each_entry(slave, &master->slaves, list) { |
3608 | + err = func(&slave->slave, arg); |
3609 | + if (err < 0) |
3610 | + return err; |
3611 | + } |
3612 | + |
3613 | + return 0; |
3614 | +} |
3615 | +EXPORT_SYMBOL_GPL(snd_ctl_apply_vmaster_slaves); |
3616 | diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c |
3617 | index 978dc1801b3a..f6d2985b2520 100644 |
3618 | --- a/sound/hda/hdac_controller.c |
3619 | +++ b/sound/hda/hdac_controller.c |
3620 | @@ -284,6 +284,11 @@ int snd_hdac_bus_parse_capabilities(struct hdac_bus *bus) |
3621 | dev_dbg(bus->dev, "HDA capability ID: 0x%x\n", |
3622 | (cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF); |
3623 | |
3624 | + if (cur_cap == -1) { |
3625 | + dev_dbg(bus->dev, "Invalid capability reg read\n"); |
3626 | + break; |
3627 | + } |
3628 | + |
3629 | switch ((cur_cap & AZX_CAP_HDR_ID_MASK) >> AZX_CAP_HDR_ID_OFF) { |
3630 | case AZX_ML_CAP_ID: |
3631 | dev_dbg(bus->dev, "Found ML capability\n"); |
3632 | diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c |
3633 | index 821aad374a06..0bb46966d2d4 100644 |
3634 | --- a/sound/pci/hda/hda_codec.c |
3635 | +++ b/sound/pci/hda/hda_codec.c |
3636 | @@ -1803,36 +1803,6 @@ static int check_slave_present(struct hda_codec *codec, |
3637 | return 1; |
3638 | } |
3639 | |
3640 | -/* guess the value corresponding to 0dB */ |
3641 | -static int get_kctl_0dB_offset(struct hda_codec *codec, |
3642 | - struct snd_kcontrol *kctl, int *step_to_check) |
3643 | -{ |
3644 | - int _tlv[4]; |
3645 | - const int *tlv = NULL; |
3646 | - int val = -1; |
3647 | - |
3648 | - if ((kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) && |
3649 | - kctl->tlv.c == snd_hda_mixer_amp_tlv) { |
3650 | - get_ctl_amp_tlv(kctl, _tlv); |
3651 | - tlv = _tlv; |
3652 | - } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) |
3653 | - tlv = kctl->tlv.p; |
3654 | - if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) { |
3655 | - int step = tlv[3]; |
3656 | - step &= ~TLV_DB_SCALE_MUTE; |
3657 | - if (!step) |
3658 | - return -1; |
3659 | - if (*step_to_check && *step_to_check != step) { |
3660 | - codec_err(codec, "Mismatching dB step for vmaster slave (%d!=%d)\n", |
3661 | -- *step_to_check, step); |
3662 | - return -1; |
3663 | - } |
3664 | - *step_to_check = step; |
3665 | - val = -tlv[2] / step; |
3666 | - } |
3667 | - return val; |
3668 | -} |
3669 | - |
3670 | /* call kctl->put with the given value(s) */ |
3671 | static int put_kctl_with_value(struct snd_kcontrol *kctl, int val) |
3672 | { |
3673 | @@ -1847,19 +1817,58 @@ static int put_kctl_with_value(struct snd_kcontrol *kctl, int val) |
3674 | return 0; |
3675 | } |
3676 | |
3677 | -/* initialize the slave volume with 0dB */ |
3678 | -static int init_slave_0dB(struct hda_codec *codec, |
3679 | - void *data, struct snd_kcontrol *slave) |
3680 | +struct slave_init_arg { |
3681 | + struct hda_codec *codec; |
3682 | + int step; |
3683 | +}; |
3684 | + |
3685 | +/* initialize the slave volume with 0dB via snd_ctl_apply_vmaster_slaves() */ |
3686 | +static int init_slave_0dB(struct snd_kcontrol *kctl, void *_arg) |
3687 | { |
3688 | - int offset = get_kctl_0dB_offset(codec, slave, data); |
3689 | - if (offset > 0) |
3690 | - put_kctl_with_value(slave, offset); |
3691 | + struct slave_init_arg *arg = _arg; |
3692 | + int _tlv[4]; |
3693 | + const int *tlv = NULL; |
3694 | + int step; |
3695 | + int val; |
3696 | + |
3697 | + if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { |
3698 | + if (kctl->tlv.c != snd_hda_mixer_amp_tlv) { |
3699 | + codec_err(arg->codec, |
3700 | + "Unexpected TLV callback for slave %s:%d\n", |
3701 | + kctl->id.name, kctl->id.index); |
3702 | + return 0; /* ignore */ |
3703 | + } |
3704 | + get_ctl_amp_tlv(kctl, _tlv); |
3705 | + tlv = _tlv; |
3706 | + } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) |
3707 | + tlv = kctl->tlv.p; |
3708 | + |
3709 | + if (!tlv || tlv[0] != SNDRV_CTL_TLVT_DB_SCALE) |
3710 | + return 0; |
3711 | + |
3712 | + step = tlv[3]; |
3713 | + step &= ~TLV_DB_SCALE_MUTE; |
3714 | + if (!step) |
3715 | + return 0; |
3716 | + if (arg->step && arg->step != step) { |
3717 | + codec_err(arg->codec, |
3718 | + "Mismatching dB step for vmaster slave (%d!=%d)\n", |
3719 | + arg->step, step); |
3720 | + return 0; |
3721 | + } |
3722 | + |
3723 | + arg->step = step; |
3724 | + val = -tlv[2] / step; |
3725 | + if (val > 0) { |
3726 | + put_kctl_with_value(kctl, val); |
3727 | + return val; |
3728 | + } |
3729 | + |
3730 | return 0; |
3731 | } |
3732 | |
3733 | -/* unmute the slave */ |
3734 | -static int init_slave_unmute(struct hda_codec *codec, |
3735 | - void *data, struct snd_kcontrol *slave) |
3736 | +/* unmute the slave via snd_ctl_apply_vmaster_slaves() */ |
3737 | +static int init_slave_unmute(struct snd_kcontrol *slave, void *_arg) |
3738 | { |
3739 | return put_kctl_with_value(slave, 1); |
3740 | } |
3741 | @@ -1919,9 +1928,13 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, |
3742 | /* init with master mute & zero volume */ |
3743 | put_kctl_with_value(kctl, 0); |
3744 | if (init_slave_vol) { |
3745 | - int step = 0; |
3746 | - map_slaves(codec, slaves, suffix, |
3747 | - tlv ? init_slave_0dB : init_slave_unmute, &step); |
3748 | + struct slave_init_arg arg = { |
3749 | + .codec = codec, |
3750 | + .step = 0, |
3751 | + }; |
3752 | + snd_ctl_apply_vmaster_slaves(kctl, |
3753 | + tlv ? init_slave_0dB : init_slave_unmute, |
3754 | + &arg); |
3755 | } |
3756 | |
3757 | if (ctl_ret) |
3758 | diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c |
3759 | index 5d2a63248b1d..0e54fe490458 100644 |
3760 | --- a/sound/usb/quirks.c |
3761 | +++ b/sound/usb/quirks.c |
3762 | @@ -1352,6 +1352,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, |
3763 | case USB_ID(0x20b1, 0x2008): /* Matrix Audio X-Sabre */ |
3764 | case USB_ID(0x20b1, 0x300a): /* Matrix Audio Mini-i Pro */ |
3765 | case USB_ID(0x22d9, 0x0416): /* OPPO HA-1 */ |
3766 | + case USB_ID(0x2772, 0x0230): /* Pro-Ject Pre Box S2 Digital */ |
3767 | if (fp->altsetting == 2) |
3768 | return SNDRV_PCM_FMTBIT_DSD_U32_BE; |
3769 | break; |
3770 | diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c |
3771 | index 0dafba2c1e7d..bd9c6b31a504 100644 |
3772 | --- a/tools/power/x86/turbostat/turbostat.c |
3773 | +++ b/tools/power/x86/turbostat/turbostat.c |
3774 | @@ -92,7 +92,6 @@ unsigned int do_ring_perf_limit_reasons; |
3775 | unsigned int crystal_hz; |
3776 | unsigned long long tsc_hz; |
3777 | int base_cpu; |
3778 | -int do_migrate; |
3779 | double discover_bclk(unsigned int family, unsigned int model); |
3780 | unsigned int has_hwp; /* IA32_PM_ENABLE, IA32_HWP_CAPABILITIES */ |
3781 | /* IA32_HWP_REQUEST, IA32_HWP_STATUS */ |
3782 | @@ -303,9 +302,6 @@ int for_all_cpus(int (func)(struct thread_data *, struct core_data *, struct pkg |
3783 | |
3784 | int cpu_migrate(int cpu) |
3785 | { |
3786 | - if (!do_migrate) |
3787 | - return 0; |
3788 | - |
3789 | CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set); |
3790 | CPU_SET_S(cpu, cpu_affinity_setsize, cpu_affinity_set); |
3791 | if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) |
3792 | @@ -5007,7 +5003,6 @@ void cmdline(int argc, char **argv) |
3793 | {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help |
3794 | {"Joules", no_argument, 0, 'J'}, |
3795 | {"list", no_argument, 0, 'l'}, |
3796 | - {"migrate", no_argument, 0, 'm'}, |
3797 | {"out", required_argument, 0, 'o'}, |
3798 | {"quiet", no_argument, 0, 'q'}, |
3799 | {"show", required_argument, 0, 's'}, |
3800 | @@ -5019,7 +5014,7 @@ void cmdline(int argc, char **argv) |
3801 | |
3802 | progname = argv[0]; |
3803 | |
3804 | - while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:Jmo:qST:v", |
3805 | + while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:JM:m:o:qST:v", |
3806 | long_options, &option_index)) != -1) { |
3807 | switch (opt) { |
3808 | case 'a': |
3809 | @@ -5062,9 +5057,6 @@ void cmdline(int argc, char **argv) |
3810 | list_header_only++; |
3811 | quiet++; |
3812 | break; |
3813 | - case 'm': |
3814 | - do_migrate = 1; |
3815 | - break; |
3816 | case 'o': |
3817 | outf = fopen_or_die(optarg, "w"); |
3818 | break; |