Contents of /trunk/kernel-alx/patches-4.19/0179-4.19.80-all-fixes.patch
Parent Directory | Revision Log
Revision 3476 -
(show annotations)
(download)
Tue Oct 29 10:31:35 2019 UTC (4 years, 10 months ago) by niro
File size: 145243 byte(s)
Tue Oct 29 10:31:35 2019 UTC (4 years, 10 months ago) by niro
File size: 145243 byte(s)
-linux-4.19.80
1 | diff --git a/Documentation/usb/rio.txt b/Documentation/usb/rio.txt |
2 | deleted file mode 100644 |
3 | index aee715af7db7..000000000000 |
4 | --- a/Documentation/usb/rio.txt |
5 | +++ /dev/null |
6 | @@ -1,138 +0,0 @@ |
7 | -Copyright (C) 1999, 2000 Bruce Tenison |
8 | -Portions Copyright (C) 1999, 2000 David Nelson |
9 | -Thanks to David Nelson for guidance and the usage of the scanner.txt |
10 | -and scanner.c files to model our driver and this informative file. |
11 | - |
12 | -Mar. 2, 2000 |
13 | - |
14 | -CHANGES |
15 | - |
16 | -- Initial Revision |
17 | - |
18 | - |
19 | -OVERVIEW |
20 | - |
21 | -This README will address issues regarding how to configure the kernel |
22 | -to access a RIO 500 mp3 player. |
23 | -Before I explain how to use this to access the Rio500 please be warned: |
24 | - |
25 | -W A R N I N G: |
26 | --------------- |
27 | - |
28 | -Please note that this software is still under development. The authors |
29 | -are in no way responsible for any damage that may occur, no matter how |
30 | -inconsequential. |
31 | - |
32 | -It seems that the Rio has a problem when sending .mp3 with low batteries. |
33 | -I suggest when the batteries are low and you want to transfer stuff that you |
34 | -replace it with a fresh one. In my case, what happened is I lost two 16kb |
35 | -blocks (they are no longer usable to store information to it). But I don't |
36 | -know if that's normal or not; it could simply be a problem with the flash |
37 | -memory. |
38 | - |
39 | -In an extreme case, I left my Rio playing overnight and the batteries wore |
40 | -down to nothing and appear to have corrupted the flash memory. My RIO |
41 | -needed to be replaced as a result. Diamond tech support is aware of the |
42 | -problem. Do NOT allow your batteries to wear down to nothing before |
43 | -changing them. It appears RIO 500 firmware does not handle low battery |
44 | -power well at all. |
45 | - |
46 | -On systems with OHCI controllers, the kernel OHCI code appears to have |
47 | -power on problems with some chipsets. If you are having problems |
48 | -connecting to your RIO 500, try turning it on first and then plugging it |
49 | -into the USB cable. |
50 | - |
51 | -Contact information: |
52 | --------------------- |
53 | - |
54 | - The main page for the project is hosted at sourceforge.net in the following |
55 | - URL: <http://rio500.sourceforge.net>. You can also go to the project's |
56 | - sourceforge home page at: <http://sourceforge.net/projects/rio500/>. |
57 | - There is also a mailing list: rio500-users@lists.sourceforge.net |
58 | - |
59 | -Authors: |
60 | -------- |
61 | - |
62 | -Most of the code was written by Cesar Miquel <miquel@df.uba.ar>. Keith |
63 | -Clayton <kclayton@jps.net> is incharge of the PPC port and making sure |
64 | -things work there. Bruce Tenison <btenison@dibbs.net> is adding support |
65 | -for .fon files and also does testing. The program will mostly sure be |
66 | -re-written and Pete Ikusz along with the rest will re-design it. I would |
67 | -also like to thank Tri Nguyen <tmn_3022000@hotmail.com> who provided use |
68 | -with some important information regarding the communication with the Rio. |
69 | - |
70 | -ADDITIONAL INFORMATION and Userspace tools |
71 | - |
72 | -http://rio500.sourceforge.net/ |
73 | - |
74 | - |
75 | -REQUIREMENTS |
76 | - |
77 | -A host with a USB port. Ideally, either a UHCI (Intel) or OHCI |
78 | -(Compaq and others) hardware port should work. |
79 | - |
80 | -A Linux development kernel (2.3.x) with USB support enabled or a |
81 | -backported version to linux-2.2.x. See http://www.linux-usb.org for |
82 | -more information on accomplishing this. |
83 | - |
84 | -A Linux kernel with RIO 500 support enabled. |
85 | - |
86 | -'lspci' which is only needed to determine the type of USB hardware |
87 | -available in your machine. |
88 | - |
89 | -CONFIGURATION |
90 | - |
91 | -Using `lspci -v`, determine the type of USB hardware available. |
92 | - |
93 | - If you see something like: |
94 | - |
95 | - USB Controller: ...... |
96 | - Flags: ..... |
97 | - I/O ports at .... |
98 | - |
99 | - Then you have a UHCI based controller. |
100 | - |
101 | - If you see something like: |
102 | - |
103 | - USB Controller: ..... |
104 | - Flags: .... |
105 | - Memory at ..... |
106 | - |
107 | - Then you have a OHCI based controller. |
108 | - |
109 | -Using `make menuconfig` or your preferred method for configuring the |
110 | -kernel, select 'Support for USB', 'OHCI/UHCI' depending on your |
111 | -hardware (determined from the steps above), 'USB Diamond Rio500 support', and |
112 | -'Preliminary USB device filesystem'. Compile and install the modules |
113 | -(you may need to execute `depmod -a` to update the module |
114 | -dependencies). |
115 | - |
116 | -Add a device for the USB rio500: |
117 | - `mknod /dev/usb/rio500 c 180 64` |
118 | - |
119 | -Set appropriate permissions for /dev/usb/rio500 (don't forget about |
120 | -group and world permissions). Both read and write permissions are |
121 | -required for proper operation. |
122 | - |
123 | -Load the appropriate modules (if compiled as modules): |
124 | - |
125 | - OHCI: |
126 | - modprobe usbcore |
127 | - modprobe usb-ohci |
128 | - modprobe rio500 |
129 | - |
130 | - UHCI: |
131 | - modprobe usbcore |
132 | - modprobe usb-uhci (or uhci) |
133 | - modprobe rio500 |
134 | - |
135 | -That's it. The Rio500 Utils at: http://rio500.sourceforge.net should |
136 | -be able to access the rio500. |
137 | - |
138 | -BUGS |
139 | - |
140 | -If you encounter any problems feel free to drop me an email. |
141 | - |
142 | -Bruce Tenison |
143 | -btenison@dibbs.net |
144 | - |
145 | diff --git a/MAINTAINERS b/MAINTAINERS |
146 | index 11a59e82d92e..d735500d3dad 100644 |
147 | --- a/MAINTAINERS |
148 | +++ b/MAINTAINERS |
149 | @@ -15117,13 +15117,6 @@ W: http://www.linux-usb.org/usbnet |
150 | S: Maintained |
151 | F: drivers/net/usb/dm9601.c |
152 | |
153 | -USB DIAMOND RIO500 DRIVER |
154 | -M: Cesar Miquel <miquel@df.uba.ar> |
155 | -L: rio500-users@lists.sourceforge.net |
156 | -W: http://rio500.sourceforge.net |
157 | -S: Maintained |
158 | -F: drivers/usb/misc/rio500* |
159 | - |
160 | USB EHCI DRIVER |
161 | M: Alan Stern <stern@rowland.harvard.edu> |
162 | L: linux-usb@vger.kernel.org |
163 | diff --git a/Makefile b/Makefile |
164 | index 4d29c7370b46..ced4a9fd9754 100644 |
165 | --- a/Makefile |
166 | +++ b/Makefile |
167 | @@ -1,7 +1,7 @@ |
168 | # SPDX-License-Identifier: GPL-2.0 |
169 | VERSION = 4 |
170 | PATCHLEVEL = 19 |
171 | -SUBLEVEL = 79 |
172 | +SUBLEVEL = 80 |
173 | EXTRAVERSION = |
174 | NAME = "People's Front" |
175 | |
176 | diff --git a/arch/arm/configs/badge4_defconfig b/arch/arm/configs/badge4_defconfig |
177 | index 5ae5b5228467..ef484c4cfd1a 100644 |
178 | --- a/arch/arm/configs/badge4_defconfig |
179 | +++ b/arch/arm/configs/badge4_defconfig |
180 | @@ -91,7 +91,6 @@ CONFIG_USB_SERIAL_PL2303=m |
181 | CONFIG_USB_SERIAL_CYBERJACK=m |
182 | CONFIG_USB_SERIAL_XIRCOM=m |
183 | CONFIG_USB_SERIAL_OMNINET=m |
184 | -CONFIG_USB_RIO500=m |
185 | CONFIG_EXT2_FS=m |
186 | CONFIG_EXT3_FS=m |
187 | CONFIG_MSDOS_FS=y |
188 | diff --git a/arch/arm/configs/corgi_defconfig b/arch/arm/configs/corgi_defconfig |
189 | index 09e1672777c9..0ba8df0d48b9 100644 |
190 | --- a/arch/arm/configs/corgi_defconfig |
191 | +++ b/arch/arm/configs/corgi_defconfig |
192 | @@ -197,7 +197,6 @@ CONFIG_USB_SERIAL_XIRCOM=m |
193 | CONFIG_USB_SERIAL_OMNINET=m |
194 | CONFIG_USB_EMI62=m |
195 | CONFIG_USB_EMI26=m |
196 | -CONFIG_USB_RIO500=m |
197 | CONFIG_USB_LEGOTOWER=m |
198 | CONFIG_USB_LCD=m |
199 | CONFIG_USB_CYTHERM=m |
200 | diff --git a/arch/arm/configs/pxa_defconfig b/arch/arm/configs/pxa_defconfig |
201 | index 6bb506edb1f5..cc63d09a1f86 100644 |
202 | --- a/arch/arm/configs/pxa_defconfig |
203 | +++ b/arch/arm/configs/pxa_defconfig |
204 | @@ -588,7 +588,6 @@ CONFIG_USB_SERIAL_XIRCOM=m |
205 | CONFIG_USB_SERIAL_OMNINET=m |
206 | CONFIG_USB_EMI62=m |
207 | CONFIG_USB_EMI26=m |
208 | -CONFIG_USB_RIO500=m |
209 | CONFIG_USB_LEGOTOWER=m |
210 | CONFIG_USB_LCD=m |
211 | CONFIG_USB_CYTHERM=m |
212 | diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig |
213 | index 2afb359f3168..bd71d5bf98c9 100644 |
214 | --- a/arch/arm/configs/s3c2410_defconfig |
215 | +++ b/arch/arm/configs/s3c2410_defconfig |
216 | @@ -334,7 +334,6 @@ CONFIG_USB_EMI62=m |
217 | CONFIG_USB_EMI26=m |
218 | CONFIG_USB_ADUTUX=m |
219 | CONFIG_USB_SEVSEG=m |
220 | -CONFIG_USB_RIO500=m |
221 | CONFIG_USB_LEGOTOWER=m |
222 | CONFIG_USB_LCD=m |
223 | CONFIG_USB_CYPRESS_CY7C63=m |
224 | diff --git a/arch/arm/configs/spitz_defconfig b/arch/arm/configs/spitz_defconfig |
225 | index 9ea82c118661..3aff4ca2a94e 100644 |
226 | --- a/arch/arm/configs/spitz_defconfig |
227 | +++ b/arch/arm/configs/spitz_defconfig |
228 | @@ -191,7 +191,6 @@ CONFIG_USB_SERIAL_XIRCOM=m |
229 | CONFIG_USB_SERIAL_OMNINET=m |
230 | CONFIG_USB_EMI62=m |
231 | CONFIG_USB_EMI26=m |
232 | -CONFIG_USB_RIO500=m |
233 | CONFIG_USB_LEGOTOWER=m |
234 | CONFIG_USB_LCD=m |
235 | CONFIG_USB_CYTHERM=m |
236 | diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c |
237 | index bc2226608e13..d668c13218b8 100644 |
238 | --- a/arch/arm64/kernel/process.c |
239 | +++ b/arch/arm64/kernel/process.c |
240 | @@ -285,22 +285,27 @@ void arch_release_task_struct(struct task_struct *tsk) |
241 | fpsimd_release_task(tsk); |
242 | } |
243 | |
244 | -/* |
245 | - * src and dst may temporarily have aliased sve_state after task_struct |
246 | - * is copied. We cannot fix this properly here, because src may have |
247 | - * live SVE state and dst's thread_info may not exist yet, so tweaking |
248 | - * either src's or dst's TIF_SVE is not safe. |
249 | - * |
250 | - * The unaliasing is done in copy_thread() instead. This works because |
251 | - * dst is not schedulable or traceable until both of these functions |
252 | - * have been called. |
253 | - */ |
254 | int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) |
255 | { |
256 | if (current->mm) |
257 | fpsimd_preserve_current_state(); |
258 | *dst = *src; |
259 | |
260 | + /* We rely on the above assignment to initialize dst's thread_flags: */ |
261 | + BUILD_BUG_ON(!IS_ENABLED(CONFIG_THREAD_INFO_IN_TASK)); |
262 | + |
263 | + /* |
264 | + * Detach src's sve_state (if any) from dst so that it does not |
265 | + * get erroneously used or freed prematurely. dst's sve_state |
266 | + * will be allocated on demand later on if dst uses SVE. |
267 | + * For consistency, also clear TIF_SVE here: this could be done |
268 | + * later in copy_process(), but to avoid tripping up future |
269 | + * maintainers it is best not to leave TIF_SVE and sve_state in |
270 | + * an inconsistent state, even temporarily. |
271 | + */ |
272 | + dst->thread.sve_state = NULL; |
273 | + clear_tsk_thread_flag(dst, TIF_SVE); |
274 | + |
275 | return 0; |
276 | } |
277 | |
278 | @@ -313,13 +318,6 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, |
279 | |
280 | memset(&p->thread.cpu_context, 0, sizeof(struct cpu_context)); |
281 | |
282 | - /* |
283 | - * Unalias p->thread.sve_state (if any) from the parent task |
284 | - * and disable discard SVE state for p: |
285 | - */ |
286 | - clear_tsk_thread_flag(p, TIF_SVE); |
287 | - p->thread.sve_state = NULL; |
288 | - |
289 | /* |
290 | * In case p was allocated the same task_struct pointer as some |
291 | * other recently-exited task, make sure p is disassociated from |
292 | diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c |
293 | index 0825c4a856e3..6106c49f84bc 100644 |
294 | --- a/arch/arm64/kernel/topology.c |
295 | +++ b/arch/arm64/kernel/topology.c |
296 | @@ -340,17 +340,28 @@ void remove_cpu_topology(unsigned int cpu) |
297 | } |
298 | |
299 | #ifdef CONFIG_ACPI |
300 | +static bool __init acpi_cpu_is_threaded(int cpu) |
301 | +{ |
302 | + int is_threaded = acpi_pptt_cpu_is_thread(cpu); |
303 | + |
304 | + /* |
305 | + * if the PPTT doesn't have thread information, assume a homogeneous |
306 | + * machine and return the current CPU's thread state. |
307 | + */ |
308 | + if (is_threaded < 0) |
309 | + is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; |
310 | + |
311 | + return !!is_threaded; |
312 | +} |
313 | + |
314 | /* |
315 | * Propagate the topology information of the processor_topology_node tree to the |
316 | * cpu_topology array. |
317 | */ |
318 | static int __init parse_acpi_topology(void) |
319 | { |
320 | - bool is_threaded; |
321 | int cpu, topology_id; |
322 | |
323 | - is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; |
324 | - |
325 | for_each_possible_cpu(cpu) { |
326 | int i, cache_id; |
327 | |
328 | @@ -358,7 +369,7 @@ static int __init parse_acpi_topology(void) |
329 | if (topology_id < 0) |
330 | return topology_id; |
331 | |
332 | - if (is_threaded) { |
333 | + if (acpi_cpu_is_threaded(cpu)) { |
334 | cpu_topology[cpu].thread_id = topology_id; |
335 | topology_id = find_acpi_cpu_topology(cpu, 1); |
336 | cpu_topology[cpu].core_id = topology_id; |
337 | diff --git a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig |
338 | index c3d0d0a6e044..6895430b5b2c 100644 |
339 | --- a/arch/mips/configs/mtx1_defconfig |
340 | +++ b/arch/mips/configs/mtx1_defconfig |
341 | @@ -623,7 +623,6 @@ CONFIG_USB_SERIAL_OMNINET=m |
342 | CONFIG_USB_EMI62=m |
343 | CONFIG_USB_EMI26=m |
344 | CONFIG_USB_ADUTUX=m |
345 | -CONFIG_USB_RIO500=m |
346 | CONFIG_USB_LEGOTOWER=m |
347 | CONFIG_USB_LCD=m |
348 | CONFIG_USB_CYPRESS_CY7C63=m |
349 | diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig |
350 | index 5f71aa598b06..1a3e1fec4e86 100644 |
351 | --- a/arch/mips/configs/rm200_defconfig |
352 | +++ b/arch/mips/configs/rm200_defconfig |
353 | @@ -335,7 +335,6 @@ CONFIG_USB_SERIAL_SAFE_PADDED=y |
354 | CONFIG_USB_SERIAL_CYBERJACK=m |
355 | CONFIG_USB_SERIAL_XIRCOM=m |
356 | CONFIG_USB_SERIAL_OMNINET=m |
357 | -CONFIG_USB_RIO500=m |
358 | CONFIG_USB_LEGOTOWER=m |
359 | CONFIG_USB_LCD=m |
360 | CONFIG_USB_CYTHERM=m |
361 | diff --git a/arch/mips/include/uapi/asm/hwcap.h b/arch/mips/include/uapi/asm/hwcap.h |
362 | index a2aba4b059e6..1ade1daa4921 100644 |
363 | --- a/arch/mips/include/uapi/asm/hwcap.h |
364 | +++ b/arch/mips/include/uapi/asm/hwcap.h |
365 | @@ -6,5 +6,16 @@ |
366 | #define HWCAP_MIPS_R6 (1 << 0) |
367 | #define HWCAP_MIPS_MSA (1 << 1) |
368 | #define HWCAP_MIPS_CRC32 (1 << 2) |
369 | +#define HWCAP_MIPS_MIPS16 (1 << 3) |
370 | +#define HWCAP_MIPS_MDMX (1 << 4) |
371 | +#define HWCAP_MIPS_MIPS3D (1 << 5) |
372 | +#define HWCAP_MIPS_SMARTMIPS (1 << 6) |
373 | +#define HWCAP_MIPS_DSP (1 << 7) |
374 | +#define HWCAP_MIPS_DSP2 (1 << 8) |
375 | +#define HWCAP_MIPS_DSP3 (1 << 9) |
376 | +#define HWCAP_MIPS_MIPS16E2 (1 << 10) |
377 | +#define HWCAP_LOONGSON_MMI (1 << 11) |
378 | +#define HWCAP_LOONGSON_EXT (1 << 12) |
379 | +#define HWCAP_LOONGSON_EXT2 (1 << 13) |
380 | |
381 | #endif /* _UAPI_ASM_HWCAP_H */ |
382 | diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c |
383 | index 958b627592c3..581defb369c3 100644 |
384 | --- a/arch/mips/kernel/cpu-probe.c |
385 | +++ b/arch/mips/kernel/cpu-probe.c |
386 | @@ -2105,6 +2105,39 @@ void cpu_probe(void) |
387 | elf_hwcap |= HWCAP_MIPS_MSA; |
388 | } |
389 | |
390 | + if (cpu_has_mips16) |
391 | + elf_hwcap |= HWCAP_MIPS_MIPS16; |
392 | + |
393 | + if (cpu_has_mdmx) |
394 | + elf_hwcap |= HWCAP_MIPS_MDMX; |
395 | + |
396 | + if (cpu_has_mips3d) |
397 | + elf_hwcap |= HWCAP_MIPS_MIPS3D; |
398 | + |
399 | + if (cpu_has_smartmips) |
400 | + elf_hwcap |= HWCAP_MIPS_SMARTMIPS; |
401 | + |
402 | + if (cpu_has_dsp) |
403 | + elf_hwcap |= HWCAP_MIPS_DSP; |
404 | + |
405 | + if (cpu_has_dsp2) |
406 | + elf_hwcap |= HWCAP_MIPS_DSP2; |
407 | + |
408 | + if (cpu_has_dsp3) |
409 | + elf_hwcap |= HWCAP_MIPS_DSP3; |
410 | + |
411 | + if (cpu_has_mips16e2) |
412 | + elf_hwcap |= HWCAP_MIPS_MIPS16E2; |
413 | + |
414 | + if (cpu_has_loongson_mmi) |
415 | + elf_hwcap |= HWCAP_LOONGSON_MMI; |
416 | + |
417 | + if (cpu_has_loongson_ext) |
418 | + elf_hwcap |= HWCAP_LOONGSON_EXT; |
419 | + |
420 | + if (cpu_has_loongson_ext2) |
421 | + elf_hwcap |= HWCAP_LOONGSON_EXT2; |
422 | + |
423 | if (cpu_has_vz) |
424 | cpu_probe_vz(c); |
425 | |
426 | diff --git a/arch/mips/loongson64/Platform b/arch/mips/loongson64/Platform |
427 | index 0fce4608aa88..12abf14aed4a 100644 |
428 | --- a/arch/mips/loongson64/Platform |
429 | +++ b/arch/mips/loongson64/Platform |
430 | @@ -43,6 +43,10 @@ else |
431 | $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) |
432 | endif |
433 | |
434 | +# Some -march= flags enable MMI instructions, and GCC complains about that |
435 | +# support being enabled alongside -msoft-float. Thus explicitly disable MMI. |
436 | +cflags-y += $(call cc-option,-mno-loongson-mmi) |
437 | + |
438 | # |
439 | # Loongson Machines' Support |
440 | # |
441 | diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile |
442 | index 6f10312e0c76..c99fa1c1bd9c 100644 |
443 | --- a/arch/mips/vdso/Makefile |
444 | +++ b/arch/mips/vdso/Makefile |
445 | @@ -9,6 +9,7 @@ ccflags-vdso := \ |
446 | $(filter -mmicromips,$(KBUILD_CFLAGS)) \ |
447 | $(filter -march=%,$(KBUILD_CFLAGS)) \ |
448 | $(filter -m%-float,$(KBUILD_CFLAGS)) \ |
449 | + $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \ |
450 | -D__VDSO__ |
451 | |
452 | ifeq ($(cc-name),clang) |
453 | diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h |
454 | index eb0f80ce8524..3aa82deeab5a 100644 |
455 | --- a/arch/x86/include/asm/mwait.h |
456 | +++ b/arch/x86/include/asm/mwait.h |
457 | @@ -21,7 +21,7 @@ |
458 | #define MWAIT_ECX_INTERRUPT_BREAK 0x1 |
459 | #define MWAITX_ECX_TIMER_ENABLE BIT(1) |
460 | #define MWAITX_MAX_LOOPS ((u32)-1) |
461 | -#define MWAITX_DISABLE_CSTATES 0xf |
462 | +#define MWAITX_DISABLE_CSTATES 0xf0 |
463 | |
464 | static inline void __monitor(const void *eax, unsigned long ecx, |
465 | unsigned long edx) |
466 | diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c |
467 | index f5b7f1b3b6d7..614c2c6b1959 100644 |
468 | --- a/arch/x86/lib/delay.c |
469 | +++ b/arch/x86/lib/delay.c |
470 | @@ -113,8 +113,8 @@ static void delay_mwaitx(unsigned long __loops) |
471 | __monitorx(raw_cpu_ptr(&cpu_tss_rw), 0, 0); |
472 | |
473 | /* |
474 | - * AMD, like Intel, supports the EAX hint and EAX=0xf |
475 | - * means, do not enter any deep C-state and we use it |
476 | + * AMD, like Intel's MWAIT version, supports the EAX hint and |
477 | + * EAX=0xf0 means, do not enter any deep C-state and we use it |
478 | * here in delay() to minimize wakeup latency. |
479 | */ |
480 | __mwaitx(MWAITX_DISABLE_CSTATES, delay, MWAITX_ECX_TIMER_ENABLE); |
481 | diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c |
482 | index 0005dfd568dd..43bcd4e7a7f9 100644 |
483 | --- a/block/blk-rq-qos.c |
484 | +++ b/block/blk-rq-qos.c |
485 | @@ -148,24 +148,27 @@ bool rq_depth_calc_max_depth(struct rq_depth *rqd) |
486 | return ret; |
487 | } |
488 | |
489 | -void rq_depth_scale_up(struct rq_depth *rqd) |
490 | +/* Returns true on success and false if scaling up wasn't possible */ |
491 | +bool rq_depth_scale_up(struct rq_depth *rqd) |
492 | { |
493 | /* |
494 | * Hit max in previous round, stop here |
495 | */ |
496 | if (rqd->scaled_max) |
497 | - return; |
498 | + return false; |
499 | |
500 | rqd->scale_step--; |
501 | |
502 | rqd->scaled_max = rq_depth_calc_max_depth(rqd); |
503 | + return true; |
504 | } |
505 | |
506 | /* |
507 | * Scale rwb down. If 'hard_throttle' is set, do it quicker, since we |
508 | - * had a latency violation. |
509 | + * had a latency violation. Returns true on success and returns false if |
510 | + * scaling down wasn't possible. |
511 | */ |
512 | -void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) |
513 | +bool rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) |
514 | { |
515 | /* |
516 | * Stop scaling down when we've hit the limit. This also prevents |
517 | @@ -173,7 +176,7 @@ void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) |
518 | * keep up. |
519 | */ |
520 | if (rqd->max_depth == 1) |
521 | - return; |
522 | + return false; |
523 | |
524 | if (rqd->scale_step < 0 && hard_throttle) |
525 | rqd->scale_step = 0; |
526 | @@ -182,6 +185,7 @@ void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) |
527 | |
528 | rqd->scaled_max = false; |
529 | rq_depth_calc_max_depth(rqd); |
530 | + return true; |
531 | } |
532 | |
533 | void rq_qos_exit(struct request_queue *q) |
534 | diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h |
535 | index 32b02efbfa66..60fac2d066cf 100644 |
536 | --- a/block/blk-rq-qos.h |
537 | +++ b/block/blk-rq-qos.h |
538 | @@ -94,8 +94,8 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos) |
539 | } |
540 | |
541 | bool rq_wait_inc_below(struct rq_wait *rq_wait, unsigned int limit); |
542 | -void rq_depth_scale_up(struct rq_depth *rqd); |
543 | -void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle); |
544 | +bool rq_depth_scale_up(struct rq_depth *rqd); |
545 | +bool rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle); |
546 | bool rq_depth_calc_max_depth(struct rq_depth *rqd); |
547 | |
548 | void rq_qos_cleanup(struct request_queue *, struct bio *); |
549 | diff --git a/block/blk-wbt.c b/block/blk-wbt.c |
550 | index 0c62bf4eca75..f1de8ba483a9 100644 |
551 | --- a/block/blk-wbt.c |
552 | +++ b/block/blk-wbt.c |
553 | @@ -307,7 +307,8 @@ static void calc_wb_limits(struct rq_wb *rwb) |
554 | |
555 | static void scale_up(struct rq_wb *rwb) |
556 | { |
557 | - rq_depth_scale_up(&rwb->rq_depth); |
558 | + if (!rq_depth_scale_up(&rwb->rq_depth)) |
559 | + return; |
560 | calc_wb_limits(rwb); |
561 | rwb->unknown_cnt = 0; |
562 | rwb_wake_all(rwb); |
563 | @@ -316,7 +317,8 @@ static void scale_up(struct rq_wb *rwb) |
564 | |
565 | static void scale_down(struct rq_wb *rwb, bool hard_throttle) |
566 | { |
567 | - rq_depth_scale_down(&rwb->rq_depth, hard_throttle); |
568 | + if (!rq_depth_scale_down(&rwb->rq_depth, hard_throttle)) |
569 | + return; |
570 | calc_wb_limits(rwb); |
571 | rwb->unknown_cnt = 0; |
572 | rwb_trace_step(rwb, "scale down"); |
573 | diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c |
574 | index da031b1df6f5..9dbf86a0c827 100644 |
575 | --- a/drivers/acpi/pptt.c |
576 | +++ b/drivers/acpi/pptt.c |
577 | @@ -509,6 +509,44 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) |
578 | return retval; |
579 | } |
580 | |
581 | +/** |
582 | + * check_acpi_cpu_flag() - Determine if CPU node has a flag set |
583 | + * @cpu: Kernel logical CPU number |
584 | + * @rev: The minimum PPTT revision defining the flag |
585 | + * @flag: The flag itself |
586 | + * |
587 | + * Check the node representing a CPU for a given flag. |
588 | + * |
589 | + * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or |
590 | + * the table revision isn't new enough. |
591 | + * 1, any passed flag set |
592 | + * 0, flag unset |
593 | + */ |
594 | +static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag) |
595 | +{ |
596 | + struct acpi_table_header *table; |
597 | + acpi_status status; |
598 | + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); |
599 | + struct acpi_pptt_processor *cpu_node = NULL; |
600 | + int ret = -ENOENT; |
601 | + |
602 | + status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); |
603 | + if (ACPI_FAILURE(status)) { |
604 | + pr_warn_once("No PPTT table found, cpu topology may be inaccurate\n"); |
605 | + return ret; |
606 | + } |
607 | + |
608 | + if (table->revision >= rev) |
609 | + cpu_node = acpi_find_processor_node(table, acpi_cpu_id); |
610 | + |
611 | + if (cpu_node) |
612 | + ret = (cpu_node->flags & flag) != 0; |
613 | + |
614 | + acpi_put_table(table); |
615 | + |
616 | + return ret; |
617 | +} |
618 | + |
619 | /** |
620 | * acpi_find_last_cache_level() - Determines the number of cache levels for a PE |
621 | * @cpu: Kernel logical cpu number |
622 | @@ -573,6 +611,20 @@ int cache_setup_acpi(unsigned int cpu) |
623 | return status; |
624 | } |
625 | |
626 | +/** |
627 | + * acpi_pptt_cpu_is_thread() - Determine if CPU is a thread |
628 | + * @cpu: Kernel logical CPU number |
629 | + * |
630 | + * Return: 1, a thread |
631 | + * 0, not a thread |
632 | + * -ENOENT ,if the PPTT doesn't exist, the CPU cannot be found or |
633 | + * the table revision isn't new enough. |
634 | + */ |
635 | +int acpi_pptt_cpu_is_thread(unsigned int cpu) |
636 | +{ |
637 | + return check_acpi_cpu_flag(cpu, 2, ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD); |
638 | +} |
639 | + |
640 | /** |
641 | * find_acpi_cpu_topology() - Determine a unique topology value for a given cpu |
642 | * @cpu: Kernel logical cpu number |
643 | diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c |
644 | index 2a29dd9c986d..d54fca902e64 100644 |
645 | --- a/drivers/firmware/efi/efi.c |
646 | +++ b/drivers/firmware/efi/efi.c |
647 | @@ -281,6 +281,9 @@ static __init int efivar_ssdt_load(void) |
648 | void *data; |
649 | int ret; |
650 | |
651 | + if (!efivar_ssdt[0]) |
652 | + return 0; |
653 | + |
654 | ret = efivar_init(efivar_ssdt_iter, &entries, true, &entries); |
655 | |
656 | list_for_each_entry_safe(entry, aux, &entries, list) { |
657 | diff --git a/drivers/firmware/google/vpd_decode.c b/drivers/firmware/google/vpd_decode.c |
658 | index e75abe9fa122..6c7ab2ba85d2 100644 |
659 | --- a/drivers/firmware/google/vpd_decode.c |
660 | +++ b/drivers/firmware/google/vpd_decode.c |
661 | @@ -62,7 +62,7 @@ static int vpd_decode_entry(const u32 max_len, const u8 *input_buf, |
662 | if (max_len - consumed < *entry_len) |
663 | return VPD_FAIL; |
664 | |
665 | - consumed += decoded_len; |
666 | + consumed += *entry_len; |
667 | *_consumed = consumed; |
668 | return VPD_OK; |
669 | } |
670 | diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c |
671 | index 6cf2e2ce4093..4935cda5301e 100644 |
672 | --- a/drivers/gpio/gpio-eic-sprd.c |
673 | +++ b/drivers/gpio/gpio-eic-sprd.c |
674 | @@ -529,11 +529,12 @@ static void sprd_eic_handle_one_type(struct gpio_chip *chip) |
675 | } |
676 | |
677 | for_each_set_bit(n, ®, SPRD_EIC_PER_BANK_NR) { |
678 | - girq = irq_find_mapping(chip->irq.domain, |
679 | - bank * SPRD_EIC_PER_BANK_NR + n); |
680 | + u32 offset = bank * SPRD_EIC_PER_BANK_NR + n; |
681 | + |
682 | + girq = irq_find_mapping(chip->irq.domain, offset); |
683 | |
684 | generic_handle_irq(girq); |
685 | - sprd_eic_toggle_trigger(chip, girq, n); |
686 | + sprd_eic_toggle_trigger(chip, girq, offset); |
687 | } |
688 | } |
689 | } |
690 | diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c |
691 | index 3289b53a7ba1..565ab945698c 100644 |
692 | --- a/drivers/gpio/gpiolib.c |
693 | +++ b/drivers/gpio/gpiolib.c |
694 | @@ -2649,8 +2649,10 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) |
695 | if (!ret) |
696 | goto set_output_value; |
697 | /* Emulate open drain by not actively driving the line high */ |
698 | - if (value) |
699 | - return gpiod_direction_input(desc); |
700 | + if (value) { |
701 | + ret = gpiod_direction_input(desc); |
702 | + goto set_output_flag; |
703 | + } |
704 | } |
705 | else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) { |
706 | ret = gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc), |
707 | @@ -2658,8 +2660,10 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) |
708 | if (!ret) |
709 | goto set_output_value; |
710 | /* Emulate open source by not actively driving the line low */ |
711 | - if (!value) |
712 | - return gpiod_direction_input(desc); |
713 | + if (!value) { |
714 | + ret = gpiod_direction_input(desc); |
715 | + goto set_output_flag; |
716 | + } |
717 | } else { |
718 | gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc), |
719 | PIN_CONFIG_DRIVE_PUSH_PULL); |
720 | @@ -2667,6 +2671,17 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) |
721 | |
722 | set_output_value: |
723 | return gpiod_direction_output_raw_commit(desc, value); |
724 | + |
725 | +set_output_flag: |
726 | + /* |
727 | + * When emulating open-source or open-drain functionalities by not |
728 | + * actively driving the line (setting mode to input) we still need to |
729 | + * set the IS_OUT flag or otherwise we won't be able to set the line |
730 | + * value anymore. |
731 | + */ |
732 | + if (ret == 0) |
733 | + set_bit(FLAG_IS_OUT, &desc->flags); |
734 | + return ret; |
735 | } |
736 | EXPORT_SYMBOL_GPL(gpiod_direction_output); |
737 | |
738 | @@ -2980,8 +2995,6 @@ static void gpio_set_open_drain_value_commit(struct gpio_desc *desc, bool value) |
739 | |
740 | if (value) { |
741 | err = chip->direction_input(chip, offset); |
742 | - if (!err) |
743 | - clear_bit(FLAG_IS_OUT, &desc->flags); |
744 | } else { |
745 | err = chip->direction_output(chip, offset, 0); |
746 | if (!err) |
747 | @@ -3011,8 +3024,6 @@ static void gpio_set_open_source_value_commit(struct gpio_desc *desc, bool value |
748 | set_bit(FLAG_IS_OUT, &desc->flags); |
749 | } else { |
750 | err = chip->direction_input(chip, offset); |
751 | - if (!err) |
752 | - clear_bit(FLAG_IS_OUT, &desc->flags); |
753 | } |
754 | trace_gpio_direction(desc_to_gpio(desc), !value, err); |
755 | if (err < 0) |
756 | diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c |
757 | index e1da67d5ee22..9e61720db7ea 100644 |
758 | --- a/drivers/iio/adc/ad799x.c |
759 | +++ b/drivers/iio/adc/ad799x.c |
760 | @@ -814,10 +814,10 @@ static int ad799x_probe(struct i2c_client *client, |
761 | |
762 | ret = ad799x_write_config(st, st->chip_config->default_config); |
763 | if (ret < 0) |
764 | - goto error_disable_reg; |
765 | + goto error_disable_vref; |
766 | ret = ad799x_read_config(st); |
767 | if (ret < 0) |
768 | - goto error_disable_reg; |
769 | + goto error_disable_vref; |
770 | st->config = ret; |
771 | |
772 | ret = iio_triggered_buffer_setup(indio_dev, NULL, |
773 | diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c |
774 | index 4e339cfd0c54..e6ce25bcc01c 100644 |
775 | --- a/drivers/iio/adc/axp288_adc.c |
776 | +++ b/drivers/iio/adc/axp288_adc.c |
777 | @@ -16,6 +16,7 @@ |
778 | * |
779 | */ |
780 | |
781 | +#include <linux/dmi.h> |
782 | #include <linux/module.h> |
783 | #include <linux/kernel.h> |
784 | #include <linux/device.h> |
785 | @@ -34,6 +35,11 @@ |
786 | #define AXP288_ADC_EN_MASK 0xF0 |
787 | #define AXP288_ADC_TS_ENABLE 0x01 |
788 | |
789 | +#define AXP288_ADC_TS_BIAS_MASK GENMASK(5, 4) |
790 | +#define AXP288_ADC_TS_BIAS_20UA (0 << 4) |
791 | +#define AXP288_ADC_TS_BIAS_40UA (1 << 4) |
792 | +#define AXP288_ADC_TS_BIAS_60UA (2 << 4) |
793 | +#define AXP288_ADC_TS_BIAS_80UA (3 << 4) |
794 | #define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0) |
795 | #define AXP288_ADC_TS_CURRENT_OFF (0 << 0) |
796 | #define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0) |
797 | @@ -186,10 +192,36 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev, |
798 | return ret; |
799 | } |
800 | |
801 | +/* |
802 | + * We rely on the machine's firmware to correctly setup the TS pin bias current |
803 | + * at boot. This lists systems with broken fw where we need to set it ourselves. |
804 | + */ |
805 | +static const struct dmi_system_id axp288_adc_ts_bias_override[] = { |
806 | + { |
807 | + /* Lenovo Ideapad 100S (11 inch) */ |
808 | + .matches = { |
809 | + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
810 | + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 100S-11IBY"), |
811 | + }, |
812 | + .driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA, |
813 | + }, |
814 | + {} |
815 | +}; |
816 | + |
817 | static int axp288_adc_initialize(struct axp288_adc_info *info) |
818 | { |
819 | + const struct dmi_system_id *bias_override; |
820 | int ret, adc_enable_val; |
821 | |
822 | + bias_override = dmi_first_match(axp288_adc_ts_bias_override); |
823 | + if (bias_override) { |
824 | + ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, |
825 | + AXP288_ADC_TS_BIAS_MASK, |
826 | + (uintptr_t)bias_override->driver_data); |
827 | + if (ret) |
828 | + return ret; |
829 | + } |
830 | + |
831 | /* |
832 | * Determine if the TS pin is enabled and set the TS current-source |
833 | * accordingly. |
834 | diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c |
835 | index 36b59d8957fb..6c5d81a89aec 100644 |
836 | --- a/drivers/iio/adc/hx711.c |
837 | +++ b/drivers/iio/adc/hx711.c |
838 | @@ -109,14 +109,14 @@ struct hx711_data { |
839 | |
840 | static int hx711_cycle(struct hx711_data *hx711_data) |
841 | { |
842 | - int val; |
843 | + unsigned long flags; |
844 | |
845 | /* |
846 | * if preempted for more then 60us while PD_SCK is high: |
847 | * hx711 is going in reset |
848 | * ==> measuring is false |
849 | */ |
850 | - preempt_disable(); |
851 | + local_irq_save(flags); |
852 | gpiod_set_value(hx711_data->gpiod_pd_sck, 1); |
853 | |
854 | /* |
855 | @@ -126,7 +126,6 @@ static int hx711_cycle(struct hx711_data *hx711_data) |
856 | */ |
857 | ndelay(hx711_data->data_ready_delay_ns); |
858 | |
859 | - val = gpiod_get_value(hx711_data->gpiod_dout); |
860 | /* |
861 | * here we are not waiting for 0.2 us as suggested by the datasheet, |
862 | * because the oscilloscope showed in a test scenario |
863 | @@ -134,7 +133,7 @@ static int hx711_cycle(struct hx711_data *hx711_data) |
864 | * and 0.56 us for PD_SCK low on TI Sitara with 800 MHz |
865 | */ |
866 | gpiod_set_value(hx711_data->gpiod_pd_sck, 0); |
867 | - preempt_enable(); |
868 | + local_irq_restore(flags); |
869 | |
870 | /* |
871 | * make it a square wave for addressing cases with capacitance on |
872 | @@ -142,7 +141,8 @@ static int hx711_cycle(struct hx711_data *hx711_data) |
873 | */ |
874 | ndelay(hx711_data->data_ready_delay_ns); |
875 | |
876 | - return val; |
877 | + /* sample as late as possible */ |
878 | + return gpiod_get_value(hx711_data->gpiod_dout); |
879 | } |
880 | |
881 | static int hx711_read(struct hx711_data *hx711_data) |
882 | diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c |
883 | index ca432e7b6ff1..38eb96693079 100644 |
884 | --- a/drivers/iio/adc/stm32-adc-core.c |
885 | +++ b/drivers/iio/adc/stm32-adc-core.c |
886 | @@ -21,45 +21,22 @@ |
887 | |
888 | #include "stm32-adc-core.h" |
889 | |
890 | -/* STM32F4 - common registers for all ADC instances: 1, 2 & 3 */ |
891 | -#define STM32F4_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) |
892 | -#define STM32F4_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x04) |
893 | - |
894 | -/* STM32F4_ADC_CSR - bit fields */ |
895 | -#define STM32F4_EOC3 BIT(17) |
896 | -#define STM32F4_EOC2 BIT(9) |
897 | -#define STM32F4_EOC1 BIT(1) |
898 | - |
899 | -/* STM32F4_ADC_CCR - bit fields */ |
900 | -#define STM32F4_ADC_ADCPRE_SHIFT 16 |
901 | -#define STM32F4_ADC_ADCPRE_MASK GENMASK(17, 16) |
902 | - |
903 | -/* STM32H7 - common registers for all ADC instances */ |
904 | -#define STM32H7_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) |
905 | -#define STM32H7_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x08) |
906 | - |
907 | -/* STM32H7_ADC_CSR - bit fields */ |
908 | -#define STM32H7_EOC_SLV BIT(18) |
909 | -#define STM32H7_EOC_MST BIT(2) |
910 | - |
911 | -/* STM32H7_ADC_CCR - bit fields */ |
912 | -#define STM32H7_PRESC_SHIFT 18 |
913 | -#define STM32H7_PRESC_MASK GENMASK(21, 18) |
914 | -#define STM32H7_CKMODE_SHIFT 16 |
915 | -#define STM32H7_CKMODE_MASK GENMASK(17, 16) |
916 | - |
917 | /** |
918 | * stm32_adc_common_regs - stm32 common registers, compatible dependent data |
919 | * @csr: common status register offset |
920 | * @eoc1: adc1 end of conversion flag in @csr |
921 | * @eoc2: adc2 end of conversion flag in @csr |
922 | * @eoc3: adc3 end of conversion flag in @csr |
923 | + * @ier: interrupt enable register offset for each adc |
924 | + * @eocie_msk: end of conversion interrupt enable mask in @ier |
925 | */ |
926 | struct stm32_adc_common_regs { |
927 | u32 csr; |
928 | u32 eoc1_msk; |
929 | u32 eoc2_msk; |
930 | u32 eoc3_msk; |
931 | + u32 ier; |
932 | + u32 eocie_msk; |
933 | }; |
934 | |
935 | struct stm32_adc_priv; |
936 | @@ -268,6 +245,8 @@ static const struct stm32_adc_common_regs stm32f4_adc_common_regs = { |
937 | .eoc1_msk = STM32F4_EOC1, |
938 | .eoc2_msk = STM32F4_EOC2, |
939 | .eoc3_msk = STM32F4_EOC3, |
940 | + .ier = STM32F4_ADC_CR1, |
941 | + .eocie_msk = STM32F4_EOCIE, |
942 | }; |
943 | |
944 | /* STM32H7 common registers definitions */ |
945 | @@ -275,8 +254,24 @@ static const struct stm32_adc_common_regs stm32h7_adc_common_regs = { |
946 | .csr = STM32H7_ADC_CSR, |
947 | .eoc1_msk = STM32H7_EOC_MST, |
948 | .eoc2_msk = STM32H7_EOC_SLV, |
949 | + .ier = STM32H7_ADC_IER, |
950 | + .eocie_msk = STM32H7_EOCIE, |
951 | +}; |
952 | + |
953 | +static const unsigned int stm32_adc_offset[STM32_ADC_MAX_ADCS] = { |
954 | + 0, STM32_ADC_OFFSET, STM32_ADC_OFFSET * 2, |
955 | }; |
956 | |
957 | +static unsigned int stm32_adc_eoc_enabled(struct stm32_adc_priv *priv, |
958 | + unsigned int adc) |
959 | +{ |
960 | + u32 ier, offset = stm32_adc_offset[adc]; |
961 | + |
962 | + ier = readl_relaxed(priv->common.base + offset + priv->cfg->regs->ier); |
963 | + |
964 | + return ier & priv->cfg->regs->eocie_msk; |
965 | +} |
966 | + |
967 | /* ADC common interrupt for all instances */ |
968 | static void stm32_adc_irq_handler(struct irq_desc *desc) |
969 | { |
970 | @@ -287,13 +282,28 @@ static void stm32_adc_irq_handler(struct irq_desc *desc) |
971 | chained_irq_enter(chip, desc); |
972 | status = readl_relaxed(priv->common.base + priv->cfg->regs->csr); |
973 | |
974 | - if (status & priv->cfg->regs->eoc1_msk) |
975 | + /* |
976 | + * End of conversion may be handled by using IRQ or DMA. There may be a |
977 | + * race here when two conversions complete at the same time on several |
978 | + * ADCs. EOC may be read 'set' for several ADCs, with: |
979 | + * - an ADC configured to use DMA (EOC triggers the DMA request, and |
980 | + * is then automatically cleared by DR read in hardware) |
981 | + * - an ADC configured to use IRQs (EOCIE bit is set. The handler must |
982 | + * be called in this case) |
983 | + * So both EOC status bit in CSR and EOCIE control bit must be checked |
984 | + * before invoking the interrupt handler (e.g. call ISR only for |
985 | + * IRQ-enabled ADCs). |
986 | + */ |
987 | + if (status & priv->cfg->regs->eoc1_msk && |
988 | + stm32_adc_eoc_enabled(priv, 0)) |
989 | generic_handle_irq(irq_find_mapping(priv->domain, 0)); |
990 | |
991 | - if (status & priv->cfg->regs->eoc2_msk) |
992 | + if (status & priv->cfg->regs->eoc2_msk && |
993 | + stm32_adc_eoc_enabled(priv, 1)) |
994 | generic_handle_irq(irq_find_mapping(priv->domain, 1)); |
995 | |
996 | - if (status & priv->cfg->regs->eoc3_msk) |
997 | + if (status & priv->cfg->regs->eoc3_msk && |
998 | + stm32_adc_eoc_enabled(priv, 2)) |
999 | generic_handle_irq(irq_find_mapping(priv->domain, 2)); |
1000 | |
1001 | chained_irq_exit(chip, desc); |
1002 | diff --git a/drivers/iio/adc/stm32-adc-core.h b/drivers/iio/adc/stm32-adc-core.h |
1003 | index 8af507b3f32d..2579d514c2a3 100644 |
1004 | --- a/drivers/iio/adc/stm32-adc-core.h |
1005 | +++ b/drivers/iio/adc/stm32-adc-core.h |
1006 | @@ -25,8 +25,145 @@ |
1007 | * -------------------------------------------------------- |
1008 | */ |
1009 | #define STM32_ADC_MAX_ADCS 3 |
1010 | +#define STM32_ADC_OFFSET 0x100 |
1011 | #define STM32_ADCX_COMN_OFFSET 0x300 |
1012 | |
1013 | +/* STM32F4 - Registers for each ADC instance */ |
1014 | +#define STM32F4_ADC_SR 0x00 |
1015 | +#define STM32F4_ADC_CR1 0x04 |
1016 | +#define STM32F4_ADC_CR2 0x08 |
1017 | +#define STM32F4_ADC_SMPR1 0x0C |
1018 | +#define STM32F4_ADC_SMPR2 0x10 |
1019 | +#define STM32F4_ADC_HTR 0x24 |
1020 | +#define STM32F4_ADC_LTR 0x28 |
1021 | +#define STM32F4_ADC_SQR1 0x2C |
1022 | +#define STM32F4_ADC_SQR2 0x30 |
1023 | +#define STM32F4_ADC_SQR3 0x34 |
1024 | +#define STM32F4_ADC_JSQR 0x38 |
1025 | +#define STM32F4_ADC_JDR1 0x3C |
1026 | +#define STM32F4_ADC_JDR2 0x40 |
1027 | +#define STM32F4_ADC_JDR3 0x44 |
1028 | +#define STM32F4_ADC_JDR4 0x48 |
1029 | +#define STM32F4_ADC_DR 0x4C |
1030 | + |
1031 | +/* STM32F4 - common registers for all ADC instances: 1, 2 & 3 */ |
1032 | +#define STM32F4_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) |
1033 | +#define STM32F4_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x04) |
1034 | + |
1035 | +/* STM32F4_ADC_SR - bit fields */ |
1036 | +#define STM32F4_STRT BIT(4) |
1037 | +#define STM32F4_EOC BIT(1) |
1038 | + |
1039 | +/* STM32F4_ADC_CR1 - bit fields */ |
1040 | +#define STM32F4_RES_SHIFT 24 |
1041 | +#define STM32F4_RES_MASK GENMASK(25, 24) |
1042 | +#define STM32F4_SCAN BIT(8) |
1043 | +#define STM32F4_EOCIE BIT(5) |
1044 | + |
1045 | +/* STM32F4_ADC_CR2 - bit fields */ |
1046 | +#define STM32F4_SWSTART BIT(30) |
1047 | +#define STM32F4_EXTEN_SHIFT 28 |
1048 | +#define STM32F4_EXTEN_MASK GENMASK(29, 28) |
1049 | +#define STM32F4_EXTSEL_SHIFT 24 |
1050 | +#define STM32F4_EXTSEL_MASK GENMASK(27, 24) |
1051 | +#define STM32F4_EOCS BIT(10) |
1052 | +#define STM32F4_DDS BIT(9) |
1053 | +#define STM32F4_DMA BIT(8) |
1054 | +#define STM32F4_ADON BIT(0) |
1055 | + |
1056 | +/* STM32F4_ADC_CSR - bit fields */ |
1057 | +#define STM32F4_EOC3 BIT(17) |
1058 | +#define STM32F4_EOC2 BIT(9) |
1059 | +#define STM32F4_EOC1 BIT(1) |
1060 | + |
1061 | +/* STM32F4_ADC_CCR - bit fields */ |
1062 | +#define STM32F4_ADC_ADCPRE_SHIFT 16 |
1063 | +#define STM32F4_ADC_ADCPRE_MASK GENMASK(17, 16) |
1064 | + |
1065 | +/* STM32H7 - Registers for each ADC instance */ |
1066 | +#define STM32H7_ADC_ISR 0x00 |
1067 | +#define STM32H7_ADC_IER 0x04 |
1068 | +#define STM32H7_ADC_CR 0x08 |
1069 | +#define STM32H7_ADC_CFGR 0x0C |
1070 | +#define STM32H7_ADC_SMPR1 0x14 |
1071 | +#define STM32H7_ADC_SMPR2 0x18 |
1072 | +#define STM32H7_ADC_PCSEL 0x1C |
1073 | +#define STM32H7_ADC_SQR1 0x30 |
1074 | +#define STM32H7_ADC_SQR2 0x34 |
1075 | +#define STM32H7_ADC_SQR3 0x38 |
1076 | +#define STM32H7_ADC_SQR4 0x3C |
1077 | +#define STM32H7_ADC_DR 0x40 |
1078 | +#define STM32H7_ADC_DIFSEL 0xC0 |
1079 | +#define STM32H7_ADC_CALFACT 0xC4 |
1080 | +#define STM32H7_ADC_CALFACT2 0xC8 |
1081 | + |
1082 | +/* STM32H7 - common registers for all ADC instances */ |
1083 | +#define STM32H7_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00) |
1084 | +#define STM32H7_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x08) |
1085 | + |
1086 | +/* STM32H7_ADC_ISR - bit fields */ |
1087 | +#define STM32MP1_VREGREADY BIT(12) |
1088 | +#define STM32H7_EOC BIT(2) |
1089 | +#define STM32H7_ADRDY BIT(0) |
1090 | + |
1091 | +/* STM32H7_ADC_IER - bit fields */ |
1092 | +#define STM32H7_EOCIE STM32H7_EOC |
1093 | + |
1094 | +/* STM32H7_ADC_CR - bit fields */ |
1095 | +#define STM32H7_ADCAL BIT(31) |
1096 | +#define STM32H7_ADCALDIF BIT(30) |
1097 | +#define STM32H7_DEEPPWD BIT(29) |
1098 | +#define STM32H7_ADVREGEN BIT(28) |
1099 | +#define STM32H7_LINCALRDYW6 BIT(27) |
1100 | +#define STM32H7_LINCALRDYW5 BIT(26) |
1101 | +#define STM32H7_LINCALRDYW4 BIT(25) |
1102 | +#define STM32H7_LINCALRDYW3 BIT(24) |
1103 | +#define STM32H7_LINCALRDYW2 BIT(23) |
1104 | +#define STM32H7_LINCALRDYW1 BIT(22) |
1105 | +#define STM32H7_ADCALLIN BIT(16) |
1106 | +#define STM32H7_BOOST BIT(8) |
1107 | +#define STM32H7_ADSTP BIT(4) |
1108 | +#define STM32H7_ADSTART BIT(2) |
1109 | +#define STM32H7_ADDIS BIT(1) |
1110 | +#define STM32H7_ADEN BIT(0) |
1111 | + |
1112 | +/* STM32H7_ADC_CFGR bit fields */ |
1113 | +#define STM32H7_EXTEN_SHIFT 10 |
1114 | +#define STM32H7_EXTEN_MASK GENMASK(11, 10) |
1115 | +#define STM32H7_EXTSEL_SHIFT 5 |
1116 | +#define STM32H7_EXTSEL_MASK GENMASK(9, 5) |
1117 | +#define STM32H7_RES_SHIFT 2 |
1118 | +#define STM32H7_RES_MASK GENMASK(4, 2) |
1119 | +#define STM32H7_DMNGT_SHIFT 0 |
1120 | +#define STM32H7_DMNGT_MASK GENMASK(1, 0) |
1121 | + |
1122 | +enum stm32h7_adc_dmngt { |
1123 | + STM32H7_DMNGT_DR_ONLY, /* Regular data in DR only */ |
1124 | + STM32H7_DMNGT_DMA_ONESHOT, /* DMA one shot mode */ |
1125 | + STM32H7_DMNGT_DFSDM, /* DFSDM mode */ |
1126 | + STM32H7_DMNGT_DMA_CIRC, /* DMA circular mode */ |
1127 | +}; |
1128 | + |
1129 | +/* STM32H7_ADC_CALFACT - bit fields */ |
1130 | +#define STM32H7_CALFACT_D_SHIFT 16 |
1131 | +#define STM32H7_CALFACT_D_MASK GENMASK(26, 16) |
1132 | +#define STM32H7_CALFACT_S_SHIFT 0 |
1133 | +#define STM32H7_CALFACT_S_MASK GENMASK(10, 0) |
1134 | + |
1135 | +/* STM32H7_ADC_CALFACT2 - bit fields */ |
1136 | +#define STM32H7_LINCALFACT_SHIFT 0 |
1137 | +#define STM32H7_LINCALFACT_MASK GENMASK(29, 0) |
1138 | + |
1139 | +/* STM32H7_ADC_CSR - bit fields */ |
1140 | +#define STM32H7_EOC_SLV BIT(18) |
1141 | +#define STM32H7_EOC_MST BIT(2) |
1142 | + |
1143 | +/* STM32H7_ADC_CCR - bit fields */ |
1144 | +#define STM32H7_PRESC_SHIFT 18 |
1145 | +#define STM32H7_PRESC_MASK GENMASK(21, 18) |
1146 | +#define STM32H7_CKMODE_SHIFT 16 |
1147 | +#define STM32H7_CKMODE_MASK GENMASK(17, 16) |
1148 | + |
1149 | /** |
1150 | * struct stm32_adc_common - stm32 ADC driver common data (for all instances) |
1151 | * @base: control registers base cpu addr |
1152 | diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c |
1153 | index 378411853d75..c52d20f7ca2e 100644 |
1154 | --- a/drivers/iio/adc/stm32-adc.c |
1155 | +++ b/drivers/iio/adc/stm32-adc.c |
1156 | @@ -27,115 +27,6 @@ |
1157 | |
1158 | #include "stm32-adc-core.h" |
1159 | |
1160 | -/* STM32F4 - Registers for each ADC instance */ |
1161 | -#define STM32F4_ADC_SR 0x00 |
1162 | -#define STM32F4_ADC_CR1 0x04 |
1163 | -#define STM32F4_ADC_CR2 0x08 |
1164 | -#define STM32F4_ADC_SMPR1 0x0C |
1165 | -#define STM32F4_ADC_SMPR2 0x10 |
1166 | -#define STM32F4_ADC_HTR 0x24 |
1167 | -#define STM32F4_ADC_LTR 0x28 |
1168 | -#define STM32F4_ADC_SQR1 0x2C |
1169 | -#define STM32F4_ADC_SQR2 0x30 |
1170 | -#define STM32F4_ADC_SQR3 0x34 |
1171 | -#define STM32F4_ADC_JSQR 0x38 |
1172 | -#define STM32F4_ADC_JDR1 0x3C |
1173 | -#define STM32F4_ADC_JDR2 0x40 |
1174 | -#define STM32F4_ADC_JDR3 0x44 |
1175 | -#define STM32F4_ADC_JDR4 0x48 |
1176 | -#define STM32F4_ADC_DR 0x4C |
1177 | - |
1178 | -/* STM32F4_ADC_SR - bit fields */ |
1179 | -#define STM32F4_STRT BIT(4) |
1180 | -#define STM32F4_EOC BIT(1) |
1181 | - |
1182 | -/* STM32F4_ADC_CR1 - bit fields */ |
1183 | -#define STM32F4_RES_SHIFT 24 |
1184 | -#define STM32F4_RES_MASK GENMASK(25, 24) |
1185 | -#define STM32F4_SCAN BIT(8) |
1186 | -#define STM32F4_EOCIE BIT(5) |
1187 | - |
1188 | -/* STM32F4_ADC_CR2 - bit fields */ |
1189 | -#define STM32F4_SWSTART BIT(30) |
1190 | -#define STM32F4_EXTEN_SHIFT 28 |
1191 | -#define STM32F4_EXTEN_MASK GENMASK(29, 28) |
1192 | -#define STM32F4_EXTSEL_SHIFT 24 |
1193 | -#define STM32F4_EXTSEL_MASK GENMASK(27, 24) |
1194 | -#define STM32F4_EOCS BIT(10) |
1195 | -#define STM32F4_DDS BIT(9) |
1196 | -#define STM32F4_DMA BIT(8) |
1197 | -#define STM32F4_ADON BIT(0) |
1198 | - |
1199 | -/* STM32H7 - Registers for each ADC instance */ |
1200 | -#define STM32H7_ADC_ISR 0x00 |
1201 | -#define STM32H7_ADC_IER 0x04 |
1202 | -#define STM32H7_ADC_CR 0x08 |
1203 | -#define STM32H7_ADC_CFGR 0x0C |
1204 | -#define STM32H7_ADC_SMPR1 0x14 |
1205 | -#define STM32H7_ADC_SMPR2 0x18 |
1206 | -#define STM32H7_ADC_PCSEL 0x1C |
1207 | -#define STM32H7_ADC_SQR1 0x30 |
1208 | -#define STM32H7_ADC_SQR2 0x34 |
1209 | -#define STM32H7_ADC_SQR3 0x38 |
1210 | -#define STM32H7_ADC_SQR4 0x3C |
1211 | -#define STM32H7_ADC_DR 0x40 |
1212 | -#define STM32H7_ADC_DIFSEL 0xC0 |
1213 | -#define STM32H7_ADC_CALFACT 0xC4 |
1214 | -#define STM32H7_ADC_CALFACT2 0xC8 |
1215 | - |
1216 | -/* STM32H7_ADC_ISR - bit fields */ |
1217 | -#define STM32MP1_VREGREADY BIT(12) |
1218 | -#define STM32H7_EOC BIT(2) |
1219 | -#define STM32H7_ADRDY BIT(0) |
1220 | - |
1221 | -/* STM32H7_ADC_IER - bit fields */ |
1222 | -#define STM32H7_EOCIE STM32H7_EOC |
1223 | - |
1224 | -/* STM32H7_ADC_CR - bit fields */ |
1225 | -#define STM32H7_ADCAL BIT(31) |
1226 | -#define STM32H7_ADCALDIF BIT(30) |
1227 | -#define STM32H7_DEEPPWD BIT(29) |
1228 | -#define STM32H7_ADVREGEN BIT(28) |
1229 | -#define STM32H7_LINCALRDYW6 BIT(27) |
1230 | -#define STM32H7_LINCALRDYW5 BIT(26) |
1231 | -#define STM32H7_LINCALRDYW4 BIT(25) |
1232 | -#define STM32H7_LINCALRDYW3 BIT(24) |
1233 | -#define STM32H7_LINCALRDYW2 BIT(23) |
1234 | -#define STM32H7_LINCALRDYW1 BIT(22) |
1235 | -#define STM32H7_ADCALLIN BIT(16) |
1236 | -#define STM32H7_BOOST BIT(8) |
1237 | -#define STM32H7_ADSTP BIT(4) |
1238 | -#define STM32H7_ADSTART BIT(2) |
1239 | -#define STM32H7_ADDIS BIT(1) |
1240 | -#define STM32H7_ADEN BIT(0) |
1241 | - |
1242 | -/* STM32H7_ADC_CFGR bit fields */ |
1243 | -#define STM32H7_EXTEN_SHIFT 10 |
1244 | -#define STM32H7_EXTEN_MASK GENMASK(11, 10) |
1245 | -#define STM32H7_EXTSEL_SHIFT 5 |
1246 | -#define STM32H7_EXTSEL_MASK GENMASK(9, 5) |
1247 | -#define STM32H7_RES_SHIFT 2 |
1248 | -#define STM32H7_RES_MASK GENMASK(4, 2) |
1249 | -#define STM32H7_DMNGT_SHIFT 0 |
1250 | -#define STM32H7_DMNGT_MASK GENMASK(1, 0) |
1251 | - |
1252 | -enum stm32h7_adc_dmngt { |
1253 | - STM32H7_DMNGT_DR_ONLY, /* Regular data in DR only */ |
1254 | - STM32H7_DMNGT_DMA_ONESHOT, /* DMA one shot mode */ |
1255 | - STM32H7_DMNGT_DFSDM, /* DFSDM mode */ |
1256 | - STM32H7_DMNGT_DMA_CIRC, /* DMA circular mode */ |
1257 | -}; |
1258 | - |
1259 | -/* STM32H7_ADC_CALFACT - bit fields */ |
1260 | -#define STM32H7_CALFACT_D_SHIFT 16 |
1261 | -#define STM32H7_CALFACT_D_MASK GENMASK(26, 16) |
1262 | -#define STM32H7_CALFACT_S_SHIFT 0 |
1263 | -#define STM32H7_CALFACT_S_MASK GENMASK(10, 0) |
1264 | - |
1265 | -/* STM32H7_ADC_CALFACT2 - bit fields */ |
1266 | -#define STM32H7_LINCALFACT_SHIFT 0 |
1267 | -#define STM32H7_LINCALFACT_MASK GENMASK(29, 0) |
1268 | - |
1269 | /* Number of linear calibration shadow registers / LINCALRDYW control bits */ |
1270 | #define STM32H7_LINCALFACT_NUM 6 |
1271 | |
1272 | diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c |
1273 | index 54d88b60e303..f9d13e4ec108 100644 |
1274 | --- a/drivers/iio/light/opt3001.c |
1275 | +++ b/drivers/iio/light/opt3001.c |
1276 | @@ -694,6 +694,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) |
1277 | struct iio_dev *iio = _iio; |
1278 | struct opt3001 *opt = iio_priv(iio); |
1279 | int ret; |
1280 | + bool wake_result_ready_queue = false; |
1281 | |
1282 | if (!opt->ok_to_ignore_lock) |
1283 | mutex_lock(&opt->lock); |
1284 | @@ -728,13 +729,16 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) |
1285 | } |
1286 | opt->result = ret; |
1287 | opt->result_ready = true; |
1288 | - wake_up(&opt->result_ready_queue); |
1289 | + wake_result_ready_queue = true; |
1290 | } |
1291 | |
1292 | out: |
1293 | if (!opt->ok_to_ignore_lock) |
1294 | mutex_unlock(&opt->lock); |
1295 | |
1296 | + if (wake_result_ready_queue) |
1297 | + wake_up(&opt->result_ready_queue); |
1298 | + |
1299 | return IRQ_HANDLED; |
1300 | } |
1301 | |
1302 | diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c |
1303 | index 5accb5241072..6e3f234e790b 100644 |
1304 | --- a/drivers/media/usb/stkwebcam/stk-webcam.c |
1305 | +++ b/drivers/media/usb/stkwebcam/stk-webcam.c |
1306 | @@ -641,8 +641,7 @@ static int v4l_stk_release(struct file *fp) |
1307 | dev->owner = NULL; |
1308 | } |
1309 | |
1310 | - if (is_present(dev)) |
1311 | - usb_autopm_put_interface(dev->interface); |
1312 | + usb_autopm_put_interface(dev->interface); |
1313 | mutex_unlock(&dev->lock); |
1314 | return v4l2_fh_release(fp); |
1315 | } |
1316 | diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c |
1317 | index a6f41f96f2a1..198e030e5b3d 100644 |
1318 | --- a/drivers/misc/mei/bus-fixup.c |
1319 | +++ b/drivers/misc/mei/bus-fixup.c |
1320 | @@ -214,13 +214,21 @@ static void mei_mkhi_fix(struct mei_cl_device *cldev) |
1321 | { |
1322 | int ret; |
1323 | |
1324 | + /* No need to enable the client if nothing is needed from it */ |
1325 | + if (!cldev->bus->fw_f_fw_ver_supported && |
1326 | + !cldev->bus->hbm_f_os_supported) |
1327 | + return; |
1328 | + |
1329 | ret = mei_cldev_enable(cldev); |
1330 | if (ret) |
1331 | return; |
1332 | |
1333 | - ret = mei_fwver(cldev); |
1334 | - if (ret < 0) |
1335 | - dev_err(&cldev->dev, "FW version command failed %d\n", ret); |
1336 | + if (cldev->bus->fw_f_fw_ver_supported) { |
1337 | + ret = mei_fwver(cldev); |
1338 | + if (ret < 0) |
1339 | + dev_err(&cldev->dev, "FW version command failed %d\n", |
1340 | + ret); |
1341 | + } |
1342 | |
1343 | if (cldev->bus->hbm_f_os_supported) { |
1344 | ret = mei_osver(cldev); |
1345 | diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h |
1346 | index cdd7af16d5ee..f85aa3f4042d 100644 |
1347 | --- a/drivers/misc/mei/hw-me-regs.h |
1348 | +++ b/drivers/misc/mei/hw-me-regs.h |
1349 | @@ -139,6 +139,9 @@ |
1350 | #define MEI_DEV_ID_CNP_H 0xA360 /* Cannon Point H */ |
1351 | #define MEI_DEV_ID_CNP_H_4 0xA364 /* Cannon Point H 4 (iTouch) */ |
1352 | |
1353 | +#define MEI_DEV_ID_CMP_LP 0x02e0 /* Comet Point LP */ |
1354 | +#define MEI_DEV_ID_CMP_LP_3 0x02e4 /* Comet Point LP 3 (iTouch) */ |
1355 | + |
1356 | #define MEI_DEV_ID_ICP_LP 0x34E0 /* Ice Lake Point LP */ |
1357 | |
1358 | #define MEI_DEV_ID_TGP_LP 0xA0E0 /* Tiger Lake Point LP */ |
1359 | diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c |
1360 | index 0759c3a668de..60c8c84181a9 100644 |
1361 | --- a/drivers/misc/mei/hw-me.c |
1362 | +++ b/drivers/misc/mei/hw-me.c |
1363 | @@ -1368,6 +1368,8 @@ static bool mei_me_fw_type_sps(struct pci_dev *pdev) |
1364 | #define MEI_CFG_FW_SPS \ |
1365 | .quirk_probe = mei_me_fw_type_sps |
1366 | |
1367 | +#define MEI_CFG_FW_VER_SUPP \ |
1368 | + .fw_ver_supported = 1 |
1369 | |
1370 | #define MEI_CFG_ICH_HFS \ |
1371 | .fw_status.count = 0 |
1372 | @@ -1405,31 +1407,41 @@ static const struct mei_cfg mei_me_ich10_cfg = { |
1373 | MEI_CFG_ICH10_HFS, |
1374 | }; |
1375 | |
1376 | -/* PCH devices */ |
1377 | -static const struct mei_cfg mei_me_pch_cfg = { |
1378 | +/* PCH6 devices */ |
1379 | +static const struct mei_cfg mei_me_pch6_cfg = { |
1380 | MEI_CFG_PCH_HFS, |
1381 | }; |
1382 | |
1383 | +/* PCH7 devices */ |
1384 | +static const struct mei_cfg mei_me_pch7_cfg = { |
1385 | + MEI_CFG_PCH_HFS, |
1386 | + MEI_CFG_FW_VER_SUPP, |
1387 | +}; |
1388 | + |
1389 | /* PCH Cougar Point and Patsburg with quirk for Node Manager exclusion */ |
1390 | static const struct mei_cfg mei_me_pch_cpt_pbg_cfg = { |
1391 | MEI_CFG_PCH_HFS, |
1392 | + MEI_CFG_FW_VER_SUPP, |
1393 | MEI_CFG_FW_NM, |
1394 | }; |
1395 | |
1396 | /* PCH8 Lynx Point and newer devices */ |
1397 | static const struct mei_cfg mei_me_pch8_cfg = { |
1398 | MEI_CFG_PCH8_HFS, |
1399 | + MEI_CFG_FW_VER_SUPP, |
1400 | }; |
1401 | |
1402 | /* PCH8 Lynx Point with quirk for SPS Firmware exclusion */ |
1403 | static const struct mei_cfg mei_me_pch8_sps_cfg = { |
1404 | MEI_CFG_PCH8_HFS, |
1405 | + MEI_CFG_FW_VER_SUPP, |
1406 | MEI_CFG_FW_SPS, |
1407 | }; |
1408 | |
1409 | /* Cannon Lake and newer devices */ |
1410 | static const struct mei_cfg mei_me_pch12_cfg = { |
1411 | MEI_CFG_PCH8_HFS, |
1412 | + MEI_CFG_FW_VER_SUPP, |
1413 | MEI_CFG_DMA_128, |
1414 | }; |
1415 | |
1416 | @@ -1441,7 +1453,8 @@ static const struct mei_cfg *const mei_cfg_list[] = { |
1417 | [MEI_ME_UNDEF_CFG] = NULL, |
1418 | [MEI_ME_ICH_CFG] = &mei_me_ich_cfg, |
1419 | [MEI_ME_ICH10_CFG] = &mei_me_ich10_cfg, |
1420 | - [MEI_ME_PCH_CFG] = &mei_me_pch_cfg, |
1421 | + [MEI_ME_PCH6_CFG] = &mei_me_pch6_cfg, |
1422 | + [MEI_ME_PCH7_CFG] = &mei_me_pch7_cfg, |
1423 | [MEI_ME_PCH_CPT_PBG_CFG] = &mei_me_pch_cpt_pbg_cfg, |
1424 | [MEI_ME_PCH8_CFG] = &mei_me_pch8_cfg, |
1425 | [MEI_ME_PCH8_SPS_CFG] = &mei_me_pch8_sps_cfg, |
1426 | @@ -1480,6 +1493,8 @@ struct mei_device *mei_me_dev_init(struct pci_dev *pdev, |
1427 | |
1428 | mei_device_init(dev, &pdev->dev, &mei_me_hw_ops); |
1429 | hw->cfg = cfg; |
1430 | + dev->fw_f_fw_ver_supported = cfg->fw_ver_supported; |
1431 | + |
1432 | return dev; |
1433 | } |
1434 | |
1435 | diff --git a/drivers/misc/mei/hw-me.h b/drivers/misc/mei/hw-me.h |
1436 | index bbcc5fc106cd..775971339789 100644 |
1437 | --- a/drivers/misc/mei/hw-me.h |
1438 | +++ b/drivers/misc/mei/hw-me.h |
1439 | @@ -32,11 +32,13 @@ |
1440 | * @fw_status: FW status |
1441 | * @quirk_probe: device exclusion quirk |
1442 | * @dma_size: device DMA buffers size |
1443 | + * @fw_ver_supported: is fw version retrievable from FW |
1444 | */ |
1445 | struct mei_cfg { |
1446 | const struct mei_fw_status fw_status; |
1447 | bool (*quirk_probe)(struct pci_dev *pdev); |
1448 | size_t dma_size[DMA_DSCR_NUM]; |
1449 | + u32 fw_ver_supported:1; |
1450 | }; |
1451 | |
1452 | |
1453 | @@ -74,7 +76,8 @@ struct mei_me_hw { |
1454 | * @MEI_ME_UNDEF_CFG: Lower sentinel. |
1455 | * @MEI_ME_ICH_CFG: I/O Controller Hub legacy devices. |
1456 | * @MEI_ME_ICH10_CFG: I/O Controller Hub platforms Gen10 |
1457 | - * @MEI_ME_PCH_CFG: Platform Controller Hub platforms (Up to Gen8). |
1458 | + * @MEI_ME_PCH6_CFG: Platform Controller Hub platforms (Gen6). |
1459 | + * @MEI_ME_PCH7_CFG: Platform Controller Hub platforms (Gen7). |
1460 | * @MEI_ME_PCH_CPT_PBG_CFG:Platform Controller Hub workstations |
1461 | * with quirk for Node Manager exclusion. |
1462 | * @MEI_ME_PCH8_CFG: Platform Controller Hub Gen8 and newer |
1463 | @@ -89,7 +92,8 @@ enum mei_cfg_idx { |
1464 | MEI_ME_UNDEF_CFG, |
1465 | MEI_ME_ICH_CFG, |
1466 | MEI_ME_ICH10_CFG, |
1467 | - MEI_ME_PCH_CFG, |
1468 | + MEI_ME_PCH6_CFG, |
1469 | + MEI_ME_PCH7_CFG, |
1470 | MEI_ME_PCH_CPT_PBG_CFG, |
1471 | MEI_ME_PCH8_CFG, |
1472 | MEI_ME_PCH8_SPS_CFG, |
1473 | diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h |
1474 | index 377397e1b5a5..fc7a5e3fbfcd 100644 |
1475 | --- a/drivers/misc/mei/mei_dev.h |
1476 | +++ b/drivers/misc/mei/mei_dev.h |
1477 | @@ -422,6 +422,8 @@ struct mei_fw_version { |
1478 | * |
1479 | * @fw_ver : FW versions |
1480 | * |
1481 | + * @fw_f_fw_ver_supported : fw feature: fw version supported |
1482 | + * |
1483 | * @me_clients_rwsem: rw lock over me_clients list |
1484 | * @me_clients : list of FW clients |
1485 | * @me_clients_map : FW clients bit map |
1486 | @@ -500,6 +502,8 @@ struct mei_device { |
1487 | |
1488 | struct mei_fw_version fw_ver[MEI_MAX_FW_VER_BLOCKS]; |
1489 | |
1490 | + unsigned int fw_f_fw_ver_supported:1; |
1491 | + |
1492 | struct rw_semaphore me_clients_rwsem; |
1493 | struct list_head me_clients; |
1494 | DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX); |
1495 | diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c |
1496 | index e41f9e0a3fdf..28cdd87851cb 100644 |
1497 | --- a/drivers/misc/mei/pci-me.c |
1498 | +++ b/drivers/misc/mei/pci-me.c |
1499 | @@ -70,13 +70,13 @@ static const struct pci_device_id mei_me_pci_tbl[] = { |
1500 | {MEI_PCI_DEVICE(MEI_DEV_ID_ICH10_3, MEI_ME_ICH10_CFG)}, |
1501 | {MEI_PCI_DEVICE(MEI_DEV_ID_ICH10_4, MEI_ME_ICH10_CFG)}, |
1502 | |
1503 | - {MEI_PCI_DEVICE(MEI_DEV_ID_IBXPK_1, MEI_ME_PCH_CFG)}, |
1504 | - {MEI_PCI_DEVICE(MEI_DEV_ID_IBXPK_2, MEI_ME_PCH_CFG)}, |
1505 | + {MEI_PCI_DEVICE(MEI_DEV_ID_IBXPK_1, MEI_ME_PCH6_CFG)}, |
1506 | + {MEI_PCI_DEVICE(MEI_DEV_ID_IBXPK_2, MEI_ME_PCH6_CFG)}, |
1507 | {MEI_PCI_DEVICE(MEI_DEV_ID_CPT_1, MEI_ME_PCH_CPT_PBG_CFG)}, |
1508 | {MEI_PCI_DEVICE(MEI_DEV_ID_PBG_1, MEI_ME_PCH_CPT_PBG_CFG)}, |
1509 | - {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_1, MEI_ME_PCH_CFG)}, |
1510 | - {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_2, MEI_ME_PCH_CFG)}, |
1511 | - {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_3, MEI_ME_PCH_CFG)}, |
1512 | + {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_1, MEI_ME_PCH7_CFG)}, |
1513 | + {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_2, MEI_ME_PCH7_CFG)}, |
1514 | + {MEI_PCI_DEVICE(MEI_DEV_ID_PPT_3, MEI_ME_PCH7_CFG)}, |
1515 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_H, MEI_ME_PCH8_SPS_CFG)}, |
1516 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_W, MEI_ME_PCH8_SPS_CFG)}, |
1517 | {MEI_PCI_DEVICE(MEI_DEV_ID_LPT_LP, MEI_ME_PCH8_CFG)}, |
1518 | @@ -105,6 +105,9 @@ static const struct pci_device_id mei_me_pci_tbl[] = { |
1519 | {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H, MEI_ME_PCH8_CFG)}, |
1520 | {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H_4, MEI_ME_PCH8_CFG)}, |
1521 | |
1522 | + {MEI_PCI_DEVICE(MEI_DEV_ID_CMP_LP, MEI_ME_PCH12_CFG)}, |
1523 | + {MEI_PCI_DEVICE(MEI_DEV_ID_CMP_LP_3, MEI_ME_PCH8_CFG)}, |
1524 | + |
1525 | {MEI_PCI_DEVICE(MEI_DEV_ID_ICP_LP, MEI_ME_PCH12_CFG)}, |
1526 | |
1527 | {MEI_PCI_DEVICE(MEI_DEV_ID_TGP_LP, MEI_ME_PCH12_CFG)}, |
1528 | diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c |
1529 | index 52d4fa4161dc..65eaa6b61868 100644 |
1530 | --- a/drivers/pci/controller/vmd.c |
1531 | +++ b/drivers/pci/controller/vmd.c |
1532 | @@ -97,6 +97,7 @@ struct vmd_dev { |
1533 | struct resource resources[3]; |
1534 | struct irq_domain *irq_domain; |
1535 | struct pci_bus *bus; |
1536 | + u8 busn_start; |
1537 | |
1538 | #ifdef CONFIG_X86_DEV_DMA_OPS |
1539 | struct dma_map_ops dma_ops; |
1540 | @@ -468,7 +469,8 @@ static char __iomem *vmd_cfg_addr(struct vmd_dev *vmd, struct pci_bus *bus, |
1541 | unsigned int devfn, int reg, int len) |
1542 | { |
1543 | char __iomem *addr = vmd->cfgbar + |
1544 | - (bus->number << 20) + (devfn << 12) + reg; |
1545 | + ((bus->number - vmd->busn_start) << 20) + |
1546 | + (devfn << 12) + reg; |
1547 | |
1548 | if ((addr - vmd->cfgbar) + len >= |
1549 | resource_size(&vmd->dev->resource[VMD_CFGBAR])) |
1550 | @@ -591,7 +593,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) |
1551 | unsigned long flags; |
1552 | LIST_HEAD(resources); |
1553 | resource_size_t offset[2] = {0}; |
1554 | - resource_size_t membar2_offset = 0x2000, busn_start = 0; |
1555 | + resource_size_t membar2_offset = 0x2000; |
1556 | |
1557 | /* |
1558 | * Shadow registers may exist in certain VMD device ids which allow |
1559 | @@ -633,14 +635,14 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) |
1560 | pci_read_config_dword(vmd->dev, PCI_REG_VMCONFIG, &vmconfig); |
1561 | if (BUS_RESTRICT_CAP(vmcap) && |
1562 | (BUS_RESTRICT_CFG(vmconfig) == 0x1)) |
1563 | - busn_start = 128; |
1564 | + vmd->busn_start = 128; |
1565 | } |
1566 | |
1567 | res = &vmd->dev->resource[VMD_CFGBAR]; |
1568 | vmd->resources[0] = (struct resource) { |
1569 | .name = "VMD CFGBAR", |
1570 | - .start = busn_start, |
1571 | - .end = busn_start + (resource_size(res) >> 20) - 1, |
1572 | + .start = vmd->busn_start, |
1573 | + .end = vmd->busn_start + (resource_size(res) >> 20) - 1, |
1574 | .flags = IORESOURCE_BUS | IORESOURCE_PCI_FIXED, |
1575 | }; |
1576 | |
1577 | @@ -708,8 +710,8 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) |
1578 | pci_add_resource_offset(&resources, &vmd->resources[1], offset[0]); |
1579 | pci_add_resource_offset(&resources, &vmd->resources[2], offset[1]); |
1580 | |
1581 | - vmd->bus = pci_create_root_bus(&vmd->dev->dev, busn_start, &vmd_ops, |
1582 | - sd, &resources); |
1583 | + vmd->bus = pci_create_root_bus(&vmd->dev->dev, vmd->busn_start, |
1584 | + &vmd_ops, sd, &resources); |
1585 | if (!vmd->bus) { |
1586 | pci_free_resource_list(&resources); |
1587 | irq_domain_remove(vmd->irq_domain); |
1588 | diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c |
1589 | index a2df02d97a8e..16fcf633e60f 100644 |
1590 | --- a/drivers/staging/fbtft/fbtft-core.c |
1591 | +++ b/drivers/staging/fbtft/fbtft-core.c |
1592 | @@ -819,7 +819,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, |
1593 | if (par->gamma.curves && gamma) { |
1594 | if (fbtft_gamma_parse_str(par, par->gamma.curves, gamma, |
1595 | strlen(gamma))) |
1596 | - goto alloc_fail; |
1597 | + goto release_framebuf; |
1598 | } |
1599 | |
1600 | /* Transmit buffer */ |
1601 | @@ -836,7 +836,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, |
1602 | if (txbuflen > 0) { |
1603 | txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL); |
1604 | if (!txbuf) |
1605 | - goto alloc_fail; |
1606 | + goto release_framebuf; |
1607 | par->txbuf.buf = txbuf; |
1608 | par->txbuf.len = txbuflen; |
1609 | } |
1610 | @@ -872,6 +872,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, |
1611 | |
1612 | return info; |
1613 | |
1614 | +release_framebuf: |
1615 | + framebuffer_release(info); |
1616 | + |
1617 | alloc_fail: |
1618 | vfree(vmem); |
1619 | |
1620 | diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c |
1621 | index 607804aa560d..76f434c1c088 100644 |
1622 | --- a/drivers/staging/vt6655/device_main.c |
1623 | +++ b/drivers/staging/vt6655/device_main.c |
1624 | @@ -1755,8 +1755,10 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) |
1625 | |
1626 | priv->hw->max_signal = 100; |
1627 | |
1628 | - if (vnt_init(priv)) |
1629 | + if (vnt_init(priv)) { |
1630 | + device_free_info(priv); |
1631 | return -ENODEV; |
1632 | + } |
1633 | |
1634 | device_print_info(priv); |
1635 | pci_set_drvdata(pcid, priv); |
1636 | diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c |
1637 | index 98d3eadd2fd0..8df305822668 100644 |
1638 | --- a/drivers/tty/serial/uartlite.c |
1639 | +++ b/drivers/tty/serial/uartlite.c |
1640 | @@ -837,7 +837,8 @@ err_uart: |
1641 | static void __exit ulite_exit(void) |
1642 | { |
1643 | platform_driver_unregister(&ulite_platform_driver); |
1644 | - uart_unregister_driver(&ulite_uart_driver); |
1645 | + if (ulite_uart_driver.state) |
1646 | + uart_unregister_driver(&ulite_uart_driver); |
1647 | } |
1648 | |
1649 | module_init(ulite_init); |
1650 | diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c |
1651 | index 407a7a6198a2..502e9bf1746f 100644 |
1652 | --- a/drivers/usb/class/usblp.c |
1653 | +++ b/drivers/usb/class/usblp.c |
1654 | @@ -461,10 +461,12 @@ static int usblp_release(struct inode *inode, struct file *file) |
1655 | |
1656 | mutex_lock(&usblp_mutex); |
1657 | usblp->used = 0; |
1658 | - if (usblp->present) { |
1659 | + if (usblp->present) |
1660 | usblp_unlink_urbs(usblp); |
1661 | - usb_autopm_put_interface(usblp->intf); |
1662 | - } else /* finish cleanup from disconnect */ |
1663 | + |
1664 | + usb_autopm_put_interface(usblp->intf); |
1665 | + |
1666 | + if (!usblp->present) /* finish cleanup from disconnect */ |
1667 | usblp_cleanup(usblp); |
1668 | mutex_unlock(&usblp_mutex); |
1669 | return 0; |
1670 | diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c |
1671 | index 213b52508621..1505e554d245 100644 |
1672 | --- a/drivers/usb/gadget/udc/dummy_hcd.c |
1673 | +++ b/drivers/usb/gadget/udc/dummy_hcd.c |
1674 | @@ -48,6 +48,7 @@ |
1675 | #define DRIVER_VERSION "02 May 2005" |
1676 | |
1677 | #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */ |
1678 | +#define POWER_BUDGET_3 900 /* in mA */ |
1679 | |
1680 | static const char driver_name[] = "dummy_hcd"; |
1681 | static const char driver_desc[] = "USB Host+Gadget Emulator"; |
1682 | @@ -2446,7 +2447,7 @@ static int dummy_start_ss(struct dummy_hcd *dum_hcd) |
1683 | dum_hcd->rh_state = DUMMY_RH_RUNNING; |
1684 | dum_hcd->stream_en_ep = 0; |
1685 | INIT_LIST_HEAD(&dum_hcd->urbp_list); |
1686 | - dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET; |
1687 | + dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET_3; |
1688 | dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING; |
1689 | dummy_hcd_to_hcd(dum_hcd)->uses_new_polling = 1; |
1690 | #ifdef CONFIG_USB_OTG |
1691 | diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c |
1692 | index f896a00662ef..9d79824ab5b6 100644 |
1693 | --- a/drivers/usb/host/xhci-ring.c |
1694 | +++ b/drivers/usb/host/xhci-ring.c |
1695 | @@ -3154,10 +3154,10 @@ static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len, |
1696 | if (usb_urb_dir_out(urb)) { |
1697 | len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs, |
1698 | seg->bounce_buf, new_buff_len, enqd_len); |
1699 | - if (len != seg->bounce_len) |
1700 | + if (len != new_buff_len) |
1701 | xhci_warn(xhci, |
1702 | "WARN Wrong bounce buffer write length: %zu != %d\n", |
1703 | - len, seg->bounce_len); |
1704 | + len, new_buff_len); |
1705 | seg->bounce_dma = dma_map_single(dev, seg->bounce_buf, |
1706 | max_pkt, DMA_TO_DEVICE); |
1707 | } else { |
1708 | diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c |
1709 | index 4ffadca2c71a..36865d50171f 100644 |
1710 | --- a/drivers/usb/host/xhci.c |
1711 | +++ b/drivers/usb/host/xhci.c |
1712 | @@ -1022,7 +1022,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) |
1713 | writel(command, &xhci->op_regs->command); |
1714 | xhci->broken_suspend = 0; |
1715 | if (xhci_handshake(&xhci->op_regs->status, |
1716 | - STS_SAVE, 0, 10 * 1000)) { |
1717 | + STS_SAVE, 0, 20 * 1000)) { |
1718 | /* |
1719 | * AMD SNPS xHC 3.0 occasionally does not clear the |
1720 | * SSS bit of USBSTS and when driver tries to poll |
1721 | @@ -1098,6 +1098,18 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) |
1722 | hibernated = true; |
1723 | |
1724 | if (!hibernated) { |
1725 | + /* |
1726 | + * Some controllers might lose power during suspend, so wait |
1727 | + * for controller not ready bit to clear, just as in xHC init. |
1728 | + */ |
1729 | + retval = xhci_handshake(&xhci->op_regs->status, |
1730 | + STS_CNR, 0, 10 * 1000 * 1000); |
1731 | + if (retval) { |
1732 | + xhci_warn(xhci, "Controller not ready at resume %d\n", |
1733 | + retval); |
1734 | + spin_unlock_irq(&xhci->lock); |
1735 | + return retval; |
1736 | + } |
1737 | /* step 1: restore register */ |
1738 | xhci_restore_registers(xhci); |
1739 | /* step 2: initialize command ring buffer */ |
1740 | @@ -3053,6 +3065,7 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, |
1741 | unsigned int ep_index; |
1742 | unsigned long flags; |
1743 | u32 ep_flag; |
1744 | + int err; |
1745 | |
1746 | xhci = hcd_to_xhci(hcd); |
1747 | if (!host_ep->hcpriv) |
1748 | @@ -3102,7 +3115,17 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, |
1749 | xhci_free_command(xhci, cfg_cmd); |
1750 | goto cleanup; |
1751 | } |
1752 | - xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, ep_index, 0); |
1753 | + |
1754 | + err = xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, |
1755 | + ep_index, 0); |
1756 | + if (err < 0) { |
1757 | + spin_unlock_irqrestore(&xhci->lock, flags); |
1758 | + xhci_free_command(xhci, cfg_cmd); |
1759 | + xhci_dbg(xhci, "%s: Failed to queue stop ep command, %d ", |
1760 | + __func__, err); |
1761 | + goto cleanup; |
1762 | + } |
1763 | + |
1764 | xhci_ring_cmd_db(xhci); |
1765 | spin_unlock_irqrestore(&xhci->lock, flags); |
1766 | |
1767 | @@ -3116,8 +3139,16 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, |
1768 | ctrl_ctx, ep_flag, ep_flag); |
1769 | xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index); |
1770 | |
1771 | - xhci_queue_configure_endpoint(xhci, cfg_cmd, cfg_cmd->in_ctx->dma, |
1772 | + err = xhci_queue_configure_endpoint(xhci, cfg_cmd, cfg_cmd->in_ctx->dma, |
1773 | udev->slot_id, false); |
1774 | + if (err < 0) { |
1775 | + spin_unlock_irqrestore(&xhci->lock, flags); |
1776 | + xhci_free_command(xhci, cfg_cmd); |
1777 | + xhci_dbg(xhci, "%s: Failed to queue config ep command, %d ", |
1778 | + __func__, err); |
1779 | + goto cleanup; |
1780 | + } |
1781 | + |
1782 | xhci_ring_cmd_db(xhci); |
1783 | spin_unlock_irqrestore(&xhci->lock, flags); |
1784 | |
1785 | @@ -4631,12 +4662,12 @@ static int xhci_update_timeout_for_endpoint(struct xhci_hcd *xhci, |
1786 | alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev, |
1787 | desc, state, timeout); |
1788 | |
1789 | - /* If we found we can't enable hub-initiated LPM, or |
1790 | + /* If we found we can't enable hub-initiated LPM, and |
1791 | * the U1 or U2 exit latency was too high to allow |
1792 | - * device-initiated LPM as well, just stop searching. |
1793 | + * device-initiated LPM as well, then we will disable LPM |
1794 | + * for this device, so stop searching any further. |
1795 | */ |
1796 | - if (alt_timeout == USB3_LPM_DISABLED || |
1797 | - alt_timeout == USB3_LPM_DEVICE_INITIATED) { |
1798 | + if (alt_timeout == USB3_LPM_DISABLED) { |
1799 | *timeout = alt_timeout; |
1800 | return -E2BIG; |
1801 | } |
1802 | @@ -4747,10 +4778,12 @@ static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd, |
1803 | if (intf->dev.driver) { |
1804 | driver = to_usb_driver(intf->dev.driver); |
1805 | if (driver && driver->disable_hub_initiated_lpm) { |
1806 | - dev_dbg(&udev->dev, "Hub-initiated %s disabled " |
1807 | - "at request of driver %s\n", |
1808 | - state_name, driver->name); |
1809 | - return xhci_get_timeout_no_hub_lpm(udev, state); |
1810 | + dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n", |
1811 | + state_name, driver->name); |
1812 | + timeout = xhci_get_timeout_no_hub_lpm(udev, |
1813 | + state); |
1814 | + if (timeout == USB3_LPM_DISABLED) |
1815 | + return timeout; |
1816 | } |
1817 | } |
1818 | |
1819 | @@ -5034,11 +5067,18 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) |
1820 | hcd->has_tt = 1; |
1821 | } else { |
1822 | /* |
1823 | - * Some 3.1 hosts return sbrn 0x30, use xhci supported protocol |
1824 | - * minor revision instead of sbrn. Minor revision is a two digit |
1825 | - * BCD containing minor and sub-minor numbers, only show minor. |
1826 | + * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts |
1827 | + * should return 0x31 for sbrn, or that the minor revision |
1828 | + * is a two digit BCD containig minor and sub-minor numbers. |
1829 | + * This was later clarified in xHCI 1.2. |
1830 | + * |
1831 | + * Some USB 3.1 capable hosts therefore have sbrn 0x30, and |
1832 | + * minor revision set to 0x1 instead of 0x10. |
1833 | */ |
1834 | - minor_rev = xhci->usb3_rhub.min_rev / 0x10; |
1835 | + if (xhci->usb3_rhub.min_rev == 0x1) |
1836 | + minor_rev = 1; |
1837 | + else |
1838 | + minor_rev = xhci->usb3_rhub.min_rev / 0x10; |
1839 | |
1840 | switch (minor_rev) { |
1841 | case 2: |
1842 | diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c |
1843 | index 9f2f563c82ed..addbb47a5033 100644 |
1844 | --- a/drivers/usb/image/microtek.c |
1845 | +++ b/drivers/usb/image/microtek.c |
1846 | @@ -721,6 +721,10 @@ static int mts_usb_probe(struct usb_interface *intf, |
1847 | |
1848 | } |
1849 | |
1850 | + if (ep_in_current != &ep_in_set[2]) { |
1851 | + MTS_WARNING("couldn't find two input bulk endpoints. Bailing out.\n"); |
1852 | + return -ENODEV; |
1853 | + } |
1854 | |
1855 | if ( ep_out == -1 ) { |
1856 | MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" ); |
1857 | diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig |
1858 | index 68d2f2cd17dd..2e3fc63619b7 100644 |
1859 | --- a/drivers/usb/misc/Kconfig |
1860 | +++ b/drivers/usb/misc/Kconfig |
1861 | @@ -46,16 +46,6 @@ config USB_SEVSEG |
1862 | To compile this driver as a module, choose M here: the |
1863 | module will be called usbsevseg. |
1864 | |
1865 | -config USB_RIO500 |
1866 | - tristate "USB Diamond Rio500 support" |
1867 | - help |
1868 | - Say Y here if you want to connect a USB Rio500 mp3 player to your |
1869 | - computer's USB port. Please read <file:Documentation/usb/rio.txt> |
1870 | - for more information. |
1871 | - |
1872 | - To compile this driver as a module, choose M here: the |
1873 | - module will be called rio500. |
1874 | - |
1875 | config USB_LEGOTOWER |
1876 | tristate "USB Lego Infrared Tower support" |
1877 | help |
1878 | diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile |
1879 | index 109f54f5b9aa..0d416eb624bb 100644 |
1880 | --- a/drivers/usb/misc/Makefile |
1881 | +++ b/drivers/usb/misc/Makefile |
1882 | @@ -17,7 +17,6 @@ obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o |
1883 | obj-$(CONFIG_USB_LCD) += usblcd.o |
1884 | obj-$(CONFIG_USB_LD) += ldusb.o |
1885 | obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o |
1886 | -obj-$(CONFIG_USB_RIO500) += rio500.o |
1887 | obj-$(CONFIG_USB_TEST) += usbtest.o |
1888 | obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o |
1889 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o |
1890 | diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c |
1891 | index 9465fb95d70a..9a51760df026 100644 |
1892 | --- a/drivers/usb/misc/adutux.c |
1893 | +++ b/drivers/usb/misc/adutux.c |
1894 | @@ -75,6 +75,7 @@ struct adu_device { |
1895 | char serial_number[8]; |
1896 | |
1897 | int open_count; /* number of times this port has been opened */ |
1898 | + unsigned long disconnected:1; |
1899 | |
1900 | char *read_buffer_primary; |
1901 | int read_buffer_length; |
1902 | @@ -116,7 +117,7 @@ static void adu_abort_transfers(struct adu_device *dev) |
1903 | { |
1904 | unsigned long flags; |
1905 | |
1906 | - if (dev->udev == NULL) |
1907 | + if (dev->disconnected) |
1908 | return; |
1909 | |
1910 | /* shutdown transfer */ |
1911 | @@ -148,6 +149,7 @@ static void adu_delete(struct adu_device *dev) |
1912 | kfree(dev->read_buffer_secondary); |
1913 | kfree(dev->interrupt_in_buffer); |
1914 | kfree(dev->interrupt_out_buffer); |
1915 | + usb_put_dev(dev->udev); |
1916 | kfree(dev); |
1917 | } |
1918 | |
1919 | @@ -243,7 +245,7 @@ static int adu_open(struct inode *inode, struct file *file) |
1920 | } |
1921 | |
1922 | dev = usb_get_intfdata(interface); |
1923 | - if (!dev || !dev->udev) { |
1924 | + if (!dev) { |
1925 | retval = -ENODEV; |
1926 | goto exit_no_device; |
1927 | } |
1928 | @@ -326,7 +328,7 @@ static int adu_release(struct inode *inode, struct file *file) |
1929 | } |
1930 | |
1931 | adu_release_internal(dev); |
1932 | - if (dev->udev == NULL) { |
1933 | + if (dev->disconnected) { |
1934 | /* the device was unplugged before the file was released */ |
1935 | if (!dev->open_count) /* ... and we're the last user */ |
1936 | adu_delete(dev); |
1937 | @@ -355,7 +357,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, |
1938 | return -ERESTARTSYS; |
1939 | |
1940 | /* verify that the device wasn't unplugged */ |
1941 | - if (dev->udev == NULL) { |
1942 | + if (dev->disconnected) { |
1943 | retval = -ENODEV; |
1944 | pr_err("No device or device unplugged %d\n", retval); |
1945 | goto exit; |
1946 | @@ -520,7 +522,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, |
1947 | goto exit_nolock; |
1948 | |
1949 | /* verify that the device wasn't unplugged */ |
1950 | - if (dev->udev == NULL) { |
1951 | + if (dev->disconnected) { |
1952 | retval = -ENODEV; |
1953 | pr_err("No device or device unplugged %d\n", retval); |
1954 | goto exit; |
1955 | @@ -665,7 +667,7 @@ static int adu_probe(struct usb_interface *interface, |
1956 | |
1957 | mutex_init(&dev->mtx); |
1958 | spin_lock_init(&dev->buflock); |
1959 | - dev->udev = udev; |
1960 | + dev->udev = usb_get_dev(udev); |
1961 | init_waitqueue_head(&dev->read_wait); |
1962 | init_waitqueue_head(&dev->write_wait); |
1963 | |
1964 | @@ -764,14 +766,18 @@ static void adu_disconnect(struct usb_interface *interface) |
1965 | |
1966 | dev = usb_get_intfdata(interface); |
1967 | |
1968 | - mutex_lock(&dev->mtx); /* not interruptible */ |
1969 | - dev->udev = NULL; /* poison */ |
1970 | usb_deregister_dev(interface, &adu_class); |
1971 | - mutex_unlock(&dev->mtx); |
1972 | + |
1973 | + usb_poison_urb(dev->interrupt_in_urb); |
1974 | + usb_poison_urb(dev->interrupt_out_urb); |
1975 | |
1976 | mutex_lock(&adutux_mutex); |
1977 | usb_set_intfdata(interface, NULL); |
1978 | |
1979 | + mutex_lock(&dev->mtx); /* not interruptible */ |
1980 | + dev->disconnected = 1; |
1981 | + mutex_unlock(&dev->mtx); |
1982 | + |
1983 | /* if the device is not opened, then we clean up right now */ |
1984 | if (!dev->open_count) |
1985 | adu_delete(dev); |
1986 | diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c |
1987 | index cf5828ce927a..34e6cd6f40d3 100644 |
1988 | --- a/drivers/usb/misc/chaoskey.c |
1989 | +++ b/drivers/usb/misc/chaoskey.c |
1990 | @@ -98,6 +98,7 @@ static void chaoskey_free(struct chaoskey *dev) |
1991 | usb_free_urb(dev->urb); |
1992 | kfree(dev->name); |
1993 | kfree(dev->buf); |
1994 | + usb_put_intf(dev->interface); |
1995 | kfree(dev); |
1996 | } |
1997 | } |
1998 | @@ -145,6 +146,8 @@ static int chaoskey_probe(struct usb_interface *interface, |
1999 | if (dev == NULL) |
2000 | goto out; |
2001 | |
2002 | + dev->interface = usb_get_intf(interface); |
2003 | + |
2004 | dev->buf = kmalloc(size, GFP_KERNEL); |
2005 | |
2006 | if (dev->buf == NULL) |
2007 | @@ -174,8 +177,6 @@ static int chaoskey_probe(struct usb_interface *interface, |
2008 | goto out; |
2009 | } |
2010 | |
2011 | - dev->interface = interface; |
2012 | - |
2013 | dev->in_ep = in_ep; |
2014 | |
2015 | if (le16_to_cpu(udev->descriptor.idVendor) != ALEA_VENDOR_ID) |
2016 | diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c |
2017 | index 55db0fc87927..2d9d9490cdd4 100644 |
2018 | --- a/drivers/usb/misc/iowarrior.c |
2019 | +++ b/drivers/usb/misc/iowarrior.c |
2020 | @@ -87,6 +87,7 @@ struct iowarrior { |
2021 | char chip_serial[9]; /* the serial number string of the chip connected */ |
2022 | int report_size; /* number of bytes in a report */ |
2023 | u16 product_id; |
2024 | + struct usb_anchor submitted; |
2025 | }; |
2026 | |
2027 | /*--------------*/ |
2028 | @@ -243,6 +244,7 @@ static inline void iowarrior_delete(struct iowarrior *dev) |
2029 | kfree(dev->int_in_buffer); |
2030 | usb_free_urb(dev->int_in_urb); |
2031 | kfree(dev->read_queue); |
2032 | + usb_put_intf(dev->interface); |
2033 | kfree(dev); |
2034 | } |
2035 | |
2036 | @@ -424,11 +426,13 @@ static ssize_t iowarrior_write(struct file *file, |
2037 | retval = -EFAULT; |
2038 | goto error; |
2039 | } |
2040 | + usb_anchor_urb(int_out_urb, &dev->submitted); |
2041 | retval = usb_submit_urb(int_out_urb, GFP_KERNEL); |
2042 | if (retval) { |
2043 | dev_dbg(&dev->interface->dev, |
2044 | "submit error %d for urb nr.%d\n", |
2045 | retval, atomic_read(&dev->write_busy)); |
2046 | + usb_unanchor_urb(int_out_urb); |
2047 | goto error; |
2048 | } |
2049 | /* submit was ok */ |
2050 | @@ -764,11 +768,13 @@ static int iowarrior_probe(struct usb_interface *interface, |
2051 | init_waitqueue_head(&dev->write_wait); |
2052 | |
2053 | dev->udev = udev; |
2054 | - dev->interface = interface; |
2055 | + dev->interface = usb_get_intf(interface); |
2056 | |
2057 | iface_desc = interface->cur_altsetting; |
2058 | dev->product_id = le16_to_cpu(udev->descriptor.idProduct); |
2059 | |
2060 | + init_usb_anchor(&dev->submitted); |
2061 | + |
2062 | res = usb_find_last_int_in_endpoint(iface_desc, &dev->int_in_endpoint); |
2063 | if (res) { |
2064 | dev_err(&interface->dev, "no interrupt-in endpoint found\n"); |
2065 | @@ -866,8 +872,6 @@ static void iowarrior_disconnect(struct usb_interface *interface) |
2066 | dev = usb_get_intfdata(interface); |
2067 | mutex_lock(&iowarrior_open_disc_lock); |
2068 | usb_set_intfdata(interface, NULL); |
2069 | - /* prevent device read, write and ioctl */ |
2070 | - dev->present = 0; |
2071 | |
2072 | minor = dev->minor; |
2073 | mutex_unlock(&iowarrior_open_disc_lock); |
2074 | @@ -878,8 +882,7 @@ static void iowarrior_disconnect(struct usb_interface *interface) |
2075 | mutex_lock(&dev->mutex); |
2076 | |
2077 | /* prevent device read, write and ioctl */ |
2078 | - |
2079 | - mutex_unlock(&dev->mutex); |
2080 | + dev->present = 0; |
2081 | |
2082 | if (dev->opened) { |
2083 | /* There is a process that holds a filedescriptor to the device , |
2084 | @@ -887,10 +890,13 @@ static void iowarrior_disconnect(struct usb_interface *interface) |
2085 | Deleting the device is postponed until close() was called. |
2086 | */ |
2087 | usb_kill_urb(dev->int_in_urb); |
2088 | + usb_kill_anchored_urbs(&dev->submitted); |
2089 | wake_up_interruptible(&dev->read_wait); |
2090 | wake_up_interruptible(&dev->write_wait); |
2091 | + mutex_unlock(&dev->mutex); |
2092 | } else { |
2093 | /* no process is using the device, cleanup now */ |
2094 | + mutex_unlock(&dev->mutex); |
2095 | iowarrior_delete(dev); |
2096 | } |
2097 | |
2098 | diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c |
2099 | index 006762b72ff5..b9cbcf35d4e1 100644 |
2100 | --- a/drivers/usb/misc/ldusb.c |
2101 | +++ b/drivers/usb/misc/ldusb.c |
2102 | @@ -153,6 +153,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in |
2103 | struct ld_usb { |
2104 | struct mutex mutex; /* locks this structure */ |
2105 | struct usb_interface *intf; /* save off the usb interface pointer */ |
2106 | + unsigned long disconnected:1; |
2107 | |
2108 | int open_count; /* number of times this port has been opened */ |
2109 | |
2110 | @@ -192,12 +193,10 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) |
2111 | /* shutdown transfer */ |
2112 | if (dev->interrupt_in_running) { |
2113 | dev->interrupt_in_running = 0; |
2114 | - if (dev->intf) |
2115 | - usb_kill_urb(dev->interrupt_in_urb); |
2116 | + usb_kill_urb(dev->interrupt_in_urb); |
2117 | } |
2118 | if (dev->interrupt_out_busy) |
2119 | - if (dev->intf) |
2120 | - usb_kill_urb(dev->interrupt_out_urb); |
2121 | + usb_kill_urb(dev->interrupt_out_urb); |
2122 | } |
2123 | |
2124 | /** |
2125 | @@ -205,8 +204,6 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) |
2126 | */ |
2127 | static void ld_usb_delete(struct ld_usb *dev) |
2128 | { |
2129 | - ld_usb_abort_transfers(dev); |
2130 | - |
2131 | /* free data structures */ |
2132 | usb_free_urb(dev->interrupt_in_urb); |
2133 | usb_free_urb(dev->interrupt_out_urb); |
2134 | @@ -263,7 +260,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) |
2135 | |
2136 | resubmit: |
2137 | /* resubmit if we're still running */ |
2138 | - if (dev->interrupt_in_running && !dev->buffer_overflow && dev->intf) { |
2139 | + if (dev->interrupt_in_running && !dev->buffer_overflow) { |
2140 | retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC); |
2141 | if (retval) { |
2142 | dev_err(&dev->intf->dev, |
2143 | @@ -392,7 +389,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) |
2144 | retval = -ENODEV; |
2145 | goto unlock_exit; |
2146 | } |
2147 | - if (dev->intf == NULL) { |
2148 | + if (dev->disconnected) { |
2149 | /* the device was unplugged before the file was released */ |
2150 | mutex_unlock(&dev->mutex); |
2151 | /* unlock here as ld_usb_delete frees dev */ |
2152 | @@ -423,7 +420,7 @@ static __poll_t ld_usb_poll(struct file *file, poll_table *wait) |
2153 | |
2154 | dev = file->private_data; |
2155 | |
2156 | - if (!dev->intf) |
2157 | + if (dev->disconnected) |
2158 | return EPOLLERR | EPOLLHUP; |
2159 | |
2160 | poll_wait(file, &dev->read_wait, wait); |
2161 | @@ -462,7 +459,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, |
2162 | } |
2163 | |
2164 | /* verify that the device wasn't unplugged */ |
2165 | - if (dev->intf == NULL) { |
2166 | + if (dev->disconnected) { |
2167 | retval = -ENODEV; |
2168 | printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval); |
2169 | goto unlock_exit; |
2170 | @@ -542,7 +539,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, |
2171 | } |
2172 | |
2173 | /* verify that the device wasn't unplugged */ |
2174 | - if (dev->intf == NULL) { |
2175 | + if (dev->disconnected) { |
2176 | retval = -ENODEV; |
2177 | printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval); |
2178 | goto unlock_exit; |
2179 | @@ -764,6 +761,9 @@ static void ld_usb_disconnect(struct usb_interface *intf) |
2180 | /* give back our minor */ |
2181 | usb_deregister_dev(intf, &ld_usb_class); |
2182 | |
2183 | + usb_poison_urb(dev->interrupt_in_urb); |
2184 | + usb_poison_urb(dev->interrupt_out_urb); |
2185 | + |
2186 | mutex_lock(&dev->mutex); |
2187 | |
2188 | /* if the device is not opened, then we clean up right now */ |
2189 | @@ -771,7 +771,7 @@ static void ld_usb_disconnect(struct usb_interface *intf) |
2190 | mutex_unlock(&dev->mutex); |
2191 | ld_usb_delete(dev); |
2192 | } else { |
2193 | - dev->intf = NULL; |
2194 | + dev->disconnected = 1; |
2195 | /* wake up pollers */ |
2196 | wake_up_interruptible_all(&dev->read_wait); |
2197 | wake_up_interruptible_all(&dev->write_wait); |
2198 | diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c |
2199 | index 006cf13b2199..9d4c52a7ebe0 100644 |
2200 | --- a/drivers/usb/misc/legousbtower.c |
2201 | +++ b/drivers/usb/misc/legousbtower.c |
2202 | @@ -179,7 +179,6 @@ static const struct usb_device_id tower_table[] = { |
2203 | }; |
2204 | |
2205 | MODULE_DEVICE_TABLE (usb, tower_table); |
2206 | -static DEFINE_MUTEX(open_disc_mutex); |
2207 | |
2208 | #define LEGO_USB_TOWER_MINOR_BASE 160 |
2209 | |
2210 | @@ -191,6 +190,7 @@ struct lego_usb_tower { |
2211 | unsigned char minor; /* the starting minor number for this device */ |
2212 | |
2213 | int open_count; /* number of times this port has been opened */ |
2214 | + unsigned long disconnected:1; |
2215 | |
2216 | char* read_buffer; |
2217 | size_t read_buffer_length; /* this much came in */ |
2218 | @@ -290,14 +290,13 @@ static inline void lego_usb_tower_debug_data(struct device *dev, |
2219 | */ |
2220 | static inline void tower_delete (struct lego_usb_tower *dev) |
2221 | { |
2222 | - tower_abort_transfers (dev); |
2223 | - |
2224 | /* free data structures */ |
2225 | usb_free_urb(dev->interrupt_in_urb); |
2226 | usb_free_urb(dev->interrupt_out_urb); |
2227 | kfree (dev->read_buffer); |
2228 | kfree (dev->interrupt_in_buffer); |
2229 | kfree (dev->interrupt_out_buffer); |
2230 | + usb_put_dev(dev->udev); |
2231 | kfree (dev); |
2232 | } |
2233 | |
2234 | @@ -332,18 +331,14 @@ static int tower_open (struct inode *inode, struct file *file) |
2235 | goto exit; |
2236 | } |
2237 | |
2238 | - mutex_lock(&open_disc_mutex); |
2239 | dev = usb_get_intfdata(interface); |
2240 | - |
2241 | if (!dev) { |
2242 | - mutex_unlock(&open_disc_mutex); |
2243 | retval = -ENODEV; |
2244 | goto exit; |
2245 | } |
2246 | |
2247 | /* lock this device */ |
2248 | if (mutex_lock_interruptible(&dev->lock)) { |
2249 | - mutex_unlock(&open_disc_mutex); |
2250 | retval = -ERESTARTSYS; |
2251 | goto exit; |
2252 | } |
2253 | @@ -351,12 +346,9 @@ static int tower_open (struct inode *inode, struct file *file) |
2254 | |
2255 | /* allow opening only once */ |
2256 | if (dev->open_count) { |
2257 | - mutex_unlock(&open_disc_mutex); |
2258 | retval = -EBUSY; |
2259 | goto unlock_exit; |
2260 | } |
2261 | - dev->open_count = 1; |
2262 | - mutex_unlock(&open_disc_mutex); |
2263 | |
2264 | /* reset the tower */ |
2265 | result = usb_control_msg (dev->udev, |
2266 | @@ -396,13 +388,14 @@ static int tower_open (struct inode *inode, struct file *file) |
2267 | dev_err(&dev->udev->dev, |
2268 | "Couldn't submit interrupt_in_urb %d\n", retval); |
2269 | dev->interrupt_in_running = 0; |
2270 | - dev->open_count = 0; |
2271 | goto unlock_exit; |
2272 | } |
2273 | |
2274 | /* save device in the file's private structure */ |
2275 | file->private_data = dev; |
2276 | |
2277 | + dev->open_count = 1; |
2278 | + |
2279 | unlock_exit: |
2280 | mutex_unlock(&dev->lock); |
2281 | |
2282 | @@ -423,10 +416,9 @@ static int tower_release (struct inode *inode, struct file *file) |
2283 | |
2284 | if (dev == NULL) { |
2285 | retval = -ENODEV; |
2286 | - goto exit_nolock; |
2287 | + goto exit; |
2288 | } |
2289 | |
2290 | - mutex_lock(&open_disc_mutex); |
2291 | if (mutex_lock_interruptible(&dev->lock)) { |
2292 | retval = -ERESTARTSYS; |
2293 | goto exit; |
2294 | @@ -438,7 +430,8 @@ static int tower_release (struct inode *inode, struct file *file) |
2295 | retval = -ENODEV; |
2296 | goto unlock_exit; |
2297 | } |
2298 | - if (dev->udev == NULL) { |
2299 | + |
2300 | + if (dev->disconnected) { |
2301 | /* the device was unplugged before the file was released */ |
2302 | |
2303 | /* unlock here as tower_delete frees dev */ |
2304 | @@ -456,10 +449,7 @@ static int tower_release (struct inode *inode, struct file *file) |
2305 | |
2306 | unlock_exit: |
2307 | mutex_unlock(&dev->lock); |
2308 | - |
2309 | exit: |
2310 | - mutex_unlock(&open_disc_mutex); |
2311 | -exit_nolock: |
2312 | return retval; |
2313 | } |
2314 | |
2315 | @@ -477,10 +467,9 @@ static void tower_abort_transfers (struct lego_usb_tower *dev) |
2316 | if (dev->interrupt_in_running) { |
2317 | dev->interrupt_in_running = 0; |
2318 | mb(); |
2319 | - if (dev->udev) |
2320 | - usb_kill_urb (dev->interrupt_in_urb); |
2321 | + usb_kill_urb(dev->interrupt_in_urb); |
2322 | } |
2323 | - if (dev->interrupt_out_busy && dev->udev) |
2324 | + if (dev->interrupt_out_busy) |
2325 | usb_kill_urb(dev->interrupt_out_urb); |
2326 | } |
2327 | |
2328 | @@ -516,7 +505,7 @@ static __poll_t tower_poll (struct file *file, poll_table *wait) |
2329 | |
2330 | dev = file->private_data; |
2331 | |
2332 | - if (!dev->udev) |
2333 | + if (dev->disconnected) |
2334 | return EPOLLERR | EPOLLHUP; |
2335 | |
2336 | poll_wait(file, &dev->read_wait, wait); |
2337 | @@ -563,7 +552,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count, |
2338 | } |
2339 | |
2340 | /* verify that the device wasn't unplugged */ |
2341 | - if (dev->udev == NULL) { |
2342 | + if (dev->disconnected) { |
2343 | retval = -ENODEV; |
2344 | pr_err("No device or device unplugged %d\n", retval); |
2345 | goto unlock_exit; |
2346 | @@ -649,7 +638,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t |
2347 | } |
2348 | |
2349 | /* verify that the device wasn't unplugged */ |
2350 | - if (dev->udev == NULL) { |
2351 | + if (dev->disconnected) { |
2352 | retval = -ENODEV; |
2353 | pr_err("No device or device unplugged %d\n", retval); |
2354 | goto unlock_exit; |
2355 | @@ -759,7 +748,7 @@ static void tower_interrupt_in_callback (struct urb *urb) |
2356 | |
2357 | resubmit: |
2358 | /* resubmit if we're still running */ |
2359 | - if (dev->interrupt_in_running && dev->udev) { |
2360 | + if (dev->interrupt_in_running) { |
2361 | retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC); |
2362 | if (retval) |
2363 | dev_err(&dev->udev->dev, |
2364 | @@ -822,8 +811,9 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device |
2365 | |
2366 | mutex_init(&dev->lock); |
2367 | |
2368 | - dev->udev = udev; |
2369 | + dev->udev = usb_get_dev(udev); |
2370 | dev->open_count = 0; |
2371 | + dev->disconnected = 0; |
2372 | |
2373 | dev->read_buffer = NULL; |
2374 | dev->read_buffer_length = 0; |
2375 | @@ -891,8 +881,10 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device |
2376 | get_version_reply, |
2377 | sizeof(*get_version_reply), |
2378 | 1000); |
2379 | - if (result < 0) { |
2380 | - dev_err(idev, "LEGO USB Tower get version control request failed\n"); |
2381 | + if (result < sizeof(*get_version_reply)) { |
2382 | + if (result >= 0) |
2383 | + result = -EIO; |
2384 | + dev_err(idev, "get version request failed: %d\n", result); |
2385 | retval = result; |
2386 | goto error; |
2387 | } |
2388 | @@ -910,7 +902,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device |
2389 | if (retval) { |
2390 | /* something prevented us from registering this driver */ |
2391 | dev_err(idev, "Not able to get a minor for this device.\n"); |
2392 | - usb_set_intfdata (interface, NULL); |
2393 | goto error; |
2394 | } |
2395 | dev->minor = interface->minor; |
2396 | @@ -942,23 +933,24 @@ static void tower_disconnect (struct usb_interface *interface) |
2397 | int minor; |
2398 | |
2399 | dev = usb_get_intfdata (interface); |
2400 | - mutex_lock(&open_disc_mutex); |
2401 | - usb_set_intfdata (interface, NULL); |
2402 | |
2403 | minor = dev->minor; |
2404 | |
2405 | - /* give back our minor */ |
2406 | + /* give back our minor and prevent further open() */ |
2407 | usb_deregister_dev (interface, &tower_class); |
2408 | |
2409 | + /* stop I/O */ |
2410 | + usb_poison_urb(dev->interrupt_in_urb); |
2411 | + usb_poison_urb(dev->interrupt_out_urb); |
2412 | + |
2413 | mutex_lock(&dev->lock); |
2414 | - mutex_unlock(&open_disc_mutex); |
2415 | |
2416 | /* if the device is not opened, then we clean up right now */ |
2417 | if (!dev->open_count) { |
2418 | mutex_unlock(&dev->lock); |
2419 | tower_delete (dev); |
2420 | } else { |
2421 | - dev->udev = NULL; |
2422 | + dev->disconnected = 1; |
2423 | /* wake up pollers */ |
2424 | wake_up_interruptible_all(&dev->read_wait); |
2425 | wake_up_interruptible_all(&dev->write_wait); |
2426 | diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c |
2427 | deleted file mode 100644 |
2428 | index a32d61a79ab8..000000000000 |
2429 | --- a/drivers/usb/misc/rio500.c |
2430 | +++ /dev/null |
2431 | @@ -1,561 +0,0 @@ |
2432 | -// SPDX-License-Identifier: GPL-2.0+ |
2433 | -/* -*- linux-c -*- */ |
2434 | - |
2435 | -/* |
2436 | - * Driver for USB Rio 500 |
2437 | - * |
2438 | - * Cesar Miquel (miquel@df.uba.ar) |
2439 | - * |
2440 | - * based on hp_scanner.c by David E. Nelson (dnelson@jump.net) |
2441 | - * |
2442 | - * Based upon mouse.c (Brad Keryan) and printer.c (Michael Gee). |
2443 | - * |
2444 | - * Changelog: |
2445 | - * 30/05/2003 replaced lock/unlock kernel with up/down |
2446 | - * Daniele Bellucci bellucda@tiscali.it |
2447 | - * */ |
2448 | - |
2449 | -#include <linux/module.h> |
2450 | -#include <linux/kernel.h> |
2451 | -#include <linux/signal.h> |
2452 | -#include <linux/sched/signal.h> |
2453 | -#include <linux/mutex.h> |
2454 | -#include <linux/errno.h> |
2455 | -#include <linux/random.h> |
2456 | -#include <linux/poll.h> |
2457 | -#include <linux/slab.h> |
2458 | -#include <linux/spinlock.h> |
2459 | -#include <linux/usb.h> |
2460 | -#include <linux/wait.h> |
2461 | - |
2462 | -#include "rio500_usb.h" |
2463 | - |
2464 | -#define DRIVER_AUTHOR "Cesar Miquel <miquel@df.uba.ar>" |
2465 | -#define DRIVER_DESC "USB Rio 500 driver" |
2466 | - |
2467 | -#define RIO_MINOR 64 |
2468 | - |
2469 | -/* stall/wait timeout for rio */ |
2470 | -#define NAK_TIMEOUT (HZ) |
2471 | - |
2472 | -#define IBUF_SIZE 0x1000 |
2473 | - |
2474 | -/* Size of the rio buffer */ |
2475 | -#define OBUF_SIZE 0x10000 |
2476 | - |
2477 | -struct rio_usb_data { |
2478 | - struct usb_device *rio_dev; /* init: probe_rio */ |
2479 | - unsigned int ifnum; /* Interface number of the USB device */ |
2480 | - int isopen; /* nz if open */ |
2481 | - int present; /* Device is present on the bus */ |
2482 | - char *obuf, *ibuf; /* transfer buffers */ |
2483 | - char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */ |
2484 | - wait_queue_head_t wait_q; /* for timeouts */ |
2485 | - struct mutex lock; /* general race avoidance */ |
2486 | -}; |
2487 | - |
2488 | -static DEFINE_MUTEX(rio500_mutex); |
2489 | -static struct rio_usb_data rio_instance; |
2490 | - |
2491 | -static int open_rio(struct inode *inode, struct file *file) |
2492 | -{ |
2493 | - struct rio_usb_data *rio = &rio_instance; |
2494 | - |
2495 | - /* against disconnect() */ |
2496 | - mutex_lock(&rio500_mutex); |
2497 | - mutex_lock(&(rio->lock)); |
2498 | - |
2499 | - if (rio->isopen || !rio->present) { |
2500 | - mutex_unlock(&(rio->lock)); |
2501 | - mutex_unlock(&rio500_mutex); |
2502 | - return -EBUSY; |
2503 | - } |
2504 | - rio->isopen = 1; |
2505 | - |
2506 | - init_waitqueue_head(&rio->wait_q); |
2507 | - |
2508 | - mutex_unlock(&(rio->lock)); |
2509 | - |
2510 | - dev_info(&rio->rio_dev->dev, "Rio opened.\n"); |
2511 | - mutex_unlock(&rio500_mutex); |
2512 | - |
2513 | - return 0; |
2514 | -} |
2515 | - |
2516 | -static int close_rio(struct inode *inode, struct file *file) |
2517 | -{ |
2518 | - struct rio_usb_data *rio = &rio_instance; |
2519 | - |
2520 | - /* against disconnect() */ |
2521 | - mutex_lock(&rio500_mutex); |
2522 | - mutex_lock(&(rio->lock)); |
2523 | - |
2524 | - rio->isopen = 0; |
2525 | - if (!rio->present) { |
2526 | - /* cleanup has been delayed */ |
2527 | - kfree(rio->ibuf); |
2528 | - kfree(rio->obuf); |
2529 | - rio->ibuf = NULL; |
2530 | - rio->obuf = NULL; |
2531 | - } else { |
2532 | - dev_info(&rio->rio_dev->dev, "Rio closed.\n"); |
2533 | - } |
2534 | - mutex_unlock(&(rio->lock)); |
2535 | - mutex_unlock(&rio500_mutex); |
2536 | - return 0; |
2537 | -} |
2538 | - |
2539 | -static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg) |
2540 | -{ |
2541 | - struct RioCommand rio_cmd; |
2542 | - struct rio_usb_data *rio = &rio_instance; |
2543 | - void __user *data; |
2544 | - unsigned char *buffer; |
2545 | - int result, requesttype; |
2546 | - int retries; |
2547 | - int retval=0; |
2548 | - |
2549 | - mutex_lock(&(rio->lock)); |
2550 | - /* Sanity check to make sure rio is connected, powered, etc */ |
2551 | - if (rio->present == 0 || rio->rio_dev == NULL) { |
2552 | - retval = -ENODEV; |
2553 | - goto err_out; |
2554 | - } |
2555 | - |
2556 | - switch (cmd) { |
2557 | - case RIO_RECV_COMMAND: |
2558 | - data = (void __user *) arg; |
2559 | - if (data == NULL) |
2560 | - break; |
2561 | - if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) { |
2562 | - retval = -EFAULT; |
2563 | - goto err_out; |
2564 | - } |
2565 | - if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) { |
2566 | - retval = -EINVAL; |
2567 | - goto err_out; |
2568 | - } |
2569 | - buffer = (unsigned char *) __get_free_page(GFP_KERNEL); |
2570 | - if (buffer == NULL) { |
2571 | - retval = -ENOMEM; |
2572 | - goto err_out; |
2573 | - } |
2574 | - if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) { |
2575 | - retval = -EFAULT; |
2576 | - free_page((unsigned long) buffer); |
2577 | - goto err_out; |
2578 | - } |
2579 | - |
2580 | - requesttype = rio_cmd.requesttype | USB_DIR_IN | |
2581 | - USB_TYPE_VENDOR | USB_RECIP_DEVICE; |
2582 | - dev_dbg(&rio->rio_dev->dev, |
2583 | - "sending command:reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n", |
2584 | - requesttype, rio_cmd.request, rio_cmd.value, |
2585 | - rio_cmd.index, rio_cmd.length); |
2586 | - /* Send rio control message */ |
2587 | - retries = 3; |
2588 | - while (retries) { |
2589 | - result = usb_control_msg(rio->rio_dev, |
2590 | - usb_rcvctrlpipe(rio-> rio_dev, 0), |
2591 | - rio_cmd.request, |
2592 | - requesttype, |
2593 | - rio_cmd.value, |
2594 | - rio_cmd.index, buffer, |
2595 | - rio_cmd.length, |
2596 | - jiffies_to_msecs(rio_cmd.timeout)); |
2597 | - if (result == -ETIMEDOUT) |
2598 | - retries--; |
2599 | - else if (result < 0) { |
2600 | - dev_err(&rio->rio_dev->dev, |
2601 | - "Error executing ioctrl. code = %d\n", |
2602 | - result); |
2603 | - retries = 0; |
2604 | - } else { |
2605 | - dev_dbg(&rio->rio_dev->dev, |
2606 | - "Executed ioctl. Result = %d (data=%02x)\n", |
2607 | - result, buffer[0]); |
2608 | - if (copy_to_user(rio_cmd.buffer, buffer, |
2609 | - rio_cmd.length)) { |
2610 | - free_page((unsigned long) buffer); |
2611 | - retval = -EFAULT; |
2612 | - goto err_out; |
2613 | - } |
2614 | - retries = 0; |
2615 | - } |
2616 | - |
2617 | - /* rio_cmd.buffer contains a raw stream of single byte |
2618 | - data which has been returned from rio. Data is |
2619 | - interpreted at application level. For data that |
2620 | - will be cast to data types longer than 1 byte, data |
2621 | - will be little_endian and will potentially need to |
2622 | - be swapped at the app level */ |
2623 | - |
2624 | - } |
2625 | - free_page((unsigned long) buffer); |
2626 | - break; |
2627 | - |
2628 | - case RIO_SEND_COMMAND: |
2629 | - data = (void __user *) arg; |
2630 | - if (data == NULL) |
2631 | - break; |
2632 | - if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) { |
2633 | - retval = -EFAULT; |
2634 | - goto err_out; |
2635 | - } |
2636 | - if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) { |
2637 | - retval = -EINVAL; |
2638 | - goto err_out; |
2639 | - } |
2640 | - buffer = (unsigned char *) __get_free_page(GFP_KERNEL); |
2641 | - if (buffer == NULL) { |
2642 | - retval = -ENOMEM; |
2643 | - goto err_out; |
2644 | - } |
2645 | - if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) { |
2646 | - free_page((unsigned long)buffer); |
2647 | - retval = -EFAULT; |
2648 | - goto err_out; |
2649 | - } |
2650 | - |
2651 | - requesttype = rio_cmd.requesttype | USB_DIR_OUT | |
2652 | - USB_TYPE_VENDOR | USB_RECIP_DEVICE; |
2653 | - dev_dbg(&rio->rio_dev->dev, |
2654 | - "sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n", |
2655 | - requesttype, rio_cmd.request, rio_cmd.value, |
2656 | - rio_cmd.index, rio_cmd.length); |
2657 | - /* Send rio control message */ |
2658 | - retries = 3; |
2659 | - while (retries) { |
2660 | - result = usb_control_msg(rio->rio_dev, |
2661 | - usb_sndctrlpipe(rio-> rio_dev, 0), |
2662 | - rio_cmd.request, |
2663 | - requesttype, |
2664 | - rio_cmd.value, |
2665 | - rio_cmd.index, buffer, |
2666 | - rio_cmd.length, |
2667 | - jiffies_to_msecs(rio_cmd.timeout)); |
2668 | - if (result == -ETIMEDOUT) |
2669 | - retries--; |
2670 | - else if (result < 0) { |
2671 | - dev_err(&rio->rio_dev->dev, |
2672 | - "Error executing ioctrl. code = %d\n", |
2673 | - result); |
2674 | - retries = 0; |
2675 | - } else { |
2676 | - dev_dbg(&rio->rio_dev->dev, |
2677 | - "Executed ioctl. Result = %d\n", result); |
2678 | - retries = 0; |
2679 | - |
2680 | - } |
2681 | - |
2682 | - } |
2683 | - free_page((unsigned long) buffer); |
2684 | - break; |
2685 | - |
2686 | - default: |
2687 | - retval = -ENOTTY; |
2688 | - break; |
2689 | - } |
2690 | - |
2691 | - |
2692 | -err_out: |
2693 | - mutex_unlock(&(rio->lock)); |
2694 | - return retval; |
2695 | -} |
2696 | - |
2697 | -static ssize_t |
2698 | -write_rio(struct file *file, const char __user *buffer, |
2699 | - size_t count, loff_t * ppos) |
2700 | -{ |
2701 | - DEFINE_WAIT(wait); |
2702 | - struct rio_usb_data *rio = &rio_instance; |
2703 | - |
2704 | - unsigned long copy_size; |
2705 | - unsigned long bytes_written = 0; |
2706 | - unsigned int partial; |
2707 | - |
2708 | - int result = 0; |
2709 | - int maxretry; |
2710 | - int errn = 0; |
2711 | - int intr; |
2712 | - |
2713 | - intr = mutex_lock_interruptible(&(rio->lock)); |
2714 | - if (intr) |
2715 | - return -EINTR; |
2716 | - /* Sanity check to make sure rio is connected, powered, etc */ |
2717 | - if (rio->present == 0 || rio->rio_dev == NULL) { |
2718 | - mutex_unlock(&(rio->lock)); |
2719 | - return -ENODEV; |
2720 | - } |
2721 | - |
2722 | - |
2723 | - |
2724 | - do { |
2725 | - unsigned long thistime; |
2726 | - char *obuf = rio->obuf; |
2727 | - |
2728 | - thistime = copy_size = |
2729 | - (count >= OBUF_SIZE) ? OBUF_SIZE : count; |
2730 | - if (copy_from_user(rio->obuf, buffer, copy_size)) { |
2731 | - errn = -EFAULT; |
2732 | - goto error; |
2733 | - } |
2734 | - maxretry = 5; |
2735 | - while (thistime) { |
2736 | - if (!rio->rio_dev) { |
2737 | - errn = -ENODEV; |
2738 | - goto error; |
2739 | - } |
2740 | - if (signal_pending(current)) { |
2741 | - mutex_unlock(&(rio->lock)); |
2742 | - return bytes_written ? bytes_written : -EINTR; |
2743 | - } |
2744 | - |
2745 | - result = usb_bulk_msg(rio->rio_dev, |
2746 | - usb_sndbulkpipe(rio->rio_dev, 2), |
2747 | - obuf, thistime, &partial, 5000); |
2748 | - |
2749 | - dev_dbg(&rio->rio_dev->dev, |
2750 | - "write stats: result:%d thistime:%lu partial:%u\n", |
2751 | - result, thistime, partial); |
2752 | - |
2753 | - if (result == -ETIMEDOUT) { /* NAK - so hold for a while */ |
2754 | - if (!maxretry--) { |
2755 | - errn = -ETIME; |
2756 | - goto error; |
2757 | - } |
2758 | - prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE); |
2759 | - schedule_timeout(NAK_TIMEOUT); |
2760 | - finish_wait(&rio->wait_q, &wait); |
2761 | - continue; |
2762 | - } else if (!result && partial) { |
2763 | - obuf += partial; |
2764 | - thistime -= partial; |
2765 | - } else |
2766 | - break; |
2767 | - } |
2768 | - if (result) { |
2769 | - dev_err(&rio->rio_dev->dev, "Write Whoops - %x\n", |
2770 | - result); |
2771 | - errn = -EIO; |
2772 | - goto error; |
2773 | - } |
2774 | - bytes_written += copy_size; |
2775 | - count -= copy_size; |
2776 | - buffer += copy_size; |
2777 | - } while (count > 0); |
2778 | - |
2779 | - mutex_unlock(&(rio->lock)); |
2780 | - |
2781 | - return bytes_written ? bytes_written : -EIO; |
2782 | - |
2783 | -error: |
2784 | - mutex_unlock(&(rio->lock)); |
2785 | - return errn; |
2786 | -} |
2787 | - |
2788 | -static ssize_t |
2789 | -read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) |
2790 | -{ |
2791 | - DEFINE_WAIT(wait); |
2792 | - struct rio_usb_data *rio = &rio_instance; |
2793 | - ssize_t read_count; |
2794 | - unsigned int partial; |
2795 | - int this_read; |
2796 | - int result; |
2797 | - int maxretry = 10; |
2798 | - char *ibuf; |
2799 | - int intr; |
2800 | - |
2801 | - intr = mutex_lock_interruptible(&(rio->lock)); |
2802 | - if (intr) |
2803 | - return -EINTR; |
2804 | - /* Sanity check to make sure rio is connected, powered, etc */ |
2805 | - if (rio->present == 0 || rio->rio_dev == NULL) { |
2806 | - mutex_unlock(&(rio->lock)); |
2807 | - return -ENODEV; |
2808 | - } |
2809 | - |
2810 | - ibuf = rio->ibuf; |
2811 | - |
2812 | - read_count = 0; |
2813 | - |
2814 | - |
2815 | - while (count > 0) { |
2816 | - if (signal_pending(current)) { |
2817 | - mutex_unlock(&(rio->lock)); |
2818 | - return read_count ? read_count : -EINTR; |
2819 | - } |
2820 | - if (!rio->rio_dev) { |
2821 | - mutex_unlock(&(rio->lock)); |
2822 | - return -ENODEV; |
2823 | - } |
2824 | - this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count; |
2825 | - |
2826 | - result = usb_bulk_msg(rio->rio_dev, |
2827 | - usb_rcvbulkpipe(rio->rio_dev, 1), |
2828 | - ibuf, this_read, &partial, |
2829 | - 8000); |
2830 | - |
2831 | - dev_dbg(&rio->rio_dev->dev, |
2832 | - "read stats: result:%d this_read:%u partial:%u\n", |
2833 | - result, this_read, partial); |
2834 | - |
2835 | - if (partial) { |
2836 | - count = this_read = partial; |
2837 | - } else if (result == -ETIMEDOUT || result == 15) { /* FIXME: 15 ??? */ |
2838 | - if (!maxretry--) { |
2839 | - mutex_unlock(&(rio->lock)); |
2840 | - dev_err(&rio->rio_dev->dev, |
2841 | - "read_rio: maxretry timeout\n"); |
2842 | - return -ETIME; |
2843 | - } |
2844 | - prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE); |
2845 | - schedule_timeout(NAK_TIMEOUT); |
2846 | - finish_wait(&rio->wait_q, &wait); |
2847 | - continue; |
2848 | - } else if (result != -EREMOTEIO) { |
2849 | - mutex_unlock(&(rio->lock)); |
2850 | - dev_err(&rio->rio_dev->dev, |
2851 | - "Read Whoops - result:%d partial:%u this_read:%u\n", |
2852 | - result, partial, this_read); |
2853 | - return -EIO; |
2854 | - } else { |
2855 | - mutex_unlock(&(rio->lock)); |
2856 | - return (0); |
2857 | - } |
2858 | - |
2859 | - if (this_read) { |
2860 | - if (copy_to_user(buffer, ibuf, this_read)) { |
2861 | - mutex_unlock(&(rio->lock)); |
2862 | - return -EFAULT; |
2863 | - } |
2864 | - count -= this_read; |
2865 | - read_count += this_read; |
2866 | - buffer += this_read; |
2867 | - } |
2868 | - } |
2869 | - mutex_unlock(&(rio->lock)); |
2870 | - return read_count; |
2871 | -} |
2872 | - |
2873 | -static const struct file_operations usb_rio_fops = { |
2874 | - .owner = THIS_MODULE, |
2875 | - .read = read_rio, |
2876 | - .write = write_rio, |
2877 | - .unlocked_ioctl = ioctl_rio, |
2878 | - .open = open_rio, |
2879 | - .release = close_rio, |
2880 | - .llseek = noop_llseek, |
2881 | -}; |
2882 | - |
2883 | -static struct usb_class_driver usb_rio_class = { |
2884 | - .name = "rio500%d", |
2885 | - .fops = &usb_rio_fops, |
2886 | - .minor_base = RIO_MINOR, |
2887 | -}; |
2888 | - |
2889 | -static int probe_rio(struct usb_interface *intf, |
2890 | - const struct usb_device_id *id) |
2891 | -{ |
2892 | - struct usb_device *dev = interface_to_usbdev(intf); |
2893 | - struct rio_usb_data *rio = &rio_instance; |
2894 | - int retval = 0; |
2895 | - |
2896 | - mutex_lock(&rio500_mutex); |
2897 | - if (rio->present) { |
2898 | - dev_info(&intf->dev, "Second USB Rio at address %d refused\n", dev->devnum); |
2899 | - retval = -EBUSY; |
2900 | - goto bail_out; |
2901 | - } else { |
2902 | - dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum); |
2903 | - } |
2904 | - |
2905 | - retval = usb_register_dev(intf, &usb_rio_class); |
2906 | - if (retval) { |
2907 | - dev_err(&dev->dev, |
2908 | - "Not able to get a minor for this device.\n"); |
2909 | - retval = -ENOMEM; |
2910 | - goto bail_out; |
2911 | - } |
2912 | - |
2913 | - rio->rio_dev = dev; |
2914 | - |
2915 | - if (!(rio->obuf = kmalloc(OBUF_SIZE, GFP_KERNEL))) { |
2916 | - dev_err(&dev->dev, |
2917 | - "probe_rio: Not enough memory for the output buffer\n"); |
2918 | - usb_deregister_dev(intf, &usb_rio_class); |
2919 | - retval = -ENOMEM; |
2920 | - goto bail_out; |
2921 | - } |
2922 | - dev_dbg(&intf->dev, "obuf address:%p\n", rio->obuf); |
2923 | - |
2924 | - if (!(rio->ibuf = kmalloc(IBUF_SIZE, GFP_KERNEL))) { |
2925 | - dev_err(&dev->dev, |
2926 | - "probe_rio: Not enough memory for the input buffer\n"); |
2927 | - usb_deregister_dev(intf, &usb_rio_class); |
2928 | - kfree(rio->obuf); |
2929 | - retval = -ENOMEM; |
2930 | - goto bail_out; |
2931 | - } |
2932 | - dev_dbg(&intf->dev, "ibuf address:%p\n", rio->ibuf); |
2933 | - |
2934 | - mutex_init(&(rio->lock)); |
2935 | - |
2936 | - usb_set_intfdata (intf, rio); |
2937 | - rio->present = 1; |
2938 | -bail_out: |
2939 | - mutex_unlock(&rio500_mutex); |
2940 | - |
2941 | - return retval; |
2942 | -} |
2943 | - |
2944 | -static void disconnect_rio(struct usb_interface *intf) |
2945 | -{ |
2946 | - struct rio_usb_data *rio = usb_get_intfdata (intf); |
2947 | - |
2948 | - usb_set_intfdata (intf, NULL); |
2949 | - mutex_lock(&rio500_mutex); |
2950 | - if (rio) { |
2951 | - usb_deregister_dev(intf, &usb_rio_class); |
2952 | - |
2953 | - mutex_lock(&(rio->lock)); |
2954 | - if (rio->isopen) { |
2955 | - rio->isopen = 0; |
2956 | - /* better let it finish - the release will do whats needed */ |
2957 | - rio->rio_dev = NULL; |
2958 | - mutex_unlock(&(rio->lock)); |
2959 | - mutex_unlock(&rio500_mutex); |
2960 | - return; |
2961 | - } |
2962 | - kfree(rio->ibuf); |
2963 | - kfree(rio->obuf); |
2964 | - |
2965 | - dev_info(&intf->dev, "USB Rio disconnected.\n"); |
2966 | - |
2967 | - rio->present = 0; |
2968 | - mutex_unlock(&(rio->lock)); |
2969 | - } |
2970 | - mutex_unlock(&rio500_mutex); |
2971 | -} |
2972 | - |
2973 | -static const struct usb_device_id rio_table[] = { |
2974 | - { USB_DEVICE(0x0841, 1) }, /* Rio 500 */ |
2975 | - { } /* Terminating entry */ |
2976 | -}; |
2977 | - |
2978 | -MODULE_DEVICE_TABLE (usb, rio_table); |
2979 | - |
2980 | -static struct usb_driver rio_driver = { |
2981 | - .name = "rio500", |
2982 | - .probe = probe_rio, |
2983 | - .disconnect = disconnect_rio, |
2984 | - .id_table = rio_table, |
2985 | -}; |
2986 | - |
2987 | -module_usb_driver(rio_driver); |
2988 | - |
2989 | -MODULE_AUTHOR( DRIVER_AUTHOR ); |
2990 | -MODULE_DESCRIPTION( DRIVER_DESC ); |
2991 | -MODULE_LICENSE("GPL"); |
2992 | - |
2993 | diff --git a/drivers/usb/misc/rio500_usb.h b/drivers/usb/misc/rio500_usb.h |
2994 | deleted file mode 100644 |
2995 | index 6db7a5863496..000000000000 |
2996 | --- a/drivers/usb/misc/rio500_usb.h |
2997 | +++ /dev/null |
2998 | @@ -1,20 +0,0 @@ |
2999 | -// SPDX-License-Identifier: GPL-2.0+ |
3000 | -/* ---------------------------------------------------------------------- |
3001 | - Copyright (C) 2000 Cesar Miquel (miquel@df.uba.ar) |
3002 | - ---------------------------------------------------------------------- */ |
3003 | - |
3004 | -#define RIO_SEND_COMMAND 0x1 |
3005 | -#define RIO_RECV_COMMAND 0x2 |
3006 | - |
3007 | -#define RIO_DIR_OUT 0x0 |
3008 | -#define RIO_DIR_IN 0x1 |
3009 | - |
3010 | -struct RioCommand { |
3011 | - short length; |
3012 | - int request; |
3013 | - int requesttype; |
3014 | - int value; |
3015 | - int index; |
3016 | - void __user *buffer; |
3017 | - int timeout; |
3018 | -}; |
3019 | diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c |
3020 | index 9ba4a4e68d91..aa982d3ca36b 100644 |
3021 | --- a/drivers/usb/misc/usblcd.c |
3022 | +++ b/drivers/usb/misc/usblcd.c |
3023 | @@ -18,6 +18,7 @@ |
3024 | #include <linux/slab.h> |
3025 | #include <linux/errno.h> |
3026 | #include <linux/mutex.h> |
3027 | +#include <linux/rwsem.h> |
3028 | #include <linux/uaccess.h> |
3029 | #include <linux/usb.h> |
3030 | |
3031 | @@ -57,6 +58,8 @@ struct usb_lcd { |
3032 | using up all RAM */ |
3033 | struct usb_anchor submitted; /* URBs to wait for |
3034 | before suspend */ |
3035 | + struct rw_semaphore io_rwsem; |
3036 | + unsigned long disconnected:1; |
3037 | }; |
3038 | #define to_lcd_dev(d) container_of(d, struct usb_lcd, kref) |
3039 | |
3040 | @@ -142,6 +145,13 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, |
3041 | |
3042 | dev = file->private_data; |
3043 | |
3044 | + down_read(&dev->io_rwsem); |
3045 | + |
3046 | + if (dev->disconnected) { |
3047 | + retval = -ENODEV; |
3048 | + goto out_up_io; |
3049 | + } |
3050 | + |
3051 | /* do a blocking bulk read to get data from the device */ |
3052 | retval = usb_bulk_msg(dev->udev, |
3053 | usb_rcvbulkpipe(dev->udev, |
3054 | @@ -158,6 +168,9 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, |
3055 | retval = bytes_read; |
3056 | } |
3057 | |
3058 | +out_up_io: |
3059 | + up_read(&dev->io_rwsem); |
3060 | + |
3061 | return retval; |
3062 | } |
3063 | |
3064 | @@ -237,11 +250,18 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, |
3065 | if (r < 0) |
3066 | return -EINTR; |
3067 | |
3068 | + down_read(&dev->io_rwsem); |
3069 | + |
3070 | + if (dev->disconnected) { |
3071 | + retval = -ENODEV; |
3072 | + goto err_up_io; |
3073 | + } |
3074 | + |
3075 | /* create a urb, and a buffer for it, and copy the data to the urb */ |
3076 | urb = usb_alloc_urb(0, GFP_KERNEL); |
3077 | if (!urb) { |
3078 | retval = -ENOMEM; |
3079 | - goto err_no_buf; |
3080 | + goto err_up_io; |
3081 | } |
3082 | |
3083 | buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL, |
3084 | @@ -278,6 +298,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, |
3085 | the USB core will eventually free it entirely */ |
3086 | usb_free_urb(urb); |
3087 | |
3088 | + up_read(&dev->io_rwsem); |
3089 | exit: |
3090 | return count; |
3091 | error_unanchor: |
3092 | @@ -285,7 +306,8 @@ error_unanchor: |
3093 | error: |
3094 | usb_free_coherent(dev->udev, count, buf, urb->transfer_dma); |
3095 | usb_free_urb(urb); |
3096 | -err_no_buf: |
3097 | +err_up_io: |
3098 | + up_read(&dev->io_rwsem); |
3099 | up(&dev->limit_sem); |
3100 | return retval; |
3101 | } |
3102 | @@ -325,6 +347,7 @@ static int lcd_probe(struct usb_interface *interface, |
3103 | |
3104 | kref_init(&dev->kref); |
3105 | sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES); |
3106 | + init_rwsem(&dev->io_rwsem); |
3107 | init_usb_anchor(&dev->submitted); |
3108 | |
3109 | dev->udev = usb_get_dev(interface_to_usbdev(interface)); |
3110 | @@ -422,6 +445,12 @@ static void lcd_disconnect(struct usb_interface *interface) |
3111 | /* give back our minor */ |
3112 | usb_deregister_dev(interface, &lcd_class); |
3113 | |
3114 | + down_write(&dev->io_rwsem); |
3115 | + dev->disconnected = 1; |
3116 | + up_write(&dev->io_rwsem); |
3117 | + |
3118 | + usb_kill_anchored_urbs(&dev->submitted); |
3119 | + |
3120 | /* decrement our usage count */ |
3121 | kref_put(&dev->kref, lcd_delete); |
3122 | |
3123 | diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c |
3124 | index 6715a128e6c8..be0505b8b5d4 100644 |
3125 | --- a/drivers/usb/misc/yurex.c |
3126 | +++ b/drivers/usb/misc/yurex.c |
3127 | @@ -60,6 +60,7 @@ struct usb_yurex { |
3128 | |
3129 | struct kref kref; |
3130 | struct mutex io_mutex; |
3131 | + unsigned long disconnected:1; |
3132 | struct fasync_struct *async_queue; |
3133 | wait_queue_head_t waitq; |
3134 | |
3135 | @@ -107,6 +108,7 @@ static void yurex_delete(struct kref *kref) |
3136 | dev->int_buffer, dev->urb->transfer_dma); |
3137 | usb_free_urb(dev->urb); |
3138 | } |
3139 | + usb_put_intf(dev->interface); |
3140 | usb_put_dev(dev->udev); |
3141 | kfree(dev); |
3142 | } |
3143 | @@ -132,6 +134,7 @@ static void yurex_interrupt(struct urb *urb) |
3144 | switch (status) { |
3145 | case 0: /*success*/ |
3146 | break; |
3147 | + /* The device is terminated or messed up, give up */ |
3148 | case -EOVERFLOW: |
3149 | dev_err(&dev->interface->dev, |
3150 | "%s - overflow with length %d, actual length is %d\n", |
3151 | @@ -140,12 +143,13 @@ static void yurex_interrupt(struct urb *urb) |
3152 | case -ENOENT: |
3153 | case -ESHUTDOWN: |
3154 | case -EILSEQ: |
3155 | - /* The device is terminated, clean up */ |
3156 | + case -EPROTO: |
3157 | + case -ETIME: |
3158 | return; |
3159 | default: |
3160 | dev_err(&dev->interface->dev, |
3161 | "%s - unknown status received: %d\n", __func__, status); |
3162 | - goto exit; |
3163 | + return; |
3164 | } |
3165 | |
3166 | /* handle received message */ |
3167 | @@ -177,7 +181,6 @@ static void yurex_interrupt(struct urb *urb) |
3168 | break; |
3169 | } |
3170 | |
3171 | -exit: |
3172 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
3173 | if (retval) { |
3174 | dev_err(&dev->interface->dev, "%s - usb_submit_urb failed: %d\n", |
3175 | @@ -204,7 +207,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_ |
3176 | init_waitqueue_head(&dev->waitq); |
3177 | |
3178 | dev->udev = usb_get_dev(interface_to_usbdev(interface)); |
3179 | - dev->interface = interface; |
3180 | + dev->interface = usb_get_intf(interface); |
3181 | |
3182 | /* set up the endpoint information */ |
3183 | iface_desc = interface->cur_altsetting; |
3184 | @@ -315,8 +318,9 @@ static void yurex_disconnect(struct usb_interface *interface) |
3185 | |
3186 | /* prevent more I/O from starting */ |
3187 | usb_poison_urb(dev->urb); |
3188 | + usb_poison_urb(dev->cntl_urb); |
3189 | mutex_lock(&dev->io_mutex); |
3190 | - dev->interface = NULL; |
3191 | + dev->disconnected = 1; |
3192 | mutex_unlock(&dev->io_mutex); |
3193 | |
3194 | /* wakeup waiters */ |
3195 | @@ -404,7 +408,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, |
3196 | dev = file->private_data; |
3197 | |
3198 | mutex_lock(&dev->io_mutex); |
3199 | - if (!dev->interface) { /* already disconnected */ |
3200 | + if (dev->disconnected) { /* already disconnected */ |
3201 | mutex_unlock(&dev->io_mutex); |
3202 | return -ENODEV; |
3203 | } |
3204 | @@ -439,7 +443,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, |
3205 | goto error; |
3206 | |
3207 | mutex_lock(&dev->io_mutex); |
3208 | - if (!dev->interface) { /* already disconnected */ |
3209 | + if (dev->disconnected) { /* already disconnected */ |
3210 | mutex_unlock(&dev->io_mutex); |
3211 | retval = -ENODEV; |
3212 | goto error; |
3213 | diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h |
3214 | index 6137f7942c05..c47b721b8bca 100644 |
3215 | --- a/drivers/usb/renesas_usbhs/common.h |
3216 | +++ b/drivers/usb/renesas_usbhs/common.h |
3217 | @@ -207,6 +207,7 @@ struct usbhs_priv; |
3218 | /* DCPCTR */ |
3219 | #define BSTS (1 << 15) /* Buffer Status */ |
3220 | #define SUREQ (1 << 14) /* Sending SETUP Token */ |
3221 | +#define INBUFM (1 << 14) /* (PIPEnCTR) Transfer Buffer Monitor */ |
3222 | #define CSSTS (1 << 12) /* CSSTS Status */ |
3223 | #define ACLRM (1 << 9) /* Buffer Auto-Clear Mode */ |
3224 | #define SQCLR (1 << 8) /* Toggle Bit Clear */ |
3225 | diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c |
3226 | index 6036cbae8c78..aeb53ec5cc6a 100644 |
3227 | --- a/drivers/usb/renesas_usbhs/fifo.c |
3228 | +++ b/drivers/usb/renesas_usbhs/fifo.c |
3229 | @@ -89,7 +89,7 @@ static void __usbhsf_pkt_del(struct usbhs_pkt *pkt) |
3230 | list_del_init(&pkt->node); |
3231 | } |
3232 | |
3233 | -static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) |
3234 | +struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) |
3235 | { |
3236 | return list_first_entry_or_null(&pipe->list, struct usbhs_pkt, node); |
3237 | } |
3238 | diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h |
3239 | index 88d1816bcda2..c3d3cc35cee0 100644 |
3240 | --- a/drivers/usb/renesas_usbhs/fifo.h |
3241 | +++ b/drivers/usb/renesas_usbhs/fifo.h |
3242 | @@ -97,5 +97,6 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, |
3243 | void *buf, int len, int zero, int sequence); |
3244 | struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt); |
3245 | void usbhs_pkt_start(struct usbhs_pipe *pipe); |
3246 | +struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe); |
3247 | |
3248 | #endif /* RENESAS_USB_FIFO_H */ |
3249 | diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c |
3250 | index 59cac40aafcc..7feac4128a2d 100644 |
3251 | --- a/drivers/usb/renesas_usbhs/mod_gadget.c |
3252 | +++ b/drivers/usb/renesas_usbhs/mod_gadget.c |
3253 | @@ -721,8 +721,7 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) |
3254 | struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); |
3255 | struct device *dev = usbhsg_gpriv_to_dev(gpriv); |
3256 | unsigned long flags; |
3257 | - |
3258 | - usbhsg_pipe_disable(uep); |
3259 | + int ret = 0; |
3260 | |
3261 | dev_dbg(dev, "set halt %d (pipe %d)\n", |
3262 | halt, usbhs_pipe_number(pipe)); |
3263 | @@ -730,6 +729,18 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) |
3264 | /******************** spin lock ********************/ |
3265 | usbhs_lock(priv, flags); |
3266 | |
3267 | + /* |
3268 | + * According to usb_ep_set_halt()'s description, this function should |
3269 | + * return -EAGAIN if the IN endpoint has any queue or data. Note |
3270 | + * that the usbhs_pipe_is_dir_in() returns false if the pipe is an |
3271 | + * IN endpoint in the gadget mode. |
3272 | + */ |
3273 | + if (!usbhs_pipe_is_dir_in(pipe) && (__usbhsf_pkt_get(pipe) || |
3274 | + usbhs_pipe_contains_transmittable_data(pipe))) { |
3275 | + ret = -EAGAIN; |
3276 | + goto out; |
3277 | + } |
3278 | + |
3279 | if (halt) |
3280 | usbhs_pipe_stall(pipe); |
3281 | else |
3282 | @@ -740,10 +751,11 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) |
3283 | else |
3284 | usbhsg_status_clr(gpriv, USBHSG_STATUS_WEDGE); |
3285 | |
3286 | +out: |
3287 | usbhs_unlock(priv, flags); |
3288 | /******************** spin unlock ******************/ |
3289 | |
3290 | - return 0; |
3291 | + return ret; |
3292 | } |
3293 | |
3294 | static int usbhsg_ep_set_halt(struct usb_ep *ep, int value) |
3295 | diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c |
3296 | index c4922b96c93b..9e5afdde1adb 100644 |
3297 | --- a/drivers/usb/renesas_usbhs/pipe.c |
3298 | +++ b/drivers/usb/renesas_usbhs/pipe.c |
3299 | @@ -277,6 +277,21 @@ int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe) |
3300 | return -EBUSY; |
3301 | } |
3302 | |
3303 | +bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe) |
3304 | +{ |
3305 | + u16 val; |
3306 | + |
3307 | + /* Do not support for DCP pipe */ |
3308 | + if (usbhs_pipe_is_dcp(pipe)) |
3309 | + return false; |
3310 | + |
3311 | + val = usbhsp_pipectrl_get(pipe); |
3312 | + if (val & INBUFM) |
3313 | + return true; |
3314 | + |
3315 | + return false; |
3316 | +} |
3317 | + |
3318 | /* |
3319 | * PID ctrl |
3320 | */ |
3321 | diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h |
3322 | index 3080423e600c..3b130529408b 100644 |
3323 | --- a/drivers/usb/renesas_usbhs/pipe.h |
3324 | +++ b/drivers/usb/renesas_usbhs/pipe.h |
3325 | @@ -83,6 +83,7 @@ void usbhs_pipe_clear(struct usbhs_pipe *pipe); |
3326 | void usbhs_pipe_clear_without_sequence(struct usbhs_pipe *pipe, |
3327 | int needs_bfre, int bfre_enable); |
3328 | int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe); |
3329 | +bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe); |
3330 | void usbhs_pipe_enable(struct usbhs_pipe *pipe); |
3331 | void usbhs_pipe_disable(struct usbhs_pipe *pipe); |
3332 | void usbhs_pipe_stall(struct usbhs_pipe *pipe); |
3333 | diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c |
3334 | index e18735e00463..f06706efb7f1 100644 |
3335 | --- a/drivers/usb/serial/ftdi_sio.c |
3336 | +++ b/drivers/usb/serial/ftdi_sio.c |
3337 | @@ -1020,6 +1020,9 @@ static const struct usb_device_id id_table_combined[] = { |
3338 | /* EZPrototypes devices */ |
3339 | { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) }, |
3340 | { USB_DEVICE_INTERFACE_NUMBER(UNJO_VID, UNJO_ISODEBUG_V1_PID, 1) }, |
3341 | + /* Sienna devices */ |
3342 | + { USB_DEVICE(FTDI_VID, FTDI_SIENNA_PID) }, |
3343 | + { USB_DEVICE(ECHELON_VID, ECHELON_U20_PID) }, |
3344 | { } /* Terminating entry */ |
3345 | }; |
3346 | |
3347 | diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h |
3348 | index f12d806220b4..22d66217cb41 100644 |
3349 | --- a/drivers/usb/serial/ftdi_sio_ids.h |
3350 | +++ b/drivers/usb/serial/ftdi_sio_ids.h |
3351 | @@ -39,6 +39,9 @@ |
3352 | |
3353 | #define FTDI_LUMEL_PD12_PID 0x6002 |
3354 | |
3355 | +/* Sienna Serial Interface by Secyourit GmbH */ |
3356 | +#define FTDI_SIENNA_PID 0x8348 |
3357 | + |
3358 | /* Cyber Cortex AV by Fabulous Silicon (http://fabuloussilicon.com) */ |
3359 | #define CYBER_CORTEX_AV_PID 0x8698 |
3360 | |
3361 | @@ -688,6 +691,12 @@ |
3362 | #define BANDB_TTL3USB9M_PID 0xAC50 |
3363 | #define BANDB_ZZ_PROG1_USB_PID 0xBA02 |
3364 | |
3365 | +/* |
3366 | + * Echelon USB Serial Interface |
3367 | + */ |
3368 | +#define ECHELON_VID 0x0920 |
3369 | +#define ECHELON_U20_PID 0x7500 |
3370 | + |
3371 | /* |
3372 | * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI |
3373 | */ |
3374 | diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c |
3375 | index d34779fe4a8d..e66a59ef43a1 100644 |
3376 | --- a/drivers/usb/serial/keyspan.c |
3377 | +++ b/drivers/usb/serial/keyspan.c |
3378 | @@ -1741,8 +1741,8 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, |
3379 | |
3380 | ep_desc = find_ep(serial, endpoint); |
3381 | if (!ep_desc) { |
3382 | - /* leak the urb, something's wrong and the callers don't care */ |
3383 | - return urb; |
3384 | + usb_free_urb(urb); |
3385 | + return NULL; |
3386 | } |
3387 | if (usb_endpoint_xfer_int(ep_desc)) { |
3388 | ep_type_name = "INT"; |
3389 | diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c |
3390 | index 56f572cb08f8..3cc659a62782 100644 |
3391 | --- a/drivers/usb/serial/option.c |
3392 | +++ b/drivers/usb/serial/option.c |
3393 | @@ -419,6 +419,7 @@ static void option_instat_callback(struct urb *urb); |
3394 | #define CINTERION_PRODUCT_PH8_AUDIO 0x0083 |
3395 | #define CINTERION_PRODUCT_AHXX_2RMNET 0x0084 |
3396 | #define CINTERION_PRODUCT_AHXX_AUDIO 0x0085 |
3397 | +#define CINTERION_PRODUCT_CLS8 0x00b0 |
3398 | |
3399 | /* Olivetti products */ |
3400 | #define OLIVETTI_VENDOR_ID 0x0b3c |
3401 | @@ -1154,6 +1155,14 @@ static const struct usb_device_id option_ids[] = { |
3402 | .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) }, |
3403 | { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff), |
3404 | .driver_info = RSVD(0) | RSVD(1) | NCTRL(2) | RSVD(3) }, |
3405 | + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1050, 0xff), /* Telit FN980 (rmnet) */ |
3406 | + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, |
3407 | + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1051, 0xff), /* Telit FN980 (MBIM) */ |
3408 | + .driver_info = NCTRL(0) | RSVD(1) }, |
3409 | + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1052, 0xff), /* Telit FN980 (RNDIS) */ |
3410 | + .driver_info = NCTRL(2) | RSVD(3) }, |
3411 | + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1053, 0xff), /* Telit FN980 (ECM) */ |
3412 | + .driver_info = NCTRL(0) | RSVD(1) }, |
3413 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), |
3414 | .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, |
3415 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), |
3416 | @@ -1847,6 +1856,8 @@ static const struct usb_device_id option_ids[] = { |
3417 | .driver_info = RSVD(4) }, |
3418 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) }, |
3419 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) }, |
3420 | + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_CLS8, 0xff), |
3421 | + .driver_info = RSVD(0) | RSVD(4) }, |
3422 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, |
3423 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) }, |
3424 | { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) }, |
3425 | diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c |
3426 | index f7aaa7f079e1..434153790982 100644 |
3427 | --- a/drivers/usb/serial/usb-serial.c |
3428 | +++ b/drivers/usb/serial/usb-serial.c |
3429 | @@ -311,10 +311,7 @@ static void serial_cleanup(struct tty_struct *tty) |
3430 | serial = port->serial; |
3431 | owner = serial->type->driver.owner; |
3432 | |
3433 | - mutex_lock(&serial->disc_mutex); |
3434 | - if (!serial->disconnected) |
3435 | - usb_autopm_put_interface(serial->interface); |
3436 | - mutex_unlock(&serial->disc_mutex); |
3437 | + usb_autopm_put_interface(serial->interface); |
3438 | |
3439 | usb_serial_put(serial); |
3440 | module_put(owner); |
3441 | diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c |
3442 | index f101347e3ea3..e0cf11f798c5 100644 |
3443 | --- a/drivers/usb/usb-skeleton.c |
3444 | +++ b/drivers/usb/usb-skeleton.c |
3445 | @@ -59,6 +59,7 @@ struct usb_skel { |
3446 | spinlock_t err_lock; /* lock for errors */ |
3447 | struct kref kref; |
3448 | struct mutex io_mutex; /* synchronize I/O with disconnect */ |
3449 | + unsigned long disconnected:1; |
3450 | wait_queue_head_t bulk_in_wait; /* to wait for an ongoing read */ |
3451 | }; |
3452 | #define to_skel_dev(d) container_of(d, struct usb_skel, kref) |
3453 | @@ -71,6 +72,7 @@ static void skel_delete(struct kref *kref) |
3454 | struct usb_skel *dev = to_skel_dev(kref); |
3455 | |
3456 | usb_free_urb(dev->bulk_in_urb); |
3457 | + usb_put_intf(dev->interface); |
3458 | usb_put_dev(dev->udev); |
3459 | kfree(dev->bulk_in_buffer); |
3460 | kfree(dev); |
3461 | @@ -122,10 +124,7 @@ static int skel_release(struct inode *inode, struct file *file) |
3462 | return -ENODEV; |
3463 | |
3464 | /* allow the device to be autosuspended */ |
3465 | - mutex_lock(&dev->io_mutex); |
3466 | - if (dev->interface) |
3467 | - usb_autopm_put_interface(dev->interface); |
3468 | - mutex_unlock(&dev->io_mutex); |
3469 | + usb_autopm_put_interface(dev->interface); |
3470 | |
3471 | /* decrement the count on our device */ |
3472 | kref_put(&dev->kref, skel_delete); |
3473 | @@ -238,7 +237,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, |
3474 | if (rv < 0) |
3475 | return rv; |
3476 | |
3477 | - if (!dev->interface) { /* disconnect() was called */ |
3478 | + if (dev->disconnected) { /* disconnect() was called */ |
3479 | rv = -ENODEV; |
3480 | goto exit; |
3481 | } |
3482 | @@ -420,7 +419,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, |
3483 | |
3484 | /* this lock makes sure we don't submit URBs to gone devices */ |
3485 | mutex_lock(&dev->io_mutex); |
3486 | - if (!dev->interface) { /* disconnect() was called */ |
3487 | + if (dev->disconnected) { /* disconnect() was called */ |
3488 | mutex_unlock(&dev->io_mutex); |
3489 | retval = -ENODEV; |
3490 | goto error; |
3491 | @@ -505,7 +504,7 @@ static int skel_probe(struct usb_interface *interface, |
3492 | init_waitqueue_head(&dev->bulk_in_wait); |
3493 | |
3494 | dev->udev = usb_get_dev(interface_to_usbdev(interface)); |
3495 | - dev->interface = interface; |
3496 | + dev->interface = usb_get_intf(interface); |
3497 | |
3498 | /* set up the endpoint information */ |
3499 | /* use only the first bulk-in and bulk-out endpoints */ |
3500 | @@ -571,7 +570,7 @@ static void skel_disconnect(struct usb_interface *interface) |
3501 | |
3502 | /* prevent more I/O from starting */ |
3503 | mutex_lock(&dev->io_mutex); |
3504 | - dev->interface = NULL; |
3505 | + dev->disconnected = 1; |
3506 | mutex_unlock(&dev->io_mutex); |
3507 | |
3508 | usb_kill_anchored_urbs(&dev->submitted); |
3509 | diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c |
3510 | index e5b9e596bb92..cd2a5864e103 100644 |
3511 | --- a/fs/btrfs/ref-verify.c |
3512 | +++ b/fs/btrfs/ref-verify.c |
3513 | @@ -511,7 +511,7 @@ static int process_leaf(struct btrfs_root *root, |
3514 | struct btrfs_extent_data_ref *dref; |
3515 | struct btrfs_shared_data_ref *sref; |
3516 | u32 count; |
3517 | - int i = 0, tree_block_level = 0, ret; |
3518 | + int i = 0, tree_block_level = 0, ret = 0; |
3519 | struct btrfs_key key; |
3520 | int nritems = btrfs_header_nritems(leaf); |
3521 | |
3522 | diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c |
3523 | index e561eb475339..4d4f57f0f08c 100644 |
3524 | --- a/fs/btrfs/tree-log.c |
3525 | +++ b/fs/btrfs/tree-log.c |
3526 | @@ -2860,7 +2860,8 @@ out: |
3527 | * in the tree of log roots |
3528 | */ |
3529 | static int update_log_root(struct btrfs_trans_handle *trans, |
3530 | - struct btrfs_root *log) |
3531 | + struct btrfs_root *log, |
3532 | + struct btrfs_root_item *root_item) |
3533 | { |
3534 | struct btrfs_fs_info *fs_info = log->fs_info; |
3535 | int ret; |
3536 | @@ -2868,10 +2869,10 @@ static int update_log_root(struct btrfs_trans_handle *trans, |
3537 | if (log->log_transid == 1) { |
3538 | /* insert root item on the first sync */ |
3539 | ret = btrfs_insert_root(trans, fs_info->log_root_tree, |
3540 | - &log->root_key, &log->root_item); |
3541 | + &log->root_key, root_item); |
3542 | } else { |
3543 | ret = btrfs_update_root(trans, fs_info->log_root_tree, |
3544 | - &log->root_key, &log->root_item); |
3545 | + &log->root_key, root_item); |
3546 | } |
3547 | return ret; |
3548 | } |
3549 | @@ -2969,6 +2970,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, |
3550 | struct btrfs_fs_info *fs_info = root->fs_info; |
3551 | struct btrfs_root *log = root->log_root; |
3552 | struct btrfs_root *log_root_tree = fs_info->log_root_tree; |
3553 | + struct btrfs_root_item new_root_item; |
3554 | int log_transid = 0; |
3555 | struct btrfs_log_ctx root_log_ctx; |
3556 | struct blk_plug plug; |
3557 | @@ -3032,17 +3034,25 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, |
3558 | goto out; |
3559 | } |
3560 | |
3561 | + /* |
3562 | + * We _must_ update under the root->log_mutex in order to make sure we |
3563 | + * have a consistent view of the log root we are trying to commit at |
3564 | + * this moment. |
3565 | + * |
3566 | + * We _must_ copy this into a local copy, because we are not holding the |
3567 | + * log_root_tree->log_mutex yet. This is important because when we |
3568 | + * commit the log_root_tree we must have a consistent view of the |
3569 | + * log_root_tree when we update the super block to point at the |
3570 | + * log_root_tree bytenr. If we update the log_root_tree here we'll race |
3571 | + * with the commit and possibly point at the new block which we may not |
3572 | + * have written out. |
3573 | + */ |
3574 | btrfs_set_root_node(&log->root_item, log->node); |
3575 | + memcpy(&new_root_item, &log->root_item, sizeof(new_root_item)); |
3576 | |
3577 | root->log_transid++; |
3578 | log->log_transid = root->log_transid; |
3579 | root->log_start_pid = 0; |
3580 | - /* |
3581 | - * Update or create log root item under the root's log_mutex to prevent |
3582 | - * races with concurrent log syncs that can lead to failure to update |
3583 | - * log root item because it was not created yet. |
3584 | - */ |
3585 | - ret = update_log_root(trans, log); |
3586 | /* |
3587 | * IO has been started, blocks of the log tree have WRITTEN flag set |
3588 | * in their headers. new modifications of the log will be written to |
3589 | @@ -3063,6 +3073,14 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, |
3590 | mutex_unlock(&log_root_tree->log_mutex); |
3591 | |
3592 | mutex_lock(&log_root_tree->log_mutex); |
3593 | + |
3594 | + /* |
3595 | + * Now we are safe to update the log_root_tree because we're under the |
3596 | + * log_mutex, and we're a current writer so we're holding the commit |
3597 | + * open until we drop the log_mutex. |
3598 | + */ |
3599 | + ret = update_log_root(trans, log, &new_root_item); |
3600 | + |
3601 | if (atomic_dec_and_test(&log_root_tree->log_writers)) { |
3602 | /* atomic_dec_and_test implies a barrier */ |
3603 | cond_wake_up_nomb(&log_root_tree->log_writer_wait); |
3604 | diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c |
3605 | index 907e85d65bb4..2fb6fa51fd3c 100644 |
3606 | --- a/fs/cifs/dir.c |
3607 | +++ b/fs/cifs/dir.c |
3608 | @@ -840,10 +840,16 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, |
3609 | static int |
3610 | cifs_d_revalidate(struct dentry *direntry, unsigned int flags) |
3611 | { |
3612 | + struct inode *inode; |
3613 | + |
3614 | if (flags & LOOKUP_RCU) |
3615 | return -ECHILD; |
3616 | |
3617 | if (d_really_is_positive(direntry)) { |
3618 | + inode = d_inode(direntry); |
3619 | + if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode))) |
3620 | + CIFS_I(inode)->time = 0; /* force reval */ |
3621 | + |
3622 | if (cifs_revalidate_dentry(direntry)) |
3623 | return 0; |
3624 | else { |
3625 | @@ -854,7 +860,7 @@ cifs_d_revalidate(struct dentry *direntry, unsigned int flags) |
3626 | * attributes will have been updated by |
3627 | * cifs_revalidate_dentry(). |
3628 | */ |
3629 | - if (IS_AUTOMOUNT(d_inode(direntry)) && |
3630 | + if (IS_AUTOMOUNT(inode) && |
3631 | !(direntry->d_flags & DCACHE_NEED_AUTOMOUNT)) { |
3632 | spin_lock(&direntry->d_lock); |
3633 | direntry->d_flags |= DCACHE_NEED_AUTOMOUNT; |
3634 | diff --git a/fs/cifs/file.c b/fs/cifs/file.c |
3635 | index 8703b5f26f45..617f86beb08b 100644 |
3636 | --- a/fs/cifs/file.c |
3637 | +++ b/fs/cifs/file.c |
3638 | @@ -252,6 +252,12 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, |
3639 | rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, |
3640 | xid, fid); |
3641 | |
3642 | + if (rc) { |
3643 | + server->ops->close(xid, tcon, fid); |
3644 | + if (rc == -ESTALE) |
3645 | + rc = -EOPENSTALE; |
3646 | + } |
3647 | + |
3648 | out: |
3649 | kfree(buf); |
3650 | return rc; |
3651 | @@ -1835,13 +1841,12 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, |
3652 | { |
3653 | struct cifsFileInfo *open_file = NULL; |
3654 | struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); |
3655 | - struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); |
3656 | |
3657 | /* only filter by fsuid on multiuser mounts */ |
3658 | if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) |
3659 | fsuid_only = false; |
3660 | |
3661 | - spin_lock(&tcon->open_file_lock); |
3662 | + spin_lock(&cifs_inode->open_file_lock); |
3663 | /* we could simply get the first_list_entry since write-only entries |
3664 | are always at the end of the list but since the first entry might |
3665 | have a close pending, we go through the whole list */ |
3666 | @@ -1853,7 +1858,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, |
3667 | /* found a good file */ |
3668 | /* lock it so it will not be closed on us */ |
3669 | cifsFileInfo_get(open_file); |
3670 | - spin_unlock(&tcon->open_file_lock); |
3671 | + spin_unlock(&cifs_inode->open_file_lock); |
3672 | return open_file; |
3673 | } /* else might as well continue, and look for |
3674 | another, or simply have the caller reopen it |
3675 | @@ -1861,7 +1866,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, |
3676 | } else /* write only file */ |
3677 | break; /* write only files are last so must be done */ |
3678 | } |
3679 | - spin_unlock(&tcon->open_file_lock); |
3680 | + spin_unlock(&cifs_inode->open_file_lock); |
3681 | return NULL; |
3682 | } |
3683 | |
3684 | @@ -1870,7 +1875,6 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode, |
3685 | { |
3686 | struct cifsFileInfo *open_file, *inv_file = NULL; |
3687 | struct cifs_sb_info *cifs_sb; |
3688 | - struct cifs_tcon *tcon; |
3689 | bool any_available = false; |
3690 | int rc; |
3691 | unsigned int refind = 0; |
3692 | @@ -1886,16 +1890,15 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode, |
3693 | } |
3694 | |
3695 | cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); |
3696 | - tcon = cifs_sb_master_tcon(cifs_sb); |
3697 | |
3698 | /* only filter by fsuid on multiuser mounts */ |
3699 | if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) |
3700 | fsuid_only = false; |
3701 | |
3702 | - spin_lock(&tcon->open_file_lock); |
3703 | + spin_lock(&cifs_inode->open_file_lock); |
3704 | refind_writable: |
3705 | if (refind > MAX_REOPEN_ATT) { |
3706 | - spin_unlock(&tcon->open_file_lock); |
3707 | + spin_unlock(&cifs_inode->open_file_lock); |
3708 | return NULL; |
3709 | } |
3710 | list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { |
3711 | @@ -1907,7 +1910,7 @@ refind_writable: |
3712 | if (!open_file->invalidHandle) { |
3713 | /* found a good writable file */ |
3714 | cifsFileInfo_get(open_file); |
3715 | - spin_unlock(&tcon->open_file_lock); |
3716 | + spin_unlock(&cifs_inode->open_file_lock); |
3717 | return open_file; |
3718 | } else { |
3719 | if (!inv_file) |
3720 | @@ -1926,7 +1929,7 @@ refind_writable: |
3721 | cifsFileInfo_get(inv_file); |
3722 | } |
3723 | |
3724 | - spin_unlock(&tcon->open_file_lock); |
3725 | + spin_unlock(&cifs_inode->open_file_lock); |
3726 | |
3727 | if (inv_file) { |
3728 | rc = cifs_reopen_file(inv_file, false); |
3729 | @@ -1940,7 +1943,7 @@ refind_writable: |
3730 | cifsFileInfo_put(inv_file); |
3731 | ++refind; |
3732 | inv_file = NULL; |
3733 | - spin_lock(&tcon->open_file_lock); |
3734 | + spin_lock(&cifs_inode->open_file_lock); |
3735 | goto refind_writable; |
3736 | } |
3737 | } |
3738 | @@ -4001,17 +4004,15 @@ static int cifs_readpage(struct file *file, struct page *page) |
3739 | static int is_inode_writable(struct cifsInodeInfo *cifs_inode) |
3740 | { |
3741 | struct cifsFileInfo *open_file; |
3742 | - struct cifs_tcon *tcon = |
3743 | - cifs_sb_master_tcon(CIFS_SB(cifs_inode->vfs_inode.i_sb)); |
3744 | |
3745 | - spin_lock(&tcon->open_file_lock); |
3746 | + spin_lock(&cifs_inode->open_file_lock); |
3747 | list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { |
3748 | if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) { |
3749 | - spin_unlock(&tcon->open_file_lock); |
3750 | + spin_unlock(&cifs_inode->open_file_lock); |
3751 | return 1; |
3752 | } |
3753 | } |
3754 | - spin_unlock(&tcon->open_file_lock); |
3755 | + spin_unlock(&cifs_inode->open_file_lock); |
3756 | return 0; |
3757 | } |
3758 | |
3759 | diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c |
3760 | index 53f3d08898af..26154db6c87f 100644 |
3761 | --- a/fs/cifs/inode.c |
3762 | +++ b/fs/cifs/inode.c |
3763 | @@ -410,6 +410,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, |
3764 | /* if uniqueid is different, return error */ |
3765 | if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM && |
3766 | CIFS_I(*pinode)->uniqueid != fattr.cf_uniqueid)) { |
3767 | + CIFS_I(*pinode)->time = 0; /* force reval */ |
3768 | rc = -ESTALE; |
3769 | goto cgiiu_exit; |
3770 | } |
3771 | @@ -417,6 +418,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, |
3772 | /* if filetype is different, return error */ |
3773 | if (unlikely(((*pinode)->i_mode & S_IFMT) != |
3774 | (fattr.cf_mode & S_IFMT))) { |
3775 | + CIFS_I(*pinode)->time = 0; /* force reval */ |
3776 | rc = -ESTALE; |
3777 | goto cgiiu_exit; |
3778 | } |
3779 | @@ -926,6 +928,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, |
3780 | /* if uniqueid is different, return error */ |
3781 | if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM && |
3782 | CIFS_I(*inode)->uniqueid != fattr.cf_uniqueid)) { |
3783 | + CIFS_I(*inode)->time = 0; /* force reval */ |
3784 | rc = -ESTALE; |
3785 | goto cgii_exit; |
3786 | } |
3787 | @@ -933,6 +936,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, |
3788 | /* if filetype is different, return error */ |
3789 | if (unlikely(((*inode)->i_mode & S_IFMT) != |
3790 | (fattr.cf_mode & S_IFMT))) { |
3791 | + CIFS_I(*inode)->time = 0; /* force reval */ |
3792 | rc = -ESTALE; |
3793 | goto cgii_exit; |
3794 | } |
3795 | diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c |
3796 | index fdafcfd8b20e..6851afc3bf80 100644 |
3797 | --- a/fs/f2fs/super.c |
3798 | +++ b/fs/f2fs/super.c |
3799 | @@ -2196,11 +2196,11 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3800 | struct super_block *sb = sbi->sb; |
3801 | unsigned int blocksize; |
3802 | |
3803 | - if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) { |
3804 | + if (le32_to_cpu(raw_super->magic) != F2FS_SUPER_MAGIC) { |
3805 | f2fs_msg(sb, KERN_INFO, |
3806 | "Magic Mismatch, valid(0x%x) - read(0x%x)", |
3807 | F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic)); |
3808 | - return 1; |
3809 | + return -EINVAL; |
3810 | } |
3811 | |
3812 | /* Currently, support only 4KB page cache size */ |
3813 | @@ -2208,7 +2208,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3814 | f2fs_msg(sb, KERN_INFO, |
3815 | "Invalid page_cache_size (%lu), supports only 4KB\n", |
3816 | PAGE_SIZE); |
3817 | - return 1; |
3818 | + return -EFSCORRUPTED; |
3819 | } |
3820 | |
3821 | /* Currently, support only 4KB block size */ |
3822 | @@ -2217,7 +2217,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3823 | f2fs_msg(sb, KERN_INFO, |
3824 | "Invalid blocksize (%u), supports only 4KB\n", |
3825 | blocksize); |
3826 | - return 1; |
3827 | + return -EFSCORRUPTED; |
3828 | } |
3829 | |
3830 | /* check log blocks per segment */ |
3831 | @@ -2225,7 +2225,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3832 | f2fs_msg(sb, KERN_INFO, |
3833 | "Invalid log blocks per segment (%u)\n", |
3834 | le32_to_cpu(raw_super->log_blocks_per_seg)); |
3835 | - return 1; |
3836 | + return -EFSCORRUPTED; |
3837 | } |
3838 | |
3839 | /* Currently, support 512/1024/2048/4096 bytes sector size */ |
3840 | @@ -2235,7 +2235,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3841 | F2FS_MIN_LOG_SECTOR_SIZE) { |
3842 | f2fs_msg(sb, KERN_INFO, "Invalid log sectorsize (%u)", |
3843 | le32_to_cpu(raw_super->log_sectorsize)); |
3844 | - return 1; |
3845 | + return -EFSCORRUPTED; |
3846 | } |
3847 | if (le32_to_cpu(raw_super->log_sectors_per_block) + |
3848 | le32_to_cpu(raw_super->log_sectorsize) != |
3849 | @@ -2244,7 +2244,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3850 | "Invalid log sectors per block(%u) log sectorsize(%u)", |
3851 | le32_to_cpu(raw_super->log_sectors_per_block), |
3852 | le32_to_cpu(raw_super->log_sectorsize)); |
3853 | - return 1; |
3854 | + return -EFSCORRUPTED; |
3855 | } |
3856 | |
3857 | segment_count = le32_to_cpu(raw_super->segment_count); |
3858 | @@ -2260,7 +2260,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3859 | f2fs_msg(sb, KERN_INFO, |
3860 | "Invalid segment count (%u)", |
3861 | segment_count); |
3862 | - return 1; |
3863 | + return -EFSCORRUPTED; |
3864 | } |
3865 | |
3866 | if (total_sections > segment_count || |
3867 | @@ -2269,28 +2269,28 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3868 | f2fs_msg(sb, KERN_INFO, |
3869 | "Invalid segment/section count (%u, %u x %u)", |
3870 | segment_count, total_sections, segs_per_sec); |
3871 | - return 1; |
3872 | + return -EFSCORRUPTED; |
3873 | } |
3874 | |
3875 | if ((segment_count / segs_per_sec) < total_sections) { |
3876 | f2fs_msg(sb, KERN_INFO, |
3877 | "Small segment_count (%u < %u * %u)", |
3878 | segment_count, segs_per_sec, total_sections); |
3879 | - return 1; |
3880 | + return -EFSCORRUPTED; |
3881 | } |
3882 | |
3883 | if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) { |
3884 | f2fs_msg(sb, KERN_INFO, |
3885 | "Wrong segment_count / block_count (%u > %llu)", |
3886 | segment_count, le64_to_cpu(raw_super->block_count)); |
3887 | - return 1; |
3888 | + return -EFSCORRUPTED; |
3889 | } |
3890 | |
3891 | if (secs_per_zone > total_sections || !secs_per_zone) { |
3892 | f2fs_msg(sb, KERN_INFO, |
3893 | "Wrong secs_per_zone / total_sections (%u, %u)", |
3894 | secs_per_zone, total_sections); |
3895 | - return 1; |
3896 | + return -EFSCORRUPTED; |
3897 | } |
3898 | if (le32_to_cpu(raw_super->extension_count) > F2FS_MAX_EXTENSION || |
3899 | raw_super->hot_ext_count > F2FS_MAX_EXTENSION || |
3900 | @@ -2301,7 +2301,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3901 | le32_to_cpu(raw_super->extension_count), |
3902 | raw_super->hot_ext_count, |
3903 | F2FS_MAX_EXTENSION); |
3904 | - return 1; |
3905 | + return -EFSCORRUPTED; |
3906 | } |
3907 | |
3908 | if (le32_to_cpu(raw_super->cp_payload) > |
3909 | @@ -2310,7 +2310,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3910 | "Insane cp_payload (%u > %u)", |
3911 | le32_to_cpu(raw_super->cp_payload), |
3912 | blocks_per_seg - F2FS_CP_PACKS); |
3913 | - return 1; |
3914 | + return -EFSCORRUPTED; |
3915 | } |
3916 | |
3917 | /* check reserved ino info */ |
3918 | @@ -2322,12 +2322,12 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
3919 | le32_to_cpu(raw_super->node_ino), |
3920 | le32_to_cpu(raw_super->meta_ino), |
3921 | le32_to_cpu(raw_super->root_ino)); |
3922 | - return 1; |
3923 | + return -EFSCORRUPTED; |
3924 | } |
3925 | |
3926 | /* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */ |
3927 | if (sanity_check_area_boundary(sbi, bh)) |
3928 | - return 1; |
3929 | + return -EFSCORRUPTED; |
3930 | |
3931 | return 0; |
3932 | } |
3933 | @@ -2612,11 +2612,11 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi, |
3934 | } |
3935 | |
3936 | /* sanity checking of raw super */ |
3937 | - if (sanity_check_raw_super(sbi, bh)) { |
3938 | + err = sanity_check_raw_super(sbi, bh); |
3939 | + if (err) { |
3940 | f2fs_msg(sb, KERN_ERR, |
3941 | "Can't find valid F2FS filesystem in %dth superblock", |
3942 | block + 1); |
3943 | - err = -EFSCORRUPTED; |
3944 | brelse(bh); |
3945 | continue; |
3946 | } |
3947 | diff --git a/fs/libfs.c b/fs/libfs.c |
3948 | index 0fb590d79f30..bd2d193d0a2a 100644 |
3949 | --- a/fs/libfs.c |
3950 | +++ b/fs/libfs.c |
3951 | @@ -86,58 +86,47 @@ int dcache_dir_close(struct inode *inode, struct file *file) |
3952 | EXPORT_SYMBOL(dcache_dir_close); |
3953 | |
3954 | /* parent is locked at least shared */ |
3955 | -static struct dentry *next_positive(struct dentry *parent, |
3956 | - struct list_head *from, |
3957 | - int count) |
3958 | +/* |
3959 | + * Returns an element of siblings' list. |
3960 | + * We are looking for <count>th positive after <p>; if |
3961 | + * found, dentry is grabbed and passed to caller via *<res>. |
3962 | + * If no such element exists, the anchor of list is returned |
3963 | + * and *<res> is set to NULL. |
3964 | + */ |
3965 | +static struct list_head *scan_positives(struct dentry *cursor, |
3966 | + struct list_head *p, |
3967 | + loff_t count, |
3968 | + struct dentry **res) |
3969 | { |
3970 | - unsigned *seq = &parent->d_inode->i_dir_seq, n; |
3971 | - struct dentry *res; |
3972 | - struct list_head *p; |
3973 | - bool skipped; |
3974 | - int i; |
3975 | + struct dentry *dentry = cursor->d_parent, *found = NULL; |
3976 | |
3977 | -retry: |
3978 | - i = count; |
3979 | - skipped = false; |
3980 | - n = smp_load_acquire(seq) & ~1; |
3981 | - res = NULL; |
3982 | - rcu_read_lock(); |
3983 | - for (p = from->next; p != &parent->d_subdirs; p = p->next) { |
3984 | + spin_lock(&dentry->d_lock); |
3985 | + while ((p = p->next) != &dentry->d_subdirs) { |
3986 | struct dentry *d = list_entry(p, struct dentry, d_child); |
3987 | - if (!simple_positive(d)) { |
3988 | - skipped = true; |
3989 | - } else if (!--i) { |
3990 | - res = d; |
3991 | - break; |
3992 | + // we must at least skip cursors, to avoid livelocks |
3993 | + if (d->d_flags & DCACHE_DENTRY_CURSOR) |
3994 | + continue; |
3995 | + if (simple_positive(d) && !--count) { |
3996 | + spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED); |
3997 | + if (simple_positive(d)) |
3998 | + found = dget_dlock(d); |
3999 | + spin_unlock(&d->d_lock); |
4000 | + if (likely(found)) |
4001 | + break; |
4002 | + count = 1; |
4003 | + } |
4004 | + if (need_resched()) { |
4005 | + list_move(&cursor->d_child, p); |
4006 | + p = &cursor->d_child; |
4007 | + spin_unlock(&dentry->d_lock); |
4008 | + cond_resched(); |
4009 | + spin_lock(&dentry->d_lock); |
4010 | } |
4011 | } |
4012 | - rcu_read_unlock(); |
4013 | - if (skipped) { |
4014 | - smp_rmb(); |
4015 | - if (unlikely(*seq != n)) |
4016 | - goto retry; |
4017 | - } |
4018 | - return res; |
4019 | -} |
4020 | - |
4021 | -static void move_cursor(struct dentry *cursor, struct list_head *after) |
4022 | -{ |
4023 | - struct dentry *parent = cursor->d_parent; |
4024 | - unsigned n, *seq = &parent->d_inode->i_dir_seq; |
4025 | - spin_lock(&parent->d_lock); |
4026 | - for (;;) { |
4027 | - n = *seq; |
4028 | - if (!(n & 1) && cmpxchg(seq, n, n + 1) == n) |
4029 | - break; |
4030 | - cpu_relax(); |
4031 | - } |
4032 | - __list_del(cursor->d_child.prev, cursor->d_child.next); |
4033 | - if (after) |
4034 | - list_add(&cursor->d_child, after); |
4035 | - else |
4036 | - list_add_tail(&cursor->d_child, &parent->d_subdirs); |
4037 | - smp_store_release(seq, n + 2); |
4038 | - spin_unlock(&parent->d_lock); |
4039 | + spin_unlock(&dentry->d_lock); |
4040 | + dput(*res); |
4041 | + *res = found; |
4042 | + return p; |
4043 | } |
4044 | |
4045 | loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) |
4046 | @@ -153,17 +142,28 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) |
4047 | return -EINVAL; |
4048 | } |
4049 | if (offset != file->f_pos) { |
4050 | + struct dentry *cursor = file->private_data; |
4051 | + struct dentry *to = NULL; |
4052 | + struct list_head *p; |
4053 | + |
4054 | file->f_pos = offset; |
4055 | - if (file->f_pos >= 2) { |
4056 | - struct dentry *cursor = file->private_data; |
4057 | - struct dentry *to; |
4058 | - loff_t n = file->f_pos - 2; |
4059 | - |
4060 | - inode_lock_shared(dentry->d_inode); |
4061 | - to = next_positive(dentry, &dentry->d_subdirs, n); |
4062 | - move_cursor(cursor, to ? &to->d_child : NULL); |
4063 | - inode_unlock_shared(dentry->d_inode); |
4064 | + inode_lock_shared(dentry->d_inode); |
4065 | + |
4066 | + if (file->f_pos > 2) { |
4067 | + p = scan_positives(cursor, &dentry->d_subdirs, |
4068 | + file->f_pos - 2, &to); |
4069 | + spin_lock(&dentry->d_lock); |
4070 | + list_move(&cursor->d_child, p); |
4071 | + spin_unlock(&dentry->d_lock); |
4072 | + } else { |
4073 | + spin_lock(&dentry->d_lock); |
4074 | + list_del_init(&cursor->d_child); |
4075 | + spin_unlock(&dentry->d_lock); |
4076 | } |
4077 | + |
4078 | + dput(to); |
4079 | + |
4080 | + inode_unlock_shared(dentry->d_inode); |
4081 | } |
4082 | return offset; |
4083 | } |
4084 | @@ -185,25 +185,29 @@ int dcache_readdir(struct file *file, struct dir_context *ctx) |
4085 | { |
4086 | struct dentry *dentry = file->f_path.dentry; |
4087 | struct dentry *cursor = file->private_data; |
4088 | - struct list_head *p = &cursor->d_child; |
4089 | - struct dentry *next; |
4090 | - bool moved = false; |
4091 | + struct list_head *anchor = &dentry->d_subdirs; |
4092 | + struct dentry *next = NULL; |
4093 | + struct list_head *p; |
4094 | |
4095 | if (!dir_emit_dots(file, ctx)) |
4096 | return 0; |
4097 | |
4098 | if (ctx->pos == 2) |
4099 | - p = &dentry->d_subdirs; |
4100 | - while ((next = next_positive(dentry, p, 1)) != NULL) { |
4101 | + p = anchor; |
4102 | + else |
4103 | + p = &cursor->d_child; |
4104 | + |
4105 | + while ((p = scan_positives(cursor, p, 1, &next)) != anchor) { |
4106 | if (!dir_emit(ctx, next->d_name.name, next->d_name.len, |
4107 | d_inode(next)->i_ino, dt_type(d_inode(next)))) |
4108 | break; |
4109 | - moved = true; |
4110 | - p = &next->d_child; |
4111 | ctx->pos++; |
4112 | } |
4113 | - if (moved) |
4114 | - move_cursor(cursor, p); |
4115 | + spin_lock(&dentry->d_lock); |
4116 | + list_move_tail(&cursor->d_child, p); |
4117 | + spin_unlock(&dentry->d_lock); |
4118 | + dput(next); |
4119 | + |
4120 | return 0; |
4121 | } |
4122 | EXPORT_SYMBOL(dcache_readdir); |
4123 | diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c |
4124 | index f516ace8f45d..29b70337dcd9 100644 |
4125 | --- a/fs/nfs/direct.c |
4126 | +++ b/fs/nfs/direct.c |
4127 | @@ -122,32 +122,49 @@ static inline int put_dreq(struct nfs_direct_req *dreq) |
4128 | } |
4129 | |
4130 | static void |
4131 | -nfs_direct_good_bytes(struct nfs_direct_req *dreq, struct nfs_pgio_header *hdr) |
4132 | +nfs_direct_handle_truncated(struct nfs_direct_req *dreq, |
4133 | + const struct nfs_pgio_header *hdr, |
4134 | + ssize_t dreq_len) |
4135 | { |
4136 | - int i; |
4137 | - ssize_t count; |
4138 | + struct nfs_direct_mirror *mirror = &dreq->mirrors[hdr->pgio_mirror_idx]; |
4139 | + |
4140 | + if (!(test_bit(NFS_IOHDR_ERROR, &hdr->flags) || |
4141 | + test_bit(NFS_IOHDR_EOF, &hdr->flags))) |
4142 | + return; |
4143 | + if (dreq->max_count >= dreq_len) { |
4144 | + dreq->max_count = dreq_len; |
4145 | + if (dreq->count > dreq_len) |
4146 | + dreq->count = dreq_len; |
4147 | + |
4148 | + if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) |
4149 | + dreq->error = hdr->error; |
4150 | + else /* Clear outstanding error if this is EOF */ |
4151 | + dreq->error = 0; |
4152 | + } |
4153 | + if (mirror->count > dreq_len) |
4154 | + mirror->count = dreq_len; |
4155 | +} |
4156 | |
4157 | - WARN_ON_ONCE(dreq->count >= dreq->max_count); |
4158 | +static void |
4159 | +nfs_direct_count_bytes(struct nfs_direct_req *dreq, |
4160 | + const struct nfs_pgio_header *hdr) |
4161 | +{ |
4162 | + struct nfs_direct_mirror *mirror = &dreq->mirrors[hdr->pgio_mirror_idx]; |
4163 | + loff_t hdr_end = hdr->io_start + hdr->good_bytes; |
4164 | + ssize_t dreq_len = 0; |
4165 | |
4166 | - if (dreq->mirror_count == 1) { |
4167 | - dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes; |
4168 | - dreq->count += hdr->good_bytes; |
4169 | - } else { |
4170 | - /* mirrored writes */ |
4171 | - count = dreq->mirrors[hdr->pgio_mirror_idx].count; |
4172 | - if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) { |
4173 | - count = hdr->io_start + hdr->good_bytes - dreq->io_start; |
4174 | - dreq->mirrors[hdr->pgio_mirror_idx].count = count; |
4175 | - } |
4176 | - /* update the dreq->count by finding the minimum agreed count from all |
4177 | - * mirrors */ |
4178 | - count = dreq->mirrors[0].count; |
4179 | + if (hdr_end > dreq->io_start) |
4180 | + dreq_len = hdr_end - dreq->io_start; |
4181 | |
4182 | - for (i = 1; i < dreq->mirror_count; i++) |
4183 | - count = min(count, dreq->mirrors[i].count); |
4184 | + nfs_direct_handle_truncated(dreq, hdr, dreq_len); |
4185 | |
4186 | - dreq->count = count; |
4187 | - } |
4188 | + if (dreq_len > dreq->max_count) |
4189 | + dreq_len = dreq->max_count; |
4190 | + |
4191 | + if (mirror->count < dreq_len) |
4192 | + mirror->count = dreq_len; |
4193 | + if (dreq->count < dreq_len) |
4194 | + dreq->count = dreq_len; |
4195 | } |
4196 | |
4197 | /* |
4198 | @@ -401,20 +418,12 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) |
4199 | struct nfs_direct_req *dreq = hdr->dreq; |
4200 | |
4201 | spin_lock(&dreq->lock); |
4202 | - if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) |
4203 | - dreq->error = hdr->error; |
4204 | - |
4205 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
4206 | spin_unlock(&dreq->lock); |
4207 | goto out_put; |
4208 | } |
4209 | |
4210 | - if (hdr->good_bytes != 0) |
4211 | - nfs_direct_good_bytes(dreq, hdr); |
4212 | - |
4213 | - if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) |
4214 | - dreq->error = 0; |
4215 | - |
4216 | + nfs_direct_count_bytes(dreq, hdr); |
4217 | spin_unlock(&dreq->lock); |
4218 | |
4219 | while (!list_empty(&hdr->pages)) { |
4220 | @@ -651,6 +660,9 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) |
4221 | nfs_direct_write_scan_commit_list(dreq->inode, &reqs, &cinfo); |
4222 | |
4223 | dreq->count = 0; |
4224 | + dreq->max_count = 0; |
4225 | + list_for_each_entry(req, &reqs, wb_list) |
4226 | + dreq->max_count += req->wb_bytes; |
4227 | dreq->verf.committed = NFS_INVALID_STABLE_HOW; |
4228 | nfs_clear_pnfs_ds_commit_verifiers(&dreq->ds_cinfo); |
4229 | for (i = 0; i < dreq->mirror_count; i++) |
4230 | @@ -783,17 +795,13 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) |
4231 | nfs_init_cinfo_from_dreq(&cinfo, dreq); |
4232 | |
4233 | spin_lock(&dreq->lock); |
4234 | - |
4235 | - if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) |
4236 | - dreq->error = hdr->error; |
4237 | - |
4238 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
4239 | spin_unlock(&dreq->lock); |
4240 | goto out_put; |
4241 | } |
4242 | |
4243 | + nfs_direct_count_bytes(dreq, hdr); |
4244 | if (hdr->good_bytes != 0) { |
4245 | - nfs_direct_good_bytes(dreq, hdr); |
4246 | if (nfs_write_need_commit(hdr)) { |
4247 | if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) |
4248 | request_commit = true; |
4249 | diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h |
4250 | index c50ef7e6b942..1d4ef0621174 100644 |
4251 | --- a/include/acpi/actbl2.h |
4252 | +++ b/include/acpi/actbl2.h |
4253 | @@ -1472,8 +1472,11 @@ struct acpi_pptt_processor { |
4254 | |
4255 | /* Flags */ |
4256 | |
4257 | -#define ACPI_PPTT_PHYSICAL_PACKAGE (1) /* Physical package */ |
4258 | -#define ACPI_PPTT_ACPI_PROCESSOR_ID_VALID (2) /* ACPI Processor ID valid */ |
4259 | +#define ACPI_PPTT_PHYSICAL_PACKAGE (1) |
4260 | +#define ACPI_PPTT_ACPI_PROCESSOR_ID_VALID (1<<1) |
4261 | +#define ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD (1<<2) /* ACPI 6.3 */ |
4262 | +#define ACPI_PPTT_ACPI_LEAF_NODE (1<<3) /* ACPI 6.3 */ |
4263 | +#define ACPI_PPTT_ACPI_IDENTICAL (1<<4) /* ACPI 6.3 */ |
4264 | |
4265 | /* 1: Cache Type Structure */ |
4266 | |
4267 | diff --git a/include/linux/acpi.h b/include/linux/acpi.h |
4268 | index b4d23b3a2ef2..59a416dfcaaa 100644 |
4269 | --- a/include/linux/acpi.h |
4270 | +++ b/include/linux/acpi.h |
4271 | @@ -1291,10 +1291,15 @@ static inline int lpit_read_residency_count_address(u64 *address) |
4272 | #endif |
4273 | |
4274 | #ifdef CONFIG_ACPI_PPTT |
4275 | +int acpi_pptt_cpu_is_thread(unsigned int cpu); |
4276 | int find_acpi_cpu_topology(unsigned int cpu, int level); |
4277 | int find_acpi_cpu_topology_package(unsigned int cpu); |
4278 | int find_acpi_cpu_cache_topology(unsigned int cpu, int level); |
4279 | #else |
4280 | +static inline int acpi_pptt_cpu_is_thread(unsigned int cpu) |
4281 | +{ |
4282 | + return -EINVAL; |
4283 | +} |
4284 | static inline int find_acpi_cpu_topology(unsigned int cpu, int level) |
4285 | { |
4286 | return -EINVAL; |
4287 | diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h |
4288 | index 9493d4a388db..8fde789f2eff 100644 |
4289 | --- a/include/linux/hwmon.h |
4290 | +++ b/include/linux/hwmon.h |
4291 | @@ -225,7 +225,7 @@ enum hwmon_power_attributes { |
4292 | #define HWMON_P_LABEL BIT(hwmon_power_label) |
4293 | #define HWMON_P_ALARM BIT(hwmon_power_alarm) |
4294 | #define HWMON_P_CAP_ALARM BIT(hwmon_power_cap_alarm) |
4295 | -#define HWMON_P_MIN_ALARM BIT(hwmon_power_max_alarm) |
4296 | +#define HWMON_P_MIN_ALARM BIT(hwmon_power_min_alarm) |
4297 | #define HWMON_P_MAX_ALARM BIT(hwmon_power_max_alarm) |
4298 | #define HWMON_P_LCRIT_ALARM BIT(hwmon_power_lcrit_alarm) |
4299 | #define HWMON_P_CRIT_ALARM BIT(hwmon_power_crit_alarm) |
4300 | diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c |
4301 | index d6b56180827c..bf3f2d325faa 100644 |
4302 | --- a/kernel/events/hw_breakpoint.c |
4303 | +++ b/kernel/events/hw_breakpoint.c |
4304 | @@ -426,7 +426,7 @@ static int hw_breakpoint_parse(struct perf_event *bp, |
4305 | |
4306 | int register_perf_hw_breakpoint(struct perf_event *bp) |
4307 | { |
4308 | - struct arch_hw_breakpoint hw; |
4309 | + struct arch_hw_breakpoint hw = { }; |
4310 | int err; |
4311 | |
4312 | err = reserve_bp_slot(bp); |
4313 | @@ -474,7 +474,7 @@ int |
4314 | modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr, |
4315 | bool check) |
4316 | { |
4317 | - struct arch_hw_breakpoint hw; |
4318 | + struct arch_hw_breakpoint hw = { }; |
4319 | int err; |
4320 | |
4321 | err = hw_breakpoint_parse(bp, attr, &hw); |
4322 | diff --git a/kernel/fork.c b/kernel/fork.c |
4323 | index e76ce81c9c75..aef1430bdce0 100644 |
4324 | --- a/kernel/fork.c |
4325 | +++ b/kernel/fork.c |
4326 | @@ -2623,7 +2623,7 @@ int sysctl_max_threads(struct ctl_table *table, int write, |
4327 | struct ctl_table t; |
4328 | int ret; |
4329 | int threads = max_threads; |
4330 | - int min = MIN_THREADS; |
4331 | + int min = 1; |
4332 | int max = MAX_THREADS; |
4333 | |
4334 | t = *table; |
4335 | @@ -2635,7 +2635,7 @@ int sysctl_max_threads(struct ctl_table *table, int write, |
4336 | if (ret || !write) |
4337 | return ret; |
4338 | |
4339 | - set_max_threads(threads); |
4340 | + max_threads = threads; |
4341 | |
4342 | return 0; |
4343 | } |
4344 | diff --git a/kernel/panic.c b/kernel/panic.c |
4345 | index 6a6df23acd1a..72e001e3753e 100644 |
4346 | --- a/kernel/panic.c |
4347 | +++ b/kernel/panic.c |
4348 | @@ -149,6 +149,7 @@ void panic(const char *fmt, ...) |
4349 | * after setting panic_cpu) from invoking panic() again. |
4350 | */ |
4351 | local_irq_disable(); |
4352 | + preempt_disable_notrace(); |
4353 | |
4354 | /* |
4355 | * It's possible to come here directly from a panic-assertion and |
4356 | diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c |
4357 | index 7e215dac9693..b84eb9659e95 100644 |
4358 | --- a/kernel/trace/ftrace.c |
4359 | +++ b/kernel/trace/ftrace.c |
4360 | @@ -3557,21 +3557,22 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, |
4361 | struct ftrace_hash *hash; |
4362 | struct list_head *mod_head; |
4363 | struct trace_array *tr = ops->private; |
4364 | - int ret = 0; |
4365 | + int ret = -ENOMEM; |
4366 | |
4367 | ftrace_ops_init(ops); |
4368 | |
4369 | if (unlikely(ftrace_disabled)) |
4370 | return -ENODEV; |
4371 | |
4372 | + if (tr && trace_array_get(tr) < 0) |
4373 | + return -ENODEV; |
4374 | + |
4375 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); |
4376 | if (!iter) |
4377 | - return -ENOMEM; |
4378 | + goto out; |
4379 | |
4380 | - if (trace_parser_get_init(&iter->parser, FTRACE_BUFF_MAX)) { |
4381 | - kfree(iter); |
4382 | - return -ENOMEM; |
4383 | - } |
4384 | + if (trace_parser_get_init(&iter->parser, FTRACE_BUFF_MAX)) |
4385 | + goto out; |
4386 | |
4387 | iter->ops = ops; |
4388 | iter->flags = flag; |
4389 | @@ -3601,13 +3602,13 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, |
4390 | |
4391 | if (!iter->hash) { |
4392 | trace_parser_put(&iter->parser); |
4393 | - kfree(iter); |
4394 | - ret = -ENOMEM; |
4395 | goto out_unlock; |
4396 | } |
4397 | } else |
4398 | iter->hash = hash; |
4399 | |
4400 | + ret = 0; |
4401 | + |
4402 | if (file->f_mode & FMODE_READ) { |
4403 | iter->pg = ftrace_pages_start; |
4404 | |
4405 | @@ -3619,7 +3620,6 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, |
4406 | /* Failed */ |
4407 | free_ftrace_hash(iter->hash); |
4408 | trace_parser_put(&iter->parser); |
4409 | - kfree(iter); |
4410 | } |
4411 | } else |
4412 | file->private_data = iter; |
4413 | @@ -3627,6 +3627,13 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, |
4414 | out_unlock: |
4415 | mutex_unlock(&ops->func_hash->regex_lock); |
4416 | |
4417 | + out: |
4418 | + if (ret) { |
4419 | + kfree(iter); |
4420 | + if (tr) |
4421 | + trace_array_put(tr); |
4422 | + } |
4423 | + |
4424 | return ret; |
4425 | } |
4426 | |
4427 | @@ -5024,6 +5031,8 @@ int ftrace_regex_release(struct inode *inode, struct file *file) |
4428 | |
4429 | mutex_unlock(&iter->ops->func_hash->regex_lock); |
4430 | free_ftrace_hash(iter->hash); |
4431 | + if (iter->tr) |
4432 | + trace_array_put(iter->tr); |
4433 | kfree(iter); |
4434 | |
4435 | return 0; |
4436 | diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c |
4437 | index 3b0de19b9ed7..27b17ea44f74 100644 |
4438 | --- a/kernel/trace/trace.c |
4439 | +++ b/kernel/trace/trace.c |
4440 | @@ -4154,9 +4154,14 @@ static int show_traces_open(struct inode *inode, struct file *file) |
4441 | if (tracing_disabled) |
4442 | return -ENODEV; |
4443 | |
4444 | + if (trace_array_get(tr) < 0) |
4445 | + return -ENODEV; |
4446 | + |
4447 | ret = seq_open(file, &show_traces_seq_ops); |
4448 | - if (ret) |
4449 | + if (ret) { |
4450 | + trace_array_put(tr); |
4451 | return ret; |
4452 | + } |
4453 | |
4454 | m = file->private_data; |
4455 | m->private = tr; |
4456 | @@ -4164,6 +4169,14 @@ static int show_traces_open(struct inode *inode, struct file *file) |
4457 | return 0; |
4458 | } |
4459 | |
4460 | +static int show_traces_release(struct inode *inode, struct file *file) |
4461 | +{ |
4462 | + struct trace_array *tr = inode->i_private; |
4463 | + |
4464 | + trace_array_put(tr); |
4465 | + return seq_release(inode, file); |
4466 | +} |
4467 | + |
4468 | static ssize_t |
4469 | tracing_write_stub(struct file *filp, const char __user *ubuf, |
4470 | size_t count, loff_t *ppos) |
4471 | @@ -4194,8 +4207,8 @@ static const struct file_operations tracing_fops = { |
4472 | static const struct file_operations show_traces_fops = { |
4473 | .open = show_traces_open, |
4474 | .read = seq_read, |
4475 | - .release = seq_release, |
4476 | .llseek = seq_lseek, |
4477 | + .release = show_traces_release, |
4478 | }; |
4479 | |
4480 | static ssize_t |
4481 | diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c |
4482 | index 1e6db9cbe4dc..8030e24dbf14 100644 |
4483 | --- a/kernel/trace/trace_hwlat.c |
4484 | +++ b/kernel/trace/trace_hwlat.c |
4485 | @@ -150,7 +150,7 @@ void trace_hwlat_callback(bool enter) |
4486 | if (enter) |
4487 | nmi_ts_start = time_get(); |
4488 | else |
4489 | - nmi_total_ts = time_get() - nmi_ts_start; |
4490 | + nmi_total_ts += time_get() - nmi_ts_start; |
4491 | } |
4492 | |
4493 | if (enter) |
4494 | @@ -256,6 +256,8 @@ static int get_sample(void) |
4495 | /* Keep a running maximum ever recorded hardware latency */ |
4496 | if (sample > tr->max_latency) |
4497 | tr->max_latency = sample; |
4498 | + if (outer_sample > tr->max_latency) |
4499 | + tr->max_latency = outer_sample; |
4500 | } |
4501 | |
4502 | out: |
4503 | diff --git a/mm/vmpressure.c b/mm/vmpressure.c |
4504 | index 4854584ec436..39021133cec8 100644 |
4505 | --- a/mm/vmpressure.c |
4506 | +++ b/mm/vmpressure.c |
4507 | @@ -358,6 +358,9 @@ void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg, int prio) |
4508 | * "hierarchy" or "local"). |
4509 | * |
4510 | * To be used as memcg event method. |
4511 | + * |
4512 | + * Return: 0 on success, -ENOMEM on memory failure or -EINVAL if @args could |
4513 | + * not be parsed. |
4514 | */ |
4515 | int vmpressure_register_event(struct mem_cgroup *memcg, |
4516 | struct eventfd_ctx *eventfd, const char *args) |
4517 | @@ -365,7 +368,7 @@ int vmpressure_register_event(struct mem_cgroup *memcg, |
4518 | struct vmpressure *vmpr = memcg_to_vmpressure(memcg); |
4519 | struct vmpressure_event *ev; |
4520 | enum vmpressure_modes mode = VMPRESSURE_NO_PASSTHROUGH; |
4521 | - enum vmpressure_levels level = -1; |
4522 | + enum vmpressure_levels level; |
4523 | char *spec, *spec_orig; |
4524 | char *token; |
4525 | int ret = 0; |
4526 | @@ -378,20 +381,18 @@ int vmpressure_register_event(struct mem_cgroup *memcg, |
4527 | |
4528 | /* Find required level */ |
4529 | token = strsep(&spec, ","); |
4530 | - level = match_string(vmpressure_str_levels, VMPRESSURE_NUM_LEVELS, token); |
4531 | - if (level < 0) { |
4532 | - ret = level; |
4533 | + ret = match_string(vmpressure_str_levels, VMPRESSURE_NUM_LEVELS, token); |
4534 | + if (ret < 0) |
4535 | goto out; |
4536 | - } |
4537 | + level = ret; |
4538 | |
4539 | /* Find optional mode */ |
4540 | token = strsep(&spec, ","); |
4541 | if (token) { |
4542 | - mode = match_string(vmpressure_str_modes, VMPRESSURE_NUM_MODES, token); |
4543 | - if (mode < 0) { |
4544 | - ret = mode; |
4545 | + ret = match_string(vmpressure_str_modes, VMPRESSURE_NUM_MODES, token); |
4546 | + if (ret < 0) |
4547 | goto out; |
4548 | - } |
4549 | + mode = ret; |
4550 | } |
4551 | |
4552 | ev = kzalloc(sizeof(*ev), GFP_KERNEL); |
4553 | @@ -407,6 +408,7 @@ int vmpressure_register_event(struct mem_cgroup *memcg, |
4554 | mutex_lock(&vmpr->events_lock); |
4555 | list_add(&ev->node, &vmpr->events); |
4556 | mutex_unlock(&vmpr->events_lock); |
4557 | + ret = 0; |
4558 | out: |
4559 | kfree(spec_orig); |
4560 | return ret; |
4561 | diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c |
4562 | index a1863000e972..663e790c2693 100644 |
4563 | --- a/tools/perf/util/jitdump.c |
4564 | +++ b/tools/perf/util/jitdump.c |
4565 | @@ -394,7 +394,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) |
4566 | size_t size; |
4567 | u16 idr_size; |
4568 | const char *sym; |
4569 | - uint32_t count; |
4570 | + uint64_t count; |
4571 | int ret, csize, usize; |
4572 | pid_t pid, tid; |
4573 | struct { |
4574 | @@ -417,7 +417,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) |
4575 | return -1; |
4576 | |
4577 | filename = event->mmap2.filename; |
4578 | - size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%u.so", |
4579 | + size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%" PRIu64 ".so", |
4580 | jd->dir, |
4581 | pid, |
4582 | count); |
4583 | @@ -530,7 +530,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr) |
4584 | return -1; |
4585 | |
4586 | filename = event->mmap2.filename; |
4587 | - size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%"PRIu64, |
4588 | + size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%" PRIu64 ".so", |
4589 | jd->dir, |
4590 | pid, |
4591 | jr->move.code_index); |
4592 | diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c |
4593 | index 19262f98cd4e..2344d86cd778 100644 |
4594 | --- a/tools/perf/util/llvm-utils.c |
4595 | +++ b/tools/perf/util/llvm-utils.c |
4596 | @@ -230,14 +230,14 @@ static int detect_kbuild_dir(char **kbuild_dir) |
4597 | const char *prefix_dir = ""; |
4598 | const char *suffix_dir = ""; |
4599 | |
4600 | + /* _UTSNAME_LENGTH is 65 */ |
4601 | + char release[128]; |
4602 | + |
4603 | char *autoconf_path; |
4604 | |
4605 | int err; |
4606 | |
4607 | if (!test_dir) { |
4608 | - /* _UTSNAME_LENGTH is 65 */ |
4609 | - char release[128]; |
4610 | - |
4611 | err = fetch_kernel_version(NULL, release, |
4612 | sizeof(release)); |
4613 | if (err) |