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