1 |
commit: 466fe7cb06476e8a577628c1620bdaff6551d949 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Apr 20 11:09:34 2019 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Apr 20 11:09:34 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=466fe7cb |
7 |
|
8 |
Linux patch 4.19.36 |
9 |
|
10 |
Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1035_linux-4.19.36.patch | 7962 ++++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 7966 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index fbfea55..043542a 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -183,6 +183,10 @@ Patch: 1034_linux-4.19.35.patch |
21 |
From: http://www.kernel.org |
22 |
Desc: Linux 4.19.35 |
23 |
|
24 |
+Patch: 1035_linux-4.19.36.patch |
25 |
+From: http://www.kernel.org |
26 |
+Desc: Linux 4.19.36 |
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/1035_linux-4.19.36.patch b/1035_linux-4.19.36.patch |
33 |
new file mode 100644 |
34 |
index 0000000..a57f768 |
35 |
--- /dev/null |
36 |
+++ b/1035_linux-4.19.36.patch |
37 |
@@ -0,0 +1,7962 @@ |
38 |
+diff --git a/MAINTAINERS b/MAINTAINERS |
39 |
+index 9e9b19ecf6f7..11a59e82d92e 100644 |
40 |
+--- a/MAINTAINERS |
41 |
++++ b/MAINTAINERS |
42 |
+@@ -7320,6 +7320,12 @@ L: alsa-devel@××××××××××××.org (moderated for non-subscribers) |
43 |
+ S: Supported |
44 |
+ F: sound/soc/intel/ |
45 |
+ |
46 |
++INTEL ATOMISP2 DUMMY / POWER-MANAGEMENT DRIVER |
47 |
++M: Hans de Goede <hdegoede@××××××.com> |
48 |
++L: platform-driver-x86@×××××××××××.org |
49 |
++S: Maintained |
50 |
++F: drivers/platform/x86/intel_atomisp2_pm.c |
51 |
++ |
52 |
+ INTEL C600 SERIES SAS CONTROLLER DRIVER |
53 |
+ M: Intel SCU Linux support <intel-linux-scu@×××××.com> |
54 |
+ M: Artur Paszkiewicz <artur.paszkiewicz@×××××.com> |
55 |
+diff --git a/Makefile b/Makefile |
56 |
+index f4229975b48c..3fac08f6a11e 100644 |
57 |
+--- a/Makefile |
58 |
++++ b/Makefile |
59 |
+@@ -1,7 +1,7 @@ |
60 |
+ # SPDX-License-Identifier: GPL-2.0 |
61 |
+ VERSION = 4 |
62 |
+ PATCHLEVEL = 19 |
63 |
+-SUBLEVEL = 35 |
64 |
++SUBLEVEL = 36 |
65 |
+ EXTRAVERSION = |
66 |
+ NAME = "People's Front" |
67 |
+ |
68 |
+diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig |
69 |
+index 2a1d2cbfee1a..651fa7978e51 100644 |
70 |
+--- a/arch/arc/configs/hsdk_defconfig |
71 |
++++ b/arch/arc/configs/hsdk_defconfig |
72 |
+@@ -8,6 +8,7 @@ CONFIG_NAMESPACES=y |
73 |
+ # CONFIG_UTS_NS is not set |
74 |
+ # CONFIG_PID_NS is not set |
75 |
+ CONFIG_BLK_DEV_INITRD=y |
76 |
++CONFIG_BLK_DEV_RAM=y |
77 |
+ CONFIG_EMBEDDED=y |
78 |
+ CONFIG_PERF_EVENTS=y |
79 |
+ # CONFIG_VM_EVENT_COUNTERS is not set |
80 |
+diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S |
81 |
+index 1f945d0f40da..208bf2c9e7b0 100644 |
82 |
+--- a/arch/arc/kernel/head.S |
83 |
++++ b/arch/arc/kernel/head.S |
84 |
+@@ -107,6 +107,7 @@ ENTRY(stext) |
85 |
+ ; r2 = pointer to uboot provided cmdline or external DTB in mem |
86 |
+ ; These are handled later in handle_uboot_args() |
87 |
+ st r0, [@uboot_tag] |
88 |
++ st r1, [@uboot_magic] |
89 |
+ st r2, [@uboot_arg] |
90 |
+ #endif |
91 |
+ |
92 |
+diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c |
93 |
+index 3320ca2fe20f..a1218937abd6 100644 |
94 |
+--- a/arch/arc/kernel/setup.c |
95 |
++++ b/arch/arc/kernel/setup.c |
96 |
+@@ -35,6 +35,7 @@ unsigned int intr_to_DE_cnt; |
97 |
+ |
98 |
+ /* Part of U-boot ABI: see head.S */ |
99 |
+ int __initdata uboot_tag; |
100 |
++int __initdata uboot_magic; |
101 |
+ char __initdata *uboot_arg; |
102 |
+ |
103 |
+ const struct machine_desc *machine_desc; |
104 |
+@@ -484,6 +485,8 @@ static inline bool uboot_arg_invalid(unsigned long addr) |
105 |
+ #define UBOOT_TAG_NONE 0 |
106 |
+ #define UBOOT_TAG_CMDLINE 1 |
107 |
+ #define UBOOT_TAG_DTB 2 |
108 |
++/* We always pass 0 as magic from U-boot */ |
109 |
++#define UBOOT_MAGIC_VALUE 0 |
110 |
+ |
111 |
+ void __init handle_uboot_args(void) |
112 |
+ { |
113 |
+@@ -499,6 +502,11 @@ void __init handle_uboot_args(void) |
114 |
+ goto ignore_uboot_args; |
115 |
+ } |
116 |
+ |
117 |
++ if (uboot_magic != UBOOT_MAGIC_VALUE) { |
118 |
++ pr_warn(IGNORE_ARGS "non zero uboot magic\n"); |
119 |
++ goto ignore_uboot_args; |
120 |
++ } |
121 |
++ |
122 |
+ if (uboot_tag != UBOOT_TAG_NONE && |
123 |
+ uboot_arg_invalid((unsigned long)uboot_arg)) { |
124 |
+ pr_warn(IGNORE_ARGS "invalid uboot arg: '%px'\n", uboot_arg); |
125 |
+diff --git a/arch/arm/crypto/sha256-armv4.pl b/arch/arm/crypto/sha256-armv4.pl |
126 |
+index b9ec44060ed3..a03cf4dfb781 100644 |
127 |
+--- a/arch/arm/crypto/sha256-armv4.pl |
128 |
++++ b/arch/arm/crypto/sha256-armv4.pl |
129 |
+@@ -212,10 +212,11 @@ K256: |
130 |
+ .global sha256_block_data_order |
131 |
+ .type sha256_block_data_order,%function |
132 |
+ sha256_block_data_order: |
133 |
++.Lsha256_block_data_order: |
134 |
+ #if __ARM_ARCH__<7 |
135 |
+ sub r3,pc,#8 @ sha256_block_data_order |
136 |
+ #else |
137 |
+- adr r3,sha256_block_data_order |
138 |
++ adr r3,.Lsha256_block_data_order |
139 |
+ #endif |
140 |
+ #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) |
141 |
+ ldr r12,.LOPENSSL_armcap |
142 |
+diff --git a/arch/arm/crypto/sha256-core.S_shipped b/arch/arm/crypto/sha256-core.S_shipped |
143 |
+index 3b58300d611c..054aae0edfce 100644 |
144 |
+--- a/arch/arm/crypto/sha256-core.S_shipped |
145 |
++++ b/arch/arm/crypto/sha256-core.S_shipped |
146 |
+@@ -93,10 +93,11 @@ K256: |
147 |
+ .global sha256_block_data_order |
148 |
+ .type sha256_block_data_order,%function |
149 |
+ sha256_block_data_order: |
150 |
++.Lsha256_block_data_order: |
151 |
+ #if __ARM_ARCH__<7 |
152 |
+ sub r3,pc,#8 @ sha256_block_data_order |
153 |
+ #else |
154 |
+- adr r3,sha256_block_data_order |
155 |
++ adr r3,.Lsha256_block_data_order |
156 |
+ #endif |
157 |
+ #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) |
158 |
+ ldr r12,.LOPENSSL_armcap |
159 |
+diff --git a/arch/arm/crypto/sha512-armv4.pl b/arch/arm/crypto/sha512-armv4.pl |
160 |
+index fb5d15048c0b..788c17b56ecc 100644 |
161 |
+--- a/arch/arm/crypto/sha512-armv4.pl |
162 |
++++ b/arch/arm/crypto/sha512-armv4.pl |
163 |
+@@ -274,10 +274,11 @@ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) |
164 |
+ .global sha512_block_data_order |
165 |
+ .type sha512_block_data_order,%function |
166 |
+ sha512_block_data_order: |
167 |
++.Lsha512_block_data_order: |
168 |
+ #if __ARM_ARCH__<7 |
169 |
+ sub r3,pc,#8 @ sha512_block_data_order |
170 |
+ #else |
171 |
+- adr r3,sha512_block_data_order |
172 |
++ adr r3,.Lsha512_block_data_order |
173 |
+ #endif |
174 |
+ #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) |
175 |
+ ldr r12,.LOPENSSL_armcap |
176 |
+diff --git a/arch/arm/crypto/sha512-core.S_shipped b/arch/arm/crypto/sha512-core.S_shipped |
177 |
+index b1c334a49cda..710ea309769e 100644 |
178 |
+--- a/arch/arm/crypto/sha512-core.S_shipped |
179 |
++++ b/arch/arm/crypto/sha512-core.S_shipped |
180 |
+@@ -141,10 +141,11 @@ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) |
181 |
+ .global sha512_block_data_order |
182 |
+ .type sha512_block_data_order,%function |
183 |
+ sha512_block_data_order: |
184 |
++.Lsha512_block_data_order: |
185 |
+ #if __ARM_ARCH__<7 |
186 |
+ sub r3,pc,#8 @ sha512_block_data_order |
187 |
+ #else |
188 |
+- adr r3,sha512_block_data_order |
189 |
++ adr r3,.Lsha512_block_data_order |
190 |
+ #endif |
191 |
+ #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) |
192 |
+ ldr r12,.LOPENSSL_armcap |
193 |
+diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c |
194 |
+index a50dc00d79a2..d0a05a3bdb96 100644 |
195 |
+--- a/arch/arm/kernel/patch.c |
196 |
++++ b/arch/arm/kernel/patch.c |
197 |
+@@ -16,7 +16,7 @@ struct patch { |
198 |
+ unsigned int insn; |
199 |
+ }; |
200 |
+ |
201 |
+-static DEFINE_SPINLOCK(patch_lock); |
202 |
++static DEFINE_RAW_SPINLOCK(patch_lock); |
203 |
+ |
204 |
+ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags) |
205 |
+ __acquires(&patch_lock) |
206 |
+@@ -33,7 +33,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags) |
207 |
+ return addr; |
208 |
+ |
209 |
+ if (flags) |
210 |
+- spin_lock_irqsave(&patch_lock, *flags); |
211 |
++ raw_spin_lock_irqsave(&patch_lock, *flags); |
212 |
+ else |
213 |
+ __acquire(&patch_lock); |
214 |
+ |
215 |
+@@ -48,7 +48,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long *flags) |
216 |
+ clear_fixmap(fixmap); |
217 |
+ |
218 |
+ if (flags) |
219 |
+- spin_unlock_irqrestore(&patch_lock, *flags); |
220 |
++ raw_spin_unlock_irqrestore(&patch_lock, *flags); |
221 |
+ else |
222 |
+ __release(&patch_lock); |
223 |
+ } |
224 |
+diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig |
225 |
+index b600e38364eb..377ff9cda667 100644 |
226 |
+--- a/arch/arm/plat-samsung/Kconfig |
227 |
++++ b/arch/arm/plat-samsung/Kconfig |
228 |
+@@ -256,7 +256,7 @@ config S3C_PM_DEBUG_LED_SMDK |
229 |
+ |
230 |
+ config SAMSUNG_PM_CHECK |
231 |
+ bool "S3C2410 PM Suspend Memory CRC" |
232 |
+- depends on PM |
233 |
++ depends on PM && (PLAT_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210) |
234 |
+ select CRC32 |
235 |
+ help |
236 |
+ Enable the PM code's memory area checksum over sleep. This option |
237 |
+diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c |
238 |
+index 44d66c33d59d..23b88b923f06 100644 |
239 |
+--- a/arch/powerpc/kernel/rtasd.c |
240 |
++++ b/arch/powerpc/kernel/rtasd.c |
241 |
+@@ -274,27 +274,16 @@ void pSeries_log_error(char *buf, unsigned int err_type, int fatal) |
242 |
+ } |
243 |
+ |
244 |
+ #ifdef CONFIG_PPC_PSERIES |
245 |
+-static s32 prrn_update_scope; |
246 |
+- |
247 |
+-static void prrn_work_fn(struct work_struct *work) |
248 |
++static void handle_prrn_event(s32 scope) |
249 |
+ { |
250 |
+ /* |
251 |
+ * For PRRN, we must pass the negative of the scope value in |
252 |
+ * the RTAS event. |
253 |
+ */ |
254 |
+- pseries_devicetree_update(-prrn_update_scope); |
255 |
++ pseries_devicetree_update(-scope); |
256 |
+ numa_update_cpu_topology(false); |
257 |
+ } |
258 |
+ |
259 |
+-static DECLARE_WORK(prrn_work, prrn_work_fn); |
260 |
+- |
261 |
+-static void prrn_schedule_update(u32 scope) |
262 |
+-{ |
263 |
+- flush_work(&prrn_work); |
264 |
+- prrn_update_scope = scope; |
265 |
+- schedule_work(&prrn_work); |
266 |
+-} |
267 |
+- |
268 |
+ static void handle_rtas_event(const struct rtas_error_log *log) |
269 |
+ { |
270 |
+ if (rtas_error_type(log) != RTAS_TYPE_PRRN || !prrn_is_enabled()) |
271 |
+@@ -303,7 +292,7 @@ static void handle_rtas_event(const struct rtas_error_log *log) |
272 |
+ /* For PRRN Events the extended log length is used to denote |
273 |
+ * the scope for calling rtas update-nodes. |
274 |
+ */ |
275 |
+- prrn_schedule_update(rtas_error_extended_log_length(log)); |
276 |
++ handle_prrn_event(rtas_error_extended_log_length(log)); |
277 |
+ } |
278 |
+ |
279 |
+ #else |
280 |
+diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c |
281 |
+index 87abd5145cc9..3fb855155286 100644 |
282 |
+--- a/arch/x86/hyperv/hv_init.c |
283 |
++++ b/arch/x86/hyperv/hv_init.c |
284 |
+@@ -101,9 +101,13 @@ static int hv_cpu_init(unsigned int cpu) |
285 |
+ u64 msr_vp_index; |
286 |
+ struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id()]; |
287 |
+ void **input_arg; |
288 |
++ struct page *pg; |
289 |
+ |
290 |
+ input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg); |
291 |
+- *input_arg = page_address(alloc_page(GFP_KERNEL)); |
292 |
++ pg = alloc_page(GFP_KERNEL); |
293 |
++ if (unlikely(!pg)) |
294 |
++ return -ENOMEM; |
295 |
++ *input_arg = page_address(pg); |
296 |
+ |
297 |
+ hv_get_vp_index(msr_vp_index); |
298 |
+ |
299 |
+diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c |
300 |
+index 2c4d5ece7456..93426c5fc70f 100644 |
301 |
+--- a/arch/x86/kernel/aperture_64.c |
302 |
++++ b/arch/x86/kernel/aperture_64.c |
303 |
+@@ -14,6 +14,7 @@ |
304 |
+ #define pr_fmt(fmt) "AGP: " fmt |
305 |
+ |
306 |
+ #include <linux/kernel.h> |
307 |
++#include <linux/kcore.h> |
308 |
+ #include <linux/types.h> |
309 |
+ #include <linux/init.h> |
310 |
+ #include <linux/memblock.h> |
311 |
+@@ -57,7 +58,7 @@ int fallback_aper_force __initdata; |
312 |
+ |
313 |
+ int fix_aperture __initdata = 1; |
314 |
+ |
315 |
+-#ifdef CONFIG_PROC_VMCORE |
316 |
++#if defined(CONFIG_PROC_VMCORE) || defined(CONFIG_PROC_KCORE) |
317 |
+ /* |
318 |
+ * If the first kernel maps the aperture over e820 RAM, the kdump kernel will |
319 |
+ * use the same range because it will remain configured in the northbridge. |
320 |
+@@ -66,20 +67,25 @@ int fix_aperture __initdata = 1; |
321 |
+ */ |
322 |
+ static unsigned long aperture_pfn_start, aperture_page_count; |
323 |
+ |
324 |
+-static int gart_oldmem_pfn_is_ram(unsigned long pfn) |
325 |
++static int gart_mem_pfn_is_ram(unsigned long pfn) |
326 |
+ { |
327 |
+ return likely((pfn < aperture_pfn_start) || |
328 |
+ (pfn >= aperture_pfn_start + aperture_page_count)); |
329 |
+ } |
330 |
+ |
331 |
+-static void exclude_from_vmcore(u64 aper_base, u32 aper_order) |
332 |
++static void __init exclude_from_core(u64 aper_base, u32 aper_order) |
333 |
+ { |
334 |
+ aperture_pfn_start = aper_base >> PAGE_SHIFT; |
335 |
+ aperture_page_count = (32 * 1024 * 1024) << aper_order >> PAGE_SHIFT; |
336 |
+- WARN_ON(register_oldmem_pfn_is_ram(&gart_oldmem_pfn_is_ram)); |
337 |
++#ifdef CONFIG_PROC_VMCORE |
338 |
++ WARN_ON(register_oldmem_pfn_is_ram(&gart_mem_pfn_is_ram)); |
339 |
++#endif |
340 |
++#ifdef CONFIG_PROC_KCORE |
341 |
++ WARN_ON(register_mem_pfn_is_ram(&gart_mem_pfn_is_ram)); |
342 |
++#endif |
343 |
+ } |
344 |
+ #else |
345 |
+-static void exclude_from_vmcore(u64 aper_base, u32 aper_order) |
346 |
++static void exclude_from_core(u64 aper_base, u32 aper_order) |
347 |
+ { |
348 |
+ } |
349 |
+ #endif |
350 |
+@@ -469,7 +475,7 @@ out: |
351 |
+ * may have allocated the range over its e820 RAM |
352 |
+ * and fixed up the northbridge |
353 |
+ */ |
354 |
+- exclude_from_vmcore(last_aper_base, last_aper_order); |
355 |
++ exclude_from_core(last_aper_base, last_aper_order); |
356 |
+ |
357 |
+ return 1; |
358 |
+ } |
359 |
+@@ -515,7 +521,7 @@ out: |
360 |
+ * overlap with the first kernel's memory. We can't access the |
361 |
+ * range through vmcore even though it should be part of the dump. |
362 |
+ */ |
363 |
+- exclude_from_vmcore(aper_alloc, aper_order); |
364 |
++ exclude_from_core(aper_alloc, aper_order); |
365 |
+ |
366 |
+ /* Fix up the north bridges */ |
367 |
+ for (i = 0; i < amd_nb_bus_dev_ranges[i].dev_limit; i++) { |
368 |
+diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c |
369 |
+index 8949b7ae6d92..fa61c870ada9 100644 |
370 |
+--- a/arch/x86/kernel/cpu/cyrix.c |
371 |
++++ b/arch/x86/kernel/cpu/cyrix.c |
372 |
+@@ -124,7 +124,7 @@ static void set_cx86_reorder(void) |
373 |
+ setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ |
374 |
+ |
375 |
+ /* Load/Store Serialize to mem access disable (=reorder it) */ |
376 |
+- setCx86_old(CX86_PCR0, getCx86_old(CX86_PCR0) & ~0x80); |
377 |
++ setCx86(CX86_PCR0, getCx86(CX86_PCR0) & ~0x80); |
378 |
+ /* set load/store serialize from 1GB to 4GB */ |
379 |
+ ccr3 |= 0xe0; |
380 |
+ setCx86(CX86_CCR3, ccr3); |
381 |
+@@ -135,11 +135,11 @@ static void set_cx86_memwb(void) |
382 |
+ pr_info("Enable Memory-Write-back mode on Cyrix/NSC processor.\n"); |
383 |
+ |
384 |
+ /* CCR2 bit 2: unlock NW bit */ |
385 |
+- setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) & ~0x04); |
386 |
++ setCx86(CX86_CCR2, getCx86(CX86_CCR2) & ~0x04); |
387 |
+ /* set 'Not Write-through' */ |
388 |
+ write_cr0(read_cr0() | X86_CR0_NW); |
389 |
+ /* CCR2 bit 2: lock NW bit and set WT1 */ |
390 |
+- setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) | 0x14); |
391 |
++ setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x14); |
392 |
+ } |
393 |
+ |
394 |
+ /* |
395 |
+@@ -153,14 +153,14 @@ static void geode_configure(void) |
396 |
+ local_irq_save(flags); |
397 |
+ |
398 |
+ /* Suspend on halt power saving and enable #SUSP pin */ |
399 |
+- setCx86_old(CX86_CCR2, getCx86_old(CX86_CCR2) | 0x88); |
400 |
++ setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88); |
401 |
+ |
402 |
+ ccr3 = getCx86(CX86_CCR3); |
403 |
+ setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ |
404 |
+ |
405 |
+ |
406 |
+ /* FPU fast, DTE cache, Mem bypass */ |
407 |
+- setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x38); |
408 |
++ setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x38); |
409 |
+ setCx86(CX86_CCR3, ccr3); /* disable MAPEN */ |
410 |
+ |
411 |
+ set_cx86_memwb(); |
412 |
+@@ -296,7 +296,7 @@ static void init_cyrix(struct cpuinfo_x86 *c) |
413 |
+ /* GXm supports extended cpuid levels 'ala' AMD */ |
414 |
+ if (c->cpuid_level == 2) { |
415 |
+ /* Enable cxMMX extensions (GX1 Datasheet 54) */ |
416 |
+- setCx86_old(CX86_CCR7, getCx86_old(CX86_CCR7) | 1); |
417 |
++ setCx86(CX86_CCR7, getCx86(CX86_CCR7) | 1); |
418 |
+ |
419 |
+ /* |
420 |
+ * GXm : 0x30 ... 0x5f GXm datasheet 51 |
421 |
+@@ -319,7 +319,7 @@ static void init_cyrix(struct cpuinfo_x86 *c) |
422 |
+ if (dir1 > 7) { |
423 |
+ dir0_msn++; /* M II */ |
424 |
+ /* Enable MMX extensions (App note 108) */ |
425 |
+- setCx86_old(CX86_CCR7, getCx86_old(CX86_CCR7)|1); |
426 |
++ setCx86(CX86_CCR7, getCx86(CX86_CCR7)|1); |
427 |
+ } else { |
428 |
+ /* A 6x86MX - it has the bug. */ |
429 |
+ set_cpu_bug(c, X86_BUG_COMA); |
430 |
+diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c |
431 |
+index b0acb22e5a46..1e3f1f140ffb 100644 |
432 |
+--- a/arch/x86/kernel/hpet.c |
433 |
++++ b/arch/x86/kernel/hpet.c |
434 |
+@@ -909,6 +909,8 @@ int __init hpet_enable(void) |
435 |
+ return 0; |
436 |
+ |
437 |
+ hpet_set_mapping(); |
438 |
++ if (!hpet_virt_address) |
439 |
++ return 0; |
440 |
+ |
441 |
+ /* |
442 |
+ * Read the period and check for a sane value: |
443 |
+diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c |
444 |
+index 34a5c1715148..2882fe1d2a78 100644 |
445 |
+--- a/arch/x86/kernel/hw_breakpoint.c |
446 |
++++ b/arch/x86/kernel/hw_breakpoint.c |
447 |
+@@ -357,6 +357,7 @@ int hw_breakpoint_arch_parse(struct perf_event *bp, |
448 |
+ #endif |
449 |
+ default: |
450 |
+ WARN_ON_ONCE(1); |
451 |
++ return -EINVAL; |
452 |
+ } |
453 |
+ |
454 |
+ /* |
455 |
+diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c |
456 |
+index f1c5eb99d445..ddb1ca6923b1 100644 |
457 |
+--- a/arch/x86/kernel/mpparse.c |
458 |
++++ b/arch/x86/kernel/mpparse.c |
459 |
+@@ -599,8 +599,8 @@ static int __init smp_scan_config(unsigned long base, unsigned long length) |
460 |
+ mpf_base = base; |
461 |
+ mpf_found = true; |
462 |
+ |
463 |
+- pr_info("found SMP MP-table at [mem %#010lx-%#010lx] mapped at [%p]\n", |
464 |
+- base, base + sizeof(*mpf) - 1, mpf); |
465 |
++ pr_info("found SMP MP-table at [mem %#010lx-%#010lx]\n", |
466 |
++ base, base + sizeof(*mpf) - 1); |
467 |
+ |
468 |
+ memblock_reserve(base, sizeof(*mpf)); |
469 |
+ if (mpf->physptr) |
470 |
+diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c |
471 |
+index 6b6bcafd1d2c..3380a312d186 100644 |
472 |
+--- a/arch/x86/kvm/vmx.c |
473 |
++++ b/arch/x86/kvm/vmx.c |
474 |
+@@ -13181,24 +13181,6 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, |
475 |
+ kvm_clear_interrupt_queue(vcpu); |
476 |
+ } |
477 |
+ |
478 |
+-static void load_vmcs12_mmu_host_state(struct kvm_vcpu *vcpu, |
479 |
+- struct vmcs12 *vmcs12) |
480 |
+-{ |
481 |
+- u32 entry_failure_code; |
482 |
+- |
483 |
+- nested_ept_uninit_mmu_context(vcpu); |
484 |
+- |
485 |
+- /* |
486 |
+- * Only PDPTE load can fail as the value of cr3 was checked on entry and |
487 |
+- * couldn't have changed. |
488 |
+- */ |
489 |
+- if (nested_vmx_load_cr3(vcpu, vmcs12->host_cr3, false, &entry_failure_code)) |
490 |
+- nested_vmx_abort(vcpu, VMX_ABORT_LOAD_HOST_PDPTE_FAIL); |
491 |
+- |
492 |
+- if (!enable_ept) |
493 |
+- vcpu->arch.walk_mmu->inject_page_fault = kvm_inject_page_fault; |
494 |
+-} |
495 |
+- |
496 |
+ /* |
497 |
+ * A part of what we need to when the nested L2 guest exits and we want to |
498 |
+ * run its L1 parent, is to reset L1's guest state to the host state specified |
499 |
+@@ -13212,6 +13194,7 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, |
500 |
+ struct vmcs12 *vmcs12) |
501 |
+ { |
502 |
+ struct kvm_segment seg; |
503 |
++ u32 entry_failure_code; |
504 |
+ |
505 |
+ if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER) |
506 |
+ vcpu->arch.efer = vmcs12->host_ia32_efer; |
507 |
+@@ -13238,7 +13221,17 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, |
508 |
+ vcpu->arch.cr4_guest_owned_bits = ~vmcs_readl(CR4_GUEST_HOST_MASK); |
509 |
+ vmx_set_cr4(vcpu, vmcs12->host_cr4); |
510 |
+ |
511 |
+- load_vmcs12_mmu_host_state(vcpu, vmcs12); |
512 |
++ nested_ept_uninit_mmu_context(vcpu); |
513 |
++ |
514 |
++ /* |
515 |
++ * Only PDPTE load can fail as the value of cr3 was checked on entry and |
516 |
++ * couldn't have changed. |
517 |
++ */ |
518 |
++ if (nested_vmx_load_cr3(vcpu, vmcs12->host_cr3, false, &entry_failure_code)) |
519 |
++ nested_vmx_abort(vcpu, VMX_ABORT_LOAD_HOST_PDPTE_FAIL); |
520 |
++ |
521 |
++ if (!enable_ept) |
522 |
++ vcpu->arch.walk_mmu->inject_page_fault = kvm_inject_page_fault; |
523 |
+ |
524 |
+ /* |
525 |
+ * If vmcs01 don't use VPID, CPU flushes TLB on every |
526 |
+@@ -13334,6 +13327,140 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, |
527 |
+ nested_vmx_abort(vcpu, VMX_ABORT_LOAD_HOST_MSR_FAIL); |
528 |
+ } |
529 |
+ |
530 |
++static inline u64 nested_vmx_get_vmcs01_guest_efer(struct vcpu_vmx *vmx) |
531 |
++{ |
532 |
++ struct shared_msr_entry *efer_msr; |
533 |
++ unsigned int i; |
534 |
++ |
535 |
++ if (vm_entry_controls_get(vmx) & VM_ENTRY_LOAD_IA32_EFER) |
536 |
++ return vmcs_read64(GUEST_IA32_EFER); |
537 |
++ |
538 |
++ if (cpu_has_load_ia32_efer) |
539 |
++ return host_efer; |
540 |
++ |
541 |
++ for (i = 0; i < vmx->msr_autoload.guest.nr; ++i) { |
542 |
++ if (vmx->msr_autoload.guest.val[i].index == MSR_EFER) |
543 |
++ return vmx->msr_autoload.guest.val[i].value; |
544 |
++ } |
545 |
++ |
546 |
++ efer_msr = find_msr_entry(vmx, MSR_EFER); |
547 |
++ if (efer_msr) |
548 |
++ return efer_msr->data; |
549 |
++ |
550 |
++ return host_efer; |
551 |
++} |
552 |
++ |
553 |
++static void nested_vmx_restore_host_state(struct kvm_vcpu *vcpu) |
554 |
++{ |
555 |
++ struct vmcs12 *vmcs12 = get_vmcs12(vcpu); |
556 |
++ struct vcpu_vmx *vmx = to_vmx(vcpu); |
557 |
++ struct vmx_msr_entry g, h; |
558 |
++ struct msr_data msr; |
559 |
++ gpa_t gpa; |
560 |
++ u32 i, j; |
561 |
++ |
562 |
++ vcpu->arch.pat = vmcs_read64(GUEST_IA32_PAT); |
563 |
++ |
564 |
++ if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS) { |
565 |
++ /* |
566 |
++ * L1's host DR7 is lost if KVM_GUESTDBG_USE_HW_BP is set |
567 |
++ * as vmcs01.GUEST_DR7 contains a userspace defined value |
568 |
++ * and vcpu->arch.dr7 is not squirreled away before the |
569 |
++ * nested VMENTER (not worth adding a variable in nested_vmx). |
570 |
++ */ |
571 |
++ if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) |
572 |
++ kvm_set_dr(vcpu, 7, DR7_FIXED_1); |
573 |
++ else |
574 |
++ WARN_ON(kvm_set_dr(vcpu, 7, vmcs_readl(GUEST_DR7))); |
575 |
++ } |
576 |
++ |
577 |
++ /* |
578 |
++ * Note that calling vmx_set_{efer,cr0,cr4} is important as they |
579 |
++ * handle a variety of side effects to KVM's software model. |
580 |
++ */ |
581 |
++ vmx_set_efer(vcpu, nested_vmx_get_vmcs01_guest_efer(vmx)); |
582 |
++ |
583 |
++ vcpu->arch.cr0_guest_owned_bits = X86_CR0_TS; |
584 |
++ vmx_set_cr0(vcpu, vmcs_readl(CR0_READ_SHADOW)); |
585 |
++ |
586 |
++ vcpu->arch.cr4_guest_owned_bits = ~vmcs_readl(CR4_GUEST_HOST_MASK); |
587 |
++ vmx_set_cr4(vcpu, vmcs_readl(CR4_READ_SHADOW)); |
588 |
++ |
589 |
++ nested_ept_uninit_mmu_context(vcpu); |
590 |
++ vcpu->arch.cr3 = vmcs_readl(GUEST_CR3); |
591 |
++ __set_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail); |
592 |
++ |
593 |
++ /* |
594 |
++ * Use ept_save_pdptrs(vcpu) to load the MMU's cached PDPTRs |
595 |
++ * from vmcs01 (if necessary). The PDPTRs are not loaded on |
596 |
++ * VMFail, like everything else we just need to ensure our |
597 |
++ * software model is up-to-date. |
598 |
++ */ |
599 |
++ ept_save_pdptrs(vcpu); |
600 |
++ |
601 |
++ kvm_mmu_reset_context(vcpu); |
602 |
++ |
603 |
++ if (cpu_has_vmx_msr_bitmap()) |
604 |
++ vmx_update_msr_bitmap(vcpu); |
605 |
++ |
606 |
++ /* |
607 |
++ * This nasty bit of open coding is a compromise between blindly |
608 |
++ * loading L1's MSRs using the exit load lists (incorrect emulation |
609 |
++ * of VMFail), leaving the nested VM's MSRs in the software model |
610 |
++ * (incorrect behavior) and snapshotting the modified MSRs (too |
611 |
++ * expensive since the lists are unbound by hardware). For each |
612 |
++ * MSR that was (prematurely) loaded from the nested VMEntry load |
613 |
++ * list, reload it from the exit load list if it exists and differs |
614 |
++ * from the guest value. The intent is to stuff host state as |
615 |
++ * silently as possible, not to fully process the exit load list. |
616 |
++ */ |
617 |
++ msr.host_initiated = false; |
618 |
++ for (i = 0; i < vmcs12->vm_entry_msr_load_count; i++) { |
619 |
++ gpa = vmcs12->vm_entry_msr_load_addr + (i * sizeof(g)); |
620 |
++ if (kvm_vcpu_read_guest(vcpu, gpa, &g, sizeof(g))) { |
621 |
++ pr_debug_ratelimited( |
622 |
++ "%s read MSR index failed (%u, 0x%08llx)\n", |
623 |
++ __func__, i, gpa); |
624 |
++ goto vmabort; |
625 |
++ } |
626 |
++ |
627 |
++ for (j = 0; j < vmcs12->vm_exit_msr_load_count; j++) { |
628 |
++ gpa = vmcs12->vm_exit_msr_load_addr + (j * sizeof(h)); |
629 |
++ if (kvm_vcpu_read_guest(vcpu, gpa, &h, sizeof(h))) { |
630 |
++ pr_debug_ratelimited( |
631 |
++ "%s read MSR failed (%u, 0x%08llx)\n", |
632 |
++ __func__, j, gpa); |
633 |
++ goto vmabort; |
634 |
++ } |
635 |
++ if (h.index != g.index) |
636 |
++ continue; |
637 |
++ if (h.value == g.value) |
638 |
++ break; |
639 |
++ |
640 |
++ if (nested_vmx_load_msr_check(vcpu, &h)) { |
641 |
++ pr_debug_ratelimited( |
642 |
++ "%s check failed (%u, 0x%x, 0x%x)\n", |
643 |
++ __func__, j, h.index, h.reserved); |
644 |
++ goto vmabort; |
645 |
++ } |
646 |
++ |
647 |
++ msr.index = h.index; |
648 |
++ msr.data = h.value; |
649 |
++ if (kvm_set_msr(vcpu, &msr)) { |
650 |
++ pr_debug_ratelimited( |
651 |
++ "%s WRMSR failed (%u, 0x%x, 0x%llx)\n", |
652 |
++ __func__, j, h.index, h.value); |
653 |
++ goto vmabort; |
654 |
++ } |
655 |
++ } |
656 |
++ } |
657 |
++ |
658 |
++ return; |
659 |
++ |
660 |
++vmabort: |
661 |
++ nested_vmx_abort(vcpu, VMX_ABORT_LOAD_HOST_MSR_FAIL); |
662 |
++} |
663 |
++ |
664 |
+ /* |
665 |
+ * Emulate an exit from nested guest (L2) to L1, i.e., prepare to run L1 |
666 |
+ * and modify vmcs12 to make it see what it would expect to see there if |
667 |
+@@ -13478,7 +13605,13 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, |
668 |
+ */ |
669 |
+ nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD); |
670 |
+ |
671 |
+- load_vmcs12_mmu_host_state(vcpu, vmcs12); |
672 |
++ /* |
673 |
++ * Restore L1's host state to KVM's software model. We're here |
674 |
++ * because a consistency check was caught by hardware, which |
675 |
++ * means some amount of guest state has been propagated to KVM's |
676 |
++ * model and needs to be unwound to the host's state. |
677 |
++ */ |
678 |
++ nested_vmx_restore_host_state(vcpu); |
679 |
+ |
680 |
+ /* |
681 |
+ * The emulated instruction was already skipped in |
682 |
+diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c |
683 |
+index b154e057ca67..6b8396ccb5c4 100644 |
684 |
+--- a/block/blk-iolatency.c |
685 |
++++ b/block/blk-iolatency.c |
686 |
+@@ -75,6 +75,7 @@ |
687 |
+ #include <linux/blk-mq.h> |
688 |
+ #include "blk-rq-qos.h" |
689 |
+ #include "blk-stat.h" |
690 |
++#include "blk.h" |
691 |
+ |
692 |
+ #define DEFAULT_SCALE_COOKIE 1000000U |
693 |
+ |
694 |
+diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c |
695 |
+index d4e5610e09c5..49e16f009095 100644 |
696 |
+--- a/drivers/acpi/ec.c |
697 |
++++ b/drivers/acpi/ec.c |
698 |
+@@ -194,6 +194,7 @@ static struct workqueue_struct *ec_query_wq; |
699 |
+ static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ |
700 |
+ static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address correction */ |
701 |
+ static int EC_FLAGS_IGNORE_DSDT_GPE; /* Needs ECDT GPE as correction setting */ |
702 |
++static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ |
703 |
+ |
704 |
+ /* -------------------------------------------------------------------------- |
705 |
+ * Logging/Debugging |
706 |
+@@ -499,6 +500,26 @@ static inline void __acpi_ec_disable_event(struct acpi_ec *ec) |
707 |
+ ec_log_drv("event blocked"); |
708 |
+ } |
709 |
+ |
710 |
++/* |
711 |
++ * Process _Q events that might have accumulated in the EC. |
712 |
++ * Run with locked ec mutex. |
713 |
++ */ |
714 |
++static void acpi_ec_clear(struct acpi_ec *ec) |
715 |
++{ |
716 |
++ int i, status; |
717 |
++ u8 value = 0; |
718 |
++ |
719 |
++ for (i = 0; i < ACPI_EC_CLEAR_MAX; i++) { |
720 |
++ status = acpi_ec_query(ec, &value); |
721 |
++ if (status || !value) |
722 |
++ break; |
723 |
++ } |
724 |
++ if (unlikely(i == ACPI_EC_CLEAR_MAX)) |
725 |
++ pr_warn("Warning: Maximum of %d stale EC events cleared\n", i); |
726 |
++ else |
727 |
++ pr_info("%d stale EC events cleared\n", i); |
728 |
++} |
729 |
++ |
730 |
+ static void acpi_ec_enable_event(struct acpi_ec *ec) |
731 |
+ { |
732 |
+ unsigned long flags; |
733 |
+@@ -507,6 +528,10 @@ static void acpi_ec_enable_event(struct acpi_ec *ec) |
734 |
+ if (acpi_ec_started(ec)) |
735 |
+ __acpi_ec_enable_event(ec); |
736 |
+ spin_unlock_irqrestore(&ec->lock, flags); |
737 |
++ |
738 |
++ /* Drain additional events if hardware requires that */ |
739 |
++ if (EC_FLAGS_CLEAR_ON_RESUME) |
740 |
++ acpi_ec_clear(ec); |
741 |
+ } |
742 |
+ |
743 |
+ #ifdef CONFIG_PM_SLEEP |
744 |
+@@ -1034,6 +1059,18 @@ void acpi_ec_unblock_transactions(void) |
745 |
+ acpi_ec_start(first_ec, true); |
746 |
+ } |
747 |
+ |
748 |
++void acpi_ec_mark_gpe_for_wake(void) |
749 |
++{ |
750 |
++ if (first_ec && !ec_no_wakeup) |
751 |
++ acpi_mark_gpe_for_wake(NULL, first_ec->gpe); |
752 |
++} |
753 |
++ |
754 |
++void acpi_ec_set_gpe_wake_mask(u8 action) |
755 |
++{ |
756 |
++ if (first_ec && !ec_no_wakeup) |
757 |
++ acpi_set_gpe_wake_mask(NULL, first_ec->gpe, action); |
758 |
++} |
759 |
++ |
760 |
+ void acpi_ec_dispatch_gpe(void) |
761 |
+ { |
762 |
+ if (first_ec) |
763 |
+@@ -1808,6 +1845,31 @@ static int ec_flag_query_handshake(const struct dmi_system_id *id) |
764 |
+ } |
765 |
+ #endif |
766 |
+ |
767 |
++/* |
768 |
++ * On some hardware it is necessary to clear events accumulated by the EC during |
769 |
++ * sleep. These ECs stop reporting GPEs until they are manually polled, if too |
770 |
++ * many events are accumulated. (e.g. Samsung Series 5/9 notebooks) |
771 |
++ * |
772 |
++ * https://bugzilla.kernel.org/show_bug.cgi?id=44161 |
773 |
++ * |
774 |
++ * Ideally, the EC should also be instructed NOT to accumulate events during |
775 |
++ * sleep (which Windows seems to do somehow), but the interface to control this |
776 |
++ * behaviour is not known at this time. |
777 |
++ * |
778 |
++ * Models known to be affected are Samsung 530Uxx/535Uxx/540Uxx/550Pxx/900Xxx, |
779 |
++ * however it is very likely that other Samsung models are affected. |
780 |
++ * |
781 |
++ * On systems which don't accumulate _Q events during sleep, this extra check |
782 |
++ * should be harmless. |
783 |
++ */ |
784 |
++static int ec_clear_on_resume(const struct dmi_system_id *id) |
785 |
++{ |
786 |
++ pr_debug("Detected system needing EC poll on resume.\n"); |
787 |
++ EC_FLAGS_CLEAR_ON_RESUME = 1; |
788 |
++ ec_event_clearing = ACPI_EC_EVT_TIMING_STATUS; |
789 |
++ return 0; |
790 |
++} |
791 |
++ |
792 |
+ /* |
793 |
+ * Some ECDTs contain wrong register addresses. |
794 |
+ * MSI MS-171F |
795 |
+@@ -1857,6 +1919,9 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { |
796 |
+ ec_honor_ecdt_gpe, "ASUS X580VD", { |
797 |
+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
798 |
+ DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL}, |
799 |
++ { |
800 |
++ ec_clear_on_resume, "Samsung hardware", { |
801 |
++ DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL}, |
802 |
+ {}, |
803 |
+ }; |
804 |
+ |
805 |
+diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h |
806 |
+index 530a3f675490..f59d0b9e2683 100644 |
807 |
+--- a/drivers/acpi/internal.h |
808 |
++++ b/drivers/acpi/internal.h |
809 |
+@@ -188,6 +188,8 @@ int acpi_ec_ecdt_probe(void); |
810 |
+ int acpi_ec_dsdt_probe(void); |
811 |
+ void acpi_ec_block_transactions(void); |
812 |
+ void acpi_ec_unblock_transactions(void); |
813 |
++void acpi_ec_mark_gpe_for_wake(void); |
814 |
++void acpi_ec_set_gpe_wake_mask(u8 action); |
815 |
+ void acpi_ec_dispatch_gpe(void); |
816 |
+ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, |
817 |
+ acpi_handle handle, acpi_ec_query_func func, |
818 |
+diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c |
819 |
+index 295b59271189..96c5e27967f4 100644 |
820 |
+--- a/drivers/acpi/sbs.c |
821 |
++++ b/drivers/acpi/sbs.c |
822 |
+@@ -441,9 +441,13 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs) |
823 |
+ |
824 |
+ /* |
825 |
+ * The spec requires that bit 4 always be 1. If it's not set, assume |
826 |
+- * that the implementation doesn't support an SBS charger |
827 |
++ * that the implementation doesn't support an SBS charger. |
828 |
++ * |
829 |
++ * And on some MacBooks a status of 0xffff is always returned, no |
830 |
++ * matter whether the charger is plugged in or not, which is also |
831 |
++ * wrong, so ignore the SBS charger for those too. |
832 |
+ */ |
833 |
+- if (!((status >> 4) & 0x1)) |
834 |
++ if (!((status >> 4) & 0x1) || status == 0xffff) |
835 |
+ return -ENODEV; |
836 |
+ |
837 |
+ sbs->charger_present = (status >> 15) & 0x1; |
838 |
+diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c |
839 |
+index 754d59f95500..74c489047f57 100644 |
840 |
+--- a/drivers/acpi/sleep.c |
841 |
++++ b/drivers/acpi/sleep.c |
842 |
+@@ -940,6 +940,8 @@ static int lps0_device_attach(struct acpi_device *adev, |
843 |
+ |
844 |
+ acpi_handle_debug(adev->handle, "_DSM function mask: 0x%x\n", |
845 |
+ bitmask); |
846 |
++ |
847 |
++ acpi_ec_mark_gpe_for_wake(); |
848 |
+ } else { |
849 |
+ acpi_handle_debug(adev->handle, |
850 |
+ "_DSM function 0 evaluation failed\n"); |
851 |
+@@ -968,11 +970,16 @@ static int acpi_s2idle_prepare(void) |
852 |
+ if (lps0_device_handle) { |
853 |
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF); |
854 |
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY); |
855 |
++ |
856 |
++ acpi_ec_set_gpe_wake_mask(ACPI_GPE_ENABLE); |
857 |
+ } |
858 |
+ |
859 |
+ if (acpi_sci_irq_valid()) |
860 |
+ enable_irq_wake(acpi_sci_irq); |
861 |
+ |
862 |
++ /* Change the configuration of GPEs to avoid spurious wakeup. */ |
863 |
++ acpi_enable_all_wakeup_gpes(); |
864 |
++ acpi_os_wait_events_complete(); |
865 |
+ return 0; |
866 |
+ } |
867 |
+ |
868 |
+@@ -1017,10 +1024,14 @@ static void acpi_s2idle_sync(void) |
869 |
+ |
870 |
+ static void acpi_s2idle_restore(void) |
871 |
+ { |
872 |
++ acpi_enable_all_runtime_gpes(); |
873 |
++ |
874 |
+ if (acpi_sci_irq_valid()) |
875 |
+ disable_irq_wake(acpi_sci_irq); |
876 |
+ |
877 |
+ if (lps0_device_handle) { |
878 |
++ acpi_ec_set_gpe_wake_mask(ACPI_GPE_DISABLE); |
879 |
++ |
880 |
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT); |
881 |
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON); |
882 |
+ } |
883 |
+diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c |
884 |
+index 78db97687f26..c4b06cc075f9 100644 |
885 |
+--- a/drivers/acpi/utils.c |
886 |
++++ b/drivers/acpi/utils.c |
887 |
+@@ -800,6 +800,7 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) |
888 |
+ match.hrv = hrv; |
889 |
+ |
890 |
+ dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb); |
891 |
++ put_device(dev); |
892 |
+ return !!dev; |
893 |
+ } |
894 |
+ EXPORT_SYMBOL(acpi_dev_present); |
895 |
+diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c |
896 |
+index f1a42f0f1ded..df3da49ff9e8 100644 |
897 |
+--- a/drivers/auxdisplay/hd44780.c |
898 |
++++ b/drivers/auxdisplay/hd44780.c |
899 |
+@@ -299,6 +299,8 @@ static int hd44780_remove(struct platform_device *pdev) |
900 |
+ struct charlcd *lcd = platform_get_drvdata(pdev); |
901 |
+ |
902 |
+ charlcd_unregister(lcd); |
903 |
++ |
904 |
++ kfree(lcd); |
905 |
+ return 0; |
906 |
+ } |
907 |
+ |
908 |
+diff --git a/drivers/base/node.c b/drivers/base/node.c |
909 |
+index 1ac4c36e13bb..c3968e2d0a98 100644 |
910 |
+--- a/drivers/base/node.c |
911 |
++++ b/drivers/base/node.c |
912 |
+@@ -197,11 +197,16 @@ static ssize_t node_read_vmstat(struct device *dev, |
913 |
+ sum_zone_numa_state(nid, i)); |
914 |
+ #endif |
915 |
+ |
916 |
+- for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) |
917 |
++ for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) { |
918 |
++ /* Skip hidden vmstat items. */ |
919 |
++ if (*vmstat_text[i + NR_VM_ZONE_STAT_ITEMS + |
920 |
++ NR_VM_NUMA_STAT_ITEMS] == '\0') |
921 |
++ continue; |
922 |
+ n += sprintf(buf+n, "%s %lu\n", |
923 |
+ vmstat_text[i + NR_VM_ZONE_STAT_ITEMS + |
924 |
+ NR_VM_NUMA_STAT_ITEMS], |
925 |
+ node_page_state(pgdat, i)); |
926 |
++ } |
927 |
+ |
928 |
+ return n; |
929 |
+ } |
930 |
+diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c |
931 |
+index 4b5714199490..bf5be0bfaf77 100644 |
932 |
+--- a/drivers/base/power/domain.c |
933 |
++++ b/drivers/base/power/domain.c |
934 |
+@@ -1388,12 +1388,12 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, |
935 |
+ if (IS_ERR(gpd_data)) |
936 |
+ return PTR_ERR(gpd_data); |
937 |
+ |
938 |
+- genpd_lock(genpd); |
939 |
+- |
940 |
+ ret = genpd->attach_dev ? genpd->attach_dev(genpd, dev) : 0; |
941 |
+ if (ret) |
942 |
+ goto out; |
943 |
+ |
944 |
++ genpd_lock(genpd); |
945 |
++ |
946 |
+ dev_pm_domain_set(dev, &genpd->domain); |
947 |
+ |
948 |
+ genpd->device_count++; |
949 |
+@@ -1401,9 +1401,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, |
950 |
+ |
951 |
+ list_add_tail(&gpd_data->base.list_node, &genpd->dev_list); |
952 |
+ |
953 |
+- out: |
954 |
+ genpd_unlock(genpd); |
955 |
+- |
956 |
++ out: |
957 |
+ if (ret) |
958 |
+ genpd_free_dev_data(dev, gpd_data); |
959 |
+ else |
960 |
+@@ -1452,15 +1451,15 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, |
961 |
+ genpd->device_count--; |
962 |
+ genpd->max_off_time_changed = true; |
963 |
+ |
964 |
+- if (genpd->detach_dev) |
965 |
+- genpd->detach_dev(genpd, dev); |
966 |
+- |
967 |
+ dev_pm_domain_set(dev, NULL); |
968 |
+ |
969 |
+ list_del_init(&pdd->list_node); |
970 |
+ |
971 |
+ genpd_unlock(genpd); |
972 |
+ |
973 |
++ if (genpd->detach_dev) |
974 |
++ genpd->detach_dev(genpd, dev); |
975 |
++ |
976 |
+ genpd_free_dev_data(dev, gpd_data); |
977 |
+ |
978 |
+ return 0; |
979 |
+diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c |
980 |
+index 7f07a5085e9b..fdcdc751d03b 100644 |
981 |
+--- a/drivers/crypto/axis/artpec6_crypto.c |
982 |
++++ b/drivers/crypto/axis/artpec6_crypto.c |
983 |
+@@ -284,6 +284,7 @@ enum artpec6_crypto_hash_flags { |
984 |
+ |
985 |
+ struct artpec6_crypto_req_common { |
986 |
+ struct list_head list; |
987 |
++ struct list_head complete_in_progress; |
988 |
+ struct artpec6_crypto_dma_descriptors *dma; |
989 |
+ struct crypto_async_request *req; |
990 |
+ void (*complete)(struct crypto_async_request *req); |
991 |
+@@ -2046,7 +2047,8 @@ static int artpec6_crypto_prepare_aead(struct aead_request *areq) |
992 |
+ return artpec6_crypto_dma_map_descs(common); |
993 |
+ } |
994 |
+ |
995 |
+-static void artpec6_crypto_process_queue(struct artpec6_crypto *ac) |
996 |
++static void artpec6_crypto_process_queue(struct artpec6_crypto *ac, |
997 |
++ struct list_head *completions) |
998 |
+ { |
999 |
+ struct artpec6_crypto_req_common *req; |
1000 |
+ |
1001 |
+@@ -2057,7 +2059,7 @@ static void artpec6_crypto_process_queue(struct artpec6_crypto *ac) |
1002 |
+ list_move_tail(&req->list, &ac->pending); |
1003 |
+ artpec6_crypto_start_dma(req); |
1004 |
+ |
1005 |
+- req->req->complete(req->req, -EINPROGRESS); |
1006 |
++ list_add_tail(&req->complete_in_progress, completions); |
1007 |
+ } |
1008 |
+ |
1009 |
+ /* |
1010 |
+@@ -2087,6 +2089,11 @@ static void artpec6_crypto_task(unsigned long data) |
1011 |
+ struct artpec6_crypto *ac = (struct artpec6_crypto *)data; |
1012 |
+ struct artpec6_crypto_req_common *req; |
1013 |
+ struct artpec6_crypto_req_common *n; |
1014 |
++ struct list_head complete_done; |
1015 |
++ struct list_head complete_in_progress; |
1016 |
++ |
1017 |
++ INIT_LIST_HEAD(&complete_done); |
1018 |
++ INIT_LIST_HEAD(&complete_in_progress); |
1019 |
+ |
1020 |
+ if (list_empty(&ac->pending)) { |
1021 |
+ pr_debug("Spurious IRQ\n"); |
1022 |
+@@ -2120,19 +2127,30 @@ static void artpec6_crypto_task(unsigned long data) |
1023 |
+ |
1024 |
+ pr_debug("Completing request %p\n", req); |
1025 |
+ |
1026 |
+- list_del(&req->list); |
1027 |
++ list_move_tail(&req->list, &complete_done); |
1028 |
+ |
1029 |
+ artpec6_crypto_dma_unmap_all(req); |
1030 |
+ artpec6_crypto_copy_bounce_buffers(req); |
1031 |
+ |
1032 |
+ ac->pending_count--; |
1033 |
+ artpec6_crypto_common_destroy(req); |
1034 |
+- req->complete(req->req); |
1035 |
+ } |
1036 |
+ |
1037 |
+- artpec6_crypto_process_queue(ac); |
1038 |
++ artpec6_crypto_process_queue(ac, &complete_in_progress); |
1039 |
+ |
1040 |
+ spin_unlock_bh(&ac->queue_lock); |
1041 |
++ |
1042 |
++ /* Perform the completion callbacks without holding the queue lock |
1043 |
++ * to allow new request submissions from the callbacks. |
1044 |
++ */ |
1045 |
++ list_for_each_entry_safe(req, n, &complete_done, list) { |
1046 |
++ req->complete(req->req); |
1047 |
++ } |
1048 |
++ |
1049 |
++ list_for_each_entry_safe(req, n, &complete_in_progress, |
1050 |
++ complete_in_progress) { |
1051 |
++ req->req->complete(req->req, -EINPROGRESS); |
1052 |
++ } |
1053 |
+ } |
1054 |
+ |
1055 |
+ static void artpec6_crypto_complete_crypto(struct crypto_async_request *req) |
1056 |
+diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c |
1057 |
+index eb27fa76e8fc..bcc6be4a5cb2 100644 |
1058 |
+--- a/drivers/gpio/gpio-pxa.c |
1059 |
++++ b/drivers/gpio/gpio-pxa.c |
1060 |
+@@ -777,6 +777,9 @@ static int pxa_gpio_suspend(void) |
1061 |
+ struct pxa_gpio_bank *c; |
1062 |
+ int gpio; |
1063 |
+ |
1064 |
++ if (!pchip) |
1065 |
++ return 0; |
1066 |
++ |
1067 |
+ for_each_gpio_bank(gpio, c, pchip) { |
1068 |
+ c->saved_gplr = readl_relaxed(c->regbase + GPLR_OFFSET); |
1069 |
+ c->saved_gpdr = readl_relaxed(c->regbase + GPDR_OFFSET); |
1070 |
+@@ -795,6 +798,9 @@ static void pxa_gpio_resume(void) |
1071 |
+ struct pxa_gpio_bank *c; |
1072 |
+ int gpio; |
1073 |
+ |
1074 |
++ if (!pchip) |
1075 |
++ return; |
1076 |
++ |
1077 |
+ for_each_gpio_bank(gpio, c, pchip) { |
1078 |
+ /* restore level with set/clear */ |
1079 |
+ writel_relaxed(c->saved_gplr, c->regbase + GPSR_OFFSET); |
1080 |
+diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c |
1081 |
+index 47243165a082..ae90a99909ef 100644 |
1082 |
+--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c |
1083 |
++++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c |
1084 |
+@@ -323,57 +323,7 @@ static int init_mqd_hiq(struct mqd_manager *mm, void **mqd, |
1085 |
+ struct kfd_mem_obj **mqd_mem_obj, uint64_t *gart_addr, |
1086 |
+ struct queue_properties *q) |
1087 |
+ { |
1088 |
+- uint64_t addr; |
1089 |
+- struct cik_mqd *m; |
1090 |
+- int retval; |
1091 |
+- |
1092 |
+- retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct cik_mqd), |
1093 |
+- mqd_mem_obj); |
1094 |
+- |
1095 |
+- if (retval != 0) |
1096 |
+- return -ENOMEM; |
1097 |
+- |
1098 |
+- m = (struct cik_mqd *) (*mqd_mem_obj)->cpu_ptr; |
1099 |
+- addr = (*mqd_mem_obj)->gpu_addr; |
1100 |
+- |
1101 |
+- memset(m, 0, ALIGN(sizeof(struct cik_mqd), 256)); |
1102 |
+- |
1103 |
+- m->header = 0xC0310800; |
1104 |
+- m->compute_pipelinestat_enable = 1; |
1105 |
+- m->compute_static_thread_mgmt_se0 = 0xFFFFFFFF; |
1106 |
+- m->compute_static_thread_mgmt_se1 = 0xFFFFFFFF; |
1107 |
+- m->compute_static_thread_mgmt_se2 = 0xFFFFFFFF; |
1108 |
+- m->compute_static_thread_mgmt_se3 = 0xFFFFFFFF; |
1109 |
+- |
1110 |
+- m->cp_hqd_persistent_state = DEFAULT_CP_HQD_PERSISTENT_STATE | |
1111 |
+- PRELOAD_REQ; |
1112 |
+- m->cp_hqd_quantum = QUANTUM_EN | QUANTUM_SCALE_1MS | |
1113 |
+- QUANTUM_DURATION(10); |
1114 |
+- |
1115 |
+- m->cp_mqd_control = MQD_CONTROL_PRIV_STATE_EN; |
1116 |
+- m->cp_mqd_base_addr_lo = lower_32_bits(addr); |
1117 |
+- m->cp_mqd_base_addr_hi = upper_32_bits(addr); |
1118 |
+- |
1119 |
+- m->cp_hqd_ib_control = DEFAULT_MIN_IB_AVAIL_SIZE; |
1120 |
+- |
1121 |
+- /* |
1122 |
+- * Pipe Priority |
1123 |
+- * Identifies the pipe relative priority when this queue is connected |
1124 |
+- * to the pipeline. The pipe priority is against the GFX pipe and HP3D. |
1125 |
+- * In KFD we are using a fixed pipe priority set to CS_MEDIUM. |
1126 |
+- * 0 = CS_LOW (typically below GFX) |
1127 |
+- * 1 = CS_MEDIUM (typically between HP3D and GFX |
1128 |
+- * 2 = CS_HIGH (typically above HP3D) |
1129 |
+- */ |
1130 |
+- m->cp_hqd_pipe_priority = 1; |
1131 |
+- m->cp_hqd_queue_priority = 15; |
1132 |
+- |
1133 |
+- *mqd = m; |
1134 |
+- if (gart_addr) |
1135 |
+- *gart_addr = addr; |
1136 |
+- retval = mm->update_mqd(mm, m, q); |
1137 |
+- |
1138 |
+- return retval; |
1139 |
++ return init_mqd(mm, mqd, mqd_mem_obj, gart_addr, q); |
1140 |
+ } |
1141 |
+ |
1142 |
+ static int update_mqd_hiq(struct mqd_manager *mm, void *mqd, |
1143 |
+diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h |
1144 |
+index ce9db7aab225..a29f87e98d9d 100644 |
1145 |
+--- a/drivers/gpu/drm/cirrus/cirrus_drv.h |
1146 |
++++ b/drivers/gpu/drm/cirrus/cirrus_drv.h |
1147 |
+@@ -146,7 +146,7 @@ struct cirrus_device { |
1148 |
+ |
1149 |
+ struct cirrus_fbdev { |
1150 |
+ struct drm_fb_helper helper; |
1151 |
+- struct drm_framebuffer gfb; |
1152 |
++ struct drm_framebuffer *gfb; |
1153 |
+ void *sysram; |
1154 |
+ int size; |
1155 |
+ int x1, y1, x2, y2; /* dirty rect */ |
1156 |
+diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c |
1157 |
+index b643ac92801c..82cc82e0bd80 100644 |
1158 |
+--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c |
1159 |
++++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c |
1160 |
+@@ -22,14 +22,14 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev, |
1161 |
+ struct drm_gem_object *obj; |
1162 |
+ struct cirrus_bo *bo; |
1163 |
+ int src_offset, dst_offset; |
1164 |
+- int bpp = afbdev->gfb.format->cpp[0]; |
1165 |
++ int bpp = afbdev->gfb->format->cpp[0]; |
1166 |
+ int ret = -EBUSY; |
1167 |
+ bool unmap = false; |
1168 |
+ bool store_for_later = false; |
1169 |
+ int x2, y2; |
1170 |
+ unsigned long flags; |
1171 |
+ |
1172 |
+- obj = afbdev->gfb.obj[0]; |
1173 |
++ obj = afbdev->gfb->obj[0]; |
1174 |
+ bo = gem_to_cirrus_bo(obj); |
1175 |
+ |
1176 |
+ /* |
1177 |
+@@ -82,7 +82,7 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev, |
1178 |
+ } |
1179 |
+ for (i = y; i < y + height; i++) { |
1180 |
+ /* assume equal stride for now */ |
1181 |
+- src_offset = dst_offset = i * afbdev->gfb.pitches[0] + (x * bpp); |
1182 |
++ src_offset = dst_offset = i * afbdev->gfb->pitches[0] + (x * bpp); |
1183 |
+ memcpy_toio(bo->kmap.virtual + src_offset, afbdev->sysram + src_offset, width * bpp); |
1184 |
+ |
1185 |
+ } |
1186 |
+@@ -192,23 +192,26 @@ static int cirrusfb_create(struct drm_fb_helper *helper, |
1187 |
+ return -ENOMEM; |
1188 |
+ |
1189 |
+ info = drm_fb_helper_alloc_fbi(helper); |
1190 |
+- if (IS_ERR(info)) |
1191 |
+- return PTR_ERR(info); |
1192 |
++ if (IS_ERR(info)) { |
1193 |
++ ret = PTR_ERR(info); |
1194 |
++ goto err_vfree; |
1195 |
++ } |
1196 |
+ |
1197 |
+ info->par = gfbdev; |
1198 |
+ |
1199 |
+- ret = cirrus_framebuffer_init(cdev->dev, &gfbdev->gfb, &mode_cmd, gobj); |
1200 |
++ fb = kzalloc(sizeof(*fb), GFP_KERNEL); |
1201 |
++ if (!fb) { |
1202 |
++ ret = -ENOMEM; |
1203 |
++ goto err_drm_gem_object_put_unlocked; |
1204 |
++ } |
1205 |
++ |
1206 |
++ ret = cirrus_framebuffer_init(cdev->dev, fb, &mode_cmd, gobj); |
1207 |
+ if (ret) |
1208 |
+- return ret; |
1209 |
++ goto err_kfree; |
1210 |
+ |
1211 |
+ gfbdev->sysram = sysram; |
1212 |
+ gfbdev->size = size; |
1213 |
+- |
1214 |
+- fb = &gfbdev->gfb; |
1215 |
+- if (!fb) { |
1216 |
+- DRM_INFO("fb is NULL\n"); |
1217 |
+- return -EINVAL; |
1218 |
+- } |
1219 |
++ gfbdev->gfb = fb; |
1220 |
+ |
1221 |
+ /* setup helper */ |
1222 |
+ gfbdev->helper.fb = fb; |
1223 |
+@@ -241,24 +244,27 @@ static int cirrusfb_create(struct drm_fb_helper *helper, |
1224 |
+ DRM_INFO(" pitch is %d\n", fb->pitches[0]); |
1225 |
+ |
1226 |
+ return 0; |
1227 |
++ |
1228 |
++err_kfree: |
1229 |
++ kfree(fb); |
1230 |
++err_drm_gem_object_put_unlocked: |
1231 |
++ drm_gem_object_put_unlocked(gobj); |
1232 |
++err_vfree: |
1233 |
++ vfree(sysram); |
1234 |
++ return ret; |
1235 |
+ } |
1236 |
+ |
1237 |
+ static int cirrus_fbdev_destroy(struct drm_device *dev, |
1238 |
+ struct cirrus_fbdev *gfbdev) |
1239 |
+ { |
1240 |
+- struct drm_framebuffer *gfb = &gfbdev->gfb; |
1241 |
++ struct drm_framebuffer *gfb = gfbdev->gfb; |
1242 |
+ |
1243 |
+ drm_fb_helper_unregister_fbi(&gfbdev->helper); |
1244 |
+ |
1245 |
+- if (gfb->obj[0]) { |
1246 |
+- drm_gem_object_put_unlocked(gfb->obj[0]); |
1247 |
+- gfb->obj[0] = NULL; |
1248 |
+- } |
1249 |
+- |
1250 |
+ vfree(gfbdev->sysram); |
1251 |
+ drm_fb_helper_fini(&gfbdev->helper); |
1252 |
+- drm_framebuffer_unregister_private(gfb); |
1253 |
+- drm_framebuffer_cleanup(gfb); |
1254 |
++ if (gfb) |
1255 |
++ drm_framebuffer_put(gfb); |
1256 |
+ |
1257 |
+ return 0; |
1258 |
+ } |
1259 |
+diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c |
1260 |
+index 336bfda40125..90a4e641d3fb 100644 |
1261 |
+--- a/drivers/gpu/drm/cirrus/cirrus_mode.c |
1262 |
++++ b/drivers/gpu/drm/cirrus/cirrus_mode.c |
1263 |
+@@ -127,7 +127,7 @@ static int cirrus_crtc_do_set_base(struct drm_crtc *crtc, |
1264 |
+ return ret; |
1265 |
+ } |
1266 |
+ |
1267 |
+- if (&cdev->mode_info.gfbdev->gfb == crtc->primary->fb) { |
1268 |
++ if (cdev->mode_info.gfbdev->gfb == crtc->primary->fb) { |
1269 |
+ /* if pushing console in kmap it */ |
1270 |
+ ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap); |
1271 |
+ if (ret) |
1272 |
+diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c |
1273 |
+index ffbf4a950f69..522d6c46d7b1 100644 |
1274 |
+--- a/drivers/gpu/drm/exynos/exynos_mixer.c |
1275 |
++++ b/drivers/gpu/drm/exynos/exynos_mixer.c |
1276 |
+@@ -20,6 +20,7 @@ |
1277 |
+ #include "regs-vp.h" |
1278 |
+ |
1279 |
+ #include <linux/kernel.h> |
1280 |
++#include <linux/ktime.h> |
1281 |
+ #include <linux/spinlock.h> |
1282 |
+ #include <linux/wait.h> |
1283 |
+ #include <linux/i2c.h> |
1284 |
+@@ -337,15 +338,62 @@ static void mixer_cfg_vp_blend(struct mixer_context *ctx) |
1285 |
+ mixer_reg_write(ctx, MXR_VIDEO_CFG, val); |
1286 |
+ } |
1287 |
+ |
1288 |
+-static void mixer_vsync_set_update(struct mixer_context *ctx, bool enable) |
1289 |
++static bool mixer_is_synced(struct mixer_context *ctx) |
1290 |
+ { |
1291 |
+- /* block update on vsync */ |
1292 |
+- mixer_reg_writemask(ctx, MXR_STATUS, enable ? |
1293 |
+- MXR_STATUS_SYNC_ENABLE : 0, MXR_STATUS_SYNC_ENABLE); |
1294 |
++ u32 base, shadow; |
1295 |
+ |
1296 |
++ if (ctx->mxr_ver == MXR_VER_16_0_33_0 || |
1297 |
++ ctx->mxr_ver == MXR_VER_128_0_0_184) |
1298 |
++ return !(mixer_reg_read(ctx, MXR_CFG) & |
1299 |
++ MXR_CFG_LAYER_UPDATE_COUNT_MASK); |
1300 |
++ |
1301 |
++ if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags) && |
1302 |
++ vp_reg_read(ctx, VP_SHADOW_UPDATE)) |
1303 |
++ return false; |
1304 |
++ |
1305 |
++ base = mixer_reg_read(ctx, MXR_CFG); |
1306 |
++ shadow = mixer_reg_read(ctx, MXR_CFG_S); |
1307 |
++ if (base != shadow) |
1308 |
++ return false; |
1309 |
++ |
1310 |
++ base = mixer_reg_read(ctx, MXR_GRAPHIC_BASE(0)); |
1311 |
++ shadow = mixer_reg_read(ctx, MXR_GRAPHIC_BASE_S(0)); |
1312 |
++ if (base != shadow) |
1313 |
++ return false; |
1314 |
++ |
1315 |
++ base = mixer_reg_read(ctx, MXR_GRAPHIC_BASE(1)); |
1316 |
++ shadow = mixer_reg_read(ctx, MXR_GRAPHIC_BASE_S(1)); |
1317 |
++ if (base != shadow) |
1318 |
++ return false; |
1319 |
++ |
1320 |
++ return true; |
1321 |
++} |
1322 |
++ |
1323 |
++static int mixer_wait_for_sync(struct mixer_context *ctx) |
1324 |
++{ |
1325 |
++ ktime_t timeout = ktime_add_us(ktime_get(), 100000); |
1326 |
++ |
1327 |
++ while (!mixer_is_synced(ctx)) { |
1328 |
++ usleep_range(1000, 2000); |
1329 |
++ if (ktime_compare(ktime_get(), timeout) > 0) |
1330 |
++ return -ETIMEDOUT; |
1331 |
++ } |
1332 |
++ return 0; |
1333 |
++} |
1334 |
++ |
1335 |
++static void mixer_disable_sync(struct mixer_context *ctx) |
1336 |
++{ |
1337 |
++ mixer_reg_writemask(ctx, MXR_STATUS, 0, MXR_STATUS_SYNC_ENABLE); |
1338 |
++} |
1339 |
++ |
1340 |
++static void mixer_enable_sync(struct mixer_context *ctx) |
1341 |
++{ |
1342 |
++ if (ctx->mxr_ver == MXR_VER_16_0_33_0 || |
1343 |
++ ctx->mxr_ver == MXR_VER_128_0_0_184) |
1344 |
++ mixer_reg_writemask(ctx, MXR_CFG, ~0, MXR_CFG_LAYER_UPDATE); |
1345 |
++ mixer_reg_writemask(ctx, MXR_STATUS, ~0, MXR_STATUS_SYNC_ENABLE); |
1346 |
+ if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) |
1347 |
+- vp_reg_write(ctx, VP_SHADOW_UPDATE, enable ? |
1348 |
+- VP_SHADOW_UPDATE_ENABLE : 0); |
1349 |
++ vp_reg_write(ctx, VP_SHADOW_UPDATE, VP_SHADOW_UPDATE_ENABLE); |
1350 |
+ } |
1351 |
+ |
1352 |
+ static void mixer_cfg_scan(struct mixer_context *ctx, int width, int height) |
1353 |
+@@ -482,7 +530,6 @@ static void vp_video_buffer(struct mixer_context *ctx, |
1354 |
+ |
1355 |
+ spin_lock_irqsave(&ctx->reg_slock, flags); |
1356 |
+ |
1357 |
+- vp_reg_write(ctx, VP_SHADOW_UPDATE, 1); |
1358 |
+ /* interlace or progressive scan mode */ |
1359 |
+ val = (test_bit(MXR_BIT_INTERLACE, &ctx->flags) ? ~0 : 0); |
1360 |
+ vp_reg_writemask(ctx, VP_MODE, val, VP_MODE_LINE_SKIP); |
1361 |
+@@ -537,11 +584,6 @@ static void vp_video_buffer(struct mixer_context *ctx, |
1362 |
+ vp_regs_dump(ctx); |
1363 |
+ } |
1364 |
+ |
1365 |
+-static void mixer_layer_update(struct mixer_context *ctx) |
1366 |
+-{ |
1367 |
+- mixer_reg_writemask(ctx, MXR_CFG, ~0, MXR_CFG_LAYER_UPDATE); |
1368 |
+-} |
1369 |
+- |
1370 |
+ static void mixer_graph_buffer(struct mixer_context *ctx, |
1371 |
+ struct exynos_drm_plane *plane) |
1372 |
+ { |
1373 |
+@@ -618,11 +660,6 @@ static void mixer_graph_buffer(struct mixer_context *ctx, |
1374 |
+ mixer_cfg_layer(ctx, win, priority, true); |
1375 |
+ mixer_cfg_gfx_blend(ctx, win, fb->format->has_alpha); |
1376 |
+ |
1377 |
+- /* layer update mandatory for mixer 16.0.33.0 */ |
1378 |
+- if (ctx->mxr_ver == MXR_VER_16_0_33_0 || |
1379 |
+- ctx->mxr_ver == MXR_VER_128_0_0_184) |
1380 |
+- mixer_layer_update(ctx); |
1381 |
+- |
1382 |
+ spin_unlock_irqrestore(&ctx->reg_slock, flags); |
1383 |
+ |
1384 |
+ mixer_regs_dump(ctx); |
1385 |
+@@ -687,7 +724,7 @@ static void mixer_win_reset(struct mixer_context *ctx) |
1386 |
+ static irqreturn_t mixer_irq_handler(int irq, void *arg) |
1387 |
+ { |
1388 |
+ struct mixer_context *ctx = arg; |
1389 |
+- u32 val, base, shadow; |
1390 |
++ u32 val; |
1391 |
+ |
1392 |
+ spin_lock(&ctx->reg_slock); |
1393 |
+ |
1394 |
+@@ -701,26 +738,9 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg) |
1395 |
+ val &= ~MXR_INT_STATUS_VSYNC; |
1396 |
+ |
1397 |
+ /* interlace scan need to check shadow register */ |
1398 |
+- if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) { |
1399 |
+- if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags) && |
1400 |
+- vp_reg_read(ctx, VP_SHADOW_UPDATE)) |
1401 |
+- goto out; |
1402 |
+- |
1403 |
+- base = mixer_reg_read(ctx, MXR_CFG); |
1404 |
+- shadow = mixer_reg_read(ctx, MXR_CFG_S); |
1405 |
+- if (base != shadow) |
1406 |
+- goto out; |
1407 |
+- |
1408 |
+- base = mixer_reg_read(ctx, MXR_GRAPHIC_BASE(0)); |
1409 |
+- shadow = mixer_reg_read(ctx, MXR_GRAPHIC_BASE_S(0)); |
1410 |
+- if (base != shadow) |
1411 |
+- goto out; |
1412 |
+- |
1413 |
+- base = mixer_reg_read(ctx, MXR_GRAPHIC_BASE(1)); |
1414 |
+- shadow = mixer_reg_read(ctx, MXR_GRAPHIC_BASE_S(1)); |
1415 |
+- if (base != shadow) |
1416 |
+- goto out; |
1417 |
+- } |
1418 |
++ if (test_bit(MXR_BIT_INTERLACE, &ctx->flags) |
1419 |
++ && !mixer_is_synced(ctx)) |
1420 |
++ goto out; |
1421 |
+ |
1422 |
+ drm_crtc_handle_vblank(&ctx->crtc->base); |
1423 |
+ } |
1424 |
+@@ -895,12 +915,14 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) |
1425 |
+ |
1426 |
+ static void mixer_atomic_begin(struct exynos_drm_crtc *crtc) |
1427 |
+ { |
1428 |
+- struct mixer_context *mixer_ctx = crtc->ctx; |
1429 |
++ struct mixer_context *ctx = crtc->ctx; |
1430 |
+ |
1431 |
+- if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) |
1432 |
++ if (!test_bit(MXR_BIT_POWERED, &ctx->flags)) |
1433 |
+ return; |
1434 |
+ |
1435 |
+- mixer_vsync_set_update(mixer_ctx, false); |
1436 |
++ if (mixer_wait_for_sync(ctx)) |
1437 |
++ dev_err(ctx->dev, "timeout waiting for VSYNC\n"); |
1438 |
++ mixer_disable_sync(ctx); |
1439 |
+ } |
1440 |
+ |
1441 |
+ static void mixer_update_plane(struct exynos_drm_crtc *crtc, |
1442 |
+@@ -942,7 +964,7 @@ static void mixer_atomic_flush(struct exynos_drm_crtc *crtc) |
1443 |
+ if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) |
1444 |
+ return; |
1445 |
+ |
1446 |
+- mixer_vsync_set_update(mixer_ctx, true); |
1447 |
++ mixer_enable_sync(mixer_ctx); |
1448 |
+ exynos_crtc_handle_event(crtc); |
1449 |
+ } |
1450 |
+ |
1451 |
+@@ -957,7 +979,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) |
1452 |
+ |
1453 |
+ exynos_drm_pipe_clk_enable(crtc, true); |
1454 |
+ |
1455 |
+- mixer_vsync_set_update(ctx, false); |
1456 |
++ mixer_disable_sync(ctx); |
1457 |
+ |
1458 |
+ mixer_reg_writemask(ctx, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET); |
1459 |
+ |
1460 |
+@@ -970,7 +992,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) |
1461 |
+ |
1462 |
+ mixer_commit(ctx); |
1463 |
+ |
1464 |
+- mixer_vsync_set_update(ctx, true); |
1465 |
++ mixer_enable_sync(ctx); |
1466 |
+ |
1467 |
+ set_bit(MXR_BIT_POWERED, &ctx->flags); |
1468 |
+ } |
1469 |
+diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/volt.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/volt.h |
1470 |
+index 8a0f85f5fc1a..6a765682fbfa 100644 |
1471 |
+--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/volt.h |
1472 |
++++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/volt.h |
1473 |
+@@ -38,6 +38,7 @@ int nvkm_volt_set_id(struct nvkm_volt *, u8 id, u8 min_id, u8 temp, |
1474 |
+ |
1475 |
+ int nv40_volt_new(struct nvkm_device *, int, struct nvkm_volt **); |
1476 |
+ int gf100_volt_new(struct nvkm_device *, int, struct nvkm_volt **); |
1477 |
++int gf117_volt_new(struct nvkm_device *, int, struct nvkm_volt **); |
1478 |
+ int gk104_volt_new(struct nvkm_device *, int, struct nvkm_volt **); |
1479 |
+ int gk20a_volt_new(struct nvkm_device *, int, struct nvkm_volt **); |
1480 |
+ int gm20b_volt_new(struct nvkm_device *, int, struct nvkm_volt **); |
1481 |
+diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c |
1482 |
+index 9109b69cd052..9635704a1d86 100644 |
1483 |
+--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c |
1484 |
++++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c |
1485 |
+@@ -161,7 +161,7 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, |
1486 |
+ } |
1487 |
+ |
1488 |
+ ret = pm_runtime_get_sync(drm->dev); |
1489 |
+- if (IS_ERR_VALUE(ret) && ret != -EACCES) |
1490 |
++ if (ret < 0 && ret != -EACCES) |
1491 |
+ return ret; |
1492 |
+ ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_USER, &args, sizeof(args)); |
1493 |
+ pm_runtime_put_autosuspend(drm->dev); |
1494 |
+diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c |
1495 |
+index e294013426ce..347a6a4cb339 100644 |
1496 |
+--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c |
1497 |
++++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c |
1498 |
+@@ -1613,7 +1613,7 @@ nvd7_chipset = { |
1499 |
+ .pci = gf106_pci_new, |
1500 |
+ .therm = gf119_therm_new, |
1501 |
+ .timer = nv41_timer_new, |
1502 |
+- .volt = gf100_volt_new, |
1503 |
++ .volt = gf117_volt_new, |
1504 |
+ .ce[0] = gf100_ce_new, |
1505 |
+ .disp = gf119_disp_new, |
1506 |
+ .dma = gf119_dma_new, |
1507 |
+diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/volt/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/volt/Kbuild |
1508 |
+index bcd179ba11d0..146adcdd316a 100644 |
1509 |
+--- a/drivers/gpu/drm/nouveau/nvkm/subdev/volt/Kbuild |
1510 |
++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/volt/Kbuild |
1511 |
+@@ -2,6 +2,7 @@ nvkm-y += nvkm/subdev/volt/base.o |
1512 |
+ nvkm-y += nvkm/subdev/volt/gpio.o |
1513 |
+ nvkm-y += nvkm/subdev/volt/nv40.o |
1514 |
+ nvkm-y += nvkm/subdev/volt/gf100.o |
1515 |
++nvkm-y += nvkm/subdev/volt/gf117.o |
1516 |
+ nvkm-y += nvkm/subdev/volt/gk104.o |
1517 |
+ nvkm-y += nvkm/subdev/volt/gk20a.o |
1518 |
+ nvkm-y += nvkm/subdev/volt/gm20b.o |
1519 |
+diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gf117.c b/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gf117.c |
1520 |
+new file mode 100644 |
1521 |
+index 000000000000..547a58f0aeac |
1522 |
+--- /dev/null |
1523 |
++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gf117.c |
1524 |
+@@ -0,0 +1,60 @@ |
1525 |
++/* |
1526 |
++ * Copyright 2019 Ilia Mirkin |
1527 |
++ * |
1528 |
++ * Permission is hereby granted, free of charge, to any person obtaining a |
1529 |
++ * copy of this software and associated documentation files (the "Software"), |
1530 |
++ * to deal in the Software without restriction, including without limitation |
1531 |
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
1532 |
++ * and/or sell copies of the Software, and to permit persons to whom the |
1533 |
++ * Software is furnished to do so, subject to the following conditions: |
1534 |
++ * |
1535 |
++ * The above copyright notice and this permission notice shall be included in |
1536 |
++ * all copies or substantial portions of the Software. |
1537 |
++ * |
1538 |
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
1539 |
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
1540 |
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
1541 |
++ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
1542 |
++ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
1543 |
++ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
1544 |
++ * OTHER DEALINGS IN THE SOFTWARE. |
1545 |
++ * |
1546 |
++ * Authors: Ilia Mirkin |
1547 |
++ */ |
1548 |
++#include "priv.h" |
1549 |
++ |
1550 |
++#include <subdev/fuse.h> |
1551 |
++ |
1552 |
++static int |
1553 |
++gf117_volt_speedo_read(struct nvkm_volt *volt) |
1554 |
++{ |
1555 |
++ struct nvkm_device *device = volt->subdev.device; |
1556 |
++ struct nvkm_fuse *fuse = device->fuse; |
1557 |
++ |
1558 |
++ if (!fuse) |
1559 |
++ return -EINVAL; |
1560 |
++ |
1561 |
++ return nvkm_fuse_read(fuse, 0x3a8); |
1562 |
++} |
1563 |
++ |
1564 |
++static const struct nvkm_volt_func |
1565 |
++gf117_volt = { |
1566 |
++ .oneinit = gf100_volt_oneinit, |
1567 |
++ .vid_get = nvkm_voltgpio_get, |
1568 |
++ .vid_set = nvkm_voltgpio_set, |
1569 |
++ .speedo_read = gf117_volt_speedo_read, |
1570 |
++}; |
1571 |
++ |
1572 |
++int |
1573 |
++gf117_volt_new(struct nvkm_device *device, int index, struct nvkm_volt **pvolt) |
1574 |
++{ |
1575 |
++ struct nvkm_volt *volt; |
1576 |
++ int ret; |
1577 |
++ |
1578 |
++ ret = nvkm_volt_new_(&gf117_volt, device, index, &volt); |
1579 |
++ *pvolt = volt; |
1580 |
++ if (ret) |
1581 |
++ return ret; |
1582 |
++ |
1583 |
++ return nvkm_voltgpio_init(volt); |
1584 |
++} |
1585 |
+diff --git a/drivers/gpu/drm/panel/panel-innolux-p079zca.c b/drivers/gpu/drm/panel/panel-innolux-p079zca.c |
1586 |
+index 72edb334d997..88c7d035ace6 100644 |
1587 |
+--- a/drivers/gpu/drm/panel/panel-innolux-p079zca.c |
1588 |
++++ b/drivers/gpu/drm/panel/panel-innolux-p079zca.c |
1589 |
+@@ -70,18 +70,12 @@ static inline struct innolux_panel *to_innolux_panel(struct drm_panel *panel) |
1590 |
+ static int innolux_panel_disable(struct drm_panel *panel) |
1591 |
+ { |
1592 |
+ struct innolux_panel *innolux = to_innolux_panel(panel); |
1593 |
+- int err; |
1594 |
+ |
1595 |
+ if (!innolux->enabled) |
1596 |
+ return 0; |
1597 |
+ |
1598 |
+ backlight_disable(innolux->backlight); |
1599 |
+ |
1600 |
+- err = mipi_dsi_dcs_set_display_off(innolux->link); |
1601 |
+- if (err < 0) |
1602 |
+- DRM_DEV_ERROR(panel->dev, "failed to set display off: %d\n", |
1603 |
+- err); |
1604 |
+- |
1605 |
+ innolux->enabled = false; |
1606 |
+ |
1607 |
+ return 0; |
1608 |
+@@ -95,6 +89,11 @@ static int innolux_panel_unprepare(struct drm_panel *panel) |
1609 |
+ if (!innolux->prepared) |
1610 |
+ return 0; |
1611 |
+ |
1612 |
++ err = mipi_dsi_dcs_set_display_off(innolux->link); |
1613 |
++ if (err < 0) |
1614 |
++ DRM_DEV_ERROR(panel->dev, "failed to set display off: %d\n", |
1615 |
++ err); |
1616 |
++ |
1617 |
+ err = mipi_dsi_dcs_enter_sleep_mode(innolux->link); |
1618 |
+ if (err < 0) { |
1619 |
+ DRM_DEV_ERROR(panel->dev, "failed to enter sleep mode: %d\n", |
1620 |
+diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c |
1621 |
+index 7c484729f9b2..268f5a3b3122 100644 |
1622 |
+--- a/drivers/gpu/drm/ttm/ttm_bo.c |
1623 |
++++ b/drivers/gpu/drm/ttm/ttm_bo.c |
1624 |
+@@ -1445,7 +1445,6 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj) |
1625 |
+ container_of(kobj, struct ttm_bo_global, kobj); |
1626 |
+ |
1627 |
+ __free_page(glob->dummy_read_page); |
1628 |
+- kfree(glob); |
1629 |
+ } |
1630 |
+ |
1631 |
+ void ttm_bo_global_release(struct drm_global_reference *ref) |
1632 |
+diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c |
1633 |
+index 450387c92b63..df73d5ff84a8 100644 |
1634 |
+--- a/drivers/gpu/drm/ttm/ttm_memory.c |
1635 |
++++ b/drivers/gpu/drm/ttm/ttm_memory.c |
1636 |
+@@ -216,14 +216,6 @@ static ssize_t ttm_mem_global_store(struct kobject *kobj, |
1637 |
+ return size; |
1638 |
+ } |
1639 |
+ |
1640 |
+-static void ttm_mem_global_kobj_release(struct kobject *kobj) |
1641 |
+-{ |
1642 |
+- struct ttm_mem_global *glob = |
1643 |
+- container_of(kobj, struct ttm_mem_global, kobj); |
1644 |
+- |
1645 |
+- kfree(glob); |
1646 |
+-} |
1647 |
+- |
1648 |
+ static struct attribute *ttm_mem_global_attrs[] = { |
1649 |
+ &ttm_mem_global_lower_mem_limit, |
1650 |
+ NULL |
1651 |
+@@ -235,7 +227,6 @@ static const struct sysfs_ops ttm_mem_global_ops = { |
1652 |
+ }; |
1653 |
+ |
1654 |
+ static struct kobj_type ttm_mem_glob_kobj_type = { |
1655 |
+- .release = &ttm_mem_global_kobj_release, |
1656 |
+ .sysfs_ops = &ttm_mem_global_ops, |
1657 |
+ .default_attrs = ttm_mem_global_attrs, |
1658 |
+ }; |
1659 |
+diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c |
1660 |
+index d5a23295dd80..bb7b58407039 100644 |
1661 |
+--- a/drivers/gpu/drm/udl/udl_gem.c |
1662 |
++++ b/drivers/gpu/drm/udl/udl_gem.c |
1663 |
+@@ -224,7 +224,7 @@ int udl_gem_mmap(struct drm_file *file, struct drm_device *dev, |
1664 |
+ *offset = drm_vma_node_offset_addr(&gobj->base.vma_node); |
1665 |
+ |
1666 |
+ out: |
1667 |
+- drm_gem_object_put(&gobj->base); |
1668 |
++ drm_gem_object_put_unlocked(&gobj->base); |
1669 |
+ unlock: |
1670 |
+ mutex_unlock(&udl->gem_lock); |
1671 |
+ return ret; |
1672 |
+diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h |
1673 |
+index b7870e7e41d4..97d33b8ed36c 100644 |
1674 |
+--- a/drivers/hid/hid-ids.h |
1675 |
++++ b/drivers/hid/hid-ids.h |
1676 |
+@@ -348,6 +348,7 @@ |
1677 |
+ #define USB_DEVICE_ID_DMI_ENC 0x5fab |
1678 |
+ |
1679 |
+ #define USB_VENDOR_ID_DRAGONRISE 0x0079 |
1680 |
++#define USB_DEVICE_ID_REDRAGON_SEYMUR2 0x0006 |
1681 |
+ #define USB_DEVICE_ID_DRAGONRISE_WIIU 0x1800 |
1682 |
+ #define USB_DEVICE_ID_DRAGONRISE_PS3 0x1801 |
1683 |
+ #define USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR 0x1803 |
1684 |
+diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c |
1685 |
+index 77316f022c5a..94088c0ed68a 100644 |
1686 |
+--- a/drivers/hid/hid-quirks.c |
1687 |
++++ b/drivers/hid/hid-quirks.c |
1688 |
+@@ -70,6 +70,7 @@ static const struct hid_device_id hid_quirks[] = { |
1689 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC), HID_QUIRK_NOGET }, |
1690 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_2NES2SNES), HID_QUIRK_MULTI_INPUT }, |
1691 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_4NES4SNES), HID_QUIRK_MULTI_INPUT }, |
1692 |
++ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_REDRAGON_SEYMUR2), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, |
1693 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR), HID_QUIRK_MULTI_INPUT }, |
1694 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE1), HID_QUIRK_MULTI_INPUT }, |
1695 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3), HID_QUIRK_MULTI_INPUT }, |
1696 |
+diff --git a/drivers/hid/i2c-hid/Makefile b/drivers/hid/i2c-hid/Makefile |
1697 |
+index 832d8f9aaba2..099e1ce2f234 100644 |
1698 |
+--- a/drivers/hid/i2c-hid/Makefile |
1699 |
++++ b/drivers/hid/i2c-hid/Makefile |
1700 |
+@@ -3,3 +3,6 @@ |
1701 |
+ # |
1702 |
+ |
1703 |
+ obj-$(CONFIG_I2C_HID) += i2c-hid.o |
1704 |
++ |
1705 |
++i2c-hid-objs = i2c-hid-core.o |
1706 |
++i2c-hid-$(CONFIG_DMI) += i2c-hid-dmi-quirks.o |
1707 |
+diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c |
1708 |
+new file mode 100644 |
1709 |
+index 000000000000..3cde7c1b9c33 |
1710 |
+--- /dev/null |
1711 |
++++ b/drivers/hid/i2c-hid/i2c-hid-core.c |
1712 |
+@@ -0,0 +1,1348 @@ |
1713 |
++/* |
1714 |
++ * HID over I2C protocol implementation |
1715 |
++ * |
1716 |
++ * Copyright (c) 2012 Benjamin Tissoires <benjamin.tissoires@×××××.com> |
1717 |
++ * Copyright (c) 2012 Ecole Nationale de l'Aviation Civile, France |
1718 |
++ * Copyright (c) 2012 Red Hat, Inc |
1719 |
++ * |
1720 |
++ * This code is partly based on "USB HID support for Linux": |
1721 |
++ * |
1722 |
++ * Copyright (c) 1999 Andreas Gal |
1723 |
++ * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@××××.cz> |
1724 |
++ * Copyright (c) 2005 Michael Haboustak <mike-@××××××××.com> for Concept2, Inc |
1725 |
++ * Copyright (c) 2007-2008 Oliver Neukum |
1726 |
++ * Copyright (c) 2006-2010 Jiri Kosina |
1727 |
++ * |
1728 |
++ * This file is subject to the terms and conditions of the GNU General Public |
1729 |
++ * License. See the file COPYING in the main directory of this archive for |
1730 |
++ * more details. |
1731 |
++ */ |
1732 |
++ |
1733 |
++#include <linux/module.h> |
1734 |
++#include <linux/i2c.h> |
1735 |
++#include <linux/interrupt.h> |
1736 |
++#include <linux/input.h> |
1737 |
++#include <linux/irq.h> |
1738 |
++#include <linux/delay.h> |
1739 |
++#include <linux/slab.h> |
1740 |
++#include <linux/pm.h> |
1741 |
++#include <linux/pm_runtime.h> |
1742 |
++#include <linux/device.h> |
1743 |
++#include <linux/wait.h> |
1744 |
++#include <linux/err.h> |
1745 |
++#include <linux/string.h> |
1746 |
++#include <linux/list.h> |
1747 |
++#include <linux/jiffies.h> |
1748 |
++#include <linux/kernel.h> |
1749 |
++#include <linux/hid.h> |
1750 |
++#include <linux/mutex.h> |
1751 |
++#include <linux/acpi.h> |
1752 |
++#include <linux/of.h> |
1753 |
++#include <linux/regulator/consumer.h> |
1754 |
++ |
1755 |
++#include <linux/platform_data/i2c-hid.h> |
1756 |
++ |
1757 |
++#include "../hid-ids.h" |
1758 |
++#include "i2c-hid.h" |
1759 |
++ |
1760 |
++/* quirks to control the device */ |
1761 |
++#define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) |
1762 |
++#define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) |
1763 |
++#define I2C_HID_QUIRK_NO_RUNTIME_PM BIT(2) |
1764 |
++#define I2C_HID_QUIRK_DELAY_AFTER_SLEEP BIT(3) |
1765 |
++ |
1766 |
++/* flags */ |
1767 |
++#define I2C_HID_STARTED 0 |
1768 |
++#define I2C_HID_RESET_PENDING 1 |
1769 |
++#define I2C_HID_READ_PENDING 2 |
1770 |
++ |
1771 |
++#define I2C_HID_PWR_ON 0x00 |
1772 |
++#define I2C_HID_PWR_SLEEP 0x01 |
1773 |
++ |
1774 |
++/* debug option */ |
1775 |
++static bool debug; |
1776 |
++module_param(debug, bool, 0444); |
1777 |
++MODULE_PARM_DESC(debug, "print a lot of debug information"); |
1778 |
++ |
1779 |
++#define i2c_hid_dbg(ihid, fmt, arg...) \ |
1780 |
++do { \ |
1781 |
++ if (debug) \ |
1782 |
++ dev_printk(KERN_DEBUG, &(ihid)->client->dev, fmt, ##arg); \ |
1783 |
++} while (0) |
1784 |
++ |
1785 |
++struct i2c_hid_desc { |
1786 |
++ __le16 wHIDDescLength; |
1787 |
++ __le16 bcdVersion; |
1788 |
++ __le16 wReportDescLength; |
1789 |
++ __le16 wReportDescRegister; |
1790 |
++ __le16 wInputRegister; |
1791 |
++ __le16 wMaxInputLength; |
1792 |
++ __le16 wOutputRegister; |
1793 |
++ __le16 wMaxOutputLength; |
1794 |
++ __le16 wCommandRegister; |
1795 |
++ __le16 wDataRegister; |
1796 |
++ __le16 wVendorID; |
1797 |
++ __le16 wProductID; |
1798 |
++ __le16 wVersionID; |
1799 |
++ __le32 reserved; |
1800 |
++} __packed; |
1801 |
++ |
1802 |
++struct i2c_hid_cmd { |
1803 |
++ unsigned int registerIndex; |
1804 |
++ __u8 opcode; |
1805 |
++ unsigned int length; |
1806 |
++ bool wait; |
1807 |
++}; |
1808 |
++ |
1809 |
++union command { |
1810 |
++ u8 data[0]; |
1811 |
++ struct cmd { |
1812 |
++ __le16 reg; |
1813 |
++ __u8 reportTypeID; |
1814 |
++ __u8 opcode; |
1815 |
++ } __packed c; |
1816 |
++}; |
1817 |
++ |
1818 |
++#define I2C_HID_CMD(opcode_) \ |
1819 |
++ .opcode = opcode_, .length = 4, \ |
1820 |
++ .registerIndex = offsetof(struct i2c_hid_desc, wCommandRegister) |
1821 |
++ |
1822 |
++/* fetch HID descriptor */ |
1823 |
++static const struct i2c_hid_cmd hid_descr_cmd = { .length = 2 }; |
1824 |
++/* fetch report descriptors */ |
1825 |
++static const struct i2c_hid_cmd hid_report_descr_cmd = { |
1826 |
++ .registerIndex = offsetof(struct i2c_hid_desc, |
1827 |
++ wReportDescRegister), |
1828 |
++ .opcode = 0x00, |
1829 |
++ .length = 2 }; |
1830 |
++/* commands */ |
1831 |
++static const struct i2c_hid_cmd hid_reset_cmd = { I2C_HID_CMD(0x01), |
1832 |
++ .wait = true }; |
1833 |
++static const struct i2c_hid_cmd hid_get_report_cmd = { I2C_HID_CMD(0x02) }; |
1834 |
++static const struct i2c_hid_cmd hid_set_report_cmd = { I2C_HID_CMD(0x03) }; |
1835 |
++static const struct i2c_hid_cmd hid_set_power_cmd = { I2C_HID_CMD(0x08) }; |
1836 |
++static const struct i2c_hid_cmd hid_no_cmd = { .length = 0 }; |
1837 |
++ |
1838 |
++/* |
1839 |
++ * These definitions are not used here, but are defined by the spec. |
1840 |
++ * Keeping them here for documentation purposes. |
1841 |
++ * |
1842 |
++ * static const struct i2c_hid_cmd hid_get_idle_cmd = { I2C_HID_CMD(0x04) }; |
1843 |
++ * static const struct i2c_hid_cmd hid_set_idle_cmd = { I2C_HID_CMD(0x05) }; |
1844 |
++ * static const struct i2c_hid_cmd hid_get_protocol_cmd = { I2C_HID_CMD(0x06) }; |
1845 |
++ * static const struct i2c_hid_cmd hid_set_protocol_cmd = { I2C_HID_CMD(0x07) }; |
1846 |
++ */ |
1847 |
++ |
1848 |
++/* The main device structure */ |
1849 |
++struct i2c_hid { |
1850 |
++ struct i2c_client *client; /* i2c client */ |
1851 |
++ struct hid_device *hid; /* pointer to corresponding HID dev */ |
1852 |
++ union { |
1853 |
++ __u8 hdesc_buffer[sizeof(struct i2c_hid_desc)]; |
1854 |
++ struct i2c_hid_desc hdesc; /* the HID Descriptor */ |
1855 |
++ }; |
1856 |
++ __le16 wHIDDescRegister; /* location of the i2c |
1857 |
++ * register of the HID |
1858 |
++ * descriptor. */ |
1859 |
++ unsigned int bufsize; /* i2c buffer size */ |
1860 |
++ u8 *inbuf; /* Input buffer */ |
1861 |
++ u8 *rawbuf; /* Raw Input buffer */ |
1862 |
++ u8 *cmdbuf; /* Command buffer */ |
1863 |
++ u8 *argsbuf; /* Command arguments buffer */ |
1864 |
++ |
1865 |
++ unsigned long flags; /* device flags */ |
1866 |
++ unsigned long quirks; /* Various quirks */ |
1867 |
++ |
1868 |
++ wait_queue_head_t wait; /* For waiting the interrupt */ |
1869 |
++ |
1870 |
++ struct i2c_hid_platform_data pdata; |
1871 |
++ |
1872 |
++ bool irq_wake_enabled; |
1873 |
++ struct mutex reset_lock; |
1874 |
++ |
1875 |
++ unsigned long sleep_delay; |
1876 |
++}; |
1877 |
++ |
1878 |
++static const struct i2c_hid_quirks { |
1879 |
++ __u16 idVendor; |
1880 |
++ __u16 idProduct; |
1881 |
++ __u32 quirks; |
1882 |
++} i2c_hid_quirks[] = { |
1883 |
++ { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8752, |
1884 |
++ I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, |
1885 |
++ { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8755, |
1886 |
++ I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, |
1887 |
++ { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, |
1888 |
++ I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | |
1889 |
++ I2C_HID_QUIRK_NO_RUNTIME_PM }, |
1890 |
++ { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_4B33, |
1891 |
++ I2C_HID_QUIRK_DELAY_AFTER_SLEEP }, |
1892 |
++ { 0, 0 } |
1893 |
++}; |
1894 |
++ |
1895 |
++/* |
1896 |
++ * i2c_hid_lookup_quirk: return any quirks associated with a I2C HID device |
1897 |
++ * @idVendor: the 16-bit vendor ID |
1898 |
++ * @idProduct: the 16-bit product ID |
1899 |
++ * |
1900 |
++ * Returns: a u32 quirks value. |
1901 |
++ */ |
1902 |
++static u32 i2c_hid_lookup_quirk(const u16 idVendor, const u16 idProduct) |
1903 |
++{ |
1904 |
++ u32 quirks = 0; |
1905 |
++ int n; |
1906 |
++ |
1907 |
++ for (n = 0; i2c_hid_quirks[n].idVendor; n++) |
1908 |
++ if (i2c_hid_quirks[n].idVendor == idVendor && |
1909 |
++ (i2c_hid_quirks[n].idProduct == (__u16)HID_ANY_ID || |
1910 |
++ i2c_hid_quirks[n].idProduct == idProduct)) |
1911 |
++ quirks = i2c_hid_quirks[n].quirks; |
1912 |
++ |
1913 |
++ return quirks; |
1914 |
++} |
1915 |
++ |
1916 |
++static int __i2c_hid_command(struct i2c_client *client, |
1917 |
++ const struct i2c_hid_cmd *command, u8 reportID, |
1918 |
++ u8 reportType, u8 *args, int args_len, |
1919 |
++ unsigned char *buf_recv, int data_len) |
1920 |
++{ |
1921 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
1922 |
++ union command *cmd = (union command *)ihid->cmdbuf; |
1923 |
++ int ret; |
1924 |
++ struct i2c_msg msg[2]; |
1925 |
++ int msg_num = 1; |
1926 |
++ |
1927 |
++ int length = command->length; |
1928 |
++ bool wait = command->wait; |
1929 |
++ unsigned int registerIndex = command->registerIndex; |
1930 |
++ |
1931 |
++ /* special case for hid_descr_cmd */ |
1932 |
++ if (command == &hid_descr_cmd) { |
1933 |
++ cmd->c.reg = ihid->wHIDDescRegister; |
1934 |
++ } else { |
1935 |
++ cmd->data[0] = ihid->hdesc_buffer[registerIndex]; |
1936 |
++ cmd->data[1] = ihid->hdesc_buffer[registerIndex + 1]; |
1937 |
++ } |
1938 |
++ |
1939 |
++ if (length > 2) { |
1940 |
++ cmd->c.opcode = command->opcode; |
1941 |
++ cmd->c.reportTypeID = reportID | reportType << 4; |
1942 |
++ } |
1943 |
++ |
1944 |
++ memcpy(cmd->data + length, args, args_len); |
1945 |
++ length += args_len; |
1946 |
++ |
1947 |
++ i2c_hid_dbg(ihid, "%s: cmd=%*ph\n", __func__, length, cmd->data); |
1948 |
++ |
1949 |
++ msg[0].addr = client->addr; |
1950 |
++ msg[0].flags = client->flags & I2C_M_TEN; |
1951 |
++ msg[0].len = length; |
1952 |
++ msg[0].buf = cmd->data; |
1953 |
++ if (data_len > 0) { |
1954 |
++ msg[1].addr = client->addr; |
1955 |
++ msg[1].flags = client->flags & I2C_M_TEN; |
1956 |
++ msg[1].flags |= I2C_M_RD; |
1957 |
++ msg[1].len = data_len; |
1958 |
++ msg[1].buf = buf_recv; |
1959 |
++ msg_num = 2; |
1960 |
++ set_bit(I2C_HID_READ_PENDING, &ihid->flags); |
1961 |
++ } |
1962 |
++ |
1963 |
++ if (wait) |
1964 |
++ set_bit(I2C_HID_RESET_PENDING, &ihid->flags); |
1965 |
++ |
1966 |
++ ret = i2c_transfer(client->adapter, msg, msg_num); |
1967 |
++ |
1968 |
++ if (data_len > 0) |
1969 |
++ clear_bit(I2C_HID_READ_PENDING, &ihid->flags); |
1970 |
++ |
1971 |
++ if (ret != msg_num) |
1972 |
++ return ret < 0 ? ret : -EIO; |
1973 |
++ |
1974 |
++ ret = 0; |
1975 |
++ |
1976 |
++ if (wait && (ihid->quirks & I2C_HID_QUIRK_NO_IRQ_AFTER_RESET)) { |
1977 |
++ msleep(100); |
1978 |
++ } else if (wait) { |
1979 |
++ i2c_hid_dbg(ihid, "%s: waiting...\n", __func__); |
1980 |
++ if (!wait_event_timeout(ihid->wait, |
1981 |
++ !test_bit(I2C_HID_RESET_PENDING, &ihid->flags), |
1982 |
++ msecs_to_jiffies(5000))) |
1983 |
++ ret = -ENODATA; |
1984 |
++ i2c_hid_dbg(ihid, "%s: finished.\n", __func__); |
1985 |
++ } |
1986 |
++ |
1987 |
++ return ret; |
1988 |
++} |
1989 |
++ |
1990 |
++static int i2c_hid_command(struct i2c_client *client, |
1991 |
++ const struct i2c_hid_cmd *command, |
1992 |
++ unsigned char *buf_recv, int data_len) |
1993 |
++{ |
1994 |
++ return __i2c_hid_command(client, command, 0, 0, NULL, 0, |
1995 |
++ buf_recv, data_len); |
1996 |
++} |
1997 |
++ |
1998 |
++static int i2c_hid_get_report(struct i2c_client *client, u8 reportType, |
1999 |
++ u8 reportID, unsigned char *buf_recv, int data_len) |
2000 |
++{ |
2001 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2002 |
++ u8 args[3]; |
2003 |
++ int ret; |
2004 |
++ int args_len = 0; |
2005 |
++ u16 readRegister = le16_to_cpu(ihid->hdesc.wDataRegister); |
2006 |
++ |
2007 |
++ i2c_hid_dbg(ihid, "%s\n", __func__); |
2008 |
++ |
2009 |
++ if (reportID >= 0x0F) { |
2010 |
++ args[args_len++] = reportID; |
2011 |
++ reportID = 0x0F; |
2012 |
++ } |
2013 |
++ |
2014 |
++ args[args_len++] = readRegister & 0xFF; |
2015 |
++ args[args_len++] = readRegister >> 8; |
2016 |
++ |
2017 |
++ ret = __i2c_hid_command(client, &hid_get_report_cmd, reportID, |
2018 |
++ reportType, args, args_len, buf_recv, data_len); |
2019 |
++ if (ret) { |
2020 |
++ dev_err(&client->dev, |
2021 |
++ "failed to retrieve report from device.\n"); |
2022 |
++ return ret; |
2023 |
++ } |
2024 |
++ |
2025 |
++ return 0; |
2026 |
++} |
2027 |
++ |
2028 |
++/** |
2029 |
++ * i2c_hid_set_or_send_report: forward an incoming report to the device |
2030 |
++ * @client: the i2c_client of the device |
2031 |
++ * @reportType: 0x03 for HID_FEATURE_REPORT ; 0x02 for HID_OUTPUT_REPORT |
2032 |
++ * @reportID: the report ID |
2033 |
++ * @buf: the actual data to transfer, without the report ID |
2034 |
++ * @len: size of buf |
2035 |
++ * @use_data: true: use SET_REPORT HID command, false: send plain OUTPUT report |
2036 |
++ */ |
2037 |
++static int i2c_hid_set_or_send_report(struct i2c_client *client, u8 reportType, |
2038 |
++ u8 reportID, unsigned char *buf, size_t data_len, bool use_data) |
2039 |
++{ |
2040 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2041 |
++ u8 *args = ihid->argsbuf; |
2042 |
++ const struct i2c_hid_cmd *hidcmd; |
2043 |
++ int ret; |
2044 |
++ u16 dataRegister = le16_to_cpu(ihid->hdesc.wDataRegister); |
2045 |
++ u16 outputRegister = le16_to_cpu(ihid->hdesc.wOutputRegister); |
2046 |
++ u16 maxOutputLength = le16_to_cpu(ihid->hdesc.wMaxOutputLength); |
2047 |
++ u16 size; |
2048 |
++ int args_len; |
2049 |
++ int index = 0; |
2050 |
++ |
2051 |
++ i2c_hid_dbg(ihid, "%s\n", __func__); |
2052 |
++ |
2053 |
++ if (data_len > ihid->bufsize) |
2054 |
++ return -EINVAL; |
2055 |
++ |
2056 |
++ size = 2 /* size */ + |
2057 |
++ (reportID ? 1 : 0) /* reportID */ + |
2058 |
++ data_len /* buf */; |
2059 |
++ args_len = (reportID >= 0x0F ? 1 : 0) /* optional third byte */ + |
2060 |
++ 2 /* dataRegister */ + |
2061 |
++ size /* args */; |
2062 |
++ |
2063 |
++ if (!use_data && maxOutputLength == 0) |
2064 |
++ return -ENOSYS; |
2065 |
++ |
2066 |
++ if (reportID >= 0x0F) { |
2067 |
++ args[index++] = reportID; |
2068 |
++ reportID = 0x0F; |
2069 |
++ } |
2070 |
++ |
2071 |
++ /* |
2072 |
++ * use the data register for feature reports or if the device does not |
2073 |
++ * support the output register |
2074 |
++ */ |
2075 |
++ if (use_data) { |
2076 |
++ args[index++] = dataRegister & 0xFF; |
2077 |
++ args[index++] = dataRegister >> 8; |
2078 |
++ hidcmd = &hid_set_report_cmd; |
2079 |
++ } else { |
2080 |
++ args[index++] = outputRegister & 0xFF; |
2081 |
++ args[index++] = outputRegister >> 8; |
2082 |
++ hidcmd = &hid_no_cmd; |
2083 |
++ } |
2084 |
++ |
2085 |
++ args[index++] = size & 0xFF; |
2086 |
++ args[index++] = size >> 8; |
2087 |
++ |
2088 |
++ if (reportID) |
2089 |
++ args[index++] = reportID; |
2090 |
++ |
2091 |
++ memcpy(&args[index], buf, data_len); |
2092 |
++ |
2093 |
++ ret = __i2c_hid_command(client, hidcmd, reportID, |
2094 |
++ reportType, args, args_len, NULL, 0); |
2095 |
++ if (ret) { |
2096 |
++ dev_err(&client->dev, "failed to set a report to device.\n"); |
2097 |
++ return ret; |
2098 |
++ } |
2099 |
++ |
2100 |
++ return data_len; |
2101 |
++} |
2102 |
++ |
2103 |
++static int i2c_hid_set_power(struct i2c_client *client, int power_state) |
2104 |
++{ |
2105 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2106 |
++ int ret; |
2107 |
++ unsigned long now, delay; |
2108 |
++ |
2109 |
++ i2c_hid_dbg(ihid, "%s\n", __func__); |
2110 |
++ |
2111 |
++ /* |
2112 |
++ * Some devices require to send a command to wakeup before power on. |
2113 |
++ * The call will get a return value (EREMOTEIO) but device will be |
2114 |
++ * triggered and activated. After that, it goes like a normal device. |
2115 |
++ */ |
2116 |
++ if (power_state == I2C_HID_PWR_ON && |
2117 |
++ ihid->quirks & I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV) { |
2118 |
++ ret = i2c_hid_command(client, &hid_set_power_cmd, NULL, 0); |
2119 |
++ |
2120 |
++ /* Device was already activated */ |
2121 |
++ if (!ret) |
2122 |
++ goto set_pwr_exit; |
2123 |
++ } |
2124 |
++ |
2125 |
++ if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP && |
2126 |
++ power_state == I2C_HID_PWR_ON) { |
2127 |
++ now = jiffies; |
2128 |
++ if (time_after(ihid->sleep_delay, now)) { |
2129 |
++ delay = jiffies_to_usecs(ihid->sleep_delay - now); |
2130 |
++ usleep_range(delay, delay + 1); |
2131 |
++ } |
2132 |
++ } |
2133 |
++ |
2134 |
++ ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state, |
2135 |
++ 0, NULL, 0, NULL, 0); |
2136 |
++ |
2137 |
++ if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP && |
2138 |
++ power_state == I2C_HID_PWR_SLEEP) |
2139 |
++ ihid->sleep_delay = jiffies + msecs_to_jiffies(20); |
2140 |
++ |
2141 |
++ if (ret) |
2142 |
++ dev_err(&client->dev, "failed to change power setting.\n"); |
2143 |
++ |
2144 |
++set_pwr_exit: |
2145 |
++ return ret; |
2146 |
++} |
2147 |
++ |
2148 |
++static int i2c_hid_hwreset(struct i2c_client *client) |
2149 |
++{ |
2150 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2151 |
++ int ret; |
2152 |
++ |
2153 |
++ i2c_hid_dbg(ihid, "%s\n", __func__); |
2154 |
++ |
2155 |
++ /* |
2156 |
++ * This prevents sending feature reports while the device is |
2157 |
++ * being reset. Otherwise we may lose the reset complete |
2158 |
++ * interrupt. |
2159 |
++ */ |
2160 |
++ mutex_lock(&ihid->reset_lock); |
2161 |
++ |
2162 |
++ ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); |
2163 |
++ if (ret) |
2164 |
++ goto out_unlock; |
2165 |
++ |
2166 |
++ /* |
2167 |
++ * The HID over I2C specification states that if a DEVICE needs time |
2168 |
++ * after the PWR_ON request, it should utilise CLOCK stretching. |
2169 |
++ * However, it has been observered that the Windows driver provides a |
2170 |
++ * 1ms sleep between the PWR_ON and RESET requests and that some devices |
2171 |
++ * rely on this. |
2172 |
++ */ |
2173 |
++ usleep_range(1000, 5000); |
2174 |
++ |
2175 |
++ i2c_hid_dbg(ihid, "resetting...\n"); |
2176 |
++ |
2177 |
++ ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0); |
2178 |
++ if (ret) { |
2179 |
++ dev_err(&client->dev, "failed to reset device.\n"); |
2180 |
++ i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
2181 |
++ } |
2182 |
++ |
2183 |
++out_unlock: |
2184 |
++ mutex_unlock(&ihid->reset_lock); |
2185 |
++ return ret; |
2186 |
++} |
2187 |
++ |
2188 |
++static void i2c_hid_get_input(struct i2c_hid *ihid) |
2189 |
++{ |
2190 |
++ int ret; |
2191 |
++ u32 ret_size; |
2192 |
++ int size = le16_to_cpu(ihid->hdesc.wMaxInputLength); |
2193 |
++ |
2194 |
++ if (size > ihid->bufsize) |
2195 |
++ size = ihid->bufsize; |
2196 |
++ |
2197 |
++ ret = i2c_master_recv(ihid->client, ihid->inbuf, size); |
2198 |
++ if (ret != size) { |
2199 |
++ if (ret < 0) |
2200 |
++ return; |
2201 |
++ |
2202 |
++ dev_err(&ihid->client->dev, "%s: got %d data instead of %d\n", |
2203 |
++ __func__, ret, size); |
2204 |
++ return; |
2205 |
++ } |
2206 |
++ |
2207 |
++ ret_size = ihid->inbuf[0] | ihid->inbuf[1] << 8; |
2208 |
++ |
2209 |
++ if (!ret_size) { |
2210 |
++ /* host or device initiated RESET completed */ |
2211 |
++ if (test_and_clear_bit(I2C_HID_RESET_PENDING, &ihid->flags)) |
2212 |
++ wake_up(&ihid->wait); |
2213 |
++ return; |
2214 |
++ } |
2215 |
++ |
2216 |
++ if ((ret_size > size) || (ret_size < 2)) { |
2217 |
++ dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n", |
2218 |
++ __func__, size, ret_size); |
2219 |
++ return; |
2220 |
++ } |
2221 |
++ |
2222 |
++ i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf); |
2223 |
++ |
2224 |
++ if (test_bit(I2C_HID_STARTED, &ihid->flags)) |
2225 |
++ hid_input_report(ihid->hid, HID_INPUT_REPORT, ihid->inbuf + 2, |
2226 |
++ ret_size - 2, 1); |
2227 |
++ |
2228 |
++ return; |
2229 |
++} |
2230 |
++ |
2231 |
++static irqreturn_t i2c_hid_irq(int irq, void *dev_id) |
2232 |
++{ |
2233 |
++ struct i2c_hid *ihid = dev_id; |
2234 |
++ |
2235 |
++ if (test_bit(I2C_HID_READ_PENDING, &ihid->flags)) |
2236 |
++ return IRQ_HANDLED; |
2237 |
++ |
2238 |
++ i2c_hid_get_input(ihid); |
2239 |
++ |
2240 |
++ return IRQ_HANDLED; |
2241 |
++} |
2242 |
++ |
2243 |
++static int i2c_hid_get_report_length(struct hid_report *report) |
2244 |
++{ |
2245 |
++ return ((report->size - 1) >> 3) + 1 + |
2246 |
++ report->device->report_enum[report->type].numbered + 2; |
2247 |
++} |
2248 |
++ |
2249 |
++/* |
2250 |
++ * Traverse the supplied list of reports and find the longest |
2251 |
++ */ |
2252 |
++static void i2c_hid_find_max_report(struct hid_device *hid, unsigned int type, |
2253 |
++ unsigned int *max) |
2254 |
++{ |
2255 |
++ struct hid_report *report; |
2256 |
++ unsigned int size; |
2257 |
++ |
2258 |
++ /* We should not rely on wMaxInputLength, as some devices may set it to |
2259 |
++ * a wrong length. */ |
2260 |
++ list_for_each_entry(report, &hid->report_enum[type].report_list, list) { |
2261 |
++ size = i2c_hid_get_report_length(report); |
2262 |
++ if (*max < size) |
2263 |
++ *max = size; |
2264 |
++ } |
2265 |
++} |
2266 |
++ |
2267 |
++static void i2c_hid_free_buffers(struct i2c_hid *ihid) |
2268 |
++{ |
2269 |
++ kfree(ihid->inbuf); |
2270 |
++ kfree(ihid->rawbuf); |
2271 |
++ kfree(ihid->argsbuf); |
2272 |
++ kfree(ihid->cmdbuf); |
2273 |
++ ihid->inbuf = NULL; |
2274 |
++ ihid->rawbuf = NULL; |
2275 |
++ ihid->cmdbuf = NULL; |
2276 |
++ ihid->argsbuf = NULL; |
2277 |
++ ihid->bufsize = 0; |
2278 |
++} |
2279 |
++ |
2280 |
++static int i2c_hid_alloc_buffers(struct i2c_hid *ihid, size_t report_size) |
2281 |
++{ |
2282 |
++ /* the worst case is computed from the set_report command with a |
2283 |
++ * reportID > 15 and the maximum report length */ |
2284 |
++ int args_len = sizeof(__u8) + /* ReportID */ |
2285 |
++ sizeof(__u8) + /* optional ReportID byte */ |
2286 |
++ sizeof(__u16) + /* data register */ |
2287 |
++ sizeof(__u16) + /* size of the report */ |
2288 |
++ report_size; /* report */ |
2289 |
++ |
2290 |
++ ihid->inbuf = kzalloc(report_size, GFP_KERNEL); |
2291 |
++ ihid->rawbuf = kzalloc(report_size, GFP_KERNEL); |
2292 |
++ ihid->argsbuf = kzalloc(args_len, GFP_KERNEL); |
2293 |
++ ihid->cmdbuf = kzalloc(sizeof(union command) + args_len, GFP_KERNEL); |
2294 |
++ |
2295 |
++ if (!ihid->inbuf || !ihid->rawbuf || !ihid->argsbuf || !ihid->cmdbuf) { |
2296 |
++ i2c_hid_free_buffers(ihid); |
2297 |
++ return -ENOMEM; |
2298 |
++ } |
2299 |
++ |
2300 |
++ ihid->bufsize = report_size; |
2301 |
++ |
2302 |
++ return 0; |
2303 |
++} |
2304 |
++ |
2305 |
++static int i2c_hid_get_raw_report(struct hid_device *hid, |
2306 |
++ unsigned char report_number, __u8 *buf, size_t count, |
2307 |
++ unsigned char report_type) |
2308 |
++{ |
2309 |
++ struct i2c_client *client = hid->driver_data; |
2310 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2311 |
++ size_t ret_count, ask_count; |
2312 |
++ int ret; |
2313 |
++ |
2314 |
++ if (report_type == HID_OUTPUT_REPORT) |
2315 |
++ return -EINVAL; |
2316 |
++ |
2317 |
++ /* +2 bytes to include the size of the reply in the query buffer */ |
2318 |
++ ask_count = min(count + 2, (size_t)ihid->bufsize); |
2319 |
++ |
2320 |
++ ret = i2c_hid_get_report(client, |
2321 |
++ report_type == HID_FEATURE_REPORT ? 0x03 : 0x01, |
2322 |
++ report_number, ihid->rawbuf, ask_count); |
2323 |
++ |
2324 |
++ if (ret < 0) |
2325 |
++ return ret; |
2326 |
++ |
2327 |
++ ret_count = ihid->rawbuf[0] | (ihid->rawbuf[1] << 8); |
2328 |
++ |
2329 |
++ if (ret_count <= 2) |
2330 |
++ return 0; |
2331 |
++ |
2332 |
++ ret_count = min(ret_count, ask_count); |
2333 |
++ |
2334 |
++ /* The query buffer contains the size, dropping it in the reply */ |
2335 |
++ count = min(count, ret_count - 2); |
2336 |
++ memcpy(buf, ihid->rawbuf + 2, count); |
2337 |
++ |
2338 |
++ return count; |
2339 |
++} |
2340 |
++ |
2341 |
++static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf, |
2342 |
++ size_t count, unsigned char report_type, bool use_data) |
2343 |
++{ |
2344 |
++ struct i2c_client *client = hid->driver_data; |
2345 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2346 |
++ int report_id = buf[0]; |
2347 |
++ int ret; |
2348 |
++ |
2349 |
++ if (report_type == HID_INPUT_REPORT) |
2350 |
++ return -EINVAL; |
2351 |
++ |
2352 |
++ mutex_lock(&ihid->reset_lock); |
2353 |
++ |
2354 |
++ if (report_id) { |
2355 |
++ buf++; |
2356 |
++ count--; |
2357 |
++ } |
2358 |
++ |
2359 |
++ ret = i2c_hid_set_or_send_report(client, |
2360 |
++ report_type == HID_FEATURE_REPORT ? 0x03 : 0x02, |
2361 |
++ report_id, buf, count, use_data); |
2362 |
++ |
2363 |
++ if (report_id && ret >= 0) |
2364 |
++ ret++; /* add report_id to the number of transfered bytes */ |
2365 |
++ |
2366 |
++ mutex_unlock(&ihid->reset_lock); |
2367 |
++ |
2368 |
++ return ret; |
2369 |
++} |
2370 |
++ |
2371 |
++static int i2c_hid_output_report(struct hid_device *hid, __u8 *buf, |
2372 |
++ size_t count) |
2373 |
++{ |
2374 |
++ return i2c_hid_output_raw_report(hid, buf, count, HID_OUTPUT_REPORT, |
2375 |
++ false); |
2376 |
++} |
2377 |
++ |
2378 |
++static int i2c_hid_raw_request(struct hid_device *hid, unsigned char reportnum, |
2379 |
++ __u8 *buf, size_t len, unsigned char rtype, |
2380 |
++ int reqtype) |
2381 |
++{ |
2382 |
++ switch (reqtype) { |
2383 |
++ case HID_REQ_GET_REPORT: |
2384 |
++ return i2c_hid_get_raw_report(hid, reportnum, buf, len, rtype); |
2385 |
++ case HID_REQ_SET_REPORT: |
2386 |
++ if (buf[0] != reportnum) |
2387 |
++ return -EINVAL; |
2388 |
++ return i2c_hid_output_raw_report(hid, buf, len, rtype, true); |
2389 |
++ default: |
2390 |
++ return -EIO; |
2391 |
++ } |
2392 |
++} |
2393 |
++ |
2394 |
++static int i2c_hid_parse(struct hid_device *hid) |
2395 |
++{ |
2396 |
++ struct i2c_client *client = hid->driver_data; |
2397 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2398 |
++ struct i2c_hid_desc *hdesc = &ihid->hdesc; |
2399 |
++ unsigned int rsize; |
2400 |
++ char *rdesc; |
2401 |
++ int ret; |
2402 |
++ int tries = 3; |
2403 |
++ char *use_override; |
2404 |
++ |
2405 |
++ i2c_hid_dbg(ihid, "entering %s\n", __func__); |
2406 |
++ |
2407 |
++ rsize = le16_to_cpu(hdesc->wReportDescLength); |
2408 |
++ if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) { |
2409 |
++ dbg_hid("weird size of report descriptor (%u)\n", rsize); |
2410 |
++ return -EINVAL; |
2411 |
++ } |
2412 |
++ |
2413 |
++ do { |
2414 |
++ ret = i2c_hid_hwreset(client); |
2415 |
++ if (ret) |
2416 |
++ msleep(1000); |
2417 |
++ } while (tries-- > 0 && ret); |
2418 |
++ |
2419 |
++ if (ret) |
2420 |
++ return ret; |
2421 |
++ |
2422 |
++ use_override = i2c_hid_get_dmi_hid_report_desc_override(client->name, |
2423 |
++ &rsize); |
2424 |
++ |
2425 |
++ if (use_override) { |
2426 |
++ rdesc = use_override; |
2427 |
++ i2c_hid_dbg(ihid, "Using a HID report descriptor override\n"); |
2428 |
++ } else { |
2429 |
++ rdesc = kzalloc(rsize, GFP_KERNEL); |
2430 |
++ |
2431 |
++ if (!rdesc) { |
2432 |
++ dbg_hid("couldn't allocate rdesc memory\n"); |
2433 |
++ return -ENOMEM; |
2434 |
++ } |
2435 |
++ |
2436 |
++ i2c_hid_dbg(ihid, "asking HID report descriptor\n"); |
2437 |
++ |
2438 |
++ ret = i2c_hid_command(client, &hid_report_descr_cmd, |
2439 |
++ rdesc, rsize); |
2440 |
++ if (ret) { |
2441 |
++ hid_err(hid, "reading report descriptor failed\n"); |
2442 |
++ kfree(rdesc); |
2443 |
++ return -EIO; |
2444 |
++ } |
2445 |
++ } |
2446 |
++ |
2447 |
++ i2c_hid_dbg(ihid, "Report Descriptor: %*ph\n", rsize, rdesc); |
2448 |
++ |
2449 |
++ ret = hid_parse_report(hid, rdesc, rsize); |
2450 |
++ if (!use_override) |
2451 |
++ kfree(rdesc); |
2452 |
++ |
2453 |
++ if (ret) { |
2454 |
++ dbg_hid("parsing report descriptor failed\n"); |
2455 |
++ return ret; |
2456 |
++ } |
2457 |
++ |
2458 |
++ return 0; |
2459 |
++} |
2460 |
++ |
2461 |
++static int i2c_hid_start(struct hid_device *hid) |
2462 |
++{ |
2463 |
++ struct i2c_client *client = hid->driver_data; |
2464 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2465 |
++ int ret; |
2466 |
++ unsigned int bufsize = HID_MIN_BUFFER_SIZE; |
2467 |
++ |
2468 |
++ i2c_hid_find_max_report(hid, HID_INPUT_REPORT, &bufsize); |
2469 |
++ i2c_hid_find_max_report(hid, HID_OUTPUT_REPORT, &bufsize); |
2470 |
++ i2c_hid_find_max_report(hid, HID_FEATURE_REPORT, &bufsize); |
2471 |
++ |
2472 |
++ if (bufsize > ihid->bufsize) { |
2473 |
++ disable_irq(client->irq); |
2474 |
++ i2c_hid_free_buffers(ihid); |
2475 |
++ |
2476 |
++ ret = i2c_hid_alloc_buffers(ihid, bufsize); |
2477 |
++ enable_irq(client->irq); |
2478 |
++ |
2479 |
++ if (ret) |
2480 |
++ return ret; |
2481 |
++ } |
2482 |
++ |
2483 |
++ return 0; |
2484 |
++} |
2485 |
++ |
2486 |
++static void i2c_hid_stop(struct hid_device *hid) |
2487 |
++{ |
2488 |
++ hid->claimed = 0; |
2489 |
++} |
2490 |
++ |
2491 |
++static int i2c_hid_open(struct hid_device *hid) |
2492 |
++{ |
2493 |
++ struct i2c_client *client = hid->driver_data; |
2494 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2495 |
++ int ret = 0; |
2496 |
++ |
2497 |
++ ret = pm_runtime_get_sync(&client->dev); |
2498 |
++ if (ret < 0) |
2499 |
++ return ret; |
2500 |
++ |
2501 |
++ set_bit(I2C_HID_STARTED, &ihid->flags); |
2502 |
++ return 0; |
2503 |
++} |
2504 |
++ |
2505 |
++static void i2c_hid_close(struct hid_device *hid) |
2506 |
++{ |
2507 |
++ struct i2c_client *client = hid->driver_data; |
2508 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2509 |
++ |
2510 |
++ clear_bit(I2C_HID_STARTED, &ihid->flags); |
2511 |
++ |
2512 |
++ /* Save some power */ |
2513 |
++ pm_runtime_put(&client->dev); |
2514 |
++} |
2515 |
++ |
2516 |
++static int i2c_hid_power(struct hid_device *hid, int lvl) |
2517 |
++{ |
2518 |
++ struct i2c_client *client = hid->driver_data; |
2519 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2520 |
++ |
2521 |
++ i2c_hid_dbg(ihid, "%s lvl:%d\n", __func__, lvl); |
2522 |
++ |
2523 |
++ switch (lvl) { |
2524 |
++ case PM_HINT_FULLON: |
2525 |
++ pm_runtime_get_sync(&client->dev); |
2526 |
++ break; |
2527 |
++ case PM_HINT_NORMAL: |
2528 |
++ pm_runtime_put(&client->dev); |
2529 |
++ break; |
2530 |
++ } |
2531 |
++ return 0; |
2532 |
++} |
2533 |
++ |
2534 |
++struct hid_ll_driver i2c_hid_ll_driver = { |
2535 |
++ .parse = i2c_hid_parse, |
2536 |
++ .start = i2c_hid_start, |
2537 |
++ .stop = i2c_hid_stop, |
2538 |
++ .open = i2c_hid_open, |
2539 |
++ .close = i2c_hid_close, |
2540 |
++ .power = i2c_hid_power, |
2541 |
++ .output_report = i2c_hid_output_report, |
2542 |
++ .raw_request = i2c_hid_raw_request, |
2543 |
++}; |
2544 |
++EXPORT_SYMBOL_GPL(i2c_hid_ll_driver); |
2545 |
++ |
2546 |
++static int i2c_hid_init_irq(struct i2c_client *client) |
2547 |
++{ |
2548 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2549 |
++ unsigned long irqflags = 0; |
2550 |
++ int ret; |
2551 |
++ |
2552 |
++ dev_dbg(&client->dev, "Requesting IRQ: %d\n", client->irq); |
2553 |
++ |
2554 |
++ if (!irq_get_trigger_type(client->irq)) |
2555 |
++ irqflags = IRQF_TRIGGER_LOW; |
2556 |
++ |
2557 |
++ ret = request_threaded_irq(client->irq, NULL, i2c_hid_irq, |
2558 |
++ irqflags | IRQF_ONESHOT, client->name, ihid); |
2559 |
++ if (ret < 0) { |
2560 |
++ dev_warn(&client->dev, |
2561 |
++ "Could not register for %s interrupt, irq = %d," |
2562 |
++ " ret = %d\n", |
2563 |
++ client->name, client->irq, ret); |
2564 |
++ |
2565 |
++ return ret; |
2566 |
++ } |
2567 |
++ |
2568 |
++ return 0; |
2569 |
++} |
2570 |
++ |
2571 |
++static int i2c_hid_fetch_hid_descriptor(struct i2c_hid *ihid) |
2572 |
++{ |
2573 |
++ struct i2c_client *client = ihid->client; |
2574 |
++ struct i2c_hid_desc *hdesc = &ihid->hdesc; |
2575 |
++ unsigned int dsize; |
2576 |
++ int ret; |
2577 |
++ |
2578 |
++ /* i2c hid fetch using a fixed descriptor size (30 bytes) */ |
2579 |
++ if (i2c_hid_get_dmi_i2c_hid_desc_override(client->name)) { |
2580 |
++ i2c_hid_dbg(ihid, "Using a HID descriptor override\n"); |
2581 |
++ ihid->hdesc = |
2582 |
++ *i2c_hid_get_dmi_i2c_hid_desc_override(client->name); |
2583 |
++ } else { |
2584 |
++ i2c_hid_dbg(ihid, "Fetching the HID descriptor\n"); |
2585 |
++ ret = i2c_hid_command(client, &hid_descr_cmd, |
2586 |
++ ihid->hdesc_buffer, |
2587 |
++ sizeof(struct i2c_hid_desc)); |
2588 |
++ if (ret) { |
2589 |
++ dev_err(&client->dev, "hid_descr_cmd failed\n"); |
2590 |
++ return -ENODEV; |
2591 |
++ } |
2592 |
++ } |
2593 |
++ |
2594 |
++ /* Validate the length of HID descriptor, the 4 first bytes: |
2595 |
++ * bytes 0-1 -> length |
2596 |
++ * bytes 2-3 -> bcdVersion (has to be 1.00) */ |
2597 |
++ /* check bcdVersion == 1.0 */ |
2598 |
++ if (le16_to_cpu(hdesc->bcdVersion) != 0x0100) { |
2599 |
++ dev_err(&client->dev, |
2600 |
++ "unexpected HID descriptor bcdVersion (0x%04hx)\n", |
2601 |
++ le16_to_cpu(hdesc->bcdVersion)); |
2602 |
++ return -ENODEV; |
2603 |
++ } |
2604 |
++ |
2605 |
++ /* Descriptor length should be 30 bytes as per the specification */ |
2606 |
++ dsize = le16_to_cpu(hdesc->wHIDDescLength); |
2607 |
++ if (dsize != sizeof(struct i2c_hid_desc)) { |
2608 |
++ dev_err(&client->dev, "weird size of HID descriptor (%u)\n", |
2609 |
++ dsize); |
2610 |
++ return -ENODEV; |
2611 |
++ } |
2612 |
++ i2c_hid_dbg(ihid, "HID Descriptor: %*ph\n", dsize, ihid->hdesc_buffer); |
2613 |
++ return 0; |
2614 |
++} |
2615 |
++ |
2616 |
++#ifdef CONFIG_ACPI |
2617 |
++static const struct acpi_device_id i2c_hid_acpi_blacklist[] = { |
2618 |
++ /* |
2619 |
++ * The CHPN0001 ACPI device, which is used to describe the Chipone |
2620 |
++ * ICN8505 controller, has a _CID of PNP0C50 but is not HID compatible. |
2621 |
++ */ |
2622 |
++ {"CHPN0001", 0 }, |
2623 |
++ { }, |
2624 |
++}; |
2625 |
++ |
2626 |
++static int i2c_hid_acpi_pdata(struct i2c_client *client, |
2627 |
++ struct i2c_hid_platform_data *pdata) |
2628 |
++{ |
2629 |
++ static guid_t i2c_hid_guid = |
2630 |
++ GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555, |
2631 |
++ 0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE); |
2632 |
++ union acpi_object *obj; |
2633 |
++ struct acpi_device *adev; |
2634 |
++ acpi_handle handle; |
2635 |
++ |
2636 |
++ handle = ACPI_HANDLE(&client->dev); |
2637 |
++ if (!handle || acpi_bus_get_device(handle, &adev)) { |
2638 |
++ dev_err(&client->dev, "Error could not get ACPI device\n"); |
2639 |
++ return -ENODEV; |
2640 |
++ } |
2641 |
++ |
2642 |
++ if (acpi_match_device_ids(adev, i2c_hid_acpi_blacklist) == 0) |
2643 |
++ return -ENODEV; |
2644 |
++ |
2645 |
++ obj = acpi_evaluate_dsm_typed(handle, &i2c_hid_guid, 1, 1, NULL, |
2646 |
++ ACPI_TYPE_INTEGER); |
2647 |
++ if (!obj) { |
2648 |
++ dev_err(&client->dev, "Error _DSM call to get HID descriptor address failed\n"); |
2649 |
++ return -ENODEV; |
2650 |
++ } |
2651 |
++ |
2652 |
++ pdata->hid_descriptor_address = obj->integer.value; |
2653 |
++ ACPI_FREE(obj); |
2654 |
++ |
2655 |
++ return 0; |
2656 |
++} |
2657 |
++ |
2658 |
++static void i2c_hid_acpi_fix_up_power(struct device *dev) |
2659 |
++{ |
2660 |
++ struct acpi_device *adev; |
2661 |
++ |
2662 |
++ adev = ACPI_COMPANION(dev); |
2663 |
++ if (adev) |
2664 |
++ acpi_device_fix_up_power(adev); |
2665 |
++} |
2666 |
++ |
2667 |
++static const struct acpi_device_id i2c_hid_acpi_match[] = { |
2668 |
++ {"ACPI0C50", 0 }, |
2669 |
++ {"PNP0C50", 0 }, |
2670 |
++ { }, |
2671 |
++}; |
2672 |
++MODULE_DEVICE_TABLE(acpi, i2c_hid_acpi_match); |
2673 |
++#else |
2674 |
++static inline int i2c_hid_acpi_pdata(struct i2c_client *client, |
2675 |
++ struct i2c_hid_platform_data *pdata) |
2676 |
++{ |
2677 |
++ return -ENODEV; |
2678 |
++} |
2679 |
++ |
2680 |
++static inline void i2c_hid_acpi_fix_up_power(struct device *dev) {} |
2681 |
++#endif |
2682 |
++ |
2683 |
++#ifdef CONFIG_OF |
2684 |
++static int i2c_hid_of_probe(struct i2c_client *client, |
2685 |
++ struct i2c_hid_platform_data *pdata) |
2686 |
++{ |
2687 |
++ struct device *dev = &client->dev; |
2688 |
++ u32 val; |
2689 |
++ int ret; |
2690 |
++ |
2691 |
++ ret = of_property_read_u32(dev->of_node, "hid-descr-addr", &val); |
2692 |
++ if (ret) { |
2693 |
++ dev_err(&client->dev, "HID register address not provided\n"); |
2694 |
++ return -ENODEV; |
2695 |
++ } |
2696 |
++ if (val >> 16) { |
2697 |
++ dev_err(&client->dev, "Bad HID register address: 0x%08x\n", |
2698 |
++ val); |
2699 |
++ return -EINVAL; |
2700 |
++ } |
2701 |
++ pdata->hid_descriptor_address = val; |
2702 |
++ |
2703 |
++ return 0; |
2704 |
++} |
2705 |
++ |
2706 |
++static const struct of_device_id i2c_hid_of_match[] = { |
2707 |
++ { .compatible = "hid-over-i2c" }, |
2708 |
++ {}, |
2709 |
++}; |
2710 |
++MODULE_DEVICE_TABLE(of, i2c_hid_of_match); |
2711 |
++#else |
2712 |
++static inline int i2c_hid_of_probe(struct i2c_client *client, |
2713 |
++ struct i2c_hid_platform_data *pdata) |
2714 |
++{ |
2715 |
++ return -ENODEV; |
2716 |
++} |
2717 |
++#endif |
2718 |
++ |
2719 |
++static void i2c_hid_fwnode_probe(struct i2c_client *client, |
2720 |
++ struct i2c_hid_platform_data *pdata) |
2721 |
++{ |
2722 |
++ u32 val; |
2723 |
++ |
2724 |
++ if (!device_property_read_u32(&client->dev, "post-power-on-delay-ms", |
2725 |
++ &val)) |
2726 |
++ pdata->post_power_delay_ms = val; |
2727 |
++} |
2728 |
++ |
2729 |
++static int i2c_hid_probe(struct i2c_client *client, |
2730 |
++ const struct i2c_device_id *dev_id) |
2731 |
++{ |
2732 |
++ int ret; |
2733 |
++ struct i2c_hid *ihid; |
2734 |
++ struct hid_device *hid; |
2735 |
++ __u16 hidRegister; |
2736 |
++ struct i2c_hid_platform_data *platform_data = client->dev.platform_data; |
2737 |
++ |
2738 |
++ dbg_hid("HID probe called for i2c 0x%02x\n", client->addr); |
2739 |
++ |
2740 |
++ if (!client->irq) { |
2741 |
++ dev_err(&client->dev, |
2742 |
++ "HID over i2c has not been provided an Int IRQ\n"); |
2743 |
++ return -EINVAL; |
2744 |
++ } |
2745 |
++ |
2746 |
++ if (client->irq < 0) { |
2747 |
++ if (client->irq != -EPROBE_DEFER) |
2748 |
++ dev_err(&client->dev, |
2749 |
++ "HID over i2c doesn't have a valid IRQ\n"); |
2750 |
++ return client->irq; |
2751 |
++ } |
2752 |
++ |
2753 |
++ ihid = devm_kzalloc(&client->dev, sizeof(*ihid), GFP_KERNEL); |
2754 |
++ if (!ihid) |
2755 |
++ return -ENOMEM; |
2756 |
++ |
2757 |
++ if (client->dev.of_node) { |
2758 |
++ ret = i2c_hid_of_probe(client, &ihid->pdata); |
2759 |
++ if (ret) |
2760 |
++ return ret; |
2761 |
++ } else if (!platform_data) { |
2762 |
++ ret = i2c_hid_acpi_pdata(client, &ihid->pdata); |
2763 |
++ if (ret) |
2764 |
++ return ret; |
2765 |
++ } else { |
2766 |
++ ihid->pdata = *platform_data; |
2767 |
++ } |
2768 |
++ |
2769 |
++ /* Parse platform agnostic common properties from ACPI / device tree */ |
2770 |
++ i2c_hid_fwnode_probe(client, &ihid->pdata); |
2771 |
++ |
2772 |
++ ihid->pdata.supplies[0].supply = "vdd"; |
2773 |
++ ihid->pdata.supplies[1].supply = "vddl"; |
2774 |
++ |
2775 |
++ ret = devm_regulator_bulk_get(&client->dev, |
2776 |
++ ARRAY_SIZE(ihid->pdata.supplies), |
2777 |
++ ihid->pdata.supplies); |
2778 |
++ if (ret) |
2779 |
++ return ret; |
2780 |
++ |
2781 |
++ ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies), |
2782 |
++ ihid->pdata.supplies); |
2783 |
++ if (ret < 0) |
2784 |
++ return ret; |
2785 |
++ |
2786 |
++ if (ihid->pdata.post_power_delay_ms) |
2787 |
++ msleep(ihid->pdata.post_power_delay_ms); |
2788 |
++ |
2789 |
++ i2c_set_clientdata(client, ihid); |
2790 |
++ |
2791 |
++ ihid->client = client; |
2792 |
++ |
2793 |
++ hidRegister = ihid->pdata.hid_descriptor_address; |
2794 |
++ ihid->wHIDDescRegister = cpu_to_le16(hidRegister); |
2795 |
++ |
2796 |
++ init_waitqueue_head(&ihid->wait); |
2797 |
++ mutex_init(&ihid->reset_lock); |
2798 |
++ |
2799 |
++ /* we need to allocate the command buffer without knowing the maximum |
2800 |
++ * size of the reports. Let's use HID_MIN_BUFFER_SIZE, then we do the |
2801 |
++ * real computation later. */ |
2802 |
++ ret = i2c_hid_alloc_buffers(ihid, HID_MIN_BUFFER_SIZE); |
2803 |
++ if (ret < 0) |
2804 |
++ goto err_regulator; |
2805 |
++ |
2806 |
++ i2c_hid_acpi_fix_up_power(&client->dev); |
2807 |
++ |
2808 |
++ pm_runtime_get_noresume(&client->dev); |
2809 |
++ pm_runtime_set_active(&client->dev); |
2810 |
++ pm_runtime_enable(&client->dev); |
2811 |
++ device_enable_async_suspend(&client->dev); |
2812 |
++ |
2813 |
++ /* Make sure there is something at this address */ |
2814 |
++ ret = i2c_smbus_read_byte(client); |
2815 |
++ if (ret < 0) { |
2816 |
++ dev_dbg(&client->dev, "nothing at this address: %d\n", ret); |
2817 |
++ ret = -ENXIO; |
2818 |
++ goto err_pm; |
2819 |
++ } |
2820 |
++ |
2821 |
++ ret = i2c_hid_fetch_hid_descriptor(ihid); |
2822 |
++ if (ret < 0) |
2823 |
++ goto err_pm; |
2824 |
++ |
2825 |
++ ret = i2c_hid_init_irq(client); |
2826 |
++ if (ret < 0) |
2827 |
++ goto err_pm; |
2828 |
++ |
2829 |
++ hid = hid_allocate_device(); |
2830 |
++ if (IS_ERR(hid)) { |
2831 |
++ ret = PTR_ERR(hid); |
2832 |
++ goto err_irq; |
2833 |
++ } |
2834 |
++ |
2835 |
++ ihid->hid = hid; |
2836 |
++ |
2837 |
++ hid->driver_data = client; |
2838 |
++ hid->ll_driver = &i2c_hid_ll_driver; |
2839 |
++ hid->dev.parent = &client->dev; |
2840 |
++ hid->bus = BUS_I2C; |
2841 |
++ hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); |
2842 |
++ hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); |
2843 |
++ hid->product = le16_to_cpu(ihid->hdesc.wProductID); |
2844 |
++ |
2845 |
++ snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX", |
2846 |
++ client->name, hid->vendor, hid->product); |
2847 |
++ strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); |
2848 |
++ |
2849 |
++ ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); |
2850 |
++ |
2851 |
++ ret = hid_add_device(hid); |
2852 |
++ if (ret) { |
2853 |
++ if (ret != -ENODEV) |
2854 |
++ hid_err(client, "can't add hid device: %d\n", ret); |
2855 |
++ goto err_mem_free; |
2856 |
++ } |
2857 |
++ |
2858 |
++ if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM)) |
2859 |
++ pm_runtime_put(&client->dev); |
2860 |
++ |
2861 |
++ return 0; |
2862 |
++ |
2863 |
++err_mem_free: |
2864 |
++ hid_destroy_device(hid); |
2865 |
++ |
2866 |
++err_irq: |
2867 |
++ free_irq(client->irq, ihid); |
2868 |
++ |
2869 |
++err_pm: |
2870 |
++ pm_runtime_put_noidle(&client->dev); |
2871 |
++ pm_runtime_disable(&client->dev); |
2872 |
++ |
2873 |
++err_regulator: |
2874 |
++ regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), |
2875 |
++ ihid->pdata.supplies); |
2876 |
++ i2c_hid_free_buffers(ihid); |
2877 |
++ return ret; |
2878 |
++} |
2879 |
++ |
2880 |
++static int i2c_hid_remove(struct i2c_client *client) |
2881 |
++{ |
2882 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2883 |
++ struct hid_device *hid; |
2884 |
++ |
2885 |
++ if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM)) |
2886 |
++ pm_runtime_get_sync(&client->dev); |
2887 |
++ pm_runtime_disable(&client->dev); |
2888 |
++ pm_runtime_set_suspended(&client->dev); |
2889 |
++ pm_runtime_put_noidle(&client->dev); |
2890 |
++ |
2891 |
++ hid = ihid->hid; |
2892 |
++ hid_destroy_device(hid); |
2893 |
++ |
2894 |
++ free_irq(client->irq, ihid); |
2895 |
++ |
2896 |
++ if (ihid->bufsize) |
2897 |
++ i2c_hid_free_buffers(ihid); |
2898 |
++ |
2899 |
++ regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), |
2900 |
++ ihid->pdata.supplies); |
2901 |
++ |
2902 |
++ return 0; |
2903 |
++} |
2904 |
++ |
2905 |
++static void i2c_hid_shutdown(struct i2c_client *client) |
2906 |
++{ |
2907 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2908 |
++ |
2909 |
++ i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
2910 |
++ free_irq(client->irq, ihid); |
2911 |
++} |
2912 |
++ |
2913 |
++#ifdef CONFIG_PM_SLEEP |
2914 |
++static int i2c_hid_suspend(struct device *dev) |
2915 |
++{ |
2916 |
++ struct i2c_client *client = to_i2c_client(dev); |
2917 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2918 |
++ struct hid_device *hid = ihid->hid; |
2919 |
++ int ret; |
2920 |
++ int wake_status; |
2921 |
++ |
2922 |
++ if (hid->driver && hid->driver->suspend) { |
2923 |
++ /* |
2924 |
++ * Wake up the device so that IO issues in |
2925 |
++ * HID driver's suspend code can succeed. |
2926 |
++ */ |
2927 |
++ ret = pm_runtime_resume(dev); |
2928 |
++ if (ret < 0) |
2929 |
++ return ret; |
2930 |
++ |
2931 |
++ ret = hid->driver->suspend(hid, PMSG_SUSPEND); |
2932 |
++ if (ret < 0) |
2933 |
++ return ret; |
2934 |
++ } |
2935 |
++ |
2936 |
++ if (!pm_runtime_suspended(dev)) { |
2937 |
++ /* Save some power */ |
2938 |
++ i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
2939 |
++ |
2940 |
++ disable_irq(client->irq); |
2941 |
++ } |
2942 |
++ |
2943 |
++ if (device_may_wakeup(&client->dev)) { |
2944 |
++ wake_status = enable_irq_wake(client->irq); |
2945 |
++ if (!wake_status) |
2946 |
++ ihid->irq_wake_enabled = true; |
2947 |
++ else |
2948 |
++ hid_warn(hid, "Failed to enable irq wake: %d\n", |
2949 |
++ wake_status); |
2950 |
++ } else { |
2951 |
++ regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), |
2952 |
++ ihid->pdata.supplies); |
2953 |
++ } |
2954 |
++ |
2955 |
++ return 0; |
2956 |
++} |
2957 |
++ |
2958 |
++static int i2c_hid_resume(struct device *dev) |
2959 |
++{ |
2960 |
++ int ret; |
2961 |
++ struct i2c_client *client = to_i2c_client(dev); |
2962 |
++ struct i2c_hid *ihid = i2c_get_clientdata(client); |
2963 |
++ struct hid_device *hid = ihid->hid; |
2964 |
++ int wake_status; |
2965 |
++ |
2966 |
++ if (!device_may_wakeup(&client->dev)) { |
2967 |
++ ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies), |
2968 |
++ ihid->pdata.supplies); |
2969 |
++ if (ret) |
2970 |
++ hid_warn(hid, "Failed to enable supplies: %d\n", ret); |
2971 |
++ |
2972 |
++ if (ihid->pdata.post_power_delay_ms) |
2973 |
++ msleep(ihid->pdata.post_power_delay_ms); |
2974 |
++ } else if (ihid->irq_wake_enabled) { |
2975 |
++ wake_status = disable_irq_wake(client->irq); |
2976 |
++ if (!wake_status) |
2977 |
++ ihid->irq_wake_enabled = false; |
2978 |
++ else |
2979 |
++ hid_warn(hid, "Failed to disable irq wake: %d\n", |
2980 |
++ wake_status); |
2981 |
++ } |
2982 |
++ |
2983 |
++ /* We'll resume to full power */ |
2984 |
++ pm_runtime_disable(dev); |
2985 |
++ pm_runtime_set_active(dev); |
2986 |
++ pm_runtime_enable(dev); |
2987 |
++ |
2988 |
++ enable_irq(client->irq); |
2989 |
++ |
2990 |
++ /* Instead of resetting device, simply powers the device on. This |
2991 |
++ * solves "incomplete reports" on Raydium devices 2386:3118 and |
2992 |
++ * 2386:4B33 and fixes various SIS touchscreens no longer sending |
2993 |
++ * data after a suspend/resume. |
2994 |
++ */ |
2995 |
++ ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); |
2996 |
++ if (ret) |
2997 |
++ return ret; |
2998 |
++ |
2999 |
++ if (hid->driver && hid->driver->reset_resume) { |
3000 |
++ ret = hid->driver->reset_resume(hid); |
3001 |
++ return ret; |
3002 |
++ } |
3003 |
++ |
3004 |
++ return 0; |
3005 |
++} |
3006 |
++#endif |
3007 |
++ |
3008 |
++#ifdef CONFIG_PM |
3009 |
++static int i2c_hid_runtime_suspend(struct device *dev) |
3010 |
++{ |
3011 |
++ struct i2c_client *client = to_i2c_client(dev); |
3012 |
++ |
3013 |
++ i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
3014 |
++ disable_irq(client->irq); |
3015 |
++ return 0; |
3016 |
++} |
3017 |
++ |
3018 |
++static int i2c_hid_runtime_resume(struct device *dev) |
3019 |
++{ |
3020 |
++ struct i2c_client *client = to_i2c_client(dev); |
3021 |
++ |
3022 |
++ enable_irq(client->irq); |
3023 |
++ i2c_hid_set_power(client, I2C_HID_PWR_ON); |
3024 |
++ return 0; |
3025 |
++} |
3026 |
++#endif |
3027 |
++ |
3028 |
++static const struct dev_pm_ops i2c_hid_pm = { |
3029 |
++ SET_SYSTEM_SLEEP_PM_OPS(i2c_hid_suspend, i2c_hid_resume) |
3030 |
++ SET_RUNTIME_PM_OPS(i2c_hid_runtime_suspend, i2c_hid_runtime_resume, |
3031 |
++ NULL) |
3032 |
++}; |
3033 |
++ |
3034 |
++static const struct i2c_device_id i2c_hid_id_table[] = { |
3035 |
++ { "hid", 0 }, |
3036 |
++ { "hid-over-i2c", 0 }, |
3037 |
++ { }, |
3038 |
++}; |
3039 |
++MODULE_DEVICE_TABLE(i2c, i2c_hid_id_table); |
3040 |
++ |
3041 |
++ |
3042 |
++static struct i2c_driver i2c_hid_driver = { |
3043 |
++ .driver = { |
3044 |
++ .name = "i2c_hid", |
3045 |
++ .pm = &i2c_hid_pm, |
3046 |
++ .acpi_match_table = ACPI_PTR(i2c_hid_acpi_match), |
3047 |
++ .of_match_table = of_match_ptr(i2c_hid_of_match), |
3048 |
++ }, |
3049 |
++ |
3050 |
++ .probe = i2c_hid_probe, |
3051 |
++ .remove = i2c_hid_remove, |
3052 |
++ .shutdown = i2c_hid_shutdown, |
3053 |
++ .id_table = i2c_hid_id_table, |
3054 |
++}; |
3055 |
++ |
3056 |
++module_i2c_driver(i2c_hid_driver); |
3057 |
++ |
3058 |
++MODULE_DESCRIPTION("HID over I2C core driver"); |
3059 |
++MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@×××××.com>"); |
3060 |
++MODULE_LICENSE("GPL"); |
3061 |
+diff --git a/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c b/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c |
3062 |
+new file mode 100644 |
3063 |
+index 000000000000..1d645c9ab417 |
3064 |
+--- /dev/null |
3065 |
++++ b/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c |
3066 |
+@@ -0,0 +1,376 @@ |
3067 |
++// SPDX-License-Identifier: GPL-2.0+ |
3068 |
++ |
3069 |
++/* |
3070 |
++ * Quirks for I2C-HID devices that do not supply proper descriptors |
3071 |
++ * |
3072 |
++ * Copyright (c) 2018 Julian Sax <jsbc@×××.de> |
3073 |
++ * |
3074 |
++ */ |
3075 |
++ |
3076 |
++#include <linux/types.h> |
3077 |
++#include <linux/dmi.h> |
3078 |
++#include <linux/mod_devicetable.h> |
3079 |
++ |
3080 |
++#include "i2c-hid.h" |
3081 |
++ |
3082 |
++ |
3083 |
++struct i2c_hid_desc_override { |
3084 |
++ union { |
3085 |
++ struct i2c_hid_desc *i2c_hid_desc; |
3086 |
++ uint8_t *i2c_hid_desc_buffer; |
3087 |
++ }; |
3088 |
++ uint8_t *hid_report_desc; |
3089 |
++ unsigned int hid_report_desc_size; |
3090 |
++ uint8_t *i2c_name; |
3091 |
++}; |
3092 |
++ |
3093 |
++ |
3094 |
++/* |
3095 |
++ * descriptors for the SIPODEV SP1064 touchpad |
3096 |
++ * |
3097 |
++ * This device does not supply any descriptors and on windows a filter |
3098 |
++ * driver operates between the i2c-hid layer and the device and injects |
3099 |
++ * these descriptors when the device is prompted. The descriptors were |
3100 |
++ * extracted by listening to the i2c-hid traffic that occurs between the |
3101 |
++ * windows filter driver and the windows i2c-hid driver. |
3102 |
++ */ |
3103 |
++ |
3104 |
++static const struct i2c_hid_desc_override sipodev_desc = { |
3105 |
++ .i2c_hid_desc_buffer = (uint8_t []) |
3106 |
++ {0x1e, 0x00, /* Length of descriptor */ |
3107 |
++ 0x00, 0x01, /* Version of descriptor */ |
3108 |
++ 0xdb, 0x01, /* Length of report descriptor */ |
3109 |
++ 0x21, 0x00, /* Location of report descriptor */ |
3110 |
++ 0x24, 0x00, /* Location of input report */ |
3111 |
++ 0x1b, 0x00, /* Max input report length */ |
3112 |
++ 0x25, 0x00, /* Location of output report */ |
3113 |
++ 0x11, 0x00, /* Max output report length */ |
3114 |
++ 0x22, 0x00, /* Location of command register */ |
3115 |
++ 0x23, 0x00, /* Location of data register */ |
3116 |
++ 0x11, 0x09, /* Vendor ID */ |
3117 |
++ 0x88, 0x52, /* Product ID */ |
3118 |
++ 0x06, 0x00, /* Version ID */ |
3119 |
++ 0x00, 0x00, 0x00, 0x00 /* Reserved */ |
3120 |
++ }, |
3121 |
++ |
3122 |
++ .hid_report_desc = (uint8_t []) |
3123 |
++ {0x05, 0x01, /* Usage Page (Desktop), */ |
3124 |
++ 0x09, 0x02, /* Usage (Mouse), */ |
3125 |
++ 0xA1, 0x01, /* Collection (Application), */ |
3126 |
++ 0x85, 0x01, /* Report ID (1), */ |
3127 |
++ 0x09, 0x01, /* Usage (Pointer), */ |
3128 |
++ 0xA1, 0x00, /* Collection (Physical), */ |
3129 |
++ 0x05, 0x09, /* Usage Page (Button), */ |
3130 |
++ 0x19, 0x01, /* Usage Minimum (01h), */ |
3131 |
++ 0x29, 0x02, /* Usage Maximum (02h), */ |
3132 |
++ 0x25, 0x01, /* Logical Maximum (1), */ |
3133 |
++ 0x75, 0x01, /* Report Size (1), */ |
3134 |
++ 0x95, 0x02, /* Report Count (2), */ |
3135 |
++ 0x81, 0x02, /* Input (Variable), */ |
3136 |
++ 0x95, 0x06, /* Report Count (6), */ |
3137 |
++ 0x81, 0x01, /* Input (Constant), */ |
3138 |
++ 0x05, 0x01, /* Usage Page (Desktop), */ |
3139 |
++ 0x09, 0x30, /* Usage (X), */ |
3140 |
++ 0x09, 0x31, /* Usage (Y), */ |
3141 |
++ 0x15, 0x81, /* Logical Minimum (-127), */ |
3142 |
++ 0x25, 0x7F, /* Logical Maximum (127), */ |
3143 |
++ 0x75, 0x08, /* Report Size (8), */ |
3144 |
++ 0x95, 0x02, /* Report Count (2), */ |
3145 |
++ 0x81, 0x06, /* Input (Variable, Relative), */ |
3146 |
++ 0xC0, /* End Collection, */ |
3147 |
++ 0xC0, /* End Collection, */ |
3148 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3149 |
++ 0x09, 0x05, /* Usage (Touchpad), */ |
3150 |
++ 0xA1, 0x01, /* Collection (Application), */ |
3151 |
++ 0x85, 0x04, /* Report ID (4), */ |
3152 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3153 |
++ 0x09, 0x22, /* Usage (Finger), */ |
3154 |
++ 0xA1, 0x02, /* Collection (Logical), */ |
3155 |
++ 0x15, 0x00, /* Logical Minimum (0), */ |
3156 |
++ 0x25, 0x01, /* Logical Maximum (1), */ |
3157 |
++ 0x09, 0x47, /* Usage (Touch Valid), */ |
3158 |
++ 0x09, 0x42, /* Usage (Tip Switch), */ |
3159 |
++ 0x95, 0x02, /* Report Count (2), */ |
3160 |
++ 0x75, 0x01, /* Report Size (1), */ |
3161 |
++ 0x81, 0x02, /* Input (Variable), */ |
3162 |
++ 0x95, 0x01, /* Report Count (1), */ |
3163 |
++ 0x75, 0x03, /* Report Size (3), */ |
3164 |
++ 0x25, 0x05, /* Logical Maximum (5), */ |
3165 |
++ 0x09, 0x51, /* Usage (Contact Identifier), */ |
3166 |
++ 0x81, 0x02, /* Input (Variable), */ |
3167 |
++ 0x75, 0x01, /* Report Size (1), */ |
3168 |
++ 0x95, 0x03, /* Report Count (3), */ |
3169 |
++ 0x81, 0x03, /* Input (Constant, Variable), */ |
3170 |
++ 0x05, 0x01, /* Usage Page (Desktop), */ |
3171 |
++ 0x26, 0x44, 0x0A, /* Logical Maximum (2628), */ |
3172 |
++ 0x75, 0x10, /* Report Size (16), */ |
3173 |
++ 0x55, 0x0E, /* Unit Exponent (14), */ |
3174 |
++ 0x65, 0x11, /* Unit (Centimeter), */ |
3175 |
++ 0x09, 0x30, /* Usage (X), */ |
3176 |
++ 0x46, 0x1A, 0x04, /* Physical Maximum (1050), */ |
3177 |
++ 0x95, 0x01, /* Report Count (1), */ |
3178 |
++ 0x81, 0x02, /* Input (Variable), */ |
3179 |
++ 0x46, 0xBC, 0x02, /* Physical Maximum (700), */ |
3180 |
++ 0x26, 0x34, 0x05, /* Logical Maximum (1332), */ |
3181 |
++ 0x09, 0x31, /* Usage (Y), */ |
3182 |
++ 0x81, 0x02, /* Input (Variable), */ |
3183 |
++ 0xC0, /* End Collection, */ |
3184 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3185 |
++ 0x09, 0x22, /* Usage (Finger), */ |
3186 |
++ 0xA1, 0x02, /* Collection (Logical), */ |
3187 |
++ 0x25, 0x01, /* Logical Maximum (1), */ |
3188 |
++ 0x09, 0x47, /* Usage (Touch Valid), */ |
3189 |
++ 0x09, 0x42, /* Usage (Tip Switch), */ |
3190 |
++ 0x95, 0x02, /* Report Count (2), */ |
3191 |
++ 0x75, 0x01, /* Report Size (1), */ |
3192 |
++ 0x81, 0x02, /* Input (Variable), */ |
3193 |
++ 0x95, 0x01, /* Report Count (1), */ |
3194 |
++ 0x75, 0x03, /* Report Size (3), */ |
3195 |
++ 0x25, 0x05, /* Logical Maximum (5), */ |
3196 |
++ 0x09, 0x51, /* Usage (Contact Identifier), */ |
3197 |
++ 0x81, 0x02, /* Input (Variable), */ |
3198 |
++ 0x75, 0x01, /* Report Size (1), */ |
3199 |
++ 0x95, 0x03, /* Report Count (3), */ |
3200 |
++ 0x81, 0x03, /* Input (Constant, Variable), */ |
3201 |
++ 0x05, 0x01, /* Usage Page (Desktop), */ |
3202 |
++ 0x26, 0x44, 0x0A, /* Logical Maximum (2628), */ |
3203 |
++ 0x75, 0x10, /* Report Size (16), */ |
3204 |
++ 0x09, 0x30, /* Usage (X), */ |
3205 |
++ 0x46, 0x1A, 0x04, /* Physical Maximum (1050), */ |
3206 |
++ 0x95, 0x01, /* Report Count (1), */ |
3207 |
++ 0x81, 0x02, /* Input (Variable), */ |
3208 |
++ 0x46, 0xBC, 0x02, /* Physical Maximum (700), */ |
3209 |
++ 0x26, 0x34, 0x05, /* Logical Maximum (1332), */ |
3210 |
++ 0x09, 0x31, /* Usage (Y), */ |
3211 |
++ 0x81, 0x02, /* Input (Variable), */ |
3212 |
++ 0xC0, /* End Collection, */ |
3213 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3214 |
++ 0x09, 0x22, /* Usage (Finger), */ |
3215 |
++ 0xA1, 0x02, /* Collection (Logical), */ |
3216 |
++ 0x25, 0x01, /* Logical Maximum (1), */ |
3217 |
++ 0x09, 0x47, /* Usage (Touch Valid), */ |
3218 |
++ 0x09, 0x42, /* Usage (Tip Switch), */ |
3219 |
++ 0x95, 0x02, /* Report Count (2), */ |
3220 |
++ 0x75, 0x01, /* Report Size (1), */ |
3221 |
++ 0x81, 0x02, /* Input (Variable), */ |
3222 |
++ 0x95, 0x01, /* Report Count (1), */ |
3223 |
++ 0x75, 0x03, /* Report Size (3), */ |
3224 |
++ 0x25, 0x05, /* Logical Maximum (5), */ |
3225 |
++ 0x09, 0x51, /* Usage (Contact Identifier), */ |
3226 |
++ 0x81, 0x02, /* Input (Variable), */ |
3227 |
++ 0x75, 0x01, /* Report Size (1), */ |
3228 |
++ 0x95, 0x03, /* Report Count (3), */ |
3229 |
++ 0x81, 0x03, /* Input (Constant, Variable), */ |
3230 |
++ 0x05, 0x01, /* Usage Page (Desktop), */ |
3231 |
++ 0x26, 0x44, 0x0A, /* Logical Maximum (2628), */ |
3232 |
++ 0x75, 0x10, /* Report Size (16), */ |
3233 |
++ 0x09, 0x30, /* Usage (X), */ |
3234 |
++ 0x46, 0x1A, 0x04, /* Physical Maximum (1050), */ |
3235 |
++ 0x95, 0x01, /* Report Count (1), */ |
3236 |
++ 0x81, 0x02, /* Input (Variable), */ |
3237 |
++ 0x46, 0xBC, 0x02, /* Physical Maximum (700), */ |
3238 |
++ 0x26, 0x34, 0x05, /* Logical Maximum (1332), */ |
3239 |
++ 0x09, 0x31, /* Usage (Y), */ |
3240 |
++ 0x81, 0x02, /* Input (Variable), */ |
3241 |
++ 0xC0, /* End Collection, */ |
3242 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3243 |
++ 0x09, 0x22, /* Usage (Finger), */ |
3244 |
++ 0xA1, 0x02, /* Collection (Logical), */ |
3245 |
++ 0x25, 0x01, /* Logical Maximum (1), */ |
3246 |
++ 0x09, 0x47, /* Usage (Touch Valid), */ |
3247 |
++ 0x09, 0x42, /* Usage (Tip Switch), */ |
3248 |
++ 0x95, 0x02, /* Report Count (2), */ |
3249 |
++ 0x75, 0x01, /* Report Size (1), */ |
3250 |
++ 0x81, 0x02, /* Input (Variable), */ |
3251 |
++ 0x95, 0x01, /* Report Count (1), */ |
3252 |
++ 0x75, 0x03, /* Report Size (3), */ |
3253 |
++ 0x25, 0x05, /* Logical Maximum (5), */ |
3254 |
++ 0x09, 0x51, /* Usage (Contact Identifier), */ |
3255 |
++ 0x81, 0x02, /* Input (Variable), */ |
3256 |
++ 0x75, 0x01, /* Report Size (1), */ |
3257 |
++ 0x95, 0x03, /* Report Count (3), */ |
3258 |
++ 0x81, 0x03, /* Input (Constant, Variable), */ |
3259 |
++ 0x05, 0x01, /* Usage Page (Desktop), */ |
3260 |
++ 0x26, 0x44, 0x0A, /* Logical Maximum (2628), */ |
3261 |
++ 0x75, 0x10, /* Report Size (16), */ |
3262 |
++ 0x09, 0x30, /* Usage (X), */ |
3263 |
++ 0x46, 0x1A, 0x04, /* Physical Maximum (1050), */ |
3264 |
++ 0x95, 0x01, /* Report Count (1), */ |
3265 |
++ 0x81, 0x02, /* Input (Variable), */ |
3266 |
++ 0x46, 0xBC, 0x02, /* Physical Maximum (700), */ |
3267 |
++ 0x26, 0x34, 0x05, /* Logical Maximum (1332), */ |
3268 |
++ 0x09, 0x31, /* Usage (Y), */ |
3269 |
++ 0x81, 0x02, /* Input (Variable), */ |
3270 |
++ 0xC0, /* End Collection, */ |
3271 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3272 |
++ 0x55, 0x0C, /* Unit Exponent (12), */ |
3273 |
++ 0x66, 0x01, 0x10, /* Unit (Seconds), */ |
3274 |
++ 0x47, 0xFF, 0xFF, 0x00, 0x00,/* Physical Maximum (65535), */ |
3275 |
++ 0x27, 0xFF, 0xFF, 0x00, 0x00,/* Logical Maximum (65535), */ |
3276 |
++ 0x75, 0x10, /* Report Size (16), */ |
3277 |
++ 0x95, 0x01, /* Report Count (1), */ |
3278 |
++ 0x09, 0x56, /* Usage (Scan Time), */ |
3279 |
++ 0x81, 0x02, /* Input (Variable), */ |
3280 |
++ 0x09, 0x54, /* Usage (Contact Count), */ |
3281 |
++ 0x25, 0x7F, /* Logical Maximum (127), */ |
3282 |
++ 0x75, 0x08, /* Report Size (8), */ |
3283 |
++ 0x81, 0x02, /* Input (Variable), */ |
3284 |
++ 0x05, 0x09, /* Usage Page (Button), */ |
3285 |
++ 0x09, 0x01, /* Usage (01h), */ |
3286 |
++ 0x25, 0x01, /* Logical Maximum (1), */ |
3287 |
++ 0x75, 0x01, /* Report Size (1), */ |
3288 |
++ 0x95, 0x01, /* Report Count (1), */ |
3289 |
++ 0x81, 0x02, /* Input (Variable), */ |
3290 |
++ 0x95, 0x07, /* Report Count (7), */ |
3291 |
++ 0x81, 0x03, /* Input (Constant, Variable), */ |
3292 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3293 |
++ 0x85, 0x02, /* Report ID (2), */ |
3294 |
++ 0x09, 0x55, /* Usage (Contact Count Maximum), */ |
3295 |
++ 0x09, 0x59, /* Usage (59h), */ |
3296 |
++ 0x75, 0x04, /* Report Size (4), */ |
3297 |
++ 0x95, 0x02, /* Report Count (2), */ |
3298 |
++ 0x25, 0x0F, /* Logical Maximum (15), */ |
3299 |
++ 0xB1, 0x02, /* Feature (Variable), */ |
3300 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3301 |
++ 0x85, 0x07, /* Report ID (7), */ |
3302 |
++ 0x09, 0x60, /* Usage (60h), */ |
3303 |
++ 0x75, 0x01, /* Report Size (1), */ |
3304 |
++ 0x95, 0x01, /* Report Count (1), */ |
3305 |
++ 0x25, 0x01, /* Logical Maximum (1), */ |
3306 |
++ 0xB1, 0x02, /* Feature (Variable), */ |
3307 |
++ 0x95, 0x07, /* Report Count (7), */ |
3308 |
++ 0xB1, 0x03, /* Feature (Constant, Variable), */ |
3309 |
++ 0x85, 0x06, /* Report ID (6), */ |
3310 |
++ 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ |
3311 |
++ 0x09, 0xC5, /* Usage (C5h), */ |
3312 |
++ 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ |
3313 |
++ 0x75, 0x08, /* Report Size (8), */ |
3314 |
++ 0x96, 0x00, 0x01, /* Report Count (256), */ |
3315 |
++ 0xB1, 0x02, /* Feature (Variable), */ |
3316 |
++ 0xC0, /* End Collection, */ |
3317 |
++ 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ |
3318 |
++ 0x09, 0x01, /* Usage (01h), */ |
3319 |
++ 0xA1, 0x01, /* Collection (Application), */ |
3320 |
++ 0x85, 0x0D, /* Report ID (13), */ |
3321 |
++ 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ |
3322 |
++ 0x19, 0x01, /* Usage Minimum (01h), */ |
3323 |
++ 0x29, 0x02, /* Usage Maximum (02h), */ |
3324 |
++ 0x75, 0x08, /* Report Size (8), */ |
3325 |
++ 0x95, 0x02, /* Report Count (2), */ |
3326 |
++ 0xB1, 0x02, /* Feature (Variable), */ |
3327 |
++ 0xC0, /* End Collection, */ |
3328 |
++ 0x05, 0x0D, /* Usage Page (Digitizer), */ |
3329 |
++ 0x09, 0x0E, /* Usage (Configuration), */ |
3330 |
++ 0xA1, 0x01, /* Collection (Application), */ |
3331 |
++ 0x85, 0x03, /* Report ID (3), */ |
3332 |
++ 0x09, 0x22, /* Usage (Finger), */ |
3333 |
++ 0xA1, 0x02, /* Collection (Logical), */ |
3334 |
++ 0x09, 0x52, /* Usage (Device Mode), */ |
3335 |
++ 0x25, 0x0A, /* Logical Maximum (10), */ |
3336 |
++ 0x95, 0x01, /* Report Count (1), */ |
3337 |
++ 0xB1, 0x02, /* Feature (Variable), */ |
3338 |
++ 0xC0, /* End Collection, */ |
3339 |
++ 0x09, 0x22, /* Usage (Finger), */ |
3340 |
++ 0xA1, 0x00, /* Collection (Physical), */ |
3341 |
++ 0x85, 0x05, /* Report ID (5), */ |
3342 |
++ 0x09, 0x57, /* Usage (57h), */ |
3343 |
++ 0x09, 0x58, /* Usage (58h), */ |
3344 |
++ 0x75, 0x01, /* Report Size (1), */ |
3345 |
++ 0x95, 0x02, /* Report Count (2), */ |
3346 |
++ 0x25, 0x01, /* Logical Maximum (1), */ |
3347 |
++ 0xB1, 0x02, /* Feature (Variable), */ |
3348 |
++ 0x95, 0x06, /* Report Count (6), */ |
3349 |
++ 0xB1, 0x03, /* Feature (Constant, Variable),*/ |
3350 |
++ 0xC0, /* End Collection, */ |
3351 |
++ 0xC0 /* End Collection */ |
3352 |
++ }, |
3353 |
++ .hid_report_desc_size = 475, |
3354 |
++ .i2c_name = "SYNA3602:00" |
3355 |
++}; |
3356 |
++ |
3357 |
++ |
3358 |
++static const struct dmi_system_id i2c_hid_dmi_desc_override_table[] = { |
3359 |
++ { |
3360 |
++ .ident = "Teclast F6 Pro", |
3361 |
++ .matches = { |
3362 |
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TECLAST"), |
3363 |
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "F6 Pro"), |
3364 |
++ }, |
3365 |
++ .driver_data = (void *)&sipodev_desc |
3366 |
++ }, |
3367 |
++ { |
3368 |
++ .ident = "Teclast F7", |
3369 |
++ .matches = { |
3370 |
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TECLAST"), |
3371 |
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "F7"), |
3372 |
++ }, |
3373 |
++ .driver_data = (void *)&sipodev_desc |
3374 |
++ }, |
3375 |
++ { |
3376 |
++ .ident = "Trekstor Primebook C13", |
3377 |
++ .matches = { |
3378 |
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TREKSTOR"), |
3379 |
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Primebook C13"), |
3380 |
++ }, |
3381 |
++ .driver_data = (void *)&sipodev_desc |
3382 |
++ }, |
3383 |
++ { |
3384 |
++ .ident = "Trekstor Primebook C11", |
3385 |
++ .matches = { |
3386 |
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TREKSTOR"), |
3387 |
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Primebook C11"), |
3388 |
++ }, |
3389 |
++ .driver_data = (void *)&sipodev_desc |
3390 |
++ }, |
3391 |
++ { |
3392 |
++ .ident = "Direkt-Tek DTLAPY116-2", |
3393 |
++ .matches = { |
3394 |
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Direkt-Tek"), |
3395 |
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "DTLAPY116-2"), |
3396 |
++ }, |
3397 |
++ .driver_data = (void *)&sipodev_desc |
3398 |
++ }, |
3399 |
++ { |
3400 |
++ .ident = "Mediacom Flexbook Edge 11", |
3401 |
++ .matches = { |
3402 |
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MEDIACOM"), |
3403 |
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "FlexBook edge11 - M-FBE11"), |
3404 |
++ }, |
3405 |
++ .driver_data = (void *)&sipodev_desc |
3406 |
++ } |
3407 |
++}; |
3408 |
++ |
3409 |
++ |
3410 |
++struct i2c_hid_desc *i2c_hid_get_dmi_i2c_hid_desc_override(uint8_t *i2c_name) |
3411 |
++{ |
3412 |
++ struct i2c_hid_desc_override *override; |
3413 |
++ const struct dmi_system_id *system_id; |
3414 |
++ |
3415 |
++ system_id = dmi_first_match(i2c_hid_dmi_desc_override_table); |
3416 |
++ if (!system_id) |
3417 |
++ return NULL; |
3418 |
++ |
3419 |
++ override = system_id->driver_data; |
3420 |
++ if (strcmp(override->i2c_name, i2c_name)) |
3421 |
++ return NULL; |
3422 |
++ |
3423 |
++ return override->i2c_hid_desc; |
3424 |
++} |
3425 |
++ |
3426 |
++char *i2c_hid_get_dmi_hid_report_desc_override(uint8_t *i2c_name, |
3427 |
++ unsigned int *size) |
3428 |
++{ |
3429 |
++ struct i2c_hid_desc_override *override; |
3430 |
++ const struct dmi_system_id *system_id; |
3431 |
++ |
3432 |
++ system_id = dmi_first_match(i2c_hid_dmi_desc_override_table); |
3433 |
++ if (!system_id) |
3434 |
++ return NULL; |
3435 |
++ |
3436 |
++ override = system_id->driver_data; |
3437 |
++ if (strcmp(override->i2c_name, i2c_name)) |
3438 |
++ return NULL; |
3439 |
++ |
3440 |
++ *size = override->hid_report_desc_size; |
3441 |
++ return override->hid_report_desc; |
3442 |
++} |
3443 |
+diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c |
3444 |
+deleted file mode 100644 |
3445 |
+index 88daa388e1f6..000000000000 |
3446 |
+--- a/drivers/hid/i2c-hid/i2c-hid.c |
3447 |
++++ /dev/null |
3448 |
+@@ -1,1328 +0,0 @@ |
3449 |
+-/* |
3450 |
+- * HID over I2C protocol implementation |
3451 |
+- * |
3452 |
+- * Copyright (c) 2012 Benjamin Tissoires <benjamin.tissoires@×××××.com> |
3453 |
+- * Copyright (c) 2012 Ecole Nationale de l'Aviation Civile, France |
3454 |
+- * Copyright (c) 2012 Red Hat, Inc |
3455 |
+- * |
3456 |
+- * This code is partly based on "USB HID support for Linux": |
3457 |
+- * |
3458 |
+- * Copyright (c) 1999 Andreas Gal |
3459 |
+- * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@××××.cz> |
3460 |
+- * Copyright (c) 2005 Michael Haboustak <mike-@××××××××.com> for Concept2, Inc |
3461 |
+- * Copyright (c) 2007-2008 Oliver Neukum |
3462 |
+- * Copyright (c) 2006-2010 Jiri Kosina |
3463 |
+- * |
3464 |
+- * This file is subject to the terms and conditions of the GNU General Public |
3465 |
+- * License. See the file COPYING in the main directory of this archive for |
3466 |
+- * more details. |
3467 |
+- */ |
3468 |
+- |
3469 |
+-#include <linux/module.h> |
3470 |
+-#include <linux/i2c.h> |
3471 |
+-#include <linux/interrupt.h> |
3472 |
+-#include <linux/input.h> |
3473 |
+-#include <linux/irq.h> |
3474 |
+-#include <linux/delay.h> |
3475 |
+-#include <linux/slab.h> |
3476 |
+-#include <linux/pm.h> |
3477 |
+-#include <linux/pm_runtime.h> |
3478 |
+-#include <linux/device.h> |
3479 |
+-#include <linux/wait.h> |
3480 |
+-#include <linux/err.h> |
3481 |
+-#include <linux/string.h> |
3482 |
+-#include <linux/list.h> |
3483 |
+-#include <linux/jiffies.h> |
3484 |
+-#include <linux/kernel.h> |
3485 |
+-#include <linux/hid.h> |
3486 |
+-#include <linux/mutex.h> |
3487 |
+-#include <linux/acpi.h> |
3488 |
+-#include <linux/of.h> |
3489 |
+-#include <linux/regulator/consumer.h> |
3490 |
+- |
3491 |
+-#include <linux/platform_data/i2c-hid.h> |
3492 |
+- |
3493 |
+-#include "../hid-ids.h" |
3494 |
+- |
3495 |
+-/* quirks to control the device */ |
3496 |
+-#define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) |
3497 |
+-#define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) |
3498 |
+-#define I2C_HID_QUIRK_NO_RUNTIME_PM BIT(2) |
3499 |
+-#define I2C_HID_QUIRK_DELAY_AFTER_SLEEP BIT(3) |
3500 |
+- |
3501 |
+-/* flags */ |
3502 |
+-#define I2C_HID_STARTED 0 |
3503 |
+-#define I2C_HID_RESET_PENDING 1 |
3504 |
+-#define I2C_HID_READ_PENDING 2 |
3505 |
+- |
3506 |
+-#define I2C_HID_PWR_ON 0x00 |
3507 |
+-#define I2C_HID_PWR_SLEEP 0x01 |
3508 |
+- |
3509 |
+-/* debug option */ |
3510 |
+-static bool debug; |
3511 |
+-module_param(debug, bool, 0444); |
3512 |
+-MODULE_PARM_DESC(debug, "print a lot of debug information"); |
3513 |
+- |
3514 |
+-#define i2c_hid_dbg(ihid, fmt, arg...) \ |
3515 |
+-do { \ |
3516 |
+- if (debug) \ |
3517 |
+- dev_printk(KERN_DEBUG, &(ihid)->client->dev, fmt, ##arg); \ |
3518 |
+-} while (0) |
3519 |
+- |
3520 |
+-struct i2c_hid_desc { |
3521 |
+- __le16 wHIDDescLength; |
3522 |
+- __le16 bcdVersion; |
3523 |
+- __le16 wReportDescLength; |
3524 |
+- __le16 wReportDescRegister; |
3525 |
+- __le16 wInputRegister; |
3526 |
+- __le16 wMaxInputLength; |
3527 |
+- __le16 wOutputRegister; |
3528 |
+- __le16 wMaxOutputLength; |
3529 |
+- __le16 wCommandRegister; |
3530 |
+- __le16 wDataRegister; |
3531 |
+- __le16 wVendorID; |
3532 |
+- __le16 wProductID; |
3533 |
+- __le16 wVersionID; |
3534 |
+- __le32 reserved; |
3535 |
+-} __packed; |
3536 |
+- |
3537 |
+-struct i2c_hid_cmd { |
3538 |
+- unsigned int registerIndex; |
3539 |
+- __u8 opcode; |
3540 |
+- unsigned int length; |
3541 |
+- bool wait; |
3542 |
+-}; |
3543 |
+- |
3544 |
+-union command { |
3545 |
+- u8 data[0]; |
3546 |
+- struct cmd { |
3547 |
+- __le16 reg; |
3548 |
+- __u8 reportTypeID; |
3549 |
+- __u8 opcode; |
3550 |
+- } __packed c; |
3551 |
+-}; |
3552 |
+- |
3553 |
+-#define I2C_HID_CMD(opcode_) \ |
3554 |
+- .opcode = opcode_, .length = 4, \ |
3555 |
+- .registerIndex = offsetof(struct i2c_hid_desc, wCommandRegister) |
3556 |
+- |
3557 |
+-/* fetch HID descriptor */ |
3558 |
+-static const struct i2c_hid_cmd hid_descr_cmd = { .length = 2 }; |
3559 |
+-/* fetch report descriptors */ |
3560 |
+-static const struct i2c_hid_cmd hid_report_descr_cmd = { |
3561 |
+- .registerIndex = offsetof(struct i2c_hid_desc, |
3562 |
+- wReportDescRegister), |
3563 |
+- .opcode = 0x00, |
3564 |
+- .length = 2 }; |
3565 |
+-/* commands */ |
3566 |
+-static const struct i2c_hid_cmd hid_reset_cmd = { I2C_HID_CMD(0x01), |
3567 |
+- .wait = true }; |
3568 |
+-static const struct i2c_hid_cmd hid_get_report_cmd = { I2C_HID_CMD(0x02) }; |
3569 |
+-static const struct i2c_hid_cmd hid_set_report_cmd = { I2C_HID_CMD(0x03) }; |
3570 |
+-static const struct i2c_hid_cmd hid_set_power_cmd = { I2C_HID_CMD(0x08) }; |
3571 |
+-static const struct i2c_hid_cmd hid_no_cmd = { .length = 0 }; |
3572 |
+- |
3573 |
+-/* |
3574 |
+- * These definitions are not used here, but are defined by the spec. |
3575 |
+- * Keeping them here for documentation purposes. |
3576 |
+- * |
3577 |
+- * static const struct i2c_hid_cmd hid_get_idle_cmd = { I2C_HID_CMD(0x04) }; |
3578 |
+- * static const struct i2c_hid_cmd hid_set_idle_cmd = { I2C_HID_CMD(0x05) }; |
3579 |
+- * static const struct i2c_hid_cmd hid_get_protocol_cmd = { I2C_HID_CMD(0x06) }; |
3580 |
+- * static const struct i2c_hid_cmd hid_set_protocol_cmd = { I2C_HID_CMD(0x07) }; |
3581 |
+- */ |
3582 |
+- |
3583 |
+-/* The main device structure */ |
3584 |
+-struct i2c_hid { |
3585 |
+- struct i2c_client *client; /* i2c client */ |
3586 |
+- struct hid_device *hid; /* pointer to corresponding HID dev */ |
3587 |
+- union { |
3588 |
+- __u8 hdesc_buffer[sizeof(struct i2c_hid_desc)]; |
3589 |
+- struct i2c_hid_desc hdesc; /* the HID Descriptor */ |
3590 |
+- }; |
3591 |
+- __le16 wHIDDescRegister; /* location of the i2c |
3592 |
+- * register of the HID |
3593 |
+- * descriptor. */ |
3594 |
+- unsigned int bufsize; /* i2c buffer size */ |
3595 |
+- u8 *inbuf; /* Input buffer */ |
3596 |
+- u8 *rawbuf; /* Raw Input buffer */ |
3597 |
+- u8 *cmdbuf; /* Command buffer */ |
3598 |
+- u8 *argsbuf; /* Command arguments buffer */ |
3599 |
+- |
3600 |
+- unsigned long flags; /* device flags */ |
3601 |
+- unsigned long quirks; /* Various quirks */ |
3602 |
+- |
3603 |
+- wait_queue_head_t wait; /* For waiting the interrupt */ |
3604 |
+- |
3605 |
+- struct i2c_hid_platform_data pdata; |
3606 |
+- |
3607 |
+- bool irq_wake_enabled; |
3608 |
+- struct mutex reset_lock; |
3609 |
+- |
3610 |
+- unsigned long sleep_delay; |
3611 |
+-}; |
3612 |
+- |
3613 |
+-static const struct i2c_hid_quirks { |
3614 |
+- __u16 idVendor; |
3615 |
+- __u16 idProduct; |
3616 |
+- __u32 quirks; |
3617 |
+-} i2c_hid_quirks[] = { |
3618 |
+- { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8752, |
3619 |
+- I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, |
3620 |
+- { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8755, |
3621 |
+- I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, |
3622 |
+- { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, |
3623 |
+- I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | |
3624 |
+- I2C_HID_QUIRK_NO_RUNTIME_PM }, |
3625 |
+- { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_4B33, |
3626 |
+- I2C_HID_QUIRK_DELAY_AFTER_SLEEP }, |
3627 |
+- { 0, 0 } |
3628 |
+-}; |
3629 |
+- |
3630 |
+-/* |
3631 |
+- * i2c_hid_lookup_quirk: return any quirks associated with a I2C HID device |
3632 |
+- * @idVendor: the 16-bit vendor ID |
3633 |
+- * @idProduct: the 16-bit product ID |
3634 |
+- * |
3635 |
+- * Returns: a u32 quirks value. |
3636 |
+- */ |
3637 |
+-static u32 i2c_hid_lookup_quirk(const u16 idVendor, const u16 idProduct) |
3638 |
+-{ |
3639 |
+- u32 quirks = 0; |
3640 |
+- int n; |
3641 |
+- |
3642 |
+- for (n = 0; i2c_hid_quirks[n].idVendor; n++) |
3643 |
+- if (i2c_hid_quirks[n].idVendor == idVendor && |
3644 |
+- (i2c_hid_quirks[n].idProduct == (__u16)HID_ANY_ID || |
3645 |
+- i2c_hid_quirks[n].idProduct == idProduct)) |
3646 |
+- quirks = i2c_hid_quirks[n].quirks; |
3647 |
+- |
3648 |
+- return quirks; |
3649 |
+-} |
3650 |
+- |
3651 |
+-static int __i2c_hid_command(struct i2c_client *client, |
3652 |
+- const struct i2c_hid_cmd *command, u8 reportID, |
3653 |
+- u8 reportType, u8 *args, int args_len, |
3654 |
+- unsigned char *buf_recv, int data_len) |
3655 |
+-{ |
3656 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
3657 |
+- union command *cmd = (union command *)ihid->cmdbuf; |
3658 |
+- int ret; |
3659 |
+- struct i2c_msg msg[2]; |
3660 |
+- int msg_num = 1; |
3661 |
+- |
3662 |
+- int length = command->length; |
3663 |
+- bool wait = command->wait; |
3664 |
+- unsigned int registerIndex = command->registerIndex; |
3665 |
+- |
3666 |
+- /* special case for hid_descr_cmd */ |
3667 |
+- if (command == &hid_descr_cmd) { |
3668 |
+- cmd->c.reg = ihid->wHIDDescRegister; |
3669 |
+- } else { |
3670 |
+- cmd->data[0] = ihid->hdesc_buffer[registerIndex]; |
3671 |
+- cmd->data[1] = ihid->hdesc_buffer[registerIndex + 1]; |
3672 |
+- } |
3673 |
+- |
3674 |
+- if (length > 2) { |
3675 |
+- cmd->c.opcode = command->opcode; |
3676 |
+- cmd->c.reportTypeID = reportID | reportType << 4; |
3677 |
+- } |
3678 |
+- |
3679 |
+- memcpy(cmd->data + length, args, args_len); |
3680 |
+- length += args_len; |
3681 |
+- |
3682 |
+- i2c_hid_dbg(ihid, "%s: cmd=%*ph\n", __func__, length, cmd->data); |
3683 |
+- |
3684 |
+- msg[0].addr = client->addr; |
3685 |
+- msg[0].flags = client->flags & I2C_M_TEN; |
3686 |
+- msg[0].len = length; |
3687 |
+- msg[0].buf = cmd->data; |
3688 |
+- if (data_len > 0) { |
3689 |
+- msg[1].addr = client->addr; |
3690 |
+- msg[1].flags = client->flags & I2C_M_TEN; |
3691 |
+- msg[1].flags |= I2C_M_RD; |
3692 |
+- msg[1].len = data_len; |
3693 |
+- msg[1].buf = buf_recv; |
3694 |
+- msg_num = 2; |
3695 |
+- set_bit(I2C_HID_READ_PENDING, &ihid->flags); |
3696 |
+- } |
3697 |
+- |
3698 |
+- if (wait) |
3699 |
+- set_bit(I2C_HID_RESET_PENDING, &ihid->flags); |
3700 |
+- |
3701 |
+- ret = i2c_transfer(client->adapter, msg, msg_num); |
3702 |
+- |
3703 |
+- if (data_len > 0) |
3704 |
+- clear_bit(I2C_HID_READ_PENDING, &ihid->flags); |
3705 |
+- |
3706 |
+- if (ret != msg_num) |
3707 |
+- return ret < 0 ? ret : -EIO; |
3708 |
+- |
3709 |
+- ret = 0; |
3710 |
+- |
3711 |
+- if (wait && (ihid->quirks & I2C_HID_QUIRK_NO_IRQ_AFTER_RESET)) { |
3712 |
+- msleep(100); |
3713 |
+- } else if (wait) { |
3714 |
+- i2c_hid_dbg(ihid, "%s: waiting...\n", __func__); |
3715 |
+- if (!wait_event_timeout(ihid->wait, |
3716 |
+- !test_bit(I2C_HID_RESET_PENDING, &ihid->flags), |
3717 |
+- msecs_to_jiffies(5000))) |
3718 |
+- ret = -ENODATA; |
3719 |
+- i2c_hid_dbg(ihid, "%s: finished.\n", __func__); |
3720 |
+- } |
3721 |
+- |
3722 |
+- return ret; |
3723 |
+-} |
3724 |
+- |
3725 |
+-static int i2c_hid_command(struct i2c_client *client, |
3726 |
+- const struct i2c_hid_cmd *command, |
3727 |
+- unsigned char *buf_recv, int data_len) |
3728 |
+-{ |
3729 |
+- return __i2c_hid_command(client, command, 0, 0, NULL, 0, |
3730 |
+- buf_recv, data_len); |
3731 |
+-} |
3732 |
+- |
3733 |
+-static int i2c_hid_get_report(struct i2c_client *client, u8 reportType, |
3734 |
+- u8 reportID, unsigned char *buf_recv, int data_len) |
3735 |
+-{ |
3736 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
3737 |
+- u8 args[3]; |
3738 |
+- int ret; |
3739 |
+- int args_len = 0; |
3740 |
+- u16 readRegister = le16_to_cpu(ihid->hdesc.wDataRegister); |
3741 |
+- |
3742 |
+- i2c_hid_dbg(ihid, "%s\n", __func__); |
3743 |
+- |
3744 |
+- if (reportID >= 0x0F) { |
3745 |
+- args[args_len++] = reportID; |
3746 |
+- reportID = 0x0F; |
3747 |
+- } |
3748 |
+- |
3749 |
+- args[args_len++] = readRegister & 0xFF; |
3750 |
+- args[args_len++] = readRegister >> 8; |
3751 |
+- |
3752 |
+- ret = __i2c_hid_command(client, &hid_get_report_cmd, reportID, |
3753 |
+- reportType, args, args_len, buf_recv, data_len); |
3754 |
+- if (ret) { |
3755 |
+- dev_err(&client->dev, |
3756 |
+- "failed to retrieve report from device.\n"); |
3757 |
+- return ret; |
3758 |
+- } |
3759 |
+- |
3760 |
+- return 0; |
3761 |
+-} |
3762 |
+- |
3763 |
+-/** |
3764 |
+- * i2c_hid_set_or_send_report: forward an incoming report to the device |
3765 |
+- * @client: the i2c_client of the device |
3766 |
+- * @reportType: 0x03 for HID_FEATURE_REPORT ; 0x02 for HID_OUTPUT_REPORT |
3767 |
+- * @reportID: the report ID |
3768 |
+- * @buf: the actual data to transfer, without the report ID |
3769 |
+- * @len: size of buf |
3770 |
+- * @use_data: true: use SET_REPORT HID command, false: send plain OUTPUT report |
3771 |
+- */ |
3772 |
+-static int i2c_hid_set_or_send_report(struct i2c_client *client, u8 reportType, |
3773 |
+- u8 reportID, unsigned char *buf, size_t data_len, bool use_data) |
3774 |
+-{ |
3775 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
3776 |
+- u8 *args = ihid->argsbuf; |
3777 |
+- const struct i2c_hid_cmd *hidcmd; |
3778 |
+- int ret; |
3779 |
+- u16 dataRegister = le16_to_cpu(ihid->hdesc.wDataRegister); |
3780 |
+- u16 outputRegister = le16_to_cpu(ihid->hdesc.wOutputRegister); |
3781 |
+- u16 maxOutputLength = le16_to_cpu(ihid->hdesc.wMaxOutputLength); |
3782 |
+- u16 size; |
3783 |
+- int args_len; |
3784 |
+- int index = 0; |
3785 |
+- |
3786 |
+- i2c_hid_dbg(ihid, "%s\n", __func__); |
3787 |
+- |
3788 |
+- if (data_len > ihid->bufsize) |
3789 |
+- return -EINVAL; |
3790 |
+- |
3791 |
+- size = 2 /* size */ + |
3792 |
+- (reportID ? 1 : 0) /* reportID */ + |
3793 |
+- data_len /* buf */; |
3794 |
+- args_len = (reportID >= 0x0F ? 1 : 0) /* optional third byte */ + |
3795 |
+- 2 /* dataRegister */ + |
3796 |
+- size /* args */; |
3797 |
+- |
3798 |
+- if (!use_data && maxOutputLength == 0) |
3799 |
+- return -ENOSYS; |
3800 |
+- |
3801 |
+- if (reportID >= 0x0F) { |
3802 |
+- args[index++] = reportID; |
3803 |
+- reportID = 0x0F; |
3804 |
+- } |
3805 |
+- |
3806 |
+- /* |
3807 |
+- * use the data register for feature reports or if the device does not |
3808 |
+- * support the output register |
3809 |
+- */ |
3810 |
+- if (use_data) { |
3811 |
+- args[index++] = dataRegister & 0xFF; |
3812 |
+- args[index++] = dataRegister >> 8; |
3813 |
+- hidcmd = &hid_set_report_cmd; |
3814 |
+- } else { |
3815 |
+- args[index++] = outputRegister & 0xFF; |
3816 |
+- args[index++] = outputRegister >> 8; |
3817 |
+- hidcmd = &hid_no_cmd; |
3818 |
+- } |
3819 |
+- |
3820 |
+- args[index++] = size & 0xFF; |
3821 |
+- args[index++] = size >> 8; |
3822 |
+- |
3823 |
+- if (reportID) |
3824 |
+- args[index++] = reportID; |
3825 |
+- |
3826 |
+- memcpy(&args[index], buf, data_len); |
3827 |
+- |
3828 |
+- ret = __i2c_hid_command(client, hidcmd, reportID, |
3829 |
+- reportType, args, args_len, NULL, 0); |
3830 |
+- if (ret) { |
3831 |
+- dev_err(&client->dev, "failed to set a report to device.\n"); |
3832 |
+- return ret; |
3833 |
+- } |
3834 |
+- |
3835 |
+- return data_len; |
3836 |
+-} |
3837 |
+- |
3838 |
+-static int i2c_hid_set_power(struct i2c_client *client, int power_state) |
3839 |
+-{ |
3840 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
3841 |
+- int ret; |
3842 |
+- unsigned long now, delay; |
3843 |
+- |
3844 |
+- i2c_hid_dbg(ihid, "%s\n", __func__); |
3845 |
+- |
3846 |
+- /* |
3847 |
+- * Some devices require to send a command to wakeup before power on. |
3848 |
+- * The call will get a return value (EREMOTEIO) but device will be |
3849 |
+- * triggered and activated. After that, it goes like a normal device. |
3850 |
+- */ |
3851 |
+- if (power_state == I2C_HID_PWR_ON && |
3852 |
+- ihid->quirks & I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV) { |
3853 |
+- ret = i2c_hid_command(client, &hid_set_power_cmd, NULL, 0); |
3854 |
+- |
3855 |
+- /* Device was already activated */ |
3856 |
+- if (!ret) |
3857 |
+- goto set_pwr_exit; |
3858 |
+- } |
3859 |
+- |
3860 |
+- if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP && |
3861 |
+- power_state == I2C_HID_PWR_ON) { |
3862 |
+- now = jiffies; |
3863 |
+- if (time_after(ihid->sleep_delay, now)) { |
3864 |
+- delay = jiffies_to_usecs(ihid->sleep_delay - now); |
3865 |
+- usleep_range(delay, delay + 1); |
3866 |
+- } |
3867 |
+- } |
3868 |
+- |
3869 |
+- ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state, |
3870 |
+- 0, NULL, 0, NULL, 0); |
3871 |
+- |
3872 |
+- if (ihid->quirks & I2C_HID_QUIRK_DELAY_AFTER_SLEEP && |
3873 |
+- power_state == I2C_HID_PWR_SLEEP) |
3874 |
+- ihid->sleep_delay = jiffies + msecs_to_jiffies(20); |
3875 |
+- |
3876 |
+- if (ret) |
3877 |
+- dev_err(&client->dev, "failed to change power setting.\n"); |
3878 |
+- |
3879 |
+-set_pwr_exit: |
3880 |
+- return ret; |
3881 |
+-} |
3882 |
+- |
3883 |
+-static int i2c_hid_hwreset(struct i2c_client *client) |
3884 |
+-{ |
3885 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
3886 |
+- int ret; |
3887 |
+- |
3888 |
+- i2c_hid_dbg(ihid, "%s\n", __func__); |
3889 |
+- |
3890 |
+- /* |
3891 |
+- * This prevents sending feature reports while the device is |
3892 |
+- * being reset. Otherwise we may lose the reset complete |
3893 |
+- * interrupt. |
3894 |
+- */ |
3895 |
+- mutex_lock(&ihid->reset_lock); |
3896 |
+- |
3897 |
+- ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); |
3898 |
+- if (ret) |
3899 |
+- goto out_unlock; |
3900 |
+- |
3901 |
+- /* |
3902 |
+- * The HID over I2C specification states that if a DEVICE needs time |
3903 |
+- * after the PWR_ON request, it should utilise CLOCK stretching. |
3904 |
+- * However, it has been observered that the Windows driver provides a |
3905 |
+- * 1ms sleep between the PWR_ON and RESET requests and that some devices |
3906 |
+- * rely on this. |
3907 |
+- */ |
3908 |
+- usleep_range(1000, 5000); |
3909 |
+- |
3910 |
+- i2c_hid_dbg(ihid, "resetting...\n"); |
3911 |
+- |
3912 |
+- ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0); |
3913 |
+- if (ret) { |
3914 |
+- dev_err(&client->dev, "failed to reset device.\n"); |
3915 |
+- i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
3916 |
+- } |
3917 |
+- |
3918 |
+-out_unlock: |
3919 |
+- mutex_unlock(&ihid->reset_lock); |
3920 |
+- return ret; |
3921 |
+-} |
3922 |
+- |
3923 |
+-static void i2c_hid_get_input(struct i2c_hid *ihid) |
3924 |
+-{ |
3925 |
+- int ret; |
3926 |
+- u32 ret_size; |
3927 |
+- int size = le16_to_cpu(ihid->hdesc.wMaxInputLength); |
3928 |
+- |
3929 |
+- if (size > ihid->bufsize) |
3930 |
+- size = ihid->bufsize; |
3931 |
+- |
3932 |
+- ret = i2c_master_recv(ihid->client, ihid->inbuf, size); |
3933 |
+- if (ret != size) { |
3934 |
+- if (ret < 0) |
3935 |
+- return; |
3936 |
+- |
3937 |
+- dev_err(&ihid->client->dev, "%s: got %d data instead of %d\n", |
3938 |
+- __func__, ret, size); |
3939 |
+- return; |
3940 |
+- } |
3941 |
+- |
3942 |
+- ret_size = ihid->inbuf[0] | ihid->inbuf[1] << 8; |
3943 |
+- |
3944 |
+- if (!ret_size) { |
3945 |
+- /* host or device initiated RESET completed */ |
3946 |
+- if (test_and_clear_bit(I2C_HID_RESET_PENDING, &ihid->flags)) |
3947 |
+- wake_up(&ihid->wait); |
3948 |
+- return; |
3949 |
+- } |
3950 |
+- |
3951 |
+- if ((ret_size > size) || (ret_size < 2)) { |
3952 |
+- dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n", |
3953 |
+- __func__, size, ret_size); |
3954 |
+- return; |
3955 |
+- } |
3956 |
+- |
3957 |
+- i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf); |
3958 |
+- |
3959 |
+- if (test_bit(I2C_HID_STARTED, &ihid->flags)) |
3960 |
+- hid_input_report(ihid->hid, HID_INPUT_REPORT, ihid->inbuf + 2, |
3961 |
+- ret_size - 2, 1); |
3962 |
+- |
3963 |
+- return; |
3964 |
+-} |
3965 |
+- |
3966 |
+-static irqreturn_t i2c_hid_irq(int irq, void *dev_id) |
3967 |
+-{ |
3968 |
+- struct i2c_hid *ihid = dev_id; |
3969 |
+- |
3970 |
+- if (test_bit(I2C_HID_READ_PENDING, &ihid->flags)) |
3971 |
+- return IRQ_HANDLED; |
3972 |
+- |
3973 |
+- i2c_hid_get_input(ihid); |
3974 |
+- |
3975 |
+- return IRQ_HANDLED; |
3976 |
+-} |
3977 |
+- |
3978 |
+-static int i2c_hid_get_report_length(struct hid_report *report) |
3979 |
+-{ |
3980 |
+- return ((report->size - 1) >> 3) + 1 + |
3981 |
+- report->device->report_enum[report->type].numbered + 2; |
3982 |
+-} |
3983 |
+- |
3984 |
+-/* |
3985 |
+- * Traverse the supplied list of reports and find the longest |
3986 |
+- */ |
3987 |
+-static void i2c_hid_find_max_report(struct hid_device *hid, unsigned int type, |
3988 |
+- unsigned int *max) |
3989 |
+-{ |
3990 |
+- struct hid_report *report; |
3991 |
+- unsigned int size; |
3992 |
+- |
3993 |
+- /* We should not rely on wMaxInputLength, as some devices may set it to |
3994 |
+- * a wrong length. */ |
3995 |
+- list_for_each_entry(report, &hid->report_enum[type].report_list, list) { |
3996 |
+- size = i2c_hid_get_report_length(report); |
3997 |
+- if (*max < size) |
3998 |
+- *max = size; |
3999 |
+- } |
4000 |
+-} |
4001 |
+- |
4002 |
+-static void i2c_hid_free_buffers(struct i2c_hid *ihid) |
4003 |
+-{ |
4004 |
+- kfree(ihid->inbuf); |
4005 |
+- kfree(ihid->rawbuf); |
4006 |
+- kfree(ihid->argsbuf); |
4007 |
+- kfree(ihid->cmdbuf); |
4008 |
+- ihid->inbuf = NULL; |
4009 |
+- ihid->rawbuf = NULL; |
4010 |
+- ihid->cmdbuf = NULL; |
4011 |
+- ihid->argsbuf = NULL; |
4012 |
+- ihid->bufsize = 0; |
4013 |
+-} |
4014 |
+- |
4015 |
+-static int i2c_hid_alloc_buffers(struct i2c_hid *ihid, size_t report_size) |
4016 |
+-{ |
4017 |
+- /* the worst case is computed from the set_report command with a |
4018 |
+- * reportID > 15 and the maximum report length */ |
4019 |
+- int args_len = sizeof(__u8) + /* ReportID */ |
4020 |
+- sizeof(__u8) + /* optional ReportID byte */ |
4021 |
+- sizeof(__u16) + /* data register */ |
4022 |
+- sizeof(__u16) + /* size of the report */ |
4023 |
+- report_size; /* report */ |
4024 |
+- |
4025 |
+- ihid->inbuf = kzalloc(report_size, GFP_KERNEL); |
4026 |
+- ihid->rawbuf = kzalloc(report_size, GFP_KERNEL); |
4027 |
+- ihid->argsbuf = kzalloc(args_len, GFP_KERNEL); |
4028 |
+- ihid->cmdbuf = kzalloc(sizeof(union command) + args_len, GFP_KERNEL); |
4029 |
+- |
4030 |
+- if (!ihid->inbuf || !ihid->rawbuf || !ihid->argsbuf || !ihid->cmdbuf) { |
4031 |
+- i2c_hid_free_buffers(ihid); |
4032 |
+- return -ENOMEM; |
4033 |
+- } |
4034 |
+- |
4035 |
+- ihid->bufsize = report_size; |
4036 |
+- |
4037 |
+- return 0; |
4038 |
+-} |
4039 |
+- |
4040 |
+-static int i2c_hid_get_raw_report(struct hid_device *hid, |
4041 |
+- unsigned char report_number, __u8 *buf, size_t count, |
4042 |
+- unsigned char report_type) |
4043 |
+-{ |
4044 |
+- struct i2c_client *client = hid->driver_data; |
4045 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4046 |
+- size_t ret_count, ask_count; |
4047 |
+- int ret; |
4048 |
+- |
4049 |
+- if (report_type == HID_OUTPUT_REPORT) |
4050 |
+- return -EINVAL; |
4051 |
+- |
4052 |
+- /* +2 bytes to include the size of the reply in the query buffer */ |
4053 |
+- ask_count = min(count + 2, (size_t)ihid->bufsize); |
4054 |
+- |
4055 |
+- ret = i2c_hid_get_report(client, |
4056 |
+- report_type == HID_FEATURE_REPORT ? 0x03 : 0x01, |
4057 |
+- report_number, ihid->rawbuf, ask_count); |
4058 |
+- |
4059 |
+- if (ret < 0) |
4060 |
+- return ret; |
4061 |
+- |
4062 |
+- ret_count = ihid->rawbuf[0] | (ihid->rawbuf[1] << 8); |
4063 |
+- |
4064 |
+- if (ret_count <= 2) |
4065 |
+- return 0; |
4066 |
+- |
4067 |
+- ret_count = min(ret_count, ask_count); |
4068 |
+- |
4069 |
+- /* The query buffer contains the size, dropping it in the reply */ |
4070 |
+- count = min(count, ret_count - 2); |
4071 |
+- memcpy(buf, ihid->rawbuf + 2, count); |
4072 |
+- |
4073 |
+- return count; |
4074 |
+-} |
4075 |
+- |
4076 |
+-static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf, |
4077 |
+- size_t count, unsigned char report_type, bool use_data) |
4078 |
+-{ |
4079 |
+- struct i2c_client *client = hid->driver_data; |
4080 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4081 |
+- int report_id = buf[0]; |
4082 |
+- int ret; |
4083 |
+- |
4084 |
+- if (report_type == HID_INPUT_REPORT) |
4085 |
+- return -EINVAL; |
4086 |
+- |
4087 |
+- mutex_lock(&ihid->reset_lock); |
4088 |
+- |
4089 |
+- if (report_id) { |
4090 |
+- buf++; |
4091 |
+- count--; |
4092 |
+- } |
4093 |
+- |
4094 |
+- ret = i2c_hid_set_or_send_report(client, |
4095 |
+- report_type == HID_FEATURE_REPORT ? 0x03 : 0x02, |
4096 |
+- report_id, buf, count, use_data); |
4097 |
+- |
4098 |
+- if (report_id && ret >= 0) |
4099 |
+- ret++; /* add report_id to the number of transfered bytes */ |
4100 |
+- |
4101 |
+- mutex_unlock(&ihid->reset_lock); |
4102 |
+- |
4103 |
+- return ret; |
4104 |
+-} |
4105 |
+- |
4106 |
+-static int i2c_hid_output_report(struct hid_device *hid, __u8 *buf, |
4107 |
+- size_t count) |
4108 |
+-{ |
4109 |
+- return i2c_hid_output_raw_report(hid, buf, count, HID_OUTPUT_REPORT, |
4110 |
+- false); |
4111 |
+-} |
4112 |
+- |
4113 |
+-static int i2c_hid_raw_request(struct hid_device *hid, unsigned char reportnum, |
4114 |
+- __u8 *buf, size_t len, unsigned char rtype, |
4115 |
+- int reqtype) |
4116 |
+-{ |
4117 |
+- switch (reqtype) { |
4118 |
+- case HID_REQ_GET_REPORT: |
4119 |
+- return i2c_hid_get_raw_report(hid, reportnum, buf, len, rtype); |
4120 |
+- case HID_REQ_SET_REPORT: |
4121 |
+- if (buf[0] != reportnum) |
4122 |
+- return -EINVAL; |
4123 |
+- return i2c_hid_output_raw_report(hid, buf, len, rtype, true); |
4124 |
+- default: |
4125 |
+- return -EIO; |
4126 |
+- } |
4127 |
+-} |
4128 |
+- |
4129 |
+-static int i2c_hid_parse(struct hid_device *hid) |
4130 |
+-{ |
4131 |
+- struct i2c_client *client = hid->driver_data; |
4132 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4133 |
+- struct i2c_hid_desc *hdesc = &ihid->hdesc; |
4134 |
+- unsigned int rsize; |
4135 |
+- char *rdesc; |
4136 |
+- int ret; |
4137 |
+- int tries = 3; |
4138 |
+- |
4139 |
+- i2c_hid_dbg(ihid, "entering %s\n", __func__); |
4140 |
+- |
4141 |
+- rsize = le16_to_cpu(hdesc->wReportDescLength); |
4142 |
+- if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) { |
4143 |
+- dbg_hid("weird size of report descriptor (%u)\n", rsize); |
4144 |
+- return -EINVAL; |
4145 |
+- } |
4146 |
+- |
4147 |
+- do { |
4148 |
+- ret = i2c_hid_hwreset(client); |
4149 |
+- if (ret) |
4150 |
+- msleep(1000); |
4151 |
+- } while (tries-- > 0 && ret); |
4152 |
+- |
4153 |
+- if (ret) |
4154 |
+- return ret; |
4155 |
+- |
4156 |
+- rdesc = kzalloc(rsize, GFP_KERNEL); |
4157 |
+- |
4158 |
+- if (!rdesc) { |
4159 |
+- dbg_hid("couldn't allocate rdesc memory\n"); |
4160 |
+- return -ENOMEM; |
4161 |
+- } |
4162 |
+- |
4163 |
+- i2c_hid_dbg(ihid, "asking HID report descriptor\n"); |
4164 |
+- |
4165 |
+- ret = i2c_hid_command(client, &hid_report_descr_cmd, rdesc, rsize); |
4166 |
+- if (ret) { |
4167 |
+- hid_err(hid, "reading report descriptor failed\n"); |
4168 |
+- kfree(rdesc); |
4169 |
+- return -EIO; |
4170 |
+- } |
4171 |
+- |
4172 |
+- i2c_hid_dbg(ihid, "Report Descriptor: %*ph\n", rsize, rdesc); |
4173 |
+- |
4174 |
+- ret = hid_parse_report(hid, rdesc, rsize); |
4175 |
+- kfree(rdesc); |
4176 |
+- if (ret) { |
4177 |
+- dbg_hid("parsing report descriptor failed\n"); |
4178 |
+- return ret; |
4179 |
+- } |
4180 |
+- |
4181 |
+- return 0; |
4182 |
+-} |
4183 |
+- |
4184 |
+-static int i2c_hid_start(struct hid_device *hid) |
4185 |
+-{ |
4186 |
+- struct i2c_client *client = hid->driver_data; |
4187 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4188 |
+- int ret; |
4189 |
+- unsigned int bufsize = HID_MIN_BUFFER_SIZE; |
4190 |
+- |
4191 |
+- i2c_hid_find_max_report(hid, HID_INPUT_REPORT, &bufsize); |
4192 |
+- i2c_hid_find_max_report(hid, HID_OUTPUT_REPORT, &bufsize); |
4193 |
+- i2c_hid_find_max_report(hid, HID_FEATURE_REPORT, &bufsize); |
4194 |
+- |
4195 |
+- if (bufsize > ihid->bufsize) { |
4196 |
+- disable_irq(client->irq); |
4197 |
+- i2c_hid_free_buffers(ihid); |
4198 |
+- |
4199 |
+- ret = i2c_hid_alloc_buffers(ihid, bufsize); |
4200 |
+- enable_irq(client->irq); |
4201 |
+- |
4202 |
+- if (ret) |
4203 |
+- return ret; |
4204 |
+- } |
4205 |
+- |
4206 |
+- return 0; |
4207 |
+-} |
4208 |
+- |
4209 |
+-static void i2c_hid_stop(struct hid_device *hid) |
4210 |
+-{ |
4211 |
+- hid->claimed = 0; |
4212 |
+-} |
4213 |
+- |
4214 |
+-static int i2c_hid_open(struct hid_device *hid) |
4215 |
+-{ |
4216 |
+- struct i2c_client *client = hid->driver_data; |
4217 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4218 |
+- int ret = 0; |
4219 |
+- |
4220 |
+- ret = pm_runtime_get_sync(&client->dev); |
4221 |
+- if (ret < 0) |
4222 |
+- return ret; |
4223 |
+- |
4224 |
+- set_bit(I2C_HID_STARTED, &ihid->flags); |
4225 |
+- return 0; |
4226 |
+-} |
4227 |
+- |
4228 |
+-static void i2c_hid_close(struct hid_device *hid) |
4229 |
+-{ |
4230 |
+- struct i2c_client *client = hid->driver_data; |
4231 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4232 |
+- |
4233 |
+- clear_bit(I2C_HID_STARTED, &ihid->flags); |
4234 |
+- |
4235 |
+- /* Save some power */ |
4236 |
+- pm_runtime_put(&client->dev); |
4237 |
+-} |
4238 |
+- |
4239 |
+-static int i2c_hid_power(struct hid_device *hid, int lvl) |
4240 |
+-{ |
4241 |
+- struct i2c_client *client = hid->driver_data; |
4242 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4243 |
+- |
4244 |
+- i2c_hid_dbg(ihid, "%s lvl:%d\n", __func__, lvl); |
4245 |
+- |
4246 |
+- switch (lvl) { |
4247 |
+- case PM_HINT_FULLON: |
4248 |
+- pm_runtime_get_sync(&client->dev); |
4249 |
+- break; |
4250 |
+- case PM_HINT_NORMAL: |
4251 |
+- pm_runtime_put(&client->dev); |
4252 |
+- break; |
4253 |
+- } |
4254 |
+- return 0; |
4255 |
+-} |
4256 |
+- |
4257 |
+-struct hid_ll_driver i2c_hid_ll_driver = { |
4258 |
+- .parse = i2c_hid_parse, |
4259 |
+- .start = i2c_hid_start, |
4260 |
+- .stop = i2c_hid_stop, |
4261 |
+- .open = i2c_hid_open, |
4262 |
+- .close = i2c_hid_close, |
4263 |
+- .power = i2c_hid_power, |
4264 |
+- .output_report = i2c_hid_output_report, |
4265 |
+- .raw_request = i2c_hid_raw_request, |
4266 |
+-}; |
4267 |
+-EXPORT_SYMBOL_GPL(i2c_hid_ll_driver); |
4268 |
+- |
4269 |
+-static int i2c_hid_init_irq(struct i2c_client *client) |
4270 |
+-{ |
4271 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4272 |
+- unsigned long irqflags = 0; |
4273 |
+- int ret; |
4274 |
+- |
4275 |
+- dev_dbg(&client->dev, "Requesting IRQ: %d\n", client->irq); |
4276 |
+- |
4277 |
+- if (!irq_get_trigger_type(client->irq)) |
4278 |
+- irqflags = IRQF_TRIGGER_LOW; |
4279 |
+- |
4280 |
+- ret = request_threaded_irq(client->irq, NULL, i2c_hid_irq, |
4281 |
+- irqflags | IRQF_ONESHOT, client->name, ihid); |
4282 |
+- if (ret < 0) { |
4283 |
+- dev_warn(&client->dev, |
4284 |
+- "Could not register for %s interrupt, irq = %d," |
4285 |
+- " ret = %d\n", |
4286 |
+- client->name, client->irq, ret); |
4287 |
+- |
4288 |
+- return ret; |
4289 |
+- } |
4290 |
+- |
4291 |
+- return 0; |
4292 |
+-} |
4293 |
+- |
4294 |
+-static int i2c_hid_fetch_hid_descriptor(struct i2c_hid *ihid) |
4295 |
+-{ |
4296 |
+- struct i2c_client *client = ihid->client; |
4297 |
+- struct i2c_hid_desc *hdesc = &ihid->hdesc; |
4298 |
+- unsigned int dsize; |
4299 |
+- int ret; |
4300 |
+- |
4301 |
+- /* i2c hid fetch using a fixed descriptor size (30 bytes) */ |
4302 |
+- i2c_hid_dbg(ihid, "Fetching the HID descriptor\n"); |
4303 |
+- ret = i2c_hid_command(client, &hid_descr_cmd, ihid->hdesc_buffer, |
4304 |
+- sizeof(struct i2c_hid_desc)); |
4305 |
+- if (ret) { |
4306 |
+- dev_err(&client->dev, "hid_descr_cmd failed\n"); |
4307 |
+- return -ENODEV; |
4308 |
+- } |
4309 |
+- |
4310 |
+- /* Validate the length of HID descriptor, the 4 first bytes: |
4311 |
+- * bytes 0-1 -> length |
4312 |
+- * bytes 2-3 -> bcdVersion (has to be 1.00) */ |
4313 |
+- /* check bcdVersion == 1.0 */ |
4314 |
+- if (le16_to_cpu(hdesc->bcdVersion) != 0x0100) { |
4315 |
+- dev_err(&client->dev, |
4316 |
+- "unexpected HID descriptor bcdVersion (0x%04hx)\n", |
4317 |
+- le16_to_cpu(hdesc->bcdVersion)); |
4318 |
+- return -ENODEV; |
4319 |
+- } |
4320 |
+- |
4321 |
+- /* Descriptor length should be 30 bytes as per the specification */ |
4322 |
+- dsize = le16_to_cpu(hdesc->wHIDDescLength); |
4323 |
+- if (dsize != sizeof(struct i2c_hid_desc)) { |
4324 |
+- dev_err(&client->dev, "weird size of HID descriptor (%u)\n", |
4325 |
+- dsize); |
4326 |
+- return -ENODEV; |
4327 |
+- } |
4328 |
+- i2c_hid_dbg(ihid, "HID Descriptor: %*ph\n", dsize, ihid->hdesc_buffer); |
4329 |
+- return 0; |
4330 |
+-} |
4331 |
+- |
4332 |
+-#ifdef CONFIG_ACPI |
4333 |
+-static const struct acpi_device_id i2c_hid_acpi_blacklist[] = { |
4334 |
+- /* |
4335 |
+- * The CHPN0001 ACPI device, which is used to describe the Chipone |
4336 |
+- * ICN8505 controller, has a _CID of PNP0C50 but is not HID compatible. |
4337 |
+- */ |
4338 |
+- {"CHPN0001", 0 }, |
4339 |
+- { }, |
4340 |
+-}; |
4341 |
+- |
4342 |
+-static int i2c_hid_acpi_pdata(struct i2c_client *client, |
4343 |
+- struct i2c_hid_platform_data *pdata) |
4344 |
+-{ |
4345 |
+- static guid_t i2c_hid_guid = |
4346 |
+- GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555, |
4347 |
+- 0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE); |
4348 |
+- union acpi_object *obj; |
4349 |
+- struct acpi_device *adev; |
4350 |
+- acpi_handle handle; |
4351 |
+- |
4352 |
+- handle = ACPI_HANDLE(&client->dev); |
4353 |
+- if (!handle || acpi_bus_get_device(handle, &adev)) { |
4354 |
+- dev_err(&client->dev, "Error could not get ACPI device\n"); |
4355 |
+- return -ENODEV; |
4356 |
+- } |
4357 |
+- |
4358 |
+- if (acpi_match_device_ids(adev, i2c_hid_acpi_blacklist) == 0) |
4359 |
+- return -ENODEV; |
4360 |
+- |
4361 |
+- obj = acpi_evaluate_dsm_typed(handle, &i2c_hid_guid, 1, 1, NULL, |
4362 |
+- ACPI_TYPE_INTEGER); |
4363 |
+- if (!obj) { |
4364 |
+- dev_err(&client->dev, "Error _DSM call to get HID descriptor address failed\n"); |
4365 |
+- return -ENODEV; |
4366 |
+- } |
4367 |
+- |
4368 |
+- pdata->hid_descriptor_address = obj->integer.value; |
4369 |
+- ACPI_FREE(obj); |
4370 |
+- |
4371 |
+- return 0; |
4372 |
+-} |
4373 |
+- |
4374 |
+-static void i2c_hid_acpi_fix_up_power(struct device *dev) |
4375 |
+-{ |
4376 |
+- struct acpi_device *adev; |
4377 |
+- |
4378 |
+- adev = ACPI_COMPANION(dev); |
4379 |
+- if (adev) |
4380 |
+- acpi_device_fix_up_power(adev); |
4381 |
+-} |
4382 |
+- |
4383 |
+-static const struct acpi_device_id i2c_hid_acpi_match[] = { |
4384 |
+- {"ACPI0C50", 0 }, |
4385 |
+- {"PNP0C50", 0 }, |
4386 |
+- { }, |
4387 |
+-}; |
4388 |
+-MODULE_DEVICE_TABLE(acpi, i2c_hid_acpi_match); |
4389 |
+-#else |
4390 |
+-static inline int i2c_hid_acpi_pdata(struct i2c_client *client, |
4391 |
+- struct i2c_hid_platform_data *pdata) |
4392 |
+-{ |
4393 |
+- return -ENODEV; |
4394 |
+-} |
4395 |
+- |
4396 |
+-static inline void i2c_hid_acpi_fix_up_power(struct device *dev) {} |
4397 |
+-#endif |
4398 |
+- |
4399 |
+-#ifdef CONFIG_OF |
4400 |
+-static int i2c_hid_of_probe(struct i2c_client *client, |
4401 |
+- struct i2c_hid_platform_data *pdata) |
4402 |
+-{ |
4403 |
+- struct device *dev = &client->dev; |
4404 |
+- u32 val; |
4405 |
+- int ret; |
4406 |
+- |
4407 |
+- ret = of_property_read_u32(dev->of_node, "hid-descr-addr", &val); |
4408 |
+- if (ret) { |
4409 |
+- dev_err(&client->dev, "HID register address not provided\n"); |
4410 |
+- return -ENODEV; |
4411 |
+- } |
4412 |
+- if (val >> 16) { |
4413 |
+- dev_err(&client->dev, "Bad HID register address: 0x%08x\n", |
4414 |
+- val); |
4415 |
+- return -EINVAL; |
4416 |
+- } |
4417 |
+- pdata->hid_descriptor_address = val; |
4418 |
+- |
4419 |
+- return 0; |
4420 |
+-} |
4421 |
+- |
4422 |
+-static const struct of_device_id i2c_hid_of_match[] = { |
4423 |
+- { .compatible = "hid-over-i2c" }, |
4424 |
+- {}, |
4425 |
+-}; |
4426 |
+-MODULE_DEVICE_TABLE(of, i2c_hid_of_match); |
4427 |
+-#else |
4428 |
+-static inline int i2c_hid_of_probe(struct i2c_client *client, |
4429 |
+- struct i2c_hid_platform_data *pdata) |
4430 |
+-{ |
4431 |
+- return -ENODEV; |
4432 |
+-} |
4433 |
+-#endif |
4434 |
+- |
4435 |
+-static void i2c_hid_fwnode_probe(struct i2c_client *client, |
4436 |
+- struct i2c_hid_platform_data *pdata) |
4437 |
+-{ |
4438 |
+- u32 val; |
4439 |
+- |
4440 |
+- if (!device_property_read_u32(&client->dev, "post-power-on-delay-ms", |
4441 |
+- &val)) |
4442 |
+- pdata->post_power_delay_ms = val; |
4443 |
+-} |
4444 |
+- |
4445 |
+-static int i2c_hid_probe(struct i2c_client *client, |
4446 |
+- const struct i2c_device_id *dev_id) |
4447 |
+-{ |
4448 |
+- int ret; |
4449 |
+- struct i2c_hid *ihid; |
4450 |
+- struct hid_device *hid; |
4451 |
+- __u16 hidRegister; |
4452 |
+- struct i2c_hid_platform_data *platform_data = client->dev.platform_data; |
4453 |
+- |
4454 |
+- dbg_hid("HID probe called for i2c 0x%02x\n", client->addr); |
4455 |
+- |
4456 |
+- if (!client->irq) { |
4457 |
+- dev_err(&client->dev, |
4458 |
+- "HID over i2c has not been provided an Int IRQ\n"); |
4459 |
+- return -EINVAL; |
4460 |
+- } |
4461 |
+- |
4462 |
+- if (client->irq < 0) { |
4463 |
+- if (client->irq != -EPROBE_DEFER) |
4464 |
+- dev_err(&client->dev, |
4465 |
+- "HID over i2c doesn't have a valid IRQ\n"); |
4466 |
+- return client->irq; |
4467 |
+- } |
4468 |
+- |
4469 |
+- ihid = devm_kzalloc(&client->dev, sizeof(*ihid), GFP_KERNEL); |
4470 |
+- if (!ihid) |
4471 |
+- return -ENOMEM; |
4472 |
+- |
4473 |
+- if (client->dev.of_node) { |
4474 |
+- ret = i2c_hid_of_probe(client, &ihid->pdata); |
4475 |
+- if (ret) |
4476 |
+- return ret; |
4477 |
+- } else if (!platform_data) { |
4478 |
+- ret = i2c_hid_acpi_pdata(client, &ihid->pdata); |
4479 |
+- if (ret) |
4480 |
+- return ret; |
4481 |
+- } else { |
4482 |
+- ihid->pdata = *platform_data; |
4483 |
+- } |
4484 |
+- |
4485 |
+- /* Parse platform agnostic common properties from ACPI / device tree */ |
4486 |
+- i2c_hid_fwnode_probe(client, &ihid->pdata); |
4487 |
+- |
4488 |
+- ihid->pdata.supplies[0].supply = "vdd"; |
4489 |
+- ihid->pdata.supplies[1].supply = "vddl"; |
4490 |
+- |
4491 |
+- ret = devm_regulator_bulk_get(&client->dev, |
4492 |
+- ARRAY_SIZE(ihid->pdata.supplies), |
4493 |
+- ihid->pdata.supplies); |
4494 |
+- if (ret) |
4495 |
+- return ret; |
4496 |
+- |
4497 |
+- ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies), |
4498 |
+- ihid->pdata.supplies); |
4499 |
+- if (ret < 0) |
4500 |
+- return ret; |
4501 |
+- |
4502 |
+- if (ihid->pdata.post_power_delay_ms) |
4503 |
+- msleep(ihid->pdata.post_power_delay_ms); |
4504 |
+- |
4505 |
+- i2c_set_clientdata(client, ihid); |
4506 |
+- |
4507 |
+- ihid->client = client; |
4508 |
+- |
4509 |
+- hidRegister = ihid->pdata.hid_descriptor_address; |
4510 |
+- ihid->wHIDDescRegister = cpu_to_le16(hidRegister); |
4511 |
+- |
4512 |
+- init_waitqueue_head(&ihid->wait); |
4513 |
+- mutex_init(&ihid->reset_lock); |
4514 |
+- |
4515 |
+- /* we need to allocate the command buffer without knowing the maximum |
4516 |
+- * size of the reports. Let's use HID_MIN_BUFFER_SIZE, then we do the |
4517 |
+- * real computation later. */ |
4518 |
+- ret = i2c_hid_alloc_buffers(ihid, HID_MIN_BUFFER_SIZE); |
4519 |
+- if (ret < 0) |
4520 |
+- goto err_regulator; |
4521 |
+- |
4522 |
+- i2c_hid_acpi_fix_up_power(&client->dev); |
4523 |
+- |
4524 |
+- pm_runtime_get_noresume(&client->dev); |
4525 |
+- pm_runtime_set_active(&client->dev); |
4526 |
+- pm_runtime_enable(&client->dev); |
4527 |
+- device_enable_async_suspend(&client->dev); |
4528 |
+- |
4529 |
+- /* Make sure there is something at this address */ |
4530 |
+- ret = i2c_smbus_read_byte(client); |
4531 |
+- if (ret < 0) { |
4532 |
+- dev_dbg(&client->dev, "nothing at this address: %d\n", ret); |
4533 |
+- ret = -ENXIO; |
4534 |
+- goto err_pm; |
4535 |
+- } |
4536 |
+- |
4537 |
+- ret = i2c_hid_fetch_hid_descriptor(ihid); |
4538 |
+- if (ret < 0) |
4539 |
+- goto err_pm; |
4540 |
+- |
4541 |
+- ret = i2c_hid_init_irq(client); |
4542 |
+- if (ret < 0) |
4543 |
+- goto err_pm; |
4544 |
+- |
4545 |
+- hid = hid_allocate_device(); |
4546 |
+- if (IS_ERR(hid)) { |
4547 |
+- ret = PTR_ERR(hid); |
4548 |
+- goto err_irq; |
4549 |
+- } |
4550 |
+- |
4551 |
+- ihid->hid = hid; |
4552 |
+- |
4553 |
+- hid->driver_data = client; |
4554 |
+- hid->ll_driver = &i2c_hid_ll_driver; |
4555 |
+- hid->dev.parent = &client->dev; |
4556 |
+- hid->bus = BUS_I2C; |
4557 |
+- hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); |
4558 |
+- hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); |
4559 |
+- hid->product = le16_to_cpu(ihid->hdesc.wProductID); |
4560 |
+- |
4561 |
+- snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX", |
4562 |
+- client->name, hid->vendor, hid->product); |
4563 |
+- strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); |
4564 |
+- |
4565 |
+- ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); |
4566 |
+- |
4567 |
+- ret = hid_add_device(hid); |
4568 |
+- if (ret) { |
4569 |
+- if (ret != -ENODEV) |
4570 |
+- hid_err(client, "can't add hid device: %d\n", ret); |
4571 |
+- goto err_mem_free; |
4572 |
+- } |
4573 |
+- |
4574 |
+- if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM)) |
4575 |
+- pm_runtime_put(&client->dev); |
4576 |
+- |
4577 |
+- return 0; |
4578 |
+- |
4579 |
+-err_mem_free: |
4580 |
+- hid_destroy_device(hid); |
4581 |
+- |
4582 |
+-err_irq: |
4583 |
+- free_irq(client->irq, ihid); |
4584 |
+- |
4585 |
+-err_pm: |
4586 |
+- pm_runtime_put_noidle(&client->dev); |
4587 |
+- pm_runtime_disable(&client->dev); |
4588 |
+- |
4589 |
+-err_regulator: |
4590 |
+- regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), |
4591 |
+- ihid->pdata.supplies); |
4592 |
+- i2c_hid_free_buffers(ihid); |
4593 |
+- return ret; |
4594 |
+-} |
4595 |
+- |
4596 |
+-static int i2c_hid_remove(struct i2c_client *client) |
4597 |
+-{ |
4598 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4599 |
+- struct hid_device *hid; |
4600 |
+- |
4601 |
+- if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM)) |
4602 |
+- pm_runtime_get_sync(&client->dev); |
4603 |
+- pm_runtime_disable(&client->dev); |
4604 |
+- pm_runtime_set_suspended(&client->dev); |
4605 |
+- pm_runtime_put_noidle(&client->dev); |
4606 |
+- |
4607 |
+- hid = ihid->hid; |
4608 |
+- hid_destroy_device(hid); |
4609 |
+- |
4610 |
+- free_irq(client->irq, ihid); |
4611 |
+- |
4612 |
+- if (ihid->bufsize) |
4613 |
+- i2c_hid_free_buffers(ihid); |
4614 |
+- |
4615 |
+- regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), |
4616 |
+- ihid->pdata.supplies); |
4617 |
+- |
4618 |
+- return 0; |
4619 |
+-} |
4620 |
+- |
4621 |
+-static void i2c_hid_shutdown(struct i2c_client *client) |
4622 |
+-{ |
4623 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4624 |
+- |
4625 |
+- i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
4626 |
+- free_irq(client->irq, ihid); |
4627 |
+-} |
4628 |
+- |
4629 |
+-#ifdef CONFIG_PM_SLEEP |
4630 |
+-static int i2c_hid_suspend(struct device *dev) |
4631 |
+-{ |
4632 |
+- struct i2c_client *client = to_i2c_client(dev); |
4633 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4634 |
+- struct hid_device *hid = ihid->hid; |
4635 |
+- int ret; |
4636 |
+- int wake_status; |
4637 |
+- |
4638 |
+- if (hid->driver && hid->driver->suspend) { |
4639 |
+- /* |
4640 |
+- * Wake up the device so that IO issues in |
4641 |
+- * HID driver's suspend code can succeed. |
4642 |
+- */ |
4643 |
+- ret = pm_runtime_resume(dev); |
4644 |
+- if (ret < 0) |
4645 |
+- return ret; |
4646 |
+- |
4647 |
+- ret = hid->driver->suspend(hid, PMSG_SUSPEND); |
4648 |
+- if (ret < 0) |
4649 |
+- return ret; |
4650 |
+- } |
4651 |
+- |
4652 |
+- if (!pm_runtime_suspended(dev)) { |
4653 |
+- /* Save some power */ |
4654 |
+- i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
4655 |
+- |
4656 |
+- disable_irq(client->irq); |
4657 |
+- } |
4658 |
+- |
4659 |
+- if (device_may_wakeup(&client->dev)) { |
4660 |
+- wake_status = enable_irq_wake(client->irq); |
4661 |
+- if (!wake_status) |
4662 |
+- ihid->irq_wake_enabled = true; |
4663 |
+- else |
4664 |
+- hid_warn(hid, "Failed to enable irq wake: %d\n", |
4665 |
+- wake_status); |
4666 |
+- } else { |
4667 |
+- regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), |
4668 |
+- ihid->pdata.supplies); |
4669 |
+- } |
4670 |
+- |
4671 |
+- return 0; |
4672 |
+-} |
4673 |
+- |
4674 |
+-static int i2c_hid_resume(struct device *dev) |
4675 |
+-{ |
4676 |
+- int ret; |
4677 |
+- struct i2c_client *client = to_i2c_client(dev); |
4678 |
+- struct i2c_hid *ihid = i2c_get_clientdata(client); |
4679 |
+- struct hid_device *hid = ihid->hid; |
4680 |
+- int wake_status; |
4681 |
+- |
4682 |
+- if (!device_may_wakeup(&client->dev)) { |
4683 |
+- ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies), |
4684 |
+- ihid->pdata.supplies); |
4685 |
+- if (ret) |
4686 |
+- hid_warn(hid, "Failed to enable supplies: %d\n", ret); |
4687 |
+- |
4688 |
+- if (ihid->pdata.post_power_delay_ms) |
4689 |
+- msleep(ihid->pdata.post_power_delay_ms); |
4690 |
+- } else if (ihid->irq_wake_enabled) { |
4691 |
+- wake_status = disable_irq_wake(client->irq); |
4692 |
+- if (!wake_status) |
4693 |
+- ihid->irq_wake_enabled = false; |
4694 |
+- else |
4695 |
+- hid_warn(hid, "Failed to disable irq wake: %d\n", |
4696 |
+- wake_status); |
4697 |
+- } |
4698 |
+- |
4699 |
+- /* We'll resume to full power */ |
4700 |
+- pm_runtime_disable(dev); |
4701 |
+- pm_runtime_set_active(dev); |
4702 |
+- pm_runtime_enable(dev); |
4703 |
+- |
4704 |
+- enable_irq(client->irq); |
4705 |
+- |
4706 |
+- /* Instead of resetting device, simply powers the device on. This |
4707 |
+- * solves "incomplete reports" on Raydium devices 2386:3118 and |
4708 |
+- * 2386:4B33 and fixes various SIS touchscreens no longer sending |
4709 |
+- * data after a suspend/resume. |
4710 |
+- */ |
4711 |
+- ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); |
4712 |
+- if (ret) |
4713 |
+- return ret; |
4714 |
+- |
4715 |
+- if (hid->driver && hid->driver->reset_resume) { |
4716 |
+- ret = hid->driver->reset_resume(hid); |
4717 |
+- return ret; |
4718 |
+- } |
4719 |
+- |
4720 |
+- return 0; |
4721 |
+-} |
4722 |
+-#endif |
4723 |
+- |
4724 |
+-#ifdef CONFIG_PM |
4725 |
+-static int i2c_hid_runtime_suspend(struct device *dev) |
4726 |
+-{ |
4727 |
+- struct i2c_client *client = to_i2c_client(dev); |
4728 |
+- |
4729 |
+- i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
4730 |
+- disable_irq(client->irq); |
4731 |
+- return 0; |
4732 |
+-} |
4733 |
+- |
4734 |
+-static int i2c_hid_runtime_resume(struct device *dev) |
4735 |
+-{ |
4736 |
+- struct i2c_client *client = to_i2c_client(dev); |
4737 |
+- |
4738 |
+- enable_irq(client->irq); |
4739 |
+- i2c_hid_set_power(client, I2C_HID_PWR_ON); |
4740 |
+- return 0; |
4741 |
+-} |
4742 |
+-#endif |
4743 |
+- |
4744 |
+-static const struct dev_pm_ops i2c_hid_pm = { |
4745 |
+- SET_SYSTEM_SLEEP_PM_OPS(i2c_hid_suspend, i2c_hid_resume) |
4746 |
+- SET_RUNTIME_PM_OPS(i2c_hid_runtime_suspend, i2c_hid_runtime_resume, |
4747 |
+- NULL) |
4748 |
+-}; |
4749 |
+- |
4750 |
+-static const struct i2c_device_id i2c_hid_id_table[] = { |
4751 |
+- { "hid", 0 }, |
4752 |
+- { "hid-over-i2c", 0 }, |
4753 |
+- { }, |
4754 |
+-}; |
4755 |
+-MODULE_DEVICE_TABLE(i2c, i2c_hid_id_table); |
4756 |
+- |
4757 |
+- |
4758 |
+-static struct i2c_driver i2c_hid_driver = { |
4759 |
+- .driver = { |
4760 |
+- .name = "i2c_hid", |
4761 |
+- .pm = &i2c_hid_pm, |
4762 |
+- .acpi_match_table = ACPI_PTR(i2c_hid_acpi_match), |
4763 |
+- .of_match_table = of_match_ptr(i2c_hid_of_match), |
4764 |
+- }, |
4765 |
+- |
4766 |
+- .probe = i2c_hid_probe, |
4767 |
+- .remove = i2c_hid_remove, |
4768 |
+- .shutdown = i2c_hid_shutdown, |
4769 |
+- .id_table = i2c_hid_id_table, |
4770 |
+-}; |
4771 |
+- |
4772 |
+-module_i2c_driver(i2c_hid_driver); |
4773 |
+- |
4774 |
+-MODULE_DESCRIPTION("HID over I2C core driver"); |
4775 |
+-MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@×××××.com>"); |
4776 |
+-MODULE_LICENSE("GPL"); |
4777 |
+diff --git a/drivers/hid/i2c-hid/i2c-hid.h b/drivers/hid/i2c-hid/i2c-hid.h |
4778 |
+new file mode 100644 |
4779 |
+index 000000000000..a8c19aef5824 |
4780 |
+--- /dev/null |
4781 |
++++ b/drivers/hid/i2c-hid/i2c-hid.h |
4782 |
+@@ -0,0 +1,20 @@ |
4783 |
++/* SPDX-License-Identifier: GPL-2.0+ */ |
4784 |
++ |
4785 |
++#ifndef I2C_HID_H |
4786 |
++#define I2C_HID_H |
4787 |
++ |
4788 |
++ |
4789 |
++#ifdef CONFIG_DMI |
4790 |
++struct i2c_hid_desc *i2c_hid_get_dmi_i2c_hid_desc_override(uint8_t *i2c_name); |
4791 |
++char *i2c_hid_get_dmi_hid_report_desc_override(uint8_t *i2c_name, |
4792 |
++ unsigned int *size); |
4793 |
++#else |
4794 |
++static inline struct i2c_hid_desc |
4795 |
++ *i2c_hid_get_dmi_i2c_hid_desc_override(uint8_t *i2c_name) |
4796 |
++{ return NULL; } |
4797 |
++static inline char *i2c_hid_get_dmi_hid_report_desc_override(uint8_t *i2c_name, |
4798 |
++ unsigned int *size) |
4799 |
++{ return NULL; } |
4800 |
++#endif |
4801 |
++ |
4802 |
++#endif |
4803 |
+diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c |
4804 |
+index 45b2460f3166..e8819d750938 100644 |
4805 |
+--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c |
4806 |
++++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c |
4807 |
+@@ -668,6 +668,10 @@ static const struct amba_id debug_ids[] = { |
4808 |
+ .id = 0x000bbd08, |
4809 |
+ .mask = 0x000fffff, |
4810 |
+ }, |
4811 |
++ { /* Debug for Cortex-A73 */ |
4812 |
++ .id = 0x000bbd09, |
4813 |
++ .mask = 0x000fffff, |
4814 |
++ }, |
4815 |
+ { 0, 0 }, |
4816 |
+ }; |
4817 |
+ |
4818 |
+diff --git a/drivers/infiniband/hw/hfi1/qp.c b/drivers/infiniband/hw/hfi1/qp.c |
4819 |
+index 9b1e84a6b1cc..63c5ba66b305 100644 |
4820 |
+--- a/drivers/infiniband/hw/hfi1/qp.c |
4821 |
++++ b/drivers/infiniband/hw/hfi1/qp.c |
4822 |
+@@ -784,7 +784,7 @@ void notify_error_qp(struct rvt_qp *qp) |
4823 |
+ write_seqlock(lock); |
4824 |
+ if (!list_empty(&priv->s_iowait.list) && |
4825 |
+ !(qp->s_flags & RVT_S_BUSY)) { |
4826 |
+- qp->s_flags &= ~RVT_S_ANY_WAIT_IO; |
4827 |
++ qp->s_flags &= ~HFI1_S_ANY_WAIT_IO; |
4828 |
+ list_del_init(&priv->s_iowait.list); |
4829 |
+ priv->s_iowait.lock = NULL; |
4830 |
+ rvt_put_qp(qp); |
4831 |
+diff --git a/drivers/infiniband/hw/i40iw/i40iw_utils.c b/drivers/infiniband/hw/i40iw/i40iw_utils.c |
4832 |
+index a9ea966877f2..dda8e79d4b27 100644 |
4833 |
+--- a/drivers/infiniband/hw/i40iw/i40iw_utils.c |
4834 |
++++ b/drivers/infiniband/hw/i40iw/i40iw_utils.c |
4835 |
+@@ -173,7 +173,12 @@ int i40iw_inetaddr_event(struct notifier_block *notifier, |
4836 |
+ |
4837 |
+ rcu_read_lock(); |
4838 |
+ in = __in_dev_get_rcu(upper_dev); |
4839 |
+- local_ipaddr = ntohl(in->ifa_list->ifa_address); |
4840 |
++ |
4841 |
++ if (!in->ifa_list) |
4842 |
++ local_ipaddr = 0; |
4843 |
++ else |
4844 |
++ local_ipaddr = ntohl(in->ifa_list->ifa_address); |
4845 |
++ |
4846 |
+ rcu_read_unlock(); |
4847 |
+ } else { |
4848 |
+ local_ipaddr = ntohl(ifa->ifa_address); |
4849 |
+@@ -185,6 +190,11 @@ int i40iw_inetaddr_event(struct notifier_block *notifier, |
4850 |
+ case NETDEV_UP: |
4851 |
+ /* Fall through */ |
4852 |
+ case NETDEV_CHANGEADDR: |
4853 |
++ |
4854 |
++ /* Just skip if no need to handle ARP cache */ |
4855 |
++ if (!local_ipaddr) |
4856 |
++ break; |
4857 |
++ |
4858 |
+ i40iw_manage_arp_cache(iwdev, |
4859 |
+ netdev->dev_addr, |
4860 |
+ &local_ipaddr, |
4861 |
+diff --git a/drivers/infiniband/hw/mlx4/alias_GUID.c b/drivers/infiniband/hw/mlx4/alias_GUID.c |
4862 |
+index 155b4dfc0ae8..baab9afa9174 100644 |
4863 |
+--- a/drivers/infiniband/hw/mlx4/alias_GUID.c |
4864 |
++++ b/drivers/infiniband/hw/mlx4/alias_GUID.c |
4865 |
+@@ -804,8 +804,8 @@ void mlx4_ib_destroy_alias_guid_service(struct mlx4_ib_dev *dev) |
4866 |
+ unsigned long flags; |
4867 |
+ |
4868 |
+ for (i = 0 ; i < dev->num_ports; i++) { |
4869 |
+- cancel_delayed_work(&dev->sriov.alias_guid.ports_guid[i].alias_guid_work); |
4870 |
+ det = &sriov->alias_guid.ports_guid[i]; |
4871 |
++ cancel_delayed_work_sync(&det->alias_guid_work); |
4872 |
+ spin_lock_irqsave(&sriov->alias_guid.ag_work_lock, flags); |
4873 |
+ while (!list_empty(&det->cb_list)) { |
4874 |
+ cb_ctx = list_entry(det->cb_list.next, |
4875 |
+diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c |
4876 |
+index d9c748b6f9e4..7f9824b0609e 100644 |
4877 |
+--- a/drivers/iommu/dmar.c |
4878 |
++++ b/drivers/iommu/dmar.c |
4879 |
+@@ -144,7 +144,7 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event) |
4880 |
+ for (tmp = dev; tmp; tmp = tmp->bus->self) |
4881 |
+ level++; |
4882 |
+ |
4883 |
+- size = sizeof(*info) + level * sizeof(struct acpi_dmar_pci_path); |
4884 |
++ size = sizeof(*info) + level * sizeof(info->path[0]); |
4885 |
+ if (size <= sizeof(dmar_pci_notify_info_buf)) { |
4886 |
+ info = (struct dmar_pci_notify_info *)dmar_pci_notify_info_buf; |
4887 |
+ } else { |
4888 |
+diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c |
4889 |
+index 2b8f5ebae821..603bf5233a99 100644 |
4890 |
+--- a/drivers/iommu/intel-iommu.c |
4891 |
++++ b/drivers/iommu/intel-iommu.c |
4892 |
+@@ -1624,6 +1624,9 @@ static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu) |
4893 |
+ u32 pmen; |
4894 |
+ unsigned long flags; |
4895 |
+ |
4896 |
++ if (!cap_plmr(iommu->cap) && !cap_phmr(iommu->cap)) |
4897 |
++ return; |
4898 |
++ |
4899 |
+ raw_spin_lock_irqsave(&iommu->register_lock, flags); |
4900 |
+ pmen = readl(iommu->reg + DMAR_PMEN_REG); |
4901 |
+ pmen &= ~DMA_PMEN_EPM; |
4902 |
+diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c |
4903 |
+index 567b29c47608..98b6e1d4b1a6 100644 |
4904 |
+--- a/drivers/irqchip/irq-mbigen.c |
4905 |
++++ b/drivers/irqchip/irq-mbigen.c |
4906 |
+@@ -161,6 +161,9 @@ static void mbigen_write_msg(struct msi_desc *desc, struct msi_msg *msg) |
4907 |
+ void __iomem *base = d->chip_data; |
4908 |
+ u32 val; |
4909 |
+ |
4910 |
++ if (!msg->address_lo && !msg->address_hi) |
4911 |
++ return; |
4912 |
++ |
4913 |
+ base += get_mbigen_vec_reg(d->hwirq); |
4914 |
+ val = readl_relaxed(base); |
4915 |
+ |
4916 |
+diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c |
4917 |
+index 0a2088e12d96..97b27f338c30 100644 |
4918 |
+--- a/drivers/irqchip/irq-stm32-exti.c |
4919 |
++++ b/drivers/irqchip/irq-stm32-exti.c |
4920 |
+@@ -650,11 +650,6 @@ stm32_exti_chip_data *stm32_exti_chip_init(struct stm32_exti_host_data *h_data, |
4921 |
+ */ |
4922 |
+ writel_relaxed(0, base + stm32_bank->imr_ofst); |
4923 |
+ writel_relaxed(0, base + stm32_bank->emr_ofst); |
4924 |
+- writel_relaxed(0, base + stm32_bank->rtsr_ofst); |
4925 |
+- writel_relaxed(0, base + stm32_bank->ftsr_ofst); |
4926 |
+- writel_relaxed(~0UL, base + stm32_bank->rpr_ofst); |
4927 |
+- if (stm32_bank->fpr_ofst != UNDEF_REG) |
4928 |
+- writel_relaxed(~0UL, base + stm32_bank->fpr_ofst); |
4929 |
+ |
4930 |
+ pr_info("%s: bank%d, External IRQs available:%#x\n", |
4931 |
+ node->full_name, bank_idx, irqs_mask); |
4932 |
+diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c |
4933 |
+index cd363a2100d4..257ae0d8cfe2 100644 |
4934 |
+--- a/drivers/media/usb/au0828/au0828-core.c |
4935 |
++++ b/drivers/media/usb/au0828/au0828-core.c |
4936 |
+@@ -629,7 +629,6 @@ static int au0828_usb_probe(struct usb_interface *interface, |
4937 |
+ pr_err("%s() au0282_dev_register failed to register on V4L2\n", |
4938 |
+ __func__); |
4939 |
+ mutex_unlock(&dev->lock); |
4940 |
+- kfree(dev); |
4941 |
+ goto done; |
4942 |
+ } |
4943 |
+ |
4944 |
+diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c |
4945 |
+index 2154d1bfd18b..07caaa2cfe1e 100644 |
4946 |
+--- a/drivers/misc/lkdtm/core.c |
4947 |
++++ b/drivers/misc/lkdtm/core.c |
4948 |
+@@ -152,7 +152,9 @@ static const struct crashtype crashtypes[] = { |
4949 |
+ CRASHTYPE(EXEC_VMALLOC), |
4950 |
+ CRASHTYPE(EXEC_RODATA), |
4951 |
+ CRASHTYPE(EXEC_USERSPACE), |
4952 |
++ CRASHTYPE(EXEC_NULL), |
4953 |
+ CRASHTYPE(ACCESS_USERSPACE), |
4954 |
++ CRASHTYPE(ACCESS_NULL), |
4955 |
+ CRASHTYPE(WRITE_RO), |
4956 |
+ CRASHTYPE(WRITE_RO_AFTER_INIT), |
4957 |
+ CRASHTYPE(WRITE_KERN), |
4958 |
+diff --git a/drivers/misc/lkdtm/lkdtm.h b/drivers/misc/lkdtm/lkdtm.h |
4959 |
+index 9e513dcfd809..8c3f2e6af256 100644 |
4960 |
+--- a/drivers/misc/lkdtm/lkdtm.h |
4961 |
++++ b/drivers/misc/lkdtm/lkdtm.h |
4962 |
+@@ -45,7 +45,9 @@ void lkdtm_EXEC_KMALLOC(void); |
4963 |
+ void lkdtm_EXEC_VMALLOC(void); |
4964 |
+ void lkdtm_EXEC_RODATA(void); |
4965 |
+ void lkdtm_EXEC_USERSPACE(void); |
4966 |
++void lkdtm_EXEC_NULL(void); |
4967 |
+ void lkdtm_ACCESS_USERSPACE(void); |
4968 |
++void lkdtm_ACCESS_NULL(void); |
4969 |
+ |
4970 |
+ /* lkdtm_refcount.c */ |
4971 |
+ void lkdtm_REFCOUNT_INC_OVERFLOW(void); |
4972 |
+diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c |
4973 |
+index 53b85c9d16b8..62f76d506f04 100644 |
4974 |
+--- a/drivers/misc/lkdtm/perms.c |
4975 |
++++ b/drivers/misc/lkdtm/perms.c |
4976 |
+@@ -47,7 +47,7 @@ static noinline void execute_location(void *dst, bool write) |
4977 |
+ { |
4978 |
+ void (*func)(void) = dst; |
4979 |
+ |
4980 |
+- pr_info("attempting ok execution at %p\n", do_nothing); |
4981 |
++ pr_info("attempting ok execution at %px\n", do_nothing); |
4982 |
+ do_nothing(); |
4983 |
+ |
4984 |
+ if (write == CODE_WRITE) { |
4985 |
+@@ -55,7 +55,7 @@ static noinline void execute_location(void *dst, bool write) |
4986 |
+ flush_icache_range((unsigned long)dst, |
4987 |
+ (unsigned long)dst + EXEC_SIZE); |
4988 |
+ } |
4989 |
+- pr_info("attempting bad execution at %p\n", func); |
4990 |
++ pr_info("attempting bad execution at %px\n", func); |
4991 |
+ func(); |
4992 |
+ } |
4993 |
+ |
4994 |
+@@ -66,14 +66,14 @@ static void execute_user_location(void *dst) |
4995 |
+ /* Intentionally crossing kernel/user memory boundary. */ |
4996 |
+ void (*func)(void) = dst; |
4997 |
+ |
4998 |
+- pr_info("attempting ok execution at %p\n", do_nothing); |
4999 |
++ pr_info("attempting ok execution at %px\n", do_nothing); |
5000 |
+ do_nothing(); |
5001 |
+ |
5002 |
+ copied = access_process_vm(current, (unsigned long)dst, do_nothing, |
5003 |
+ EXEC_SIZE, FOLL_WRITE); |
5004 |
+ if (copied < EXEC_SIZE) |
5005 |
+ return; |
5006 |
+- pr_info("attempting bad execution at %p\n", func); |
5007 |
++ pr_info("attempting bad execution at %px\n", func); |
5008 |
+ func(); |
5009 |
+ } |
5010 |
+ |
5011 |
+@@ -82,7 +82,7 @@ void lkdtm_WRITE_RO(void) |
5012 |
+ /* Explicitly cast away "const" for the test. */ |
5013 |
+ unsigned long *ptr = (unsigned long *)&rodata; |
5014 |
+ |
5015 |
+- pr_info("attempting bad rodata write at %p\n", ptr); |
5016 |
++ pr_info("attempting bad rodata write at %px\n", ptr); |
5017 |
+ *ptr ^= 0xabcd1234; |
5018 |
+ } |
5019 |
+ |
5020 |
+@@ -100,7 +100,7 @@ void lkdtm_WRITE_RO_AFTER_INIT(void) |
5021 |
+ return; |
5022 |
+ } |
5023 |
+ |
5024 |
+- pr_info("attempting bad ro_after_init write at %p\n", ptr); |
5025 |
++ pr_info("attempting bad ro_after_init write at %px\n", ptr); |
5026 |
+ *ptr ^= 0xabcd1234; |
5027 |
+ } |
5028 |
+ |
5029 |
+@@ -112,7 +112,7 @@ void lkdtm_WRITE_KERN(void) |
5030 |
+ size = (unsigned long)do_overwritten - (unsigned long)do_nothing; |
5031 |
+ ptr = (unsigned char *)do_overwritten; |
5032 |
+ |
5033 |
+- pr_info("attempting bad %zu byte write at %p\n", size, ptr); |
5034 |
++ pr_info("attempting bad %zu byte write at %px\n", size, ptr); |
5035 |
+ memcpy(ptr, (unsigned char *)do_nothing, size); |
5036 |
+ flush_icache_range((unsigned long)ptr, (unsigned long)(ptr + size)); |
5037 |
+ |
5038 |
+@@ -164,6 +164,11 @@ void lkdtm_EXEC_USERSPACE(void) |
5039 |
+ vm_munmap(user_addr, PAGE_SIZE); |
5040 |
+ } |
5041 |
+ |
5042 |
++void lkdtm_EXEC_NULL(void) |
5043 |
++{ |
5044 |
++ execute_location(NULL, CODE_AS_IS); |
5045 |
++} |
5046 |
++ |
5047 |
+ void lkdtm_ACCESS_USERSPACE(void) |
5048 |
+ { |
5049 |
+ unsigned long user_addr, tmp = 0; |
5050 |
+@@ -185,16 +190,29 @@ void lkdtm_ACCESS_USERSPACE(void) |
5051 |
+ |
5052 |
+ ptr = (unsigned long *)user_addr; |
5053 |
+ |
5054 |
+- pr_info("attempting bad read at %p\n", ptr); |
5055 |
++ pr_info("attempting bad read at %px\n", ptr); |
5056 |
+ tmp = *ptr; |
5057 |
+ tmp += 0xc0dec0de; |
5058 |
+ |
5059 |
+- pr_info("attempting bad write at %p\n", ptr); |
5060 |
++ pr_info("attempting bad write at %px\n", ptr); |
5061 |
+ *ptr = tmp; |
5062 |
+ |
5063 |
+ vm_munmap(user_addr, PAGE_SIZE); |
5064 |
+ } |
5065 |
+ |
5066 |
++void lkdtm_ACCESS_NULL(void) |
5067 |
++{ |
5068 |
++ unsigned long tmp; |
5069 |
++ unsigned long *ptr = (unsigned long *)NULL; |
5070 |
++ |
5071 |
++ pr_info("attempting bad read at %px\n", ptr); |
5072 |
++ tmp = *ptr; |
5073 |
++ tmp += 0xc0dec0de; |
5074 |
++ |
5075 |
++ pr_info("attempting bad write at %px\n", ptr); |
5076 |
++ *ptr = tmp; |
5077 |
++} |
5078 |
++ |
5079 |
+ void __init lkdtm_perms_init(void) |
5080 |
+ { |
5081 |
+ /* Make sure we can write to __ro_after_init values during __init */ |
5082 |
+diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c |
5083 |
+index 9e68c3645e22..e6f14257a7d0 100644 |
5084 |
+--- a/drivers/mmc/host/davinci_mmc.c |
5085 |
++++ b/drivers/mmc/host/davinci_mmc.c |
5086 |
+@@ -1117,7 +1117,7 @@ static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host *host) |
5087 |
+ { |
5088 |
+ } |
5089 |
+ #endif |
5090 |
+-static void __init init_mmcsd_host(struct mmc_davinci_host *host) |
5091 |
++static void init_mmcsd_host(struct mmc_davinci_host *host) |
5092 |
+ { |
5093 |
+ |
5094 |
+ mmc_davinci_reset_ctrl(host, 1); |
5095 |
+diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c |
5096 |
+index afed0f0f4027..c0c75c111abb 100644 |
5097 |
+--- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c |
5098 |
++++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c |
5099 |
+@@ -59,7 +59,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) |
5100 |
+ |
5101 |
+ desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); |
5102 |
+ stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum, |
5103 |
+- STMMAC_RING_MODE, 0, false, skb->len); |
5104 |
++ STMMAC_RING_MODE, 1, false, skb->len); |
5105 |
+ tx_q->tx_skbuff[entry] = NULL; |
5106 |
+ entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); |
5107 |
+ |
5108 |
+@@ -91,7 +91,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) |
5109 |
+ tx_q->tx_skbuff_dma[entry].is_jumbo = true; |
5110 |
+ desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); |
5111 |
+ stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum, |
5112 |
+- STMMAC_RING_MODE, 0, true, skb->len); |
5113 |
++ STMMAC_RING_MODE, 1, true, skb->len); |
5114 |
+ } |
5115 |
+ |
5116 |
+ tx_q->cur_tx = entry; |
5117 |
+diff --git a/drivers/net/wireless/rsi/rsi_common.h b/drivers/net/wireless/rsi/rsi_common.h |
5118 |
+index d9ff3b8be86e..60f1f286b030 100644 |
5119 |
+--- a/drivers/net/wireless/rsi/rsi_common.h |
5120 |
++++ b/drivers/net/wireless/rsi/rsi_common.h |
5121 |
+@@ -75,7 +75,6 @@ static inline int rsi_kill_thread(struct rsi_thread *handle) |
5122 |
+ atomic_inc(&handle->thread_done); |
5123 |
+ rsi_set_event(&handle->event); |
5124 |
+ |
5125 |
+- wait_for_completion(&handle->completion); |
5126 |
+ return kthread_stop(handle->task); |
5127 |
+ } |
5128 |
+ |
5129 |
+diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c |
5130 |
+index 7eb1549cea81..30649addc625 100644 |
5131 |
+--- a/drivers/pci/pci.c |
5132 |
++++ b/drivers/pci/pci.c |
5133 |
+@@ -2489,6 +2489,25 @@ void pci_config_pm_runtime_put(struct pci_dev *pdev) |
5134 |
+ pm_runtime_put_sync(parent); |
5135 |
+ } |
5136 |
+ |
5137 |
++static const struct dmi_system_id bridge_d3_blacklist[] = { |
5138 |
++#ifdef CONFIG_X86 |
5139 |
++ { |
5140 |
++ /* |
5141 |
++ * Gigabyte X299 root port is not marked as hotplug capable |
5142 |
++ * which allows Linux to power manage it. However, this |
5143 |
++ * confuses the BIOS SMI handler so don't power manage root |
5144 |
++ * ports on that system. |
5145 |
++ */ |
5146 |
++ .ident = "X299 DESIGNARE EX-CF", |
5147 |
++ .matches = { |
5148 |
++ DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."), |
5149 |
++ DMI_MATCH(DMI_BOARD_NAME, "X299 DESIGNARE EX-CF"), |
5150 |
++ }, |
5151 |
++ }, |
5152 |
++#endif |
5153 |
++ { } |
5154 |
++}; |
5155 |
++ |
5156 |
+ /** |
5157 |
+ * pci_bridge_d3_possible - Is it possible to put the bridge into D3 |
5158 |
+ * @bridge: Bridge to check |
5159 |
+@@ -2530,6 +2549,9 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) |
5160 |
+ if (bridge->is_hotplug_bridge) |
5161 |
+ return false; |
5162 |
+ |
5163 |
++ if (dmi_check_system(bridge_d3_blacklist)) |
5164 |
++ return false; |
5165 |
++ |
5166 |
+ /* |
5167 |
+ * It should be safe to put PCIe ports from 2015 or newer |
5168 |
+ * to D3. |
5169 |
+diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c |
5170 |
+index a3dd777e3ce8..c6ff4d5fa482 100644 |
5171 |
+--- a/drivers/pinctrl/core.c |
5172 |
++++ b/drivers/pinctrl/core.c |
5173 |
+@@ -627,7 +627,7 @@ static int pinctrl_generic_group_name_to_selector(struct pinctrl_dev *pctldev, |
5174 |
+ while (selector < ngroups) { |
5175 |
+ const char *gname = ops->get_group_name(pctldev, selector); |
5176 |
+ |
5177 |
+- if (!strcmp(function, gname)) |
5178 |
++ if (gname && !strcmp(function, gname)) |
5179 |
+ return selector; |
5180 |
+ |
5181 |
+ selector++; |
5182 |
+@@ -743,7 +743,7 @@ int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, |
5183 |
+ while (group_selector < ngroups) { |
5184 |
+ const char *gname = pctlops->get_group_name(pctldev, |
5185 |
+ group_selector); |
5186 |
+- if (!strcmp(gname, pin_group)) { |
5187 |
++ if (gname && !strcmp(gname, pin_group)) { |
5188 |
+ dev_dbg(pctldev->dev, |
5189 |
+ "found group selector %u for %s\n", |
5190 |
+ group_selector, |
5191 |
+diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig |
5192 |
+index 7563c07e14e4..1e2524de6a63 100644 |
5193 |
+--- a/drivers/platform/x86/Kconfig |
5194 |
++++ b/drivers/platform/x86/Kconfig |
5195 |
+@@ -1231,6 +1231,18 @@ config I2C_MULTI_INSTANTIATE |
5196 |
+ To compile this driver as a module, choose M here: the module |
5197 |
+ will be called i2c-multi-instantiate. |
5198 |
+ |
5199 |
++config INTEL_ATOMISP2_PM |
5200 |
++ tristate "Intel AtomISP2 dummy / power-management driver" |
5201 |
++ depends on PCI && IOSF_MBI && PM |
5202 |
++ help |
5203 |
++ Power-management driver for Intel's Image Signal Processor found on |
5204 |
++ Bay and Cherry Trail devices. This dummy driver's sole purpose is to |
5205 |
++ turn the ISP off (put it in D3) to save power and to allow entering |
5206 |
++ of S0ix modes. |
5207 |
++ |
5208 |
++ To compile this driver as a module, choose M here: the module |
5209 |
++ will be called intel_atomisp2_pm. |
5210 |
++ |
5211 |
+ endif # X86_PLATFORM_DEVICES |
5212 |
+ |
5213 |
+ config PMC_ATOM |
5214 |
+diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile |
5215 |
+index e6d1becf81ce..dc29af4d8e2f 100644 |
5216 |
+--- a/drivers/platform/x86/Makefile |
5217 |
++++ b/drivers/platform/x86/Makefile |
5218 |
+@@ -92,3 +92,4 @@ obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o |
5219 |
+ obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o |
5220 |
+ obj-$(CONFIG_INTEL_CHTDC_TI_PWRBTN) += intel_chtdc_ti_pwrbtn.o |
5221 |
+ obj-$(CONFIG_I2C_MULTI_INSTANTIATE) += i2c-multi-instantiate.o |
5222 |
++obj-$(CONFIG_INTEL_ATOMISP2_PM) += intel_atomisp2_pm.o |
5223 |
+diff --git a/drivers/platform/x86/intel_atomisp2_pm.c b/drivers/platform/x86/intel_atomisp2_pm.c |
5224 |
+new file mode 100644 |
5225 |
+index 000000000000..9371603a0ac9 |
5226 |
+--- /dev/null |
5227 |
++++ b/drivers/platform/x86/intel_atomisp2_pm.c |
5228 |
+@@ -0,0 +1,119 @@ |
5229 |
++// SPDX-License-Identifier: GPL-2.0 |
5230 |
++/* |
5231 |
++ * Dummy driver for Intel's Image Signal Processor found on Bay and Cherry |
5232 |
++ * Trail devices. The sole purpose of this driver is to allow the ISP to |
5233 |
++ * be put in D3. |
5234 |
++ * |
5235 |
++ * Copyright (C) 2018 Hans de Goede <hdegoede@××××××.com> |
5236 |
++ * |
5237 |
++ * Based on various non upstream patches for ISP support: |
5238 |
++ * Copyright (C) 2010-2017 Intel Corporation. All rights reserved. |
5239 |
++ * Copyright (c) 2010 Silicon Hive www.siliconhive.com. |
5240 |
++ */ |
5241 |
++ |
5242 |
++#include <linux/delay.h> |
5243 |
++#include <linux/module.h> |
5244 |
++#include <linux/mod_devicetable.h> |
5245 |
++#include <linux/pci.h> |
5246 |
++#include <linux/pm_runtime.h> |
5247 |
++#include <asm/iosf_mbi.h> |
5248 |
++ |
5249 |
++/* PCI configuration regs */ |
5250 |
++#define PCI_INTERRUPT_CTRL 0x9c |
5251 |
++ |
5252 |
++#define PCI_CSI_CONTROL 0xe8 |
5253 |
++#define PCI_CSI_CONTROL_PORTS_OFF_MASK 0x7 |
5254 |
++ |
5255 |
++/* IOSF BT_MBI_UNIT_PMC regs */ |
5256 |
++#define ISPSSPM0 0x39 |
5257 |
++#define ISPSSPM0_ISPSSC_OFFSET 0 |
5258 |
++#define ISPSSPM0_ISPSSC_MASK 0x00000003 |
5259 |
++#define ISPSSPM0_ISPSSS_OFFSET 24 |
5260 |
++#define ISPSSPM0_ISPSSS_MASK 0x03000000 |
5261 |
++#define ISPSSPM0_IUNIT_POWER_ON 0x0 |
5262 |
++#define ISPSSPM0_IUNIT_POWER_OFF 0x3 |
5263 |
++ |
5264 |
++static int isp_probe(struct pci_dev *dev, const struct pci_device_id *id) |
5265 |
++{ |
5266 |
++ unsigned long timeout; |
5267 |
++ u32 val; |
5268 |
++ |
5269 |
++ pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, 0); |
5270 |
++ |
5271 |
++ /* |
5272 |
++ * MRFLD IUNIT DPHY is located in an always-power-on island |
5273 |
++ * MRFLD HW design need all CSI ports are disabled before |
5274 |
++ * powering down the IUNIT. |
5275 |
++ */ |
5276 |
++ pci_read_config_dword(dev, PCI_CSI_CONTROL, &val); |
5277 |
++ val |= PCI_CSI_CONTROL_PORTS_OFF_MASK; |
5278 |
++ pci_write_config_dword(dev, PCI_CSI_CONTROL, val); |
5279 |
++ |
5280 |
++ /* Write 0x3 to ISPSSPM0 bit[1:0] to power off the IUNIT */ |
5281 |
++ iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0, |
5282 |
++ ISPSSPM0_IUNIT_POWER_OFF, ISPSSPM0_ISPSSC_MASK); |
5283 |
++ |
5284 |
++ /* |
5285 |
++ * There should be no IUNIT access while power-down is |
5286 |
++ * in progress HW sighting: 4567865 |
5287 |
++ * Wait up to 50 ms for the IUNIT to shut down. |
5288 |
++ */ |
5289 |
++ timeout = jiffies + msecs_to_jiffies(50); |
5290 |
++ while (1) { |
5291 |
++ /* Wait until ISPSSPM0 bit[25:24] shows 0x3 */ |
5292 |
++ iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0, &val); |
5293 |
++ val = (val & ISPSSPM0_ISPSSS_MASK) >> ISPSSPM0_ISPSSS_OFFSET; |
5294 |
++ if (val == ISPSSPM0_IUNIT_POWER_OFF) |
5295 |
++ break; |
5296 |
++ |
5297 |
++ if (time_after(jiffies, timeout)) { |
5298 |
++ dev_err(&dev->dev, "IUNIT power-off timeout.\n"); |
5299 |
++ return -EBUSY; |
5300 |
++ } |
5301 |
++ usleep_range(1000, 2000); |
5302 |
++ } |
5303 |
++ |
5304 |
++ pm_runtime_allow(&dev->dev); |
5305 |
++ pm_runtime_put_sync_suspend(&dev->dev); |
5306 |
++ |
5307 |
++ return 0; |
5308 |
++} |
5309 |
++ |
5310 |
++static void isp_remove(struct pci_dev *dev) |
5311 |
++{ |
5312 |
++ pm_runtime_get_sync(&dev->dev); |
5313 |
++ pm_runtime_forbid(&dev->dev); |
5314 |
++} |
5315 |
++ |
5316 |
++static int isp_pci_suspend(struct device *dev) |
5317 |
++{ |
5318 |
++ return 0; |
5319 |
++} |
5320 |
++ |
5321 |
++static int isp_pci_resume(struct device *dev) |
5322 |
++{ |
5323 |
++ return 0; |
5324 |
++} |
5325 |
++ |
5326 |
++static UNIVERSAL_DEV_PM_OPS(isp_pm_ops, isp_pci_suspend, |
5327 |
++ isp_pci_resume, NULL); |
5328 |
++ |
5329 |
++static const struct pci_device_id isp_id_table[] = { |
5330 |
++ { PCI_VDEVICE(INTEL, 0x22b8), }, |
5331 |
++ { 0, } |
5332 |
++}; |
5333 |
++MODULE_DEVICE_TABLE(pci, isp_id_table); |
5334 |
++ |
5335 |
++static struct pci_driver isp_pci_driver = { |
5336 |
++ .name = "intel_atomisp2_pm", |
5337 |
++ .id_table = isp_id_table, |
5338 |
++ .probe = isp_probe, |
5339 |
++ .remove = isp_remove, |
5340 |
++ .driver.pm = &isp_pm_ops, |
5341 |
++}; |
5342 |
++ |
5343 |
++module_pci_driver(isp_pci_driver); |
5344 |
++ |
5345 |
++MODULE_DESCRIPTION("Intel AtomISP2 dummy / power-management drv (for suspend)"); |
5346 |
++MODULE_AUTHOR("Hans de Goede <hdegoede@××××××.com>"); |
5347 |
++MODULE_LICENSE("GPL v2"); |
5348 |
+diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c |
5349 |
+index 18e4289baf99..655790f30434 100644 |
5350 |
+--- a/drivers/scsi/scsi_lib.c |
5351 |
++++ b/drivers/scsi/scsi_lib.c |
5352 |
+@@ -3095,7 +3095,6 @@ void scsi_device_resume(struct scsi_device *sdev) |
5353 |
+ * device deleted during suspend) |
5354 |
+ */ |
5355 |
+ mutex_lock(&sdev->state_mutex); |
5356 |
+- WARN_ON_ONCE(!sdev->quiesced_by); |
5357 |
+ sdev->quiesced_by = NULL; |
5358 |
+ blk_clear_preempt_only(sdev->request_queue); |
5359 |
+ if (sdev->sdev_state == SDEV_QUIESCE) |
5360 |
+diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c |
5361 |
+index 6fd2fe210fc3..4d0fc6b01fa0 100644 |
5362 |
+--- a/drivers/scsi/scsi_transport_iscsi.c |
5363 |
++++ b/drivers/scsi/scsi_transport_iscsi.c |
5364 |
+@@ -2185,6 +2185,8 @@ void iscsi_remove_session(struct iscsi_cls_session *session) |
5365 |
+ scsi_target_unblock(&session->dev, SDEV_TRANSPORT_OFFLINE); |
5366 |
+ /* flush running scans then delete devices */ |
5367 |
+ flush_work(&session->scan_work); |
5368 |
++ /* flush running unbind operations */ |
5369 |
++ flush_work(&session->unbind_work); |
5370 |
+ __iscsi_unbind_session(&session->unbind_work); |
5371 |
+ |
5372 |
+ /* hw iscsi may not have removed all connections from session */ |
5373 |
+diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c |
5374 |
+index ed71a4c9c8b2..4b452f36f054 100644 |
5375 |
+--- a/drivers/soc/tegra/pmc.c |
5376 |
++++ b/drivers/soc/tegra/pmc.c |
5377 |
+@@ -524,16 +524,10 @@ EXPORT_SYMBOL(tegra_powergate_power_off); |
5378 |
+ */ |
5379 |
+ int tegra_powergate_is_powered(unsigned int id) |
5380 |
+ { |
5381 |
+- int status; |
5382 |
+- |
5383 |
+ if (!tegra_powergate_is_valid(id)) |
5384 |
+ return -EINVAL; |
5385 |
+ |
5386 |
+- mutex_lock(&pmc->powergates_lock); |
5387 |
+- status = tegra_powergate_state(id); |
5388 |
+- mutex_unlock(&pmc->powergates_lock); |
5389 |
+- |
5390 |
+- return status; |
5391 |
++ return tegra_powergate_state(id); |
5392 |
+ } |
5393 |
+ |
5394 |
+ /** |
5395 |
+diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c |
5396 |
+index 24b006a95142..8646fb7425f2 100644 |
5397 |
+--- a/drivers/thermal/broadcom/bcm2835_thermal.c |
5398 |
++++ b/drivers/thermal/broadcom/bcm2835_thermal.c |
5399 |
+@@ -128,8 +128,7 @@ static const struct debugfs_reg32 bcm2835_thermal_regs[] = { |
5400 |
+ |
5401 |
+ static void bcm2835_thermal_debugfs(struct platform_device *pdev) |
5402 |
+ { |
5403 |
+- struct thermal_zone_device *tz = platform_get_drvdata(pdev); |
5404 |
+- struct bcm2835_thermal_data *data = tz->devdata; |
5405 |
++ struct bcm2835_thermal_data *data = platform_get_drvdata(pdev); |
5406 |
+ struct debugfs_regset32 *regset; |
5407 |
+ |
5408 |
+ data->debugfsdir = debugfs_create_dir("bcm2835_thermal", NULL); |
5409 |
+@@ -275,7 +274,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) |
5410 |
+ |
5411 |
+ data->tz = tz; |
5412 |
+ |
5413 |
+- platform_set_drvdata(pdev, tz); |
5414 |
++ platform_set_drvdata(pdev, data); |
5415 |
+ |
5416 |
+ /* |
5417 |
+ * Thermal_zone doesn't enable hwmon as default, |
5418 |
+@@ -299,8 +298,8 @@ err_clk: |
5419 |
+ |
5420 |
+ static int bcm2835_thermal_remove(struct platform_device *pdev) |
5421 |
+ { |
5422 |
+- struct thermal_zone_device *tz = platform_get_drvdata(pdev); |
5423 |
+- struct bcm2835_thermal_data *data = tz->devdata; |
5424 |
++ struct bcm2835_thermal_data *data = platform_get_drvdata(pdev); |
5425 |
++ struct thermal_zone_device *tz = data->tz; |
5426 |
+ |
5427 |
+ debugfs_remove_recursive(data->debugfsdir); |
5428 |
+ thermal_zone_of_sensor_unregister(&pdev->dev, tz); |
5429 |
+diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c |
5430 |
+index e26b01c05e82..e9d58de8b5da 100644 |
5431 |
+--- a/drivers/thermal/int340x_thermal/int3400_thermal.c |
5432 |
++++ b/drivers/thermal/int340x_thermal/int3400_thermal.c |
5433 |
+@@ -22,6 +22,13 @@ enum int3400_thermal_uuid { |
5434 |
+ INT3400_THERMAL_PASSIVE_1, |
5435 |
+ INT3400_THERMAL_ACTIVE, |
5436 |
+ INT3400_THERMAL_CRITICAL, |
5437 |
++ INT3400_THERMAL_ADAPTIVE_PERFORMANCE, |
5438 |
++ INT3400_THERMAL_EMERGENCY_CALL_MODE, |
5439 |
++ INT3400_THERMAL_PASSIVE_2, |
5440 |
++ INT3400_THERMAL_POWER_BOSS, |
5441 |
++ INT3400_THERMAL_VIRTUAL_SENSOR, |
5442 |
++ INT3400_THERMAL_COOLING_MODE, |
5443 |
++ INT3400_THERMAL_HARDWARE_DUTY_CYCLING, |
5444 |
+ INT3400_THERMAL_MAXIMUM_UUID, |
5445 |
+ }; |
5446 |
+ |
5447 |
+@@ -29,6 +36,13 @@ static char *int3400_thermal_uuids[INT3400_THERMAL_MAXIMUM_UUID] = { |
5448 |
+ "42A441D6-AE6A-462b-A84B-4A8CE79027D3", |
5449 |
+ "3A95C389-E4B8-4629-A526-C52C88626BAE", |
5450 |
+ "97C68AE7-15FA-499c-B8C9-5DA81D606E0A", |
5451 |
++ "63BE270F-1C11-48FD-A6F7-3AF253FF3E2D", |
5452 |
++ "5349962F-71E6-431D-9AE8-0A635B710AEE", |
5453 |
++ "9E04115A-AE87-4D1C-9500-0F3E340BFE75", |
5454 |
++ "F5A35014-C209-46A4-993A-EB56DE7530A1", |
5455 |
++ "6ED722A7-9240-48A5-B479-31EEF723D7CF", |
5456 |
++ "16CAF1B7-DD38-40ED-B1C1-1B8A1913D531", |
5457 |
++ "BE84BABF-C4D4-403D-B495-3128FD44dAC1", |
5458 |
+ }; |
5459 |
+ |
5460 |
+ struct int3400_thermal_priv { |
5461 |
+@@ -302,10 +316,9 @@ static int int3400_thermal_probe(struct platform_device *pdev) |
5462 |
+ |
5463 |
+ platform_set_drvdata(pdev, priv); |
5464 |
+ |
5465 |
+- if (priv->uuid_bitmap & 1 << INT3400_THERMAL_PASSIVE_1) { |
5466 |
+- int3400_thermal_ops.get_mode = int3400_thermal_get_mode; |
5467 |
+- int3400_thermal_ops.set_mode = int3400_thermal_set_mode; |
5468 |
+- } |
5469 |
++ int3400_thermal_ops.get_mode = int3400_thermal_get_mode; |
5470 |
++ int3400_thermal_ops.set_mode = int3400_thermal_set_mode; |
5471 |
++ |
5472 |
+ priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0, |
5473 |
+ priv, &int3400_thermal_ops, |
5474 |
+ &int3400_thermal_params, 0, 0); |
5475 |
+diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c |
5476 |
+index cde891c54cde..8e8328347c0e 100644 |
5477 |
+--- a/drivers/thermal/intel_powerclamp.c |
5478 |
++++ b/drivers/thermal/intel_powerclamp.c |
5479 |
+@@ -101,7 +101,7 @@ struct powerclamp_worker_data { |
5480 |
+ bool clamping; |
5481 |
+ }; |
5482 |
+ |
5483 |
+-static struct powerclamp_worker_data * __percpu worker_data; |
5484 |
++static struct powerclamp_worker_data __percpu *worker_data; |
5485 |
+ static struct thermal_cooling_device *cooling_dev; |
5486 |
+ static unsigned long *cpu_clamping_mask; /* bit map for tracking per cpu |
5487 |
+ * clamping kthread worker |
5488 |
+@@ -494,7 +494,7 @@ static void start_power_clamp_worker(unsigned long cpu) |
5489 |
+ struct powerclamp_worker_data *w_data = per_cpu_ptr(worker_data, cpu); |
5490 |
+ struct kthread_worker *worker; |
5491 |
+ |
5492 |
+- worker = kthread_create_worker_on_cpu(cpu, 0, "kidle_inject/%ld", cpu); |
5493 |
++ worker = kthread_create_worker_on_cpu(cpu, 0, "kidle_inj/%ld", cpu); |
5494 |
+ if (IS_ERR(worker)) |
5495 |
+ return; |
5496 |
+ |
5497 |
+diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c |
5498 |
+index 48eef552cba4..fc9399d9c082 100644 |
5499 |
+--- a/drivers/thermal/samsung/exynos_tmu.c |
5500 |
++++ b/drivers/thermal/samsung/exynos_tmu.c |
5501 |
+@@ -666,7 +666,7 @@ static int exynos_get_temp(void *p, int *temp) |
5502 |
+ struct exynos_tmu_data *data = p; |
5503 |
+ int value, ret = 0; |
5504 |
+ |
5505 |
+- if (!data || !data->tmu_read || !data->enabled) |
5506 |
++ if (!data || !data->tmu_read) |
5507 |
+ return -EINVAL; |
5508 |
+ else if (!data->enabled) |
5509 |
+ /* |
5510 |
+diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c |
5511 |
+index 0e3627289047..77efa0a43fe7 100644 |
5512 |
+--- a/drivers/tty/serial/xilinx_uartps.c |
5513 |
++++ b/drivers/tty/serial/xilinx_uartps.c |
5514 |
+@@ -1223,7 +1223,7 @@ static void cdns_uart_console_write(struct console *co, const char *s, |
5515 |
+ * |
5516 |
+ * Return: 0 on success, negative errno otherwise. |
5517 |
+ */ |
5518 |
+-static int __init cdns_uart_console_setup(struct console *co, char *options) |
5519 |
++static int cdns_uart_console_setup(struct console *co, char *options) |
5520 |
+ { |
5521 |
+ struct uart_port *port = console_port; |
5522 |
+ |
5523 |
+diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c |
5524 |
+index 89bac3d2f05b..619128b55837 100644 |
5525 |
+--- a/fs/9p/v9fs.c |
5526 |
++++ b/fs/9p/v9fs.c |
5527 |
+@@ -61,6 +61,8 @@ enum { |
5528 |
+ Opt_cache_loose, Opt_fscache, Opt_mmap, |
5529 |
+ /* Access options */ |
5530 |
+ Opt_access, Opt_posixacl, |
5531 |
++ /* Lock timeout option */ |
5532 |
++ Opt_locktimeout, |
5533 |
+ /* Error token */ |
5534 |
+ Opt_err |
5535 |
+ }; |
5536 |
+@@ -80,6 +82,7 @@ static const match_table_t tokens = { |
5537 |
+ {Opt_cachetag, "cachetag=%s"}, |
5538 |
+ {Opt_access, "access=%s"}, |
5539 |
+ {Opt_posixacl, "posixacl"}, |
5540 |
++ {Opt_locktimeout, "locktimeout=%u"}, |
5541 |
+ {Opt_err, NULL} |
5542 |
+ }; |
5543 |
+ |
5544 |
+@@ -187,6 +190,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) |
5545 |
+ #ifdef CONFIG_9P_FSCACHE |
5546 |
+ v9ses->cachetag = NULL; |
5547 |
+ #endif |
5548 |
++ v9ses->session_lock_timeout = P9_LOCK_TIMEOUT; |
5549 |
+ |
5550 |
+ if (!opts) |
5551 |
+ return 0; |
5552 |
+@@ -359,6 +363,23 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) |
5553 |
+ #endif |
5554 |
+ break; |
5555 |
+ |
5556 |
++ case Opt_locktimeout: |
5557 |
++ r = match_int(&args[0], &option); |
5558 |
++ if (r < 0) { |
5559 |
++ p9_debug(P9_DEBUG_ERROR, |
5560 |
++ "integer field, but no integer?\n"); |
5561 |
++ ret = r; |
5562 |
++ continue; |
5563 |
++ } |
5564 |
++ if (option < 1) { |
5565 |
++ p9_debug(P9_DEBUG_ERROR, |
5566 |
++ "locktimeout must be a greater than zero integer.\n"); |
5567 |
++ ret = -EINVAL; |
5568 |
++ continue; |
5569 |
++ } |
5570 |
++ v9ses->session_lock_timeout = (long)option * HZ; |
5571 |
++ break; |
5572 |
++ |
5573 |
+ default: |
5574 |
+ continue; |
5575 |
+ } |
5576 |
+diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h |
5577 |
+index 982e017acadb..129e5243a6bf 100644 |
5578 |
+--- a/fs/9p/v9fs.h |
5579 |
++++ b/fs/9p/v9fs.h |
5580 |
+@@ -116,6 +116,7 @@ struct v9fs_session_info { |
5581 |
+ struct p9_client *clnt; /* 9p client */ |
5582 |
+ struct list_head slist; /* list of sessions registered with v9fs */ |
5583 |
+ struct rw_semaphore rename_sem; |
5584 |
++ long session_lock_timeout; /* retry interval for blocking locks */ |
5585 |
+ }; |
5586 |
+ |
5587 |
+ /* cache_validity flags */ |
5588 |
+diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c |
5589 |
+index 48db9a9f13f9..cb6c4031af55 100644 |
5590 |
+--- a/fs/9p/vfs_dir.c |
5591 |
++++ b/fs/9p/vfs_dir.c |
5592 |
+@@ -105,7 +105,6 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx) |
5593 |
+ int err = 0; |
5594 |
+ struct p9_fid *fid; |
5595 |
+ int buflen; |
5596 |
+- int reclen = 0; |
5597 |
+ struct p9_rdir *rdir; |
5598 |
+ struct kvec kvec; |
5599 |
+ |
5600 |
+@@ -138,11 +137,10 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx) |
5601 |
+ while (rdir->head < rdir->tail) { |
5602 |
+ err = p9stat_read(fid->clnt, rdir->buf + rdir->head, |
5603 |
+ rdir->tail - rdir->head, &st); |
5604 |
+- if (err) { |
5605 |
++ if (err <= 0) { |
5606 |
+ p9_debug(P9_DEBUG_VFS, "returned %d\n", err); |
5607 |
+ return -EIO; |
5608 |
+ } |
5609 |
+- reclen = st.size+2; |
5610 |
+ |
5611 |
+ over = !dir_emit(ctx, st.name, strlen(st.name), |
5612 |
+ v9fs_qid2ino(&st.qid), dt_type(&st)); |
5613 |
+@@ -150,8 +148,8 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx) |
5614 |
+ if (over) |
5615 |
+ return 0; |
5616 |
+ |
5617 |
+- rdir->head += reclen; |
5618 |
+- ctx->pos += reclen; |
5619 |
++ rdir->head += err; |
5620 |
++ ctx->pos += err; |
5621 |
+ } |
5622 |
+ } |
5623 |
+ } |
5624 |
+diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c |
5625 |
+index c87e6d6ec069..05454a7e22dc 100644 |
5626 |
+--- a/fs/9p/vfs_file.c |
5627 |
++++ b/fs/9p/vfs_file.c |
5628 |
+@@ -154,6 +154,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) |
5629 |
+ uint8_t status = P9_LOCK_ERROR; |
5630 |
+ int res = 0; |
5631 |
+ unsigned char fl_type; |
5632 |
++ struct v9fs_session_info *v9ses; |
5633 |
+ |
5634 |
+ fid = filp->private_data; |
5635 |
+ BUG_ON(fid == NULL); |
5636 |
+@@ -189,6 +190,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) |
5637 |
+ if (IS_SETLKW(cmd)) |
5638 |
+ flock.flags = P9_LOCK_FLAGS_BLOCK; |
5639 |
+ |
5640 |
++ v9ses = v9fs_inode2v9ses(file_inode(filp)); |
5641 |
++ |
5642 |
+ /* |
5643 |
+ * if its a blocked request and we get P9_LOCK_BLOCKED as the status |
5644 |
+ * for lock request, keep on trying |
5645 |
+@@ -202,7 +205,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) |
5646 |
+ break; |
5647 |
+ if (status == P9_LOCK_BLOCKED && !IS_SETLKW(cmd)) |
5648 |
+ break; |
5649 |
+- if (schedule_timeout_interruptible(P9_LOCK_TIMEOUT) != 0) |
5650 |
++ if (schedule_timeout_interruptible(v9ses->session_lock_timeout) |
5651 |
++ != 0) |
5652 |
+ break; |
5653 |
+ /* |
5654 |
+ * p9_client_lock_dotl overwrites flock.client_id with the |
5655 |
+diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c |
5656 |
+index 020f49c15b30..b59ebed4f615 100644 |
5657 |
+--- a/fs/cifs/inode.c |
5658 |
++++ b/fs/cifs/inode.c |
5659 |
+@@ -780,43 +780,50 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, |
5660 |
+ } else if ((rc == -EACCES) && backup_cred(cifs_sb) && |
5661 |
+ (strcmp(server->vals->version_string, SMB1_VERSION_STRING) |
5662 |
+ == 0)) { |
5663 |
+- /* |
5664 |
+- * For SMB2 and later the backup intent flag is already |
5665 |
+- * sent if needed on open and there is no path based |
5666 |
+- * FindFirst operation to use to retry with |
5667 |
+- */ |
5668 |
++ /* |
5669 |
++ * For SMB2 and later the backup intent flag is already |
5670 |
++ * sent if needed on open and there is no path based |
5671 |
++ * FindFirst operation to use to retry with |
5672 |
++ */ |
5673 |
+ |
5674 |
+- srchinf = kzalloc(sizeof(struct cifs_search_info), |
5675 |
+- GFP_KERNEL); |
5676 |
+- if (srchinf == NULL) { |
5677 |
+- rc = -ENOMEM; |
5678 |
+- goto cgii_exit; |
5679 |
+- } |
5680 |
++ srchinf = kzalloc(sizeof(struct cifs_search_info), |
5681 |
++ GFP_KERNEL); |
5682 |
++ if (srchinf == NULL) { |
5683 |
++ rc = -ENOMEM; |
5684 |
++ goto cgii_exit; |
5685 |
++ } |
5686 |
+ |
5687 |
+- srchinf->endOfSearch = false; |
5688 |
++ srchinf->endOfSearch = false; |
5689 |
++ if (tcon->unix_ext) |
5690 |
++ srchinf->info_level = SMB_FIND_FILE_UNIX; |
5691 |
++ else if ((tcon->ses->capabilities & |
5692 |
++ tcon->ses->server->vals->cap_nt_find) == 0) |
5693 |
++ srchinf->info_level = SMB_FIND_FILE_INFO_STANDARD; |
5694 |
++ else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) |
5695 |
+ srchinf->info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO; |
5696 |
++ else /* no srvino useful for fallback to some netapp */ |
5697 |
++ srchinf->info_level = SMB_FIND_FILE_DIRECTORY_INFO; |
5698 |
+ |
5699 |
+- srchflgs = CIFS_SEARCH_CLOSE_ALWAYS | |
5700 |
+- CIFS_SEARCH_CLOSE_AT_END | |
5701 |
+- CIFS_SEARCH_BACKUP_SEARCH; |
5702 |
++ srchflgs = CIFS_SEARCH_CLOSE_ALWAYS | |
5703 |
++ CIFS_SEARCH_CLOSE_AT_END | |
5704 |
++ CIFS_SEARCH_BACKUP_SEARCH; |
5705 |
+ |
5706 |
+- rc = CIFSFindFirst(xid, tcon, full_path, |
5707 |
+- cifs_sb, NULL, srchflgs, srchinf, false); |
5708 |
+- if (!rc) { |
5709 |
+- data = |
5710 |
+- (FILE_ALL_INFO *)srchinf->srch_entries_start; |
5711 |
++ rc = CIFSFindFirst(xid, tcon, full_path, |
5712 |
++ cifs_sb, NULL, srchflgs, srchinf, false); |
5713 |
++ if (!rc) { |
5714 |
++ data = (FILE_ALL_INFO *)srchinf->srch_entries_start; |
5715 |
+ |
5716 |
+- cifs_dir_info_to_fattr(&fattr, |
5717 |
+- (FILE_DIRECTORY_INFO *)data, cifs_sb); |
5718 |
+- fattr.cf_uniqueid = le64_to_cpu( |
5719 |
+- ((SEARCH_ID_FULL_DIR_INFO *)data)->UniqueId); |
5720 |
+- validinum = true; |
5721 |
++ cifs_dir_info_to_fattr(&fattr, |
5722 |
++ (FILE_DIRECTORY_INFO *)data, cifs_sb); |
5723 |
++ fattr.cf_uniqueid = le64_to_cpu( |
5724 |
++ ((SEARCH_ID_FULL_DIR_INFO *)data)->UniqueId); |
5725 |
++ validinum = true; |
5726 |
+ |
5727 |
+- cifs_buf_release(srchinf->ntwrk_buf_start); |
5728 |
+- } |
5729 |
+- kfree(srchinf); |
5730 |
+- if (rc) |
5731 |
+- goto cgii_exit; |
5732 |
++ cifs_buf_release(srchinf->ntwrk_buf_start); |
5733 |
++ } |
5734 |
++ kfree(srchinf); |
5735 |
++ if (rc) |
5736 |
++ goto cgii_exit; |
5737 |
+ } else |
5738 |
+ goto cgii_exit; |
5739 |
+ |
5740 |
+diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c |
5741 |
+index c3ae8c1d6089..18814f1d67d9 100644 |
5742 |
+--- a/fs/cifs/smb2maperror.c |
5743 |
++++ b/fs/cifs/smb2maperror.c |
5744 |
+@@ -1036,7 +1036,8 @@ static const struct status_to_posix_error smb2_error_map_table[] = { |
5745 |
+ {STATUS_UNFINISHED_CONTEXT_DELETED, -EIO, |
5746 |
+ "STATUS_UNFINISHED_CONTEXT_DELETED"}, |
5747 |
+ {STATUS_NO_TGT_REPLY, -EIO, "STATUS_NO_TGT_REPLY"}, |
5748 |
+- {STATUS_OBJECTID_NOT_FOUND, -EIO, "STATUS_OBJECTID_NOT_FOUND"}, |
5749 |
++ /* Note that ENOATTTR and ENODATA are the same errno */ |
5750 |
++ {STATUS_OBJECTID_NOT_FOUND, -ENODATA, "STATUS_OBJECTID_NOT_FOUND"}, |
5751 |
+ {STATUS_NO_IP_ADDRESSES, -EIO, "STATUS_NO_IP_ADDRESSES"}, |
5752 |
+ {STATUS_WRONG_CREDENTIAL_HANDLE, -EIO, |
5753 |
+ "STATUS_WRONG_CREDENTIAL_HANDLE"}, |
5754 |
+diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c |
5755 |
+index 2e76fb55d94a..5f24fdc140ad 100644 |
5756 |
+--- a/fs/ext4/ioctl.c |
5757 |
++++ b/fs/ext4/ioctl.c |
5758 |
+@@ -999,6 +999,13 @@ resizefs_out: |
5759 |
+ if (!blk_queue_discard(q)) |
5760 |
+ return -EOPNOTSUPP; |
5761 |
+ |
5762 |
++ /* |
5763 |
++ * We haven't replayed the journal, so we cannot use our |
5764 |
++ * block-bitmap-guided storage zapping commands. |
5765 |
++ */ |
5766 |
++ if (test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) |
5767 |
++ return -EROFS; |
5768 |
++ |
5769 |
+ if (copy_from_user(&range, (struct fstrim_range __user *)arg, |
5770 |
+ sizeof(range))) |
5771 |
+ return -EFAULT; |
5772 |
+diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c |
5773 |
+index 3d9b18505c0c..e7ae26e36c9c 100644 |
5774 |
+--- a/fs/ext4/resize.c |
5775 |
++++ b/fs/ext4/resize.c |
5776 |
+@@ -932,11 +932,18 @@ static int add_new_gdb_meta_bg(struct super_block *sb, |
5777 |
+ memcpy(n_group_desc, o_group_desc, |
5778 |
+ EXT4_SB(sb)->s_gdb_count * sizeof(struct buffer_head *)); |
5779 |
+ n_group_desc[gdb_num] = gdb_bh; |
5780 |
++ |
5781 |
++ BUFFER_TRACE(gdb_bh, "get_write_access"); |
5782 |
++ err = ext4_journal_get_write_access(handle, gdb_bh); |
5783 |
++ if (err) { |
5784 |
++ kvfree(n_group_desc); |
5785 |
++ brelse(gdb_bh); |
5786 |
++ return err; |
5787 |
++ } |
5788 |
++ |
5789 |
+ EXT4_SB(sb)->s_group_desc = n_group_desc; |
5790 |
+ EXT4_SB(sb)->s_gdb_count++; |
5791 |
+ kvfree(o_group_desc); |
5792 |
+- BUFFER_TRACE(gdb_bh, "get_write_access"); |
5793 |
+- err = ext4_journal_get_write_access(handle, gdb_bh); |
5794 |
+ return err; |
5795 |
+ } |
5796 |
+ |
5797 |
+@@ -2073,6 +2080,10 @@ out: |
5798 |
+ free_flex_gd(flex_gd); |
5799 |
+ if (resize_inode != NULL) |
5800 |
+ iput(resize_inode); |
5801 |
+- ext4_msg(sb, KERN_INFO, "resized filesystem to %llu", n_blocks_count); |
5802 |
++ if (err) |
5803 |
++ ext4_warning(sb, "error (%d) occurred during " |
5804 |
++ "file system resize", err); |
5805 |
++ ext4_msg(sb, KERN_INFO, "resized filesystem to %llu", |
5806 |
++ ext4_blocks_count(es)); |
5807 |
+ return err; |
5808 |
+ } |
5809 |
+diff --git a/fs/ext4/super.c b/fs/ext4/super.c |
5810 |
+index a1cf7d68b4f0..abba7ece78e9 100644 |
5811 |
+--- a/fs/ext4/super.c |
5812 |
++++ b/fs/ext4/super.c |
5813 |
+@@ -430,6 +430,12 @@ static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn) |
5814 |
+ spin_unlock(&sbi->s_md_lock); |
5815 |
+ } |
5816 |
+ |
5817 |
++static bool system_going_down(void) |
5818 |
++{ |
5819 |
++ return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF |
5820 |
++ || system_state == SYSTEM_RESTART; |
5821 |
++} |
5822 |
++ |
5823 |
+ /* Deal with the reporting of failure conditions on a filesystem such as |
5824 |
+ * inconsistencies detected or read IO failures. |
5825 |
+ * |
5826 |
+@@ -460,7 +466,12 @@ static void ext4_handle_error(struct super_block *sb) |
5827 |
+ if (journal) |
5828 |
+ jbd2_journal_abort(journal, -EIO); |
5829 |
+ } |
5830 |
+- if (test_opt(sb, ERRORS_RO)) { |
5831 |
++ /* |
5832 |
++ * We force ERRORS_RO behavior when system is rebooting. Otherwise we |
5833 |
++ * could panic during 'reboot -f' as the underlying device got already |
5834 |
++ * disabled. |
5835 |
++ */ |
5836 |
++ if (test_opt(sb, ERRORS_RO) || system_going_down()) { |
5837 |
+ ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); |
5838 |
+ /* |
5839 |
+ * Make sure updated value of ->s_mount_flags will be visible |
5840 |
+@@ -468,8 +479,7 @@ static void ext4_handle_error(struct super_block *sb) |
5841 |
+ */ |
5842 |
+ smp_wmb(); |
5843 |
+ sb->s_flags |= SB_RDONLY; |
5844 |
+- } |
5845 |
+- if (test_opt(sb, ERRORS_PANIC)) { |
5846 |
++ } else if (test_opt(sb, ERRORS_PANIC)) { |
5847 |
+ if (EXT4_SB(sb)->s_journal && |
5848 |
+ !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) |
5849 |
+ return; |
5850 |
+diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c |
5851 |
+index 214a968962a1..ebe649d9793c 100644 |
5852 |
+--- a/fs/f2fs/debug.c |
5853 |
++++ b/fs/f2fs/debug.c |
5854 |
+@@ -190,8 +190,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi) |
5855 |
+ si->base_mem += MAIN_SEGS(sbi) * sizeof(struct seg_entry); |
5856 |
+ si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi)); |
5857 |
+ si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); |
5858 |
+- if (f2fs_discard_en(sbi)) |
5859 |
+- si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); |
5860 |
++ si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); |
5861 |
+ si->base_mem += SIT_VBLOCK_MAP_SIZE; |
5862 |
+ if (sbi->segs_per_sec > 1) |
5863 |
+ si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry); |
5864 |
+diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h |
5865 |
+index a3ba20e5946f..1f5d5f62bb77 100644 |
5866 |
+--- a/fs/f2fs/f2fs.h |
5867 |
++++ b/fs/f2fs/f2fs.h |
5868 |
+@@ -3409,11 +3409,20 @@ static inline int get_blkz_type(struct f2fs_sb_info *sbi, |
5869 |
+ } |
5870 |
+ #endif |
5871 |
+ |
5872 |
+-static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi) |
5873 |
++static inline bool f2fs_hw_should_discard(struct f2fs_sb_info *sbi) |
5874 |
+ { |
5875 |
+- struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev); |
5876 |
++ return f2fs_sb_has_blkzoned(sbi->sb); |
5877 |
++} |
5878 |
+ |
5879 |
+- return blk_queue_discard(q) || f2fs_sb_has_blkzoned(sbi->sb); |
5880 |
++static inline bool f2fs_hw_support_discard(struct f2fs_sb_info *sbi) |
5881 |
++{ |
5882 |
++ return blk_queue_discard(bdev_get_queue(sbi->sb->s_bdev)); |
5883 |
++} |
5884 |
++ |
5885 |
++static inline bool f2fs_realtime_discard_enable(struct f2fs_sb_info *sbi) |
5886 |
++{ |
5887 |
++ return (test_opt(sbi, DISCARD) && f2fs_hw_support_discard(sbi)) || |
5888 |
++ f2fs_hw_should_discard(sbi); |
5889 |
+ } |
5890 |
+ |
5891 |
+ static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt) |
5892 |
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c |
5893 |
+index 81c1dd635a8d..b3f46e3bec17 100644 |
5894 |
+--- a/fs/f2fs/file.c |
5895 |
++++ b/fs/f2fs/file.c |
5896 |
+@@ -770,7 +770,6 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) |
5897 |
+ { |
5898 |
+ struct inode *inode = d_inode(dentry); |
5899 |
+ int err; |
5900 |
+- bool size_changed = false; |
5901 |
+ |
5902 |
+ if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) |
5903 |
+ return -EIO; |
5904 |
+@@ -830,8 +829,6 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) |
5905 |
+ down_write(&F2FS_I(inode)->i_sem); |
5906 |
+ F2FS_I(inode)->last_disk_size = i_size_read(inode); |
5907 |
+ up_write(&F2FS_I(inode)->i_sem); |
5908 |
+- |
5909 |
+- size_changed = true; |
5910 |
+ } |
5911 |
+ |
5912 |
+ __setattr_copy(inode, attr); |
5913 |
+@@ -845,7 +842,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) |
5914 |
+ } |
5915 |
+ |
5916 |
+ /* file size may changed here */ |
5917 |
+- f2fs_mark_inode_dirty_sync(inode, size_changed); |
5918 |
++ f2fs_mark_inode_dirty_sync(inode, true); |
5919 |
+ |
5920 |
+ /* inode change will produce dirty node pages flushed by checkpoint */ |
5921 |
+ f2fs_balance_fs(F2FS_I_SB(inode), true); |
5922 |
+@@ -1983,7 +1980,7 @@ static int f2fs_ioc_fitrim(struct file *filp, unsigned long arg) |
5923 |
+ if (!capable(CAP_SYS_ADMIN)) |
5924 |
+ return -EPERM; |
5925 |
+ |
5926 |
+- if (!blk_queue_discard(q)) |
5927 |
++ if (!f2fs_hw_support_discard(F2FS_SB(sb))) |
5928 |
+ return -EOPNOTSUPP; |
5929 |
+ |
5930 |
+ if (copy_from_user(&range, (struct fstrim_range __user *)arg, |
5931 |
+diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c |
5932 |
+index 9a8579fb3a30..ae0e5f2e67b4 100644 |
5933 |
+--- a/fs/f2fs/recovery.c |
5934 |
++++ b/fs/f2fs/recovery.c |
5935 |
+@@ -99,8 +99,12 @@ err_out: |
5936 |
+ return ERR_PTR(err); |
5937 |
+ } |
5938 |
+ |
5939 |
+-static void del_fsync_inode(struct fsync_inode_entry *entry) |
5940 |
++static void del_fsync_inode(struct fsync_inode_entry *entry, int drop) |
5941 |
+ { |
5942 |
++ if (drop) { |
5943 |
++ /* inode should not be recovered, drop it */ |
5944 |
++ f2fs_inode_synced(entry->inode); |
5945 |
++ } |
5946 |
+ iput(entry->inode); |
5947 |
+ list_del(&entry->list); |
5948 |
+ kmem_cache_free(fsync_entry_slab, entry); |
5949 |
+@@ -321,12 +325,12 @@ next: |
5950 |
+ return err; |
5951 |
+ } |
5952 |
+ |
5953 |
+-static void destroy_fsync_dnodes(struct list_head *head) |
5954 |
++static void destroy_fsync_dnodes(struct list_head *head, int drop) |
5955 |
+ { |
5956 |
+ struct fsync_inode_entry *entry, *tmp; |
5957 |
+ |
5958 |
+ list_for_each_entry_safe(entry, tmp, head, list) |
5959 |
+- del_fsync_inode(entry); |
5960 |
++ del_fsync_inode(entry, drop); |
5961 |
+ } |
5962 |
+ |
5963 |
+ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi, |
5964 |
+@@ -561,7 +565,7 @@ out: |
5965 |
+ } |
5966 |
+ |
5967 |
+ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list, |
5968 |
+- struct list_head *dir_list) |
5969 |
++ struct list_head *tmp_inode_list, struct list_head *dir_list) |
5970 |
+ { |
5971 |
+ struct curseg_info *curseg; |
5972 |
+ struct page *page = NULL; |
5973 |
+@@ -615,7 +619,7 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list, |
5974 |
+ } |
5975 |
+ |
5976 |
+ if (entry->blkaddr == blkaddr) |
5977 |
+- del_fsync_inode(entry); |
5978 |
++ list_move_tail(&entry->list, tmp_inode_list); |
5979 |
+ next: |
5980 |
+ /* check next segment */ |
5981 |
+ blkaddr = next_blkaddr_of_node(page); |
5982 |
+@@ -628,7 +632,7 @@ next: |
5983 |
+ |
5984 |
+ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) |
5985 |
+ { |
5986 |
+- struct list_head inode_list; |
5987 |
++ struct list_head inode_list, tmp_inode_list; |
5988 |
+ struct list_head dir_list; |
5989 |
+ int err; |
5990 |
+ int ret = 0; |
5991 |
+@@ -659,6 +663,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) |
5992 |
+ } |
5993 |
+ |
5994 |
+ INIT_LIST_HEAD(&inode_list); |
5995 |
++ INIT_LIST_HEAD(&tmp_inode_list); |
5996 |
+ INIT_LIST_HEAD(&dir_list); |
5997 |
+ |
5998 |
+ /* prevent checkpoint */ |
5999 |
+@@ -677,11 +682,16 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) |
6000 |
+ need_writecp = true; |
6001 |
+ |
6002 |
+ /* step #2: recover data */ |
6003 |
+- err = recover_data(sbi, &inode_list, &dir_list); |
6004 |
++ err = recover_data(sbi, &inode_list, &tmp_inode_list, &dir_list); |
6005 |
+ if (!err) |
6006 |
+ f2fs_bug_on(sbi, !list_empty(&inode_list)); |
6007 |
++ else { |
6008 |
++ /* restore s_flags to let iput() trash data */ |
6009 |
++ sbi->sb->s_flags = s_flags; |
6010 |
++ } |
6011 |
+ skip: |
6012 |
+- destroy_fsync_dnodes(&inode_list); |
6013 |
++ destroy_fsync_dnodes(&inode_list, err); |
6014 |
++ destroy_fsync_dnodes(&tmp_inode_list, err); |
6015 |
+ |
6016 |
+ /* truncate meta pages to be used by the recovery */ |
6017 |
+ truncate_inode_pages_range(META_MAPPING(sbi), |
6018 |
+@@ -690,13 +700,13 @@ skip: |
6019 |
+ if (err) { |
6020 |
+ truncate_inode_pages_final(NODE_MAPPING(sbi)); |
6021 |
+ truncate_inode_pages_final(META_MAPPING(sbi)); |
6022 |
++ } else { |
6023 |
++ clear_sbi_flag(sbi, SBI_POR_DOING); |
6024 |
+ } |
6025 |
+- |
6026 |
+- clear_sbi_flag(sbi, SBI_POR_DOING); |
6027 |
+ mutex_unlock(&sbi->cp_mutex); |
6028 |
+ |
6029 |
+ /* let's drop all the directory inodes for clean checkpoint */ |
6030 |
+- destroy_fsync_dnodes(&dir_list); |
6031 |
++ destroy_fsync_dnodes(&dir_list, err); |
6032 |
+ |
6033 |
+ if (need_writecp) { |
6034 |
+ set_sbi_flag(sbi, SBI_IS_RECOVERED); |
6035 |
+diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c |
6036 |
+index 1fa6f8185766..ac038563273d 100644 |
6037 |
+--- a/fs/f2fs/segment.c |
6038 |
++++ b/fs/f2fs/segment.c |
6039 |
+@@ -1744,11 +1744,11 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, |
6040 |
+ struct list_head *head = &SM_I(sbi)->dcc_info->entry_list; |
6041 |
+ int i; |
6042 |
+ |
6043 |
+- if (se->valid_blocks == max_blocks || !f2fs_discard_en(sbi)) |
6044 |
++ if (se->valid_blocks == max_blocks || !f2fs_hw_support_discard(sbi)) |
6045 |
+ return false; |
6046 |
+ |
6047 |
+ if (!force) { |
6048 |
+- if (!test_opt(sbi, DISCARD) || !se->valid_blocks || |
6049 |
++ if (!f2fs_realtime_discard_enable(sbi) || !se->valid_blocks || |
6050 |
+ SM_I(sbi)->dcc_info->nr_discards >= |
6051 |
+ SM_I(sbi)->dcc_info->max_discards) |
6052 |
+ return false; |
6053 |
+@@ -1854,7 +1854,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, |
6054 |
+ dirty_i->nr_dirty[PRE]--; |
6055 |
+ } |
6056 |
+ |
6057 |
+- if (!test_opt(sbi, DISCARD)) |
6058 |
++ if (!f2fs_realtime_discard_enable(sbi)) |
6059 |
+ continue; |
6060 |
+ |
6061 |
+ if (force && start >= cpc->trim_start && |
6062 |
+@@ -2044,8 +2044,7 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) |
6063 |
+ del = 0; |
6064 |
+ } |
6065 |
+ |
6066 |
+- if (f2fs_discard_en(sbi) && |
6067 |
+- !f2fs_test_and_set_bit(offset, se->discard_map)) |
6068 |
++ if (!f2fs_test_and_set_bit(offset, se->discard_map)) |
6069 |
+ sbi->discard_blks--; |
6070 |
+ |
6071 |
+ /* don't overwrite by SSR to keep node chain */ |
6072 |
+@@ -2073,8 +2072,7 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) |
6073 |
+ del = 0; |
6074 |
+ } |
6075 |
+ |
6076 |
+- if (f2fs_discard_en(sbi) && |
6077 |
+- f2fs_test_and_clear_bit(offset, se->discard_map)) |
6078 |
++ if (f2fs_test_and_clear_bit(offset, se->discard_map)) |
6079 |
+ sbi->discard_blks++; |
6080 |
+ } |
6081 |
+ if (!f2fs_test_bit(offset, se->ckpt_valid_map)) |
6082 |
+@@ -2690,7 +2688,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) |
6083 |
+ * discard option. User configuration looks like using runtime discard |
6084 |
+ * or periodic fstrim instead of it. |
6085 |
+ */ |
6086 |
+- if (test_opt(sbi, DISCARD)) |
6087 |
++ if (f2fs_realtime_discard_enable(sbi)) |
6088 |
+ goto out; |
6089 |
+ |
6090 |
+ start_block = START_BLOCK(sbi, start_segno); |
6091 |
+@@ -3781,13 +3779,11 @@ static int build_sit_info(struct f2fs_sb_info *sbi) |
6092 |
+ return -ENOMEM; |
6093 |
+ #endif |
6094 |
+ |
6095 |
+- if (f2fs_discard_en(sbi)) { |
6096 |
+- sit_i->sentries[start].discard_map |
6097 |
+- = f2fs_kzalloc(sbi, SIT_VBLOCK_MAP_SIZE, |
6098 |
+- GFP_KERNEL); |
6099 |
+- if (!sit_i->sentries[start].discard_map) |
6100 |
+- return -ENOMEM; |
6101 |
+- } |
6102 |
++ sit_i->sentries[start].discard_map |
6103 |
++ = f2fs_kzalloc(sbi, SIT_VBLOCK_MAP_SIZE, |
6104 |
++ GFP_KERNEL); |
6105 |
++ if (!sit_i->sentries[start].discard_map) |
6106 |
++ return -ENOMEM; |
6107 |
+ } |
6108 |
+ |
6109 |
+ sit_i->tmp_map = f2fs_kzalloc(sbi, SIT_VBLOCK_MAP_SIZE, GFP_KERNEL); |
6110 |
+@@ -3935,18 +3931,16 @@ static int build_sit_entries(struct f2fs_sb_info *sbi) |
6111 |
+ total_node_blocks += se->valid_blocks; |
6112 |
+ |
6113 |
+ /* build discard map only one time */ |
6114 |
+- if (f2fs_discard_en(sbi)) { |
6115 |
+- if (is_set_ckpt_flags(sbi, CP_TRIMMED_FLAG)) { |
6116 |
+- memset(se->discard_map, 0xff, |
6117 |
+- SIT_VBLOCK_MAP_SIZE); |
6118 |
+- } else { |
6119 |
+- memcpy(se->discard_map, |
6120 |
+- se->cur_valid_map, |
6121 |
+- SIT_VBLOCK_MAP_SIZE); |
6122 |
+- sbi->discard_blks += |
6123 |
+- sbi->blocks_per_seg - |
6124 |
+- se->valid_blocks; |
6125 |
+- } |
6126 |
++ if (is_set_ckpt_flags(sbi, CP_TRIMMED_FLAG)) { |
6127 |
++ memset(se->discard_map, 0xff, |
6128 |
++ SIT_VBLOCK_MAP_SIZE); |
6129 |
++ } else { |
6130 |
++ memcpy(se->discard_map, |
6131 |
++ se->cur_valid_map, |
6132 |
++ SIT_VBLOCK_MAP_SIZE); |
6133 |
++ sbi->discard_blks += |
6134 |
++ sbi->blocks_per_seg - |
6135 |
++ se->valid_blocks; |
6136 |
+ } |
6137 |
+ |
6138 |
+ if (sbi->segs_per_sec > 1) |
6139 |
+@@ -3984,16 +3978,13 @@ static int build_sit_entries(struct f2fs_sb_info *sbi) |
6140 |
+ if (IS_NODESEG(se->type)) |
6141 |
+ total_node_blocks += se->valid_blocks; |
6142 |
+ |
6143 |
+- if (f2fs_discard_en(sbi)) { |
6144 |
+- if (is_set_ckpt_flags(sbi, CP_TRIMMED_FLAG)) { |
6145 |
+- memset(se->discard_map, 0xff, |
6146 |
+- SIT_VBLOCK_MAP_SIZE); |
6147 |
+- } else { |
6148 |
+- memcpy(se->discard_map, se->cur_valid_map, |
6149 |
+- SIT_VBLOCK_MAP_SIZE); |
6150 |
+- sbi->discard_blks += old_valid_blocks; |
6151 |
+- sbi->discard_blks -= se->valid_blocks; |
6152 |
+- } |
6153 |
++ if (is_set_ckpt_flags(sbi, CP_TRIMMED_FLAG)) { |
6154 |
++ memset(se->discard_map, 0xff, SIT_VBLOCK_MAP_SIZE); |
6155 |
++ } else { |
6156 |
++ memcpy(se->discard_map, se->cur_valid_map, |
6157 |
++ SIT_VBLOCK_MAP_SIZE); |
6158 |
++ sbi->discard_blks += old_valid_blocks; |
6159 |
++ sbi->discard_blks -= se->valid_blocks; |
6160 |
+ } |
6161 |
+ |
6162 |
+ if (sbi->segs_per_sec > 1) { |
6163 |
+diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c |
6164 |
+index 79370b7fa9d2..2264f27fd26d 100644 |
6165 |
+--- a/fs/f2fs/super.c |
6166 |
++++ b/fs/f2fs/super.c |
6167 |
+@@ -360,7 +360,6 @@ static int f2fs_check_quota_options(struct f2fs_sb_info *sbi) |
6168 |
+ static int parse_options(struct super_block *sb, char *options) |
6169 |
+ { |
6170 |
+ struct f2fs_sb_info *sbi = F2FS_SB(sb); |
6171 |
+- struct request_queue *q; |
6172 |
+ substring_t args[MAX_OPT_ARGS]; |
6173 |
+ char *p, *name; |
6174 |
+ int arg = 0; |
6175 |
+@@ -415,14 +414,7 @@ static int parse_options(struct super_block *sb, char *options) |
6176 |
+ return -EINVAL; |
6177 |
+ break; |
6178 |
+ case Opt_discard: |
6179 |
+- q = bdev_get_queue(sb->s_bdev); |
6180 |
+- if (blk_queue_discard(q)) { |
6181 |
+- set_opt(sbi, DISCARD); |
6182 |
+- } else if (!f2fs_sb_has_blkzoned(sb)) { |
6183 |
+- f2fs_msg(sb, KERN_WARNING, |
6184 |
+- "mounting with \"discard\" option, but " |
6185 |
+- "the device does not support discard"); |
6186 |
+- } |
6187 |
++ set_opt(sbi, DISCARD); |
6188 |
+ break; |
6189 |
+ case Opt_nodiscard: |
6190 |
+ if (f2fs_sb_has_blkzoned(sb)) { |
6191 |
+@@ -1033,7 +1025,8 @@ static void f2fs_put_super(struct super_block *sb) |
6192 |
+ /* be sure to wait for any on-going discard commands */ |
6193 |
+ dropped = f2fs_wait_discard_bios(sbi); |
6194 |
+ |
6195 |
+- if (f2fs_discard_en(sbi) && !sbi->discard_blks && !dropped) { |
6196 |
++ if ((f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi)) && |
6197 |
++ !sbi->discard_blks && !dropped) { |
6198 |
+ struct cp_control cpc = { |
6199 |
+ .reason = CP_UMOUNT | CP_TRIMMED, |
6200 |
+ }; |
6201 |
+@@ -1403,8 +1396,7 @@ static void default_options(struct f2fs_sb_info *sbi) |
6202 |
+ set_opt(sbi, NOHEAP); |
6203 |
+ sbi->sb->s_flags |= SB_LAZYTIME; |
6204 |
+ set_opt(sbi, FLUSH_MERGE); |
6205 |
+- if (blk_queue_discard(bdev_get_queue(sbi->sb->s_bdev))) |
6206 |
+- set_opt(sbi, DISCARD); |
6207 |
++ set_opt(sbi, DISCARD); |
6208 |
+ if (f2fs_sb_has_blkzoned(sbi->sb)) |
6209 |
+ set_opt_mode(sbi, F2FS_MOUNT_LFS); |
6210 |
+ else |
6211 |
+@@ -1893,6 +1885,19 @@ void f2fs_quota_off_umount(struct super_block *sb) |
6212 |
+ } |
6213 |
+ } |
6214 |
+ |
6215 |
++static void f2fs_truncate_quota_inode_pages(struct super_block *sb) |
6216 |
++{ |
6217 |
++ struct quota_info *dqopt = sb_dqopt(sb); |
6218 |
++ int type; |
6219 |
++ |
6220 |
++ for (type = 0; type < MAXQUOTAS; type++) { |
6221 |
++ if (!dqopt->files[type]) |
6222 |
++ continue; |
6223 |
++ f2fs_inode_synced(dqopt->files[type]); |
6224 |
++ } |
6225 |
++} |
6226 |
++ |
6227 |
++ |
6228 |
+ static int f2fs_get_projid(struct inode *inode, kprojid_t *projid) |
6229 |
+ { |
6230 |
+ *projid = F2FS_I(inode)->i_projid; |
6231 |
+@@ -2337,7 +2342,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) |
6232 |
+ unsigned int segment_count_main; |
6233 |
+ unsigned int cp_pack_start_sum, cp_payload; |
6234 |
+ block_t user_block_count; |
6235 |
+- int i; |
6236 |
++ int i, j; |
6237 |
+ |
6238 |
+ total = le32_to_cpu(raw_super->segment_count); |
6239 |
+ fsmeta = le32_to_cpu(raw_super->segment_count_ckpt); |
6240 |
+@@ -2378,11 +2383,43 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) |
6241 |
+ if (le32_to_cpu(ckpt->cur_node_segno[i]) >= main_segs || |
6242 |
+ le16_to_cpu(ckpt->cur_node_blkoff[i]) >= blocks_per_seg) |
6243 |
+ return 1; |
6244 |
++ for (j = i + 1; j < NR_CURSEG_NODE_TYPE; j++) { |
6245 |
++ if (le32_to_cpu(ckpt->cur_node_segno[i]) == |
6246 |
++ le32_to_cpu(ckpt->cur_node_segno[j])) { |
6247 |
++ f2fs_msg(sbi->sb, KERN_ERR, |
6248 |
++ "Node segment (%u, %u) has the same " |
6249 |
++ "segno: %u", i, j, |
6250 |
++ le32_to_cpu(ckpt->cur_node_segno[i])); |
6251 |
++ return 1; |
6252 |
++ } |
6253 |
++ } |
6254 |
+ } |
6255 |
+ for (i = 0; i < NR_CURSEG_DATA_TYPE; i++) { |
6256 |
+ if (le32_to_cpu(ckpt->cur_data_segno[i]) >= main_segs || |
6257 |
+ le16_to_cpu(ckpt->cur_data_blkoff[i]) >= blocks_per_seg) |
6258 |
+ return 1; |
6259 |
++ for (j = i + 1; j < NR_CURSEG_DATA_TYPE; j++) { |
6260 |
++ if (le32_to_cpu(ckpt->cur_data_segno[i]) == |
6261 |
++ le32_to_cpu(ckpt->cur_data_segno[j])) { |
6262 |
++ f2fs_msg(sbi->sb, KERN_ERR, |
6263 |
++ "Data segment (%u, %u) has the same " |
6264 |
++ "segno: %u", i, j, |
6265 |
++ le32_to_cpu(ckpt->cur_data_segno[i])); |
6266 |
++ return 1; |
6267 |
++ } |
6268 |
++ } |
6269 |
++ } |
6270 |
++ for (i = 0; i < NR_CURSEG_NODE_TYPE; i++) { |
6271 |
++ for (j = i; j < NR_CURSEG_DATA_TYPE; j++) { |
6272 |
++ if (le32_to_cpu(ckpt->cur_node_segno[i]) == |
6273 |
++ le32_to_cpu(ckpt->cur_data_segno[j])) { |
6274 |
++ f2fs_msg(sbi->sb, KERN_ERR, |
6275 |
++ "Data segment (%u) and Data segment (%u)" |
6276 |
++ " has the same segno: %u", i, j, |
6277 |
++ le32_to_cpu(ckpt->cur_node_segno[i])); |
6278 |
++ return 1; |
6279 |
++ } |
6280 |
++ } |
6281 |
+ } |
6282 |
+ |
6283 |
+ sit_bitmap_size = le32_to_cpu(ckpt->sit_ver_bitmap_bytesize); |
6284 |
+@@ -3107,10 +3144,10 @@ skip_recovery: |
6285 |
+ |
6286 |
+ free_meta: |
6287 |
+ #ifdef CONFIG_QUOTA |
6288 |
++ f2fs_truncate_quota_inode_pages(sb); |
6289 |
+ if (f2fs_sb_has_quota_ino(sb) && !f2fs_readonly(sb)) |
6290 |
+ f2fs_quota_off_umount(sbi->sb); |
6291 |
+ #endif |
6292 |
+- f2fs_sync_inode_meta(sbi); |
6293 |
+ /* |
6294 |
+ * Some dirty meta pages can be produced by f2fs_recover_orphan_inodes() |
6295 |
+ * failed by EIO. Then, iput(node_inode) can trigger balance_fs_bg() |
6296 |
+diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c |
6297 |
+index 780bba695453..97a51690338e 100644 |
6298 |
+--- a/fs/notify/inotify/inotify_user.c |
6299 |
++++ b/fs/notify/inotify/inotify_user.c |
6300 |
+@@ -519,8 +519,10 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, |
6301 |
+ fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group); |
6302 |
+ if (!fsn_mark) |
6303 |
+ return -ENOENT; |
6304 |
+- else if (create) |
6305 |
+- return -EEXIST; |
6306 |
++ else if (create) { |
6307 |
++ ret = -EEXIST; |
6308 |
++ goto out; |
6309 |
++ } |
6310 |
+ |
6311 |
+ i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark); |
6312 |
+ |
6313 |
+@@ -548,6 +550,7 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, |
6314 |
+ /* return the wd */ |
6315 |
+ ret = i_mark->wd; |
6316 |
+ |
6317 |
++out: |
6318 |
+ /* match the get from fsnotify_find_mark() */ |
6319 |
+ fsnotify_put_mark(fsn_mark); |
6320 |
+ |
6321 |
+diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c |
6322 |
+index d297fe4472a9..d0137e3e585e 100644 |
6323 |
+--- a/fs/proc/kcore.c |
6324 |
++++ b/fs/proc/kcore.c |
6325 |
+@@ -54,6 +54,28 @@ static LIST_HEAD(kclist_head); |
6326 |
+ static DECLARE_RWSEM(kclist_lock); |
6327 |
+ static int kcore_need_update = 1; |
6328 |
+ |
6329 |
++/* |
6330 |
++ * Returns > 0 for RAM pages, 0 for non-RAM pages, < 0 on error |
6331 |
++ * Same as oldmem_pfn_is_ram in vmcore |
6332 |
++ */ |
6333 |
++static int (*mem_pfn_is_ram)(unsigned long pfn); |
6334 |
++ |
6335 |
++int __init register_mem_pfn_is_ram(int (*fn)(unsigned long pfn)) |
6336 |
++{ |
6337 |
++ if (mem_pfn_is_ram) |
6338 |
++ return -EBUSY; |
6339 |
++ mem_pfn_is_ram = fn; |
6340 |
++ return 0; |
6341 |
++} |
6342 |
++ |
6343 |
++static int pfn_is_ram(unsigned long pfn) |
6344 |
++{ |
6345 |
++ if (mem_pfn_is_ram) |
6346 |
++ return mem_pfn_is_ram(pfn); |
6347 |
++ else |
6348 |
++ return 1; |
6349 |
++} |
6350 |
++ |
6351 |
+ /* This doesn't grab kclist_lock, so it should only be used at init time. */ |
6352 |
+ void __init kclist_add(struct kcore_list *new, void *addr, size_t size, |
6353 |
+ int type) |
6354 |
+@@ -465,6 +487,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) |
6355 |
+ goto out; |
6356 |
+ } |
6357 |
+ m = NULL; /* skip the list anchor */ |
6358 |
++ } else if (!pfn_is_ram(__pa(start) >> PAGE_SHIFT)) { |
6359 |
++ if (clear_user(buffer, tsz)) { |
6360 |
++ ret = -EFAULT; |
6361 |
++ goto out; |
6362 |
++ } |
6363 |
+ } else if (m->type == KCORE_VMALLOC) { |
6364 |
+ vread(buf, (char *)start, tsz); |
6365 |
+ /* we have to zero-fill user buffer even if no read */ |
6366 |
+diff --git a/include/linux/atalk.h b/include/linux/atalk.h |
6367 |
+index 23f805562f4e..d5cfc0b15b76 100644 |
6368 |
+--- a/include/linux/atalk.h |
6369 |
++++ b/include/linux/atalk.h |
6370 |
+@@ -158,19 +158,29 @@ extern int sysctl_aarp_retransmit_limit; |
6371 |
+ extern int sysctl_aarp_resolve_time; |
6372 |
+ |
6373 |
+ #ifdef CONFIG_SYSCTL |
6374 |
+-extern void atalk_register_sysctl(void); |
6375 |
++extern int atalk_register_sysctl(void); |
6376 |
+ extern void atalk_unregister_sysctl(void); |
6377 |
+ #else |
6378 |
+-#define atalk_register_sysctl() do { } while(0) |
6379 |
+-#define atalk_unregister_sysctl() do { } while(0) |
6380 |
++static inline int atalk_register_sysctl(void) |
6381 |
++{ |
6382 |
++ return 0; |
6383 |
++} |
6384 |
++static inline void atalk_unregister_sysctl(void) |
6385 |
++{ |
6386 |
++} |
6387 |
+ #endif |
6388 |
+ |
6389 |
+ #ifdef CONFIG_PROC_FS |
6390 |
+ extern int atalk_proc_init(void); |
6391 |
+ extern void atalk_proc_exit(void); |
6392 |
+ #else |
6393 |
+-#define atalk_proc_init() ({ 0; }) |
6394 |
+-#define atalk_proc_exit() do { } while(0) |
6395 |
++static inline int atalk_proc_init(void) |
6396 |
++{ |
6397 |
++ return 0; |
6398 |
++} |
6399 |
++static inline void atalk_proc_exit(void) |
6400 |
++{ |
6401 |
++} |
6402 |
+ #endif /* CONFIG_PROC_FS */ |
6403 |
+ |
6404 |
+ #endif /* __LINUX_ATALK_H__ */ |
6405 |
+diff --git a/include/linux/compiler.h b/include/linux/compiler.h |
6406 |
+index 269d376f5a11..81c2238b884c 100644 |
6407 |
+--- a/include/linux/compiler.h |
6408 |
++++ b/include/linux/compiler.h |
6409 |
+@@ -124,7 +124,10 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, |
6410 |
+ # define ASM_UNREACHABLE |
6411 |
+ #endif |
6412 |
+ #ifndef unreachable |
6413 |
+-# define unreachable() do { annotate_reachable(); do { } while (1); } while (0) |
6414 |
++# define unreachable() do { \ |
6415 |
++ annotate_unreachable(); \ |
6416 |
++ __builtin_unreachable(); \ |
6417 |
++} while (0) |
6418 |
+ #endif |
6419 |
+ |
6420 |
+ /* |
6421 |
+diff --git a/include/linux/kcore.h b/include/linux/kcore.h |
6422 |
+index 8c3f8c14eeaa..c843f4a9c512 100644 |
6423 |
+--- a/include/linux/kcore.h |
6424 |
++++ b/include/linux/kcore.h |
6425 |
+@@ -44,6 +44,8 @@ void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz) |
6426 |
+ m->vaddr = (unsigned long)vaddr; |
6427 |
+ kclist_add(m, addr, sz, KCORE_REMAP); |
6428 |
+ } |
6429 |
++ |
6430 |
++extern int __init register_mem_pfn_is_ram(int (*fn)(unsigned long pfn)); |
6431 |
+ #else |
6432 |
+ static inline |
6433 |
+ void kclist_add(struct kcore_list *new, void *addr, size_t size, int type) |
6434 |
+diff --git a/include/linux/swap.h b/include/linux/swap.h |
6435 |
+index 77221c16733a..7bd0a6f2ac2b 100644 |
6436 |
+--- a/include/linux/swap.h |
6437 |
++++ b/include/linux/swap.h |
6438 |
+@@ -155,9 +155,9 @@ struct swap_extent { |
6439 |
+ /* |
6440 |
+ * Max bad pages in the new format.. |
6441 |
+ */ |
6442 |
+-#define __swapoffset(x) ((unsigned long)&((union swap_header *)0)->x) |
6443 |
+ #define MAX_SWAP_BADPAGES \ |
6444 |
+- ((__swapoffset(magic.magic) - __swapoffset(info.badpages)) / sizeof(int)) |
6445 |
++ ((offsetof(union swap_header, magic.magic) - \ |
6446 |
++ offsetof(union swap_header, info.badpages)) / sizeof(int)) |
6447 |
+ |
6448 |
+ enum { |
6449 |
+ SWP_USED = (1 << 0), /* is slot in swap_info[] used? */ |
6450 |
+diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h |
6451 |
+index 0db1b9b428b7..1dfb75057580 100644 |
6452 |
+--- a/include/net/bluetooth/hci_core.h |
6453 |
++++ b/include/net/bluetooth/hci_core.h |
6454 |
+@@ -259,6 +259,8 @@ struct hci_dev { |
6455 |
+ __u16 le_max_tx_time; |
6456 |
+ __u16 le_max_rx_len; |
6457 |
+ __u16 le_max_rx_time; |
6458 |
++ __u8 le_max_key_size; |
6459 |
++ __u8 le_min_key_size; |
6460 |
+ __u16 discov_interleaved_timeout; |
6461 |
+ __u16 conn_info_min_age; |
6462 |
+ __u16 conn_info_max_age; |
6463 |
+diff --git a/include/net/xfrm.h b/include/net/xfrm.h |
6464 |
+index da588def3c61..5e3daf53b3d1 100644 |
6465 |
+--- a/include/net/xfrm.h |
6466 |
++++ b/include/net/xfrm.h |
6467 |
+@@ -850,7 +850,7 @@ static inline void xfrm_pols_put(struct xfrm_policy **pols, int npols) |
6468 |
+ xfrm_pol_put(pols[i]); |
6469 |
+ } |
6470 |
+ |
6471 |
+-void __xfrm_state_destroy(struct xfrm_state *); |
6472 |
++void __xfrm_state_destroy(struct xfrm_state *, bool); |
6473 |
+ |
6474 |
+ static inline void __xfrm_state_put(struct xfrm_state *x) |
6475 |
+ { |
6476 |
+@@ -860,7 +860,13 @@ static inline void __xfrm_state_put(struct xfrm_state *x) |
6477 |
+ static inline void xfrm_state_put(struct xfrm_state *x) |
6478 |
+ { |
6479 |
+ if (refcount_dec_and_test(&x->refcnt)) |
6480 |
+- __xfrm_state_destroy(x); |
6481 |
++ __xfrm_state_destroy(x, false); |
6482 |
++} |
6483 |
++ |
6484 |
++static inline void xfrm_state_put_sync(struct xfrm_state *x) |
6485 |
++{ |
6486 |
++ if (refcount_dec_and_test(&x->refcnt)) |
6487 |
++ __xfrm_state_destroy(x, true); |
6488 |
+ } |
6489 |
+ |
6490 |
+ static inline void xfrm_state_hold(struct xfrm_state *x) |
6491 |
+@@ -1616,7 +1622,7 @@ struct xfrmk_spdinfo { |
6492 |
+ |
6493 |
+ struct xfrm_state *xfrm_find_acq_byseq(struct net *net, u32 mark, u32 seq); |
6494 |
+ int xfrm_state_delete(struct xfrm_state *x); |
6495 |
+-int xfrm_state_flush(struct net *net, u8 proto, bool task_valid); |
6496 |
++int xfrm_state_flush(struct net *net, u8 proto, bool task_valid, bool sync); |
6497 |
+ int xfrm_dev_state_flush(struct net *net, struct net_device *dev, bool task_valid); |
6498 |
+ void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si); |
6499 |
+ void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si); |
6500 |
+diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h |
6501 |
+index 573d5b901fb1..6d182746afab 100644 |
6502 |
+--- a/include/trace/events/rxrpc.h |
6503 |
++++ b/include/trace/events/rxrpc.h |
6504 |
+@@ -76,6 +76,7 @@ enum rxrpc_client_trace { |
6505 |
+ rxrpc_client_chan_disconnect, |
6506 |
+ rxrpc_client_chan_pass, |
6507 |
+ rxrpc_client_chan_unstarted, |
6508 |
++ rxrpc_client_chan_wait_failed, |
6509 |
+ rxrpc_client_cleanup, |
6510 |
+ rxrpc_client_count, |
6511 |
+ rxrpc_client_discard, |
6512 |
+@@ -275,6 +276,7 @@ enum rxrpc_tx_point { |
6513 |
+ EM(rxrpc_client_chan_disconnect, "ChDisc") \ |
6514 |
+ EM(rxrpc_client_chan_pass, "ChPass") \ |
6515 |
+ EM(rxrpc_client_chan_unstarted, "ChUnst") \ |
6516 |
++ EM(rxrpc_client_chan_wait_failed, "ChWtFl") \ |
6517 |
+ EM(rxrpc_client_cleanup, "Clean ") \ |
6518 |
+ EM(rxrpc_client_count, "Count ") \ |
6519 |
+ EM(rxrpc_client_discard, "Discar") \ |
6520 |
+diff --git a/include/uapi/linux/netfilter/xt_cgroup.h b/include/uapi/linux/netfilter/xt_cgroup.h |
6521 |
+index e96dfa1b34f7..b74e370d6133 100644 |
6522 |
+--- a/include/uapi/linux/netfilter/xt_cgroup.h |
6523 |
++++ b/include/uapi/linux/netfilter/xt_cgroup.h |
6524 |
+@@ -22,4 +22,20 @@ struct xt_cgroup_info_v1 { |
6525 |
+ void *priv __attribute__((aligned(8))); |
6526 |
+ }; |
6527 |
+ |
6528 |
++#define XT_CGROUP_PATH_MAX 512 |
6529 |
++ |
6530 |
++struct xt_cgroup_info_v2 { |
6531 |
++ __u8 has_path; |
6532 |
++ __u8 has_classid; |
6533 |
++ __u8 invert_path; |
6534 |
++ __u8 invert_classid; |
6535 |
++ union { |
6536 |
++ char path[XT_CGROUP_PATH_MAX]; |
6537 |
++ __u32 classid; |
6538 |
++ }; |
6539 |
++ |
6540 |
++ /* kernel internal data */ |
6541 |
++ void *priv __attribute__((aligned(8))); |
6542 |
++}; |
6543 |
++ |
6544 |
+ #endif /* _UAPI_XT_CGROUP_H */ |
6545 |
+diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c |
6546 |
+index 2ada5e21dfa6..4a8f390a2b82 100644 |
6547 |
+--- a/kernel/bpf/inode.c |
6548 |
++++ b/kernel/bpf/inode.c |
6549 |
+@@ -554,19 +554,6 @@ struct bpf_prog *bpf_prog_get_type_path(const char *name, enum bpf_prog_type typ |
6550 |
+ } |
6551 |
+ EXPORT_SYMBOL(bpf_prog_get_type_path); |
6552 |
+ |
6553 |
+-static void bpf_evict_inode(struct inode *inode) |
6554 |
+-{ |
6555 |
+- enum bpf_type type; |
6556 |
+- |
6557 |
+- truncate_inode_pages_final(&inode->i_data); |
6558 |
+- clear_inode(inode); |
6559 |
+- |
6560 |
+- if (S_ISLNK(inode->i_mode)) |
6561 |
+- kfree(inode->i_link); |
6562 |
+- if (!bpf_inode_type(inode, &type)) |
6563 |
+- bpf_any_put(inode->i_private, type); |
6564 |
+-} |
6565 |
+- |
6566 |
+ /* |
6567 |
+ * Display the mount options in /proc/mounts. |
6568 |
+ */ |
6569 |
+@@ -579,11 +566,28 @@ static int bpf_show_options(struct seq_file *m, struct dentry *root) |
6570 |
+ return 0; |
6571 |
+ } |
6572 |
+ |
6573 |
++static void bpf_destroy_inode_deferred(struct rcu_head *head) |
6574 |
++{ |
6575 |
++ struct inode *inode = container_of(head, struct inode, i_rcu); |
6576 |
++ enum bpf_type type; |
6577 |
++ |
6578 |
++ if (S_ISLNK(inode->i_mode)) |
6579 |
++ kfree(inode->i_link); |
6580 |
++ if (!bpf_inode_type(inode, &type)) |
6581 |
++ bpf_any_put(inode->i_private, type); |
6582 |
++ free_inode_nonrcu(inode); |
6583 |
++} |
6584 |
++ |
6585 |
++static void bpf_destroy_inode(struct inode *inode) |
6586 |
++{ |
6587 |
++ call_rcu(&inode->i_rcu, bpf_destroy_inode_deferred); |
6588 |
++} |
6589 |
++ |
6590 |
+ static const struct super_operations bpf_super_ops = { |
6591 |
+ .statfs = simple_statfs, |
6592 |
+ .drop_inode = generic_delete_inode, |
6593 |
+ .show_options = bpf_show_options, |
6594 |
+- .evict_inode = bpf_evict_inode, |
6595 |
++ .destroy_inode = bpf_destroy_inode, |
6596 |
+ }; |
6597 |
+ |
6598 |
+ enum { |
6599 |
+diff --git a/kernel/events/core.c b/kernel/events/core.c |
6600 |
+index aa996a0854b9..87bd96399d1c 100644 |
6601 |
+--- a/kernel/events/core.c |
6602 |
++++ b/kernel/events/core.c |
6603 |
+@@ -7178,6 +7178,7 @@ static void perf_event_mmap_output(struct perf_event *event, |
6604 |
+ struct perf_output_handle handle; |
6605 |
+ struct perf_sample_data sample; |
6606 |
+ int size = mmap_event->event_id.header.size; |
6607 |
++ u32 type = mmap_event->event_id.header.type; |
6608 |
+ int ret; |
6609 |
+ |
6610 |
+ if (!perf_event_mmap_match(event, data)) |
6611 |
+@@ -7221,6 +7222,7 @@ static void perf_event_mmap_output(struct perf_event *event, |
6612 |
+ perf_output_end(&handle); |
6613 |
+ out: |
6614 |
+ mmap_event->event_id.header.size = size; |
6615 |
++ mmap_event->event_id.header.type = type; |
6616 |
+ } |
6617 |
+ |
6618 |
+ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) |
6619 |
+diff --git a/kernel/hung_task.c b/kernel/hung_task.c |
6620 |
+index 9eca2371f189..4a9191617076 100644 |
6621 |
+--- a/kernel/hung_task.c |
6622 |
++++ b/kernel/hung_task.c |
6623 |
+@@ -15,6 +15,7 @@ |
6624 |
+ #include <linux/lockdep.h> |
6625 |
+ #include <linux/export.h> |
6626 |
+ #include <linux/sysctl.h> |
6627 |
++#include <linux/suspend.h> |
6628 |
+ #include <linux/utsname.h> |
6629 |
+ #include <linux/sched/signal.h> |
6630 |
+ #include <linux/sched/debug.h> |
6631 |
+@@ -240,6 +241,28 @@ void reset_hung_task_detector(void) |
6632 |
+ } |
6633 |
+ EXPORT_SYMBOL_GPL(reset_hung_task_detector); |
6634 |
+ |
6635 |
++static bool hung_detector_suspended; |
6636 |
++ |
6637 |
++static int hungtask_pm_notify(struct notifier_block *self, |
6638 |
++ unsigned long action, void *hcpu) |
6639 |
++{ |
6640 |
++ switch (action) { |
6641 |
++ case PM_SUSPEND_PREPARE: |
6642 |
++ case PM_HIBERNATION_PREPARE: |
6643 |
++ case PM_RESTORE_PREPARE: |
6644 |
++ hung_detector_suspended = true; |
6645 |
++ break; |
6646 |
++ case PM_POST_SUSPEND: |
6647 |
++ case PM_POST_HIBERNATION: |
6648 |
++ case PM_POST_RESTORE: |
6649 |
++ hung_detector_suspended = false; |
6650 |
++ break; |
6651 |
++ default: |
6652 |
++ break; |
6653 |
++ } |
6654 |
++ return NOTIFY_OK; |
6655 |
++} |
6656 |
++ |
6657 |
+ /* |
6658 |
+ * kthread which checks for tasks stuck in D state |
6659 |
+ */ |
6660 |
+@@ -259,7 +282,8 @@ static int watchdog(void *dummy) |
6661 |
+ interval = min_t(unsigned long, interval, timeout); |
6662 |
+ t = hung_timeout_jiffies(hung_last_checked, interval); |
6663 |
+ if (t <= 0) { |
6664 |
+- if (!atomic_xchg(&reset_hung_task, 0)) |
6665 |
++ if (!atomic_xchg(&reset_hung_task, 0) && |
6666 |
++ !hung_detector_suspended) |
6667 |
+ check_hung_uninterruptible_tasks(timeout); |
6668 |
+ hung_last_checked = jiffies; |
6669 |
+ continue; |
6670 |
+@@ -273,6 +297,10 @@ static int watchdog(void *dummy) |
6671 |
+ static int __init hung_task_init(void) |
6672 |
+ { |
6673 |
+ atomic_notifier_chain_register(&panic_notifier_list, &panic_block); |
6674 |
++ |
6675 |
++ /* Disable hung task detector on suspend */ |
6676 |
++ pm_notifier(hungtask_pm_notify, 0); |
6677 |
++ |
6678 |
+ watchdog_task = kthread_run(watchdog, NULL, "khungtaskd"); |
6679 |
+ |
6680 |
+ return 0; |
6681 |
+diff --git a/kernel/sched/core.c b/kernel/sched/core.c |
6682 |
+index 9a4f57d7e931..d7f409866cdf 100644 |
6683 |
+--- a/kernel/sched/core.c |
6684 |
++++ b/kernel/sched/core.c |
6685 |
+@@ -6930,7 +6930,7 @@ static int __maybe_unused cpu_period_quota_parse(char *buf, |
6686 |
+ { |
6687 |
+ char tok[21]; /* U64_MAX */ |
6688 |
+ |
6689 |
+- if (!sscanf(buf, "%s %llu", tok, periodp)) |
6690 |
++ if (sscanf(buf, "%20s %llu", tok, periodp) < 1) |
6691 |
+ return -EINVAL; |
6692 |
+ |
6693 |
+ *periodp *= NSEC_PER_USEC; |
6694 |
+diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c |
6695 |
+index 3fffad3bc8a8..217f81ecae17 100644 |
6696 |
+--- a/kernel/sched/cpufreq_schedutil.c |
6697 |
++++ b/kernel/sched/cpufreq_schedutil.c |
6698 |
+@@ -50,10 +50,10 @@ struct sugov_cpu { |
6699 |
+ |
6700 |
+ bool iowait_boost_pending; |
6701 |
+ unsigned int iowait_boost; |
6702 |
+- unsigned int iowait_boost_max; |
6703 |
+ u64 last_update; |
6704 |
+ |
6705 |
+ unsigned long bw_dl; |
6706 |
++ unsigned long min; |
6707 |
+ unsigned long max; |
6708 |
+ |
6709 |
+ /* The field below is for single-CPU policies only: */ |
6710 |
+@@ -283,8 +283,7 @@ static bool sugov_iowait_reset(struct sugov_cpu *sg_cpu, u64 time, |
6711 |
+ if (delta_ns <= TICK_NSEC) |
6712 |
+ return false; |
6713 |
+ |
6714 |
+- sg_cpu->iowait_boost = set_iowait_boost |
6715 |
+- ? sg_cpu->sg_policy->policy->min : 0; |
6716 |
++ sg_cpu->iowait_boost = set_iowait_boost ? sg_cpu->min : 0; |
6717 |
+ sg_cpu->iowait_boost_pending = set_iowait_boost; |
6718 |
+ |
6719 |
+ return true; |
6720 |
+@@ -324,14 +323,13 @@ static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, |
6721 |
+ |
6722 |
+ /* Double the boost at each request */ |
6723 |
+ if (sg_cpu->iowait_boost) { |
6724 |
+- sg_cpu->iowait_boost <<= 1; |
6725 |
+- if (sg_cpu->iowait_boost > sg_cpu->iowait_boost_max) |
6726 |
+- sg_cpu->iowait_boost = sg_cpu->iowait_boost_max; |
6727 |
++ sg_cpu->iowait_boost = |
6728 |
++ min_t(unsigned int, sg_cpu->iowait_boost << 1, SCHED_CAPACITY_SCALE); |
6729 |
+ return; |
6730 |
+ } |
6731 |
+ |
6732 |
+ /* First wakeup after IO: start with minimum boost */ |
6733 |
+- sg_cpu->iowait_boost = sg_cpu->sg_policy->policy->min; |
6734 |
++ sg_cpu->iowait_boost = sg_cpu->min; |
6735 |
+ } |
6736 |
+ |
6737 |
+ /** |
6738 |
+@@ -353,47 +351,38 @@ static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, |
6739 |
+ * This mechanism is designed to boost high frequently IO waiting tasks, while |
6740 |
+ * being more conservative on tasks which does sporadic IO operations. |
6741 |
+ */ |
6742 |
+-static void sugov_iowait_apply(struct sugov_cpu *sg_cpu, u64 time, |
6743 |
+- unsigned long *util, unsigned long *max) |
6744 |
++static unsigned long sugov_iowait_apply(struct sugov_cpu *sg_cpu, u64 time, |
6745 |
++ unsigned long util, unsigned long max) |
6746 |
+ { |
6747 |
+- unsigned int boost_util, boost_max; |
6748 |
++ unsigned long boost; |
6749 |
+ |
6750 |
+ /* No boost currently required */ |
6751 |
+ if (!sg_cpu->iowait_boost) |
6752 |
+- return; |
6753 |
++ return util; |
6754 |
+ |
6755 |
+ /* Reset boost if the CPU appears to have been idle enough */ |
6756 |
+ if (sugov_iowait_reset(sg_cpu, time, false)) |
6757 |
+- return; |
6758 |
++ return util; |
6759 |
+ |
6760 |
+- /* |
6761 |
+- * An IO waiting task has just woken up: |
6762 |
+- * allow to further double the boost value |
6763 |
+- */ |
6764 |
+- if (sg_cpu->iowait_boost_pending) { |
6765 |
+- sg_cpu->iowait_boost_pending = false; |
6766 |
+- } else { |
6767 |
++ if (!sg_cpu->iowait_boost_pending) { |
6768 |
+ /* |
6769 |
+- * Otherwise: reduce the boost value and disable it when we |
6770 |
+- * reach the minimum. |
6771 |
++ * No boost pending; reduce the boost value. |
6772 |
+ */ |
6773 |
+ sg_cpu->iowait_boost >>= 1; |
6774 |
+- if (sg_cpu->iowait_boost < sg_cpu->sg_policy->policy->min) { |
6775 |
++ if (sg_cpu->iowait_boost < sg_cpu->min) { |
6776 |
+ sg_cpu->iowait_boost = 0; |
6777 |
+- return; |
6778 |
++ return util; |
6779 |
+ } |
6780 |
+ } |
6781 |
+ |
6782 |
++ sg_cpu->iowait_boost_pending = false; |
6783 |
++ |
6784 |
+ /* |
6785 |
+- * Apply the current boost value: a CPU is boosted only if its current |
6786 |
+- * utilization is smaller then the current IO boost level. |
6787 |
++ * @util is already in capacity scale; convert iowait_boost |
6788 |
++ * into the same scale so we can compare. |
6789 |
+ */ |
6790 |
+- boost_util = sg_cpu->iowait_boost; |
6791 |
+- boost_max = sg_cpu->iowait_boost_max; |
6792 |
+- if (*util * boost_max < *max * boost_util) { |
6793 |
+- *util = boost_util; |
6794 |
+- *max = boost_max; |
6795 |
+- } |
6796 |
++ boost = (sg_cpu->iowait_boost * max) >> SCHED_CAPACITY_SHIFT; |
6797 |
++ return max(boost, util); |
6798 |
+ } |
6799 |
+ |
6800 |
+ #ifdef CONFIG_NO_HZ_COMMON |
6801 |
+@@ -440,7 +429,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, |
6802 |
+ |
6803 |
+ util = sugov_get_util(sg_cpu); |
6804 |
+ max = sg_cpu->max; |
6805 |
+- sugov_iowait_apply(sg_cpu, time, &util, &max); |
6806 |
++ util = sugov_iowait_apply(sg_cpu, time, util, max); |
6807 |
+ next_f = get_next_freq(sg_policy, util, max); |
6808 |
+ /* |
6809 |
+ * Do not reduce the frequency if the CPU has not been idle |
6810 |
+@@ -480,7 +469,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time) |
6811 |
+ |
6812 |
+ j_util = sugov_get_util(j_sg_cpu); |
6813 |
+ j_max = j_sg_cpu->max; |
6814 |
+- sugov_iowait_apply(j_sg_cpu, time, &j_util, &j_max); |
6815 |
++ j_util = sugov_iowait_apply(j_sg_cpu, time, j_util, j_max); |
6816 |
+ |
6817 |
+ if (j_util * max > j_max * util) { |
6818 |
+ util = j_util; |
6819 |
+@@ -817,7 +806,9 @@ static int sugov_start(struct cpufreq_policy *policy) |
6820 |
+ memset(sg_cpu, 0, sizeof(*sg_cpu)); |
6821 |
+ sg_cpu->cpu = cpu; |
6822 |
+ sg_cpu->sg_policy = sg_policy; |
6823 |
+- sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq; |
6824 |
++ sg_cpu->min = |
6825 |
++ (SCHED_CAPACITY_SCALE * policy->cpuinfo.min_freq) / |
6826 |
++ policy->cpuinfo.max_freq; |
6827 |
+ } |
6828 |
+ |
6829 |
+ for_each_cpu(cpu, policy->cpus) { |
6830 |
+diff --git a/lib/div64.c b/lib/div64.c |
6831 |
+index 01c8602bb6ff..ee146bb4c558 100644 |
6832 |
+--- a/lib/div64.c |
6833 |
++++ b/lib/div64.c |
6834 |
+@@ -109,7 +109,7 @@ u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder) |
6835 |
+ quot = div_u64_rem(dividend, divisor, &rem32); |
6836 |
+ *remainder = rem32; |
6837 |
+ } else { |
6838 |
+- int n = 1 + fls(high); |
6839 |
++ int n = fls(high); |
6840 |
+ quot = div_u64(dividend >> n, divisor >> n); |
6841 |
+ |
6842 |
+ if (quot != 0) |
6843 |
+@@ -147,7 +147,7 @@ u64 div64_u64(u64 dividend, u64 divisor) |
6844 |
+ if (high == 0) { |
6845 |
+ quot = div_u64(dividend, divisor); |
6846 |
+ } else { |
6847 |
+- int n = 1 + fls(high); |
6848 |
++ int n = fls(high); |
6849 |
+ quot = div_u64(dividend >> n, divisor >> n); |
6850 |
+ |
6851 |
+ if (quot != 0) |
6852 |
+diff --git a/mm/vmstat.c b/mm/vmstat.c |
6853 |
+index 7878da76abf2..2878dc4e9af6 100644 |
6854 |
+--- a/mm/vmstat.c |
6855 |
++++ b/mm/vmstat.c |
6856 |
+@@ -1547,6 +1547,10 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, |
6857 |
+ if (is_zone_first_populated(pgdat, zone)) { |
6858 |
+ seq_printf(m, "\n per-node stats"); |
6859 |
+ for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) { |
6860 |
++ /* Skip hidden vmstat items. */ |
6861 |
++ if (*vmstat_text[i + NR_VM_ZONE_STAT_ITEMS + |
6862 |
++ NR_VM_NUMA_STAT_ITEMS] == '\0') |
6863 |
++ continue; |
6864 |
+ seq_printf(m, "\n %-12s %lu", |
6865 |
+ vmstat_text[i + NR_VM_ZONE_STAT_ITEMS + |
6866 |
+ NR_VM_NUMA_STAT_ITEMS], |
6867 |
+diff --git a/net/9p/protocol.c b/net/9p/protocol.c |
6868 |
+index ee32bbf12675..b4d80c533f89 100644 |
6869 |
+--- a/net/9p/protocol.c |
6870 |
++++ b/net/9p/protocol.c |
6871 |
+@@ -571,9 +571,10 @@ int p9stat_read(struct p9_client *clnt, char *buf, int len, struct p9_wstat *st) |
6872 |
+ if (ret) { |
6873 |
+ p9_debug(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); |
6874 |
+ trace_9p_protocol_dump(clnt, &fake_pdu); |
6875 |
++ return ret; |
6876 |
+ } |
6877 |
+ |
6878 |
+- return ret; |
6879 |
++ return fake_pdu.offset; |
6880 |
+ } |
6881 |
+ EXPORT_SYMBOL(p9stat_read); |
6882 |
+ |
6883 |
+diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c |
6884 |
+index 8006295f8bd7..dda73991bb54 100644 |
6885 |
+--- a/net/appletalk/atalk_proc.c |
6886 |
++++ b/net/appletalk/atalk_proc.c |
6887 |
+@@ -255,7 +255,7 @@ out_interface: |
6888 |
+ goto out; |
6889 |
+ } |
6890 |
+ |
6891 |
+-void __exit atalk_proc_exit(void) |
6892 |
++void atalk_proc_exit(void) |
6893 |
+ { |
6894 |
+ remove_proc_entry("interface", atalk_proc_dir); |
6895 |
+ remove_proc_entry("route", atalk_proc_dir); |
6896 |
+diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c |
6897 |
+index 9b6bc5abe946..795fbc6c06aa 100644 |
6898 |
+--- a/net/appletalk/ddp.c |
6899 |
++++ b/net/appletalk/ddp.c |
6900 |
+@@ -1910,12 +1910,16 @@ static const char atalk_err_snap[] __initconst = |
6901 |
+ /* Called by proto.c on kernel start up */ |
6902 |
+ static int __init atalk_init(void) |
6903 |
+ { |
6904 |
+- int rc = proto_register(&ddp_proto, 0); |
6905 |
++ int rc; |
6906 |
+ |
6907 |
+- if (rc != 0) |
6908 |
++ rc = proto_register(&ddp_proto, 0); |
6909 |
++ if (rc) |
6910 |
+ goto out; |
6911 |
+ |
6912 |
+- (void)sock_register(&atalk_family_ops); |
6913 |
++ rc = sock_register(&atalk_family_ops); |
6914 |
++ if (rc) |
6915 |
++ goto out_proto; |
6916 |
++ |
6917 |
+ ddp_dl = register_snap_client(ddp_snap_id, atalk_rcv); |
6918 |
+ if (!ddp_dl) |
6919 |
+ printk(atalk_err_snap); |
6920 |
+@@ -1923,12 +1927,33 @@ static int __init atalk_init(void) |
6921 |
+ dev_add_pack(<alk_packet_type); |
6922 |
+ dev_add_pack(&ppptalk_packet_type); |
6923 |
+ |
6924 |
+- register_netdevice_notifier(&ddp_notifier); |
6925 |
++ rc = register_netdevice_notifier(&ddp_notifier); |
6926 |
++ if (rc) |
6927 |
++ goto out_sock; |
6928 |
++ |
6929 |
+ aarp_proto_init(); |
6930 |
+- atalk_proc_init(); |
6931 |
+- atalk_register_sysctl(); |
6932 |
++ rc = atalk_proc_init(); |
6933 |
++ if (rc) |
6934 |
++ goto out_aarp; |
6935 |
++ |
6936 |
++ rc = atalk_register_sysctl(); |
6937 |
++ if (rc) |
6938 |
++ goto out_proc; |
6939 |
+ out: |
6940 |
+ return rc; |
6941 |
++out_proc: |
6942 |
++ atalk_proc_exit(); |
6943 |
++out_aarp: |
6944 |
++ aarp_cleanup_module(); |
6945 |
++ unregister_netdevice_notifier(&ddp_notifier); |
6946 |
++out_sock: |
6947 |
++ dev_remove_pack(&ppptalk_packet_type); |
6948 |
++ dev_remove_pack(<alk_packet_type); |
6949 |
++ unregister_snap_client(ddp_dl); |
6950 |
++ sock_unregister(PF_APPLETALK); |
6951 |
++out_proto: |
6952 |
++ proto_unregister(&ddp_proto); |
6953 |
++ goto out; |
6954 |
+ } |
6955 |
+ module_init(atalk_init); |
6956 |
+ |
6957 |
+diff --git a/net/appletalk/sysctl_net_atalk.c b/net/appletalk/sysctl_net_atalk.c |
6958 |
+index c744a853fa5f..d945b7c0176d 100644 |
6959 |
+--- a/net/appletalk/sysctl_net_atalk.c |
6960 |
++++ b/net/appletalk/sysctl_net_atalk.c |
6961 |
+@@ -45,9 +45,12 @@ static struct ctl_table atalk_table[] = { |
6962 |
+ |
6963 |
+ static struct ctl_table_header *atalk_table_header; |
6964 |
+ |
6965 |
+-void atalk_register_sysctl(void) |
6966 |
++int __init atalk_register_sysctl(void) |
6967 |
+ { |
6968 |
+ atalk_table_header = register_net_sysctl(&init_net, "net/appletalk", atalk_table); |
6969 |
++ if (!atalk_table_header) |
6970 |
++ return -ENOMEM; |
6971 |
++ return 0; |
6972 |
+ } |
6973 |
+ |
6974 |
+ void atalk_unregister_sysctl(void) |
6975 |
+diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c |
6976 |
+index 74b29c7d841c..a06f03047717 100644 |
6977 |
+--- a/net/bluetooth/hci_core.c |
6978 |
++++ b/net/bluetooth/hci_core.c |
6979 |
+@@ -3084,6 +3084,8 @@ struct hci_dev *hci_alloc_dev(void) |
6980 |
+ hdev->le_max_tx_time = 0x0148; |
6981 |
+ hdev->le_max_rx_len = 0x001b; |
6982 |
+ hdev->le_max_rx_time = 0x0148; |
6983 |
++ hdev->le_max_key_size = SMP_MAX_ENC_KEY_SIZE; |
6984 |
++ hdev->le_min_key_size = SMP_MIN_ENC_KEY_SIZE; |
6985 |
+ hdev->le_tx_def_phys = HCI_LE_SET_PHY_1M; |
6986 |
+ hdev->le_rx_def_phys = HCI_LE_SET_PHY_1M; |
6987 |
+ |
6988 |
+diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c |
6989 |
+index 73f7211d0431..a1c1b7e8a45c 100644 |
6990 |
+--- a/net/bluetooth/smp.c |
6991 |
++++ b/net/bluetooth/smp.c |
6992 |
+@@ -88,9 +88,6 @@ struct smp_dev { |
6993 |
+ u8 local_rand[16]; |
6994 |
+ bool debug_key; |
6995 |
+ |
6996 |
+- u8 min_key_size; |
6997 |
+- u8 max_key_size; |
6998 |
+- |
6999 |
+ struct crypto_cipher *tfm_aes; |
7000 |
+ struct crypto_shash *tfm_cmac; |
7001 |
+ struct crypto_kpp *tfm_ecdh; |
7002 |
+@@ -720,7 +717,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn, |
7003 |
+ if (rsp == NULL) { |
7004 |
+ req->io_capability = conn->hcon->io_capability; |
7005 |
+ req->oob_flag = oob_flag; |
7006 |
+- req->max_key_size = SMP_DEV(hdev)->max_key_size; |
7007 |
++ req->max_key_size = hdev->le_max_key_size; |
7008 |
+ req->init_key_dist = local_dist; |
7009 |
+ req->resp_key_dist = remote_dist; |
7010 |
+ req->auth_req = (authreq & AUTH_REQ_MASK(hdev)); |
7011 |
+@@ -731,7 +728,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn, |
7012 |
+ |
7013 |
+ rsp->io_capability = conn->hcon->io_capability; |
7014 |
+ rsp->oob_flag = oob_flag; |
7015 |
+- rsp->max_key_size = SMP_DEV(hdev)->max_key_size; |
7016 |
++ rsp->max_key_size = hdev->le_max_key_size; |
7017 |
+ rsp->init_key_dist = req->init_key_dist & remote_dist; |
7018 |
+ rsp->resp_key_dist = req->resp_key_dist & local_dist; |
7019 |
+ rsp->auth_req = (authreq & AUTH_REQ_MASK(hdev)); |
7020 |
+@@ -745,7 +742,7 @@ static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) |
7021 |
+ struct hci_dev *hdev = conn->hcon->hdev; |
7022 |
+ struct smp_chan *smp = chan->data; |
7023 |
+ |
7024 |
+- if (max_key_size > SMP_DEV(hdev)->max_key_size || |
7025 |
++ if (max_key_size > hdev->le_max_key_size || |
7026 |
+ max_key_size < SMP_MIN_ENC_KEY_SIZE) |
7027 |
+ return SMP_ENC_KEY_SIZE; |
7028 |
+ |
7029 |
+@@ -3264,8 +3261,6 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid) |
7030 |
+ smp->tfm_aes = tfm_aes; |
7031 |
+ smp->tfm_cmac = tfm_cmac; |
7032 |
+ smp->tfm_ecdh = tfm_ecdh; |
7033 |
+- smp->min_key_size = SMP_MIN_ENC_KEY_SIZE; |
7034 |
+- smp->max_key_size = SMP_MAX_ENC_KEY_SIZE; |
7035 |
+ |
7036 |
+ create_chan: |
7037 |
+ chan = l2cap_chan_create(); |
7038 |
+@@ -3391,7 +3386,7 @@ static ssize_t le_min_key_size_read(struct file *file, |
7039 |
+ struct hci_dev *hdev = file->private_data; |
7040 |
+ char buf[4]; |
7041 |
+ |
7042 |
+- snprintf(buf, sizeof(buf), "%2u\n", SMP_DEV(hdev)->min_key_size); |
7043 |
++ snprintf(buf, sizeof(buf), "%2u\n", hdev->le_min_key_size); |
7044 |
+ |
7045 |
+ return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
7046 |
+ } |
7047 |
+@@ -3412,11 +3407,11 @@ static ssize_t le_min_key_size_write(struct file *file, |
7048 |
+ |
7049 |
+ sscanf(buf, "%hhu", &key_size); |
7050 |
+ |
7051 |
+- if (key_size > SMP_DEV(hdev)->max_key_size || |
7052 |
++ if (key_size > hdev->le_max_key_size || |
7053 |
+ key_size < SMP_MIN_ENC_KEY_SIZE) |
7054 |
+ return -EINVAL; |
7055 |
+ |
7056 |
+- SMP_DEV(hdev)->min_key_size = key_size; |
7057 |
++ hdev->le_min_key_size = key_size; |
7058 |
+ |
7059 |
+ return count; |
7060 |
+ } |
7061 |
+@@ -3435,7 +3430,7 @@ static ssize_t le_max_key_size_read(struct file *file, |
7062 |
+ struct hci_dev *hdev = file->private_data; |
7063 |
+ char buf[4]; |
7064 |
+ |
7065 |
+- snprintf(buf, sizeof(buf), "%2u\n", SMP_DEV(hdev)->max_key_size); |
7066 |
++ snprintf(buf, sizeof(buf), "%2u\n", hdev->le_max_key_size); |
7067 |
+ |
7068 |
+ return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
7069 |
+ } |
7070 |
+@@ -3457,10 +3452,10 @@ static ssize_t le_max_key_size_write(struct file *file, |
7071 |
+ sscanf(buf, "%hhu", &key_size); |
7072 |
+ |
7073 |
+ if (key_size > SMP_MAX_ENC_KEY_SIZE || |
7074 |
+- key_size < SMP_DEV(hdev)->min_key_size) |
7075 |
++ key_size < hdev->le_min_key_size) |
7076 |
+ return -EINVAL; |
7077 |
+ |
7078 |
+- SMP_DEV(hdev)->max_key_size = key_size; |
7079 |
++ hdev->le_max_key_size = key_size; |
7080 |
+ |
7081 |
+ return count; |
7082 |
+ } |
7083 |
+diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c |
7084 |
+index c4a7db62658e..01ecd510014f 100644 |
7085 |
+--- a/net/ipv6/ip6_gre.c |
7086 |
++++ b/net/ipv6/ip6_gre.c |
7087 |
+@@ -1743,6 +1743,9 @@ static int ip6erspan_tap_validate(struct nlattr *tb[], struct nlattr *data[], |
7088 |
+ static void ip6erspan_set_version(struct nlattr *data[], |
7089 |
+ struct __ip6_tnl_parm *parms) |
7090 |
+ { |
7091 |
++ if (!data) |
7092 |
++ return; |
7093 |
++ |
7094 |
+ parms->erspan_ver = 1; |
7095 |
+ if (data[IFLA_GRE_ERSPAN_VER]) |
7096 |
+ parms->erspan_ver = nla_get_u8(data[IFLA_GRE_ERSPAN_VER]); |
7097 |
+diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c |
7098 |
+index f5b4febeaa25..bc65db782bfb 100644 |
7099 |
+--- a/net/ipv6/xfrm6_tunnel.c |
7100 |
++++ b/net/ipv6/xfrm6_tunnel.c |
7101 |
+@@ -344,8 +344,8 @@ static void __net_exit xfrm6_tunnel_net_exit(struct net *net) |
7102 |
+ struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); |
7103 |
+ unsigned int i; |
7104 |
+ |
7105 |
+- xfrm_state_flush(net, IPSEC_PROTO_ANY, false); |
7106 |
+ xfrm_flush_gc(); |
7107 |
++ xfrm_state_flush(net, IPSEC_PROTO_ANY, false, true); |
7108 |
+ |
7109 |
+ for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++) |
7110 |
+ WARN_ON_ONCE(!hlist_empty(&xfrm6_tn->spi_byaddr[i])); |
7111 |
+diff --git a/net/key/af_key.c b/net/key/af_key.c |
7112 |
+index 7da629d59717..7d4bed955060 100644 |
7113 |
+--- a/net/key/af_key.c |
7114 |
++++ b/net/key/af_key.c |
7115 |
+@@ -1773,7 +1773,7 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, const struct sadb_m |
7116 |
+ if (proto == 0) |
7117 |
+ return -EINVAL; |
7118 |
+ |
7119 |
+- err = xfrm_state_flush(net, proto, true); |
7120 |
++ err = xfrm_state_flush(net, proto, true, false); |
7121 |
+ err2 = unicast_flush_resp(sk, hdr); |
7122 |
+ if (err || err2) { |
7123 |
+ if (err == -ESRCH) /* empty table - go quietly */ |
7124 |
+diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c |
7125 |
+index 7d424fd27025..c06393fc716d 100644 |
7126 |
+--- a/net/netfilter/nf_tables_api.c |
7127 |
++++ b/net/netfilter/nf_tables_api.c |
7128 |
+@@ -7203,9 +7203,6 @@ static void __nft_release_tables(struct net *net) |
7129 |
+ |
7130 |
+ list_for_each_entry(chain, &table->chains, list) |
7131 |
+ nf_tables_unregister_hook(net, table, chain); |
7132 |
+- list_for_each_entry(flowtable, &table->flowtables, list) |
7133 |
+- nf_unregister_net_hooks(net, flowtable->ops, |
7134 |
+- flowtable->ops_len); |
7135 |
+ /* No packets are walking on these chains anymore. */ |
7136 |
+ ctx.table = table; |
7137 |
+ list_for_each_entry(chain, &table->chains, list) { |
7138 |
+diff --git a/net/netfilter/xt_cgroup.c b/net/netfilter/xt_cgroup.c |
7139 |
+index 5d92e1781980..5cb1ecb29ea4 100644 |
7140 |
+--- a/net/netfilter/xt_cgroup.c |
7141 |
++++ b/net/netfilter/xt_cgroup.c |
7142 |
+@@ -68,6 +68,38 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_param *par) |
7143 |
+ return 0; |
7144 |
+ } |
7145 |
+ |
7146 |
++static int cgroup_mt_check_v2(const struct xt_mtchk_param *par) |
7147 |
++{ |
7148 |
++ struct xt_cgroup_info_v2 *info = par->matchinfo; |
7149 |
++ struct cgroup *cgrp; |
7150 |
++ |
7151 |
++ if ((info->invert_path & ~1) || (info->invert_classid & ~1)) |
7152 |
++ return -EINVAL; |
7153 |
++ |
7154 |
++ if (!info->has_path && !info->has_classid) { |
7155 |
++ pr_info("xt_cgroup: no path or classid specified\n"); |
7156 |
++ return -EINVAL; |
7157 |
++ } |
7158 |
++ |
7159 |
++ if (info->has_path && info->has_classid) { |
7160 |
++ pr_info_ratelimited("path and classid specified\n"); |
7161 |
++ return -EINVAL; |
7162 |
++ } |
7163 |
++ |
7164 |
++ info->priv = NULL; |
7165 |
++ if (info->has_path) { |
7166 |
++ cgrp = cgroup_get_from_path(info->path); |
7167 |
++ if (IS_ERR(cgrp)) { |
7168 |
++ pr_info_ratelimited("invalid path, errno=%ld\n", |
7169 |
++ PTR_ERR(cgrp)); |
7170 |
++ return -EINVAL; |
7171 |
++ } |
7172 |
++ info->priv = cgrp; |
7173 |
++ } |
7174 |
++ |
7175 |
++ return 0; |
7176 |
++} |
7177 |
++ |
7178 |
+ static bool |
7179 |
+ cgroup_mt_v0(const struct sk_buff *skb, struct xt_action_param *par) |
7180 |
+ { |
7181 |
+@@ -99,6 +131,24 @@ static bool cgroup_mt_v1(const struct sk_buff *skb, struct xt_action_param *par) |
7182 |
+ info->invert_classid; |
7183 |
+ } |
7184 |
+ |
7185 |
++static bool cgroup_mt_v2(const struct sk_buff *skb, struct xt_action_param *par) |
7186 |
++{ |
7187 |
++ const struct xt_cgroup_info_v2 *info = par->matchinfo; |
7188 |
++ struct sock_cgroup_data *skcd = &skb->sk->sk_cgrp_data; |
7189 |
++ struct cgroup *ancestor = info->priv; |
7190 |
++ struct sock *sk = skb->sk; |
7191 |
++ |
7192 |
++ if (!sk || !sk_fullsock(sk) || !net_eq(xt_net(par), sock_net(sk))) |
7193 |
++ return false; |
7194 |
++ |
7195 |
++ if (ancestor) |
7196 |
++ return cgroup_is_descendant(sock_cgroup_ptr(skcd), ancestor) ^ |
7197 |
++ info->invert_path; |
7198 |
++ else |
7199 |
++ return (info->classid == sock_cgroup_classid(skcd)) ^ |
7200 |
++ info->invert_classid; |
7201 |
++} |
7202 |
++ |
7203 |
+ static void cgroup_mt_destroy_v1(const struct xt_mtdtor_param *par) |
7204 |
+ { |
7205 |
+ struct xt_cgroup_info_v1 *info = par->matchinfo; |
7206 |
+@@ -107,6 +157,14 @@ static void cgroup_mt_destroy_v1(const struct xt_mtdtor_param *par) |
7207 |
+ cgroup_put(info->priv); |
7208 |
+ } |
7209 |
+ |
7210 |
++static void cgroup_mt_destroy_v2(const struct xt_mtdtor_param *par) |
7211 |
++{ |
7212 |
++ struct xt_cgroup_info_v2 *info = par->matchinfo; |
7213 |
++ |
7214 |
++ if (info->priv) |
7215 |
++ cgroup_put(info->priv); |
7216 |
++} |
7217 |
++ |
7218 |
+ static struct xt_match cgroup_mt_reg[] __read_mostly = { |
7219 |
+ { |
7220 |
+ .name = "cgroup", |
7221 |
+@@ -134,6 +192,20 @@ static struct xt_match cgroup_mt_reg[] __read_mostly = { |
7222 |
+ (1 << NF_INET_POST_ROUTING) | |
7223 |
+ (1 << NF_INET_LOCAL_IN), |
7224 |
+ }, |
7225 |
++ { |
7226 |
++ .name = "cgroup", |
7227 |
++ .revision = 2, |
7228 |
++ .family = NFPROTO_UNSPEC, |
7229 |
++ .checkentry = cgroup_mt_check_v2, |
7230 |
++ .match = cgroup_mt_v2, |
7231 |
++ .matchsize = sizeof(struct xt_cgroup_info_v2), |
7232 |
++ .usersize = offsetof(struct xt_cgroup_info_v2, priv), |
7233 |
++ .destroy = cgroup_mt_destroy_v2, |
7234 |
++ .me = THIS_MODULE, |
7235 |
++ .hooks = (1 << NF_INET_LOCAL_OUT) | |
7236 |
++ (1 << NF_INET_POST_ROUTING) | |
7237 |
++ (1 << NF_INET_LOCAL_IN), |
7238 |
++ }, |
7239 |
+ }; |
7240 |
+ |
7241 |
+ static int __init cgroup_mt_init(void) |
7242 |
+diff --git a/net/rds/rdma.c b/net/rds/rdma.c |
7243 |
+index 98237feb607a..e1965d9cbcf8 100644 |
7244 |
+--- a/net/rds/rdma.c |
7245 |
++++ b/net/rds/rdma.c |
7246 |
+@@ -517,9 +517,10 @@ static int rds_rdma_pages(struct rds_iovec iov[], int nr_iovecs) |
7247 |
+ return tot_pages; |
7248 |
+ } |
7249 |
+ |
7250 |
+-int rds_rdma_extra_size(struct rds_rdma_args *args) |
7251 |
++int rds_rdma_extra_size(struct rds_rdma_args *args, |
7252 |
++ struct rds_iov_vector *iov) |
7253 |
+ { |
7254 |
+- struct rds_iovec vec; |
7255 |
++ struct rds_iovec *vec; |
7256 |
+ struct rds_iovec __user *local_vec; |
7257 |
+ int tot_pages = 0; |
7258 |
+ unsigned int nr_pages; |
7259 |
+@@ -530,13 +531,23 @@ int rds_rdma_extra_size(struct rds_rdma_args *args) |
7260 |
+ if (args->nr_local == 0) |
7261 |
+ return -EINVAL; |
7262 |
+ |
7263 |
++ iov->iov = kcalloc(args->nr_local, |
7264 |
++ sizeof(struct rds_iovec), |
7265 |
++ GFP_KERNEL); |
7266 |
++ if (!iov->iov) |
7267 |
++ return -ENOMEM; |
7268 |
++ |
7269 |
++ vec = &iov->iov[0]; |
7270 |
++ |
7271 |
++ if (copy_from_user(vec, local_vec, args->nr_local * |
7272 |
++ sizeof(struct rds_iovec))) |
7273 |
++ return -EFAULT; |
7274 |
++ iov->len = args->nr_local; |
7275 |
++ |
7276 |
+ /* figure out the number of pages in the vector */ |
7277 |
+- for (i = 0; i < args->nr_local; i++) { |
7278 |
+- if (copy_from_user(&vec, &local_vec[i], |
7279 |
+- sizeof(struct rds_iovec))) |
7280 |
+- return -EFAULT; |
7281 |
++ for (i = 0; i < args->nr_local; i++, vec++) { |
7282 |
+ |
7283 |
+- nr_pages = rds_pages_in_vec(&vec); |
7284 |
++ nr_pages = rds_pages_in_vec(vec); |
7285 |
+ if (nr_pages == 0) |
7286 |
+ return -EINVAL; |
7287 |
+ |
7288 |
+@@ -558,15 +569,15 @@ int rds_rdma_extra_size(struct rds_rdma_args *args) |
7289 |
+ * Extract all arguments and set up the rdma_op |
7290 |
+ */ |
7291 |
+ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, |
7292 |
+- struct cmsghdr *cmsg) |
7293 |
++ struct cmsghdr *cmsg, |
7294 |
++ struct rds_iov_vector *vec) |
7295 |
+ { |
7296 |
+ struct rds_rdma_args *args; |
7297 |
+ struct rm_rdma_op *op = &rm->rdma; |
7298 |
+ int nr_pages; |
7299 |
+ unsigned int nr_bytes; |
7300 |
+ struct page **pages = NULL; |
7301 |
+- struct rds_iovec iovstack[UIO_FASTIOV], *iovs = iovstack; |
7302 |
+- int iov_size; |
7303 |
++ struct rds_iovec *iovs; |
7304 |
+ unsigned int i, j; |
7305 |
+ int ret = 0; |
7306 |
+ |
7307 |
+@@ -586,31 +597,23 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, |
7308 |
+ goto out_ret; |
7309 |
+ } |
7310 |
+ |
7311 |
+- /* Check whether to allocate the iovec area */ |
7312 |
+- iov_size = args->nr_local * sizeof(struct rds_iovec); |
7313 |
+- if (args->nr_local > UIO_FASTIOV) { |
7314 |
+- iovs = sock_kmalloc(rds_rs_to_sk(rs), iov_size, GFP_KERNEL); |
7315 |
+- if (!iovs) { |
7316 |
+- ret = -ENOMEM; |
7317 |
+- goto out_ret; |
7318 |
+- } |
7319 |
++ if (vec->len != args->nr_local) { |
7320 |
++ ret = -EINVAL; |
7321 |
++ goto out_ret; |
7322 |
+ } |
7323 |
+ |
7324 |
+- if (copy_from_user(iovs, (struct rds_iovec __user *)(unsigned long) args->local_vec_addr, iov_size)) { |
7325 |
+- ret = -EFAULT; |
7326 |
+- goto out; |
7327 |
+- } |
7328 |
++ iovs = vec->iov; |
7329 |
+ |
7330 |
+ nr_pages = rds_rdma_pages(iovs, args->nr_local); |
7331 |
+ if (nr_pages < 0) { |
7332 |
+ ret = -EINVAL; |
7333 |
+- goto out; |
7334 |
++ goto out_ret; |
7335 |
+ } |
7336 |
+ |
7337 |
+ pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL); |
7338 |
+ if (!pages) { |
7339 |
+ ret = -ENOMEM; |
7340 |
+- goto out; |
7341 |
++ goto out_ret; |
7342 |
+ } |
7343 |
+ |
7344 |
+ op->op_write = !!(args->flags & RDS_RDMA_READWRITE); |
7345 |
+@@ -623,7 +626,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, |
7346 |
+ op->op_sg = rds_message_alloc_sgs(rm, nr_pages); |
7347 |
+ if (!op->op_sg) { |
7348 |
+ ret = -ENOMEM; |
7349 |
+- goto out; |
7350 |
++ goto out_pages; |
7351 |
+ } |
7352 |
+ |
7353 |
+ if (op->op_notify || op->op_recverr) { |
7354 |
+@@ -635,7 +638,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, |
7355 |
+ op->op_notifier = kmalloc(sizeof(struct rds_notifier), GFP_KERNEL); |
7356 |
+ if (!op->op_notifier) { |
7357 |
+ ret = -ENOMEM; |
7358 |
+- goto out; |
7359 |
++ goto out_pages; |
7360 |
+ } |
7361 |
+ op->op_notifier->n_user_token = args->user_token; |
7362 |
+ op->op_notifier->n_status = RDS_RDMA_SUCCESS; |
7363 |
+@@ -681,7 +684,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, |
7364 |
+ */ |
7365 |
+ ret = rds_pin_pages(iov->addr, nr, pages, !op->op_write); |
7366 |
+ if (ret < 0) |
7367 |
+- goto out; |
7368 |
++ goto out_pages; |
7369 |
+ else |
7370 |
+ ret = 0; |
7371 |
+ |
7372 |
+@@ -714,13 +717,11 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, |
7373 |
+ nr_bytes, |
7374 |
+ (unsigned int) args->remote_vec.bytes); |
7375 |
+ ret = -EINVAL; |
7376 |
+- goto out; |
7377 |
++ goto out_pages; |
7378 |
+ } |
7379 |
+ op->op_bytes = nr_bytes; |
7380 |
+ |
7381 |
+-out: |
7382 |
+- if (iovs != iovstack) |
7383 |
+- sock_kfree_s(rds_rs_to_sk(rs), iovs, iov_size); |
7384 |
++out_pages: |
7385 |
+ kfree(pages); |
7386 |
+ out_ret: |
7387 |
+ if (ret) |
7388 |
+diff --git a/net/rds/rds.h b/net/rds/rds.h |
7389 |
+index c4dcf654d8fe..4234ab81b5af 100644 |
7390 |
+--- a/net/rds/rds.h |
7391 |
++++ b/net/rds/rds.h |
7392 |
+@@ -386,6 +386,18 @@ static inline void rds_message_zcopy_queue_init(struct rds_msg_zcopy_queue *q) |
7393 |
+ INIT_LIST_HEAD(&q->zcookie_head); |
7394 |
+ } |
7395 |
+ |
7396 |
++struct rds_iov_vector { |
7397 |
++ struct rds_iovec *iov; |
7398 |
++ int len; |
7399 |
++}; |
7400 |
++ |
7401 |
++struct rds_iov_vector_arr { |
7402 |
++ struct rds_iov_vector *vec; |
7403 |
++ int len; |
7404 |
++ int indx; |
7405 |
++ int incr; |
7406 |
++}; |
7407 |
++ |
7408 |
+ struct rds_message { |
7409 |
+ refcount_t m_refcount; |
7410 |
+ struct list_head m_sock_item; |
7411 |
+@@ -904,13 +916,13 @@ int rds_get_mr(struct rds_sock *rs, char __user *optval, int optlen); |
7412 |
+ int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen); |
7413 |
+ int rds_free_mr(struct rds_sock *rs, char __user *optval, int optlen); |
7414 |
+ void rds_rdma_drop_keys(struct rds_sock *rs); |
7415 |
+-int rds_rdma_extra_size(struct rds_rdma_args *args); |
7416 |
+-int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, |
7417 |
+- struct cmsghdr *cmsg); |
7418 |
++int rds_rdma_extra_size(struct rds_rdma_args *args, |
7419 |
++ struct rds_iov_vector *iov); |
7420 |
+ int rds_cmsg_rdma_dest(struct rds_sock *rs, struct rds_message *rm, |
7421 |
+ struct cmsghdr *cmsg); |
7422 |
+ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm, |
7423 |
+- struct cmsghdr *cmsg); |
7424 |
++ struct cmsghdr *cmsg, |
7425 |
++ struct rds_iov_vector *vec); |
7426 |
+ int rds_cmsg_rdma_map(struct rds_sock *rs, struct rds_message *rm, |
7427 |
+ struct cmsghdr *cmsg); |
7428 |
+ void rds_rdma_free_op(struct rm_rdma_op *ro); |
7429 |
+diff --git a/net/rds/send.c b/net/rds/send.c |
7430 |
+index fe785ee819dd..ec2267cbf85f 100644 |
7431 |
+--- a/net/rds/send.c |
7432 |
++++ b/net/rds/send.c |
7433 |
+@@ -876,13 +876,15 @@ out: |
7434 |
+ * rds_message is getting to be quite complicated, and we'd like to allocate |
7435 |
+ * it all in one go. This figures out how big it needs to be up front. |
7436 |
+ */ |
7437 |
+-static int rds_rm_size(struct msghdr *msg, int num_sgs) |
7438 |
++static int rds_rm_size(struct msghdr *msg, int num_sgs, |
7439 |
++ struct rds_iov_vector_arr *vct) |
7440 |
+ { |
7441 |
+ struct cmsghdr *cmsg; |
7442 |
+ int size = 0; |
7443 |
+ int cmsg_groups = 0; |
7444 |
+ int retval; |
7445 |
+ bool zcopy_cookie = false; |
7446 |
++ struct rds_iov_vector *iov, *tmp_iov; |
7447 |
+ |
7448 |
+ for_each_cmsghdr(cmsg, msg) { |
7449 |
+ if (!CMSG_OK(msg, cmsg)) |
7450 |
+@@ -893,8 +895,24 @@ static int rds_rm_size(struct msghdr *msg, int num_sgs) |
7451 |
+ |
7452 |
+ switch (cmsg->cmsg_type) { |
7453 |
+ case RDS_CMSG_RDMA_ARGS: |
7454 |
++ if (vct->indx >= vct->len) { |
7455 |
++ vct->len += vct->incr; |
7456 |
++ tmp_iov = |
7457 |
++ krealloc(vct->vec, |
7458 |
++ vct->len * |
7459 |
++ sizeof(struct rds_iov_vector), |
7460 |
++ GFP_KERNEL); |
7461 |
++ if (!tmp_iov) { |
7462 |
++ vct->len -= vct->incr; |
7463 |
++ return -ENOMEM; |
7464 |
++ } |
7465 |
++ vct->vec = tmp_iov; |
7466 |
++ } |
7467 |
++ iov = &vct->vec[vct->indx]; |
7468 |
++ memset(iov, 0, sizeof(struct rds_iov_vector)); |
7469 |
++ vct->indx++; |
7470 |
+ cmsg_groups |= 1; |
7471 |
+- retval = rds_rdma_extra_size(CMSG_DATA(cmsg)); |
7472 |
++ retval = rds_rdma_extra_size(CMSG_DATA(cmsg), iov); |
7473 |
+ if (retval < 0) |
7474 |
+ return retval; |
7475 |
+ size += retval; |
7476 |
+@@ -951,10 +969,11 @@ static int rds_cmsg_zcopy(struct rds_sock *rs, struct rds_message *rm, |
7477 |
+ } |
7478 |
+ |
7479 |
+ static int rds_cmsg_send(struct rds_sock *rs, struct rds_message *rm, |
7480 |
+- struct msghdr *msg, int *allocated_mr) |
7481 |
++ struct msghdr *msg, int *allocated_mr, |
7482 |
++ struct rds_iov_vector_arr *vct) |
7483 |
+ { |
7484 |
+ struct cmsghdr *cmsg; |
7485 |
+- int ret = 0; |
7486 |
++ int ret = 0, ind = 0; |
7487 |
+ |
7488 |
+ for_each_cmsghdr(cmsg, msg) { |
7489 |
+ if (!CMSG_OK(msg, cmsg)) |
7490 |
+@@ -968,7 +987,10 @@ static int rds_cmsg_send(struct rds_sock *rs, struct rds_message *rm, |
7491 |
+ */ |
7492 |
+ switch (cmsg->cmsg_type) { |
7493 |
+ case RDS_CMSG_RDMA_ARGS: |
7494 |
+- ret = rds_cmsg_rdma_args(rs, rm, cmsg); |
7495 |
++ if (ind >= vct->indx) |
7496 |
++ return -ENOMEM; |
7497 |
++ ret = rds_cmsg_rdma_args(rs, rm, cmsg, &vct->vec[ind]); |
7498 |
++ ind++; |
7499 |
+ break; |
7500 |
+ |
7501 |
+ case RDS_CMSG_RDMA_DEST: |
7502 |
+@@ -1084,6 +1106,11 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) |
7503 |
+ sock_flag(rds_rs_to_sk(rs), SOCK_ZEROCOPY)); |
7504 |
+ int num_sgs = ceil(payload_len, PAGE_SIZE); |
7505 |
+ int namelen; |
7506 |
++ struct rds_iov_vector_arr vct = {0}; |
7507 |
++ int ind; |
7508 |
++ |
7509 |
++ /* expect 1 RDMA CMSG per rds_sendmsg. can still grow if more needed. */ |
7510 |
++ vct.incr = 1; |
7511 |
+ |
7512 |
+ /* Mirror Linux UDP mirror of BSD error message compatibility */ |
7513 |
+ /* XXX: Perhaps MSG_MORE someday */ |
7514 |
+@@ -1220,7 +1247,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) |
7515 |
+ num_sgs = iov_iter_npages(&msg->msg_iter, INT_MAX); |
7516 |
+ } |
7517 |
+ /* size of rm including all sgs */ |
7518 |
+- ret = rds_rm_size(msg, num_sgs); |
7519 |
++ ret = rds_rm_size(msg, num_sgs, &vct); |
7520 |
+ if (ret < 0) |
7521 |
+ goto out; |
7522 |
+ |
7523 |
+@@ -1270,7 +1297,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) |
7524 |
+ rm->m_conn_path = cpath; |
7525 |
+ |
7526 |
+ /* Parse any control messages the user may have included. */ |
7527 |
+- ret = rds_cmsg_send(rs, rm, msg, &allocated_mr); |
7528 |
++ ret = rds_cmsg_send(rs, rm, msg, &allocated_mr, &vct); |
7529 |
+ if (ret) { |
7530 |
+ /* Trigger connection so that its ready for the next retry */ |
7531 |
+ if (ret == -EAGAIN) |
7532 |
+@@ -1348,9 +1375,18 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) |
7533 |
+ if (ret) |
7534 |
+ goto out; |
7535 |
+ rds_message_put(rm); |
7536 |
++ |
7537 |
++ for (ind = 0; ind < vct.indx; ind++) |
7538 |
++ kfree(vct.vec[ind].iov); |
7539 |
++ kfree(vct.vec); |
7540 |
++ |
7541 |
+ return payload_len; |
7542 |
+ |
7543 |
+ out: |
7544 |
++ for (ind = 0; ind < vct.indx; ind++) |
7545 |
++ kfree(vct.vec[ind].iov); |
7546 |
++ kfree(vct.vec); |
7547 |
++ |
7548 |
+ /* If the user included a RDMA_MAP cmsg, we allocated a MR on the fly. |
7549 |
+ * If the sendmsg goes through, we keep the MR. If it fails with EAGAIN |
7550 |
+ * or in any other way, we need to destroy the MR again */ |
7551 |
+diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c |
7552 |
+index 6e419b15a9f8..c979a56faaef 100644 |
7553 |
+--- a/net/rxrpc/conn_client.c |
7554 |
++++ b/net/rxrpc/conn_client.c |
7555 |
+@@ -707,6 +707,7 @@ int rxrpc_connect_call(struct rxrpc_sock *rx, |
7556 |
+ |
7557 |
+ ret = rxrpc_wait_for_channel(call, gfp); |
7558 |
+ if (ret < 0) { |
7559 |
++ trace_rxrpc_client(call->conn, ret, rxrpc_client_chan_wait_failed); |
7560 |
+ rxrpc_disconnect_client_call(call); |
7561 |
+ goto out; |
7562 |
+ } |
7563 |
+@@ -777,16 +778,22 @@ static void rxrpc_set_client_reap_timer(struct rxrpc_net *rxnet) |
7564 |
+ */ |
7565 |
+ void rxrpc_disconnect_client_call(struct rxrpc_call *call) |
7566 |
+ { |
7567 |
+- unsigned int channel = call->cid & RXRPC_CHANNELMASK; |
7568 |
+ struct rxrpc_connection *conn = call->conn; |
7569 |
+- struct rxrpc_channel *chan = &conn->channels[channel]; |
7570 |
++ struct rxrpc_channel *chan = NULL; |
7571 |
+ struct rxrpc_net *rxnet = conn->params.local->rxnet; |
7572 |
++ unsigned int channel = -1; |
7573 |
++ u32 cid; |
7574 |
+ |
7575 |
++ spin_lock(&conn->channel_lock); |
7576 |
++ |
7577 |
++ cid = call->cid; |
7578 |
++ if (cid) { |
7579 |
++ channel = cid & RXRPC_CHANNELMASK; |
7580 |
++ chan = &conn->channels[channel]; |
7581 |
++ } |
7582 |
+ trace_rxrpc_client(conn, channel, rxrpc_client_chan_disconnect); |
7583 |
+ call->conn = NULL; |
7584 |
+ |
7585 |
+- spin_lock(&conn->channel_lock); |
7586 |
+- |
7587 |
+ /* Calls that have never actually been assigned a channel can simply be |
7588 |
+ * discarded. If the conn didn't get used either, it will follow |
7589 |
+ * immediately unless someone else grabs it in the meantime. |
7590 |
+@@ -810,7 +817,10 @@ void rxrpc_disconnect_client_call(struct rxrpc_call *call) |
7591 |
+ goto out; |
7592 |
+ } |
7593 |
+ |
7594 |
+- ASSERTCMP(rcu_access_pointer(chan->call), ==, call); |
7595 |
++ if (rcu_access_pointer(chan->call) != call) { |
7596 |
++ spin_unlock(&conn->channel_lock); |
7597 |
++ BUG(); |
7598 |
++ } |
7599 |
+ |
7600 |
+ /* If a client call was exposed to the world, we save the result for |
7601 |
+ * retransmission. |
7602 |
+diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c |
7603 |
+index cc0203efb584..3f729cd512af 100644 |
7604 |
+--- a/net/xfrm/xfrm_state.c |
7605 |
++++ b/net/xfrm/xfrm_state.c |
7606 |
+@@ -432,7 +432,7 @@ void xfrm_state_free(struct xfrm_state *x) |
7607 |
+ } |
7608 |
+ EXPORT_SYMBOL(xfrm_state_free); |
7609 |
+ |
7610 |
+-static void xfrm_state_gc_destroy(struct xfrm_state *x) |
7611 |
++static void ___xfrm_state_destroy(struct xfrm_state *x) |
7612 |
+ { |
7613 |
+ tasklet_hrtimer_cancel(&x->mtimer); |
7614 |
+ del_timer_sync(&x->rtimer); |
7615 |
+@@ -474,7 +474,7 @@ static void xfrm_state_gc_task(struct work_struct *work) |
7616 |
+ synchronize_rcu(); |
7617 |
+ |
7618 |
+ hlist_for_each_entry_safe(x, tmp, &gc_list, gclist) |
7619 |
+- xfrm_state_gc_destroy(x); |
7620 |
++ ___xfrm_state_destroy(x); |
7621 |
+ } |
7622 |
+ |
7623 |
+ static enum hrtimer_restart xfrm_timer_handler(struct hrtimer *me) |
7624 |
+@@ -598,14 +598,19 @@ struct xfrm_state *xfrm_state_alloc(struct net *net) |
7625 |
+ } |
7626 |
+ EXPORT_SYMBOL(xfrm_state_alloc); |
7627 |
+ |
7628 |
+-void __xfrm_state_destroy(struct xfrm_state *x) |
7629 |
++void __xfrm_state_destroy(struct xfrm_state *x, bool sync) |
7630 |
+ { |
7631 |
+ WARN_ON(x->km.state != XFRM_STATE_DEAD); |
7632 |
+ |
7633 |
+- spin_lock_bh(&xfrm_state_gc_lock); |
7634 |
+- hlist_add_head(&x->gclist, &xfrm_state_gc_list); |
7635 |
+- spin_unlock_bh(&xfrm_state_gc_lock); |
7636 |
+- schedule_work(&xfrm_state_gc_work); |
7637 |
++ if (sync) { |
7638 |
++ synchronize_rcu(); |
7639 |
++ ___xfrm_state_destroy(x); |
7640 |
++ } else { |
7641 |
++ spin_lock_bh(&xfrm_state_gc_lock); |
7642 |
++ hlist_add_head(&x->gclist, &xfrm_state_gc_list); |
7643 |
++ spin_unlock_bh(&xfrm_state_gc_lock); |
7644 |
++ schedule_work(&xfrm_state_gc_work); |
7645 |
++ } |
7646 |
+ } |
7647 |
+ EXPORT_SYMBOL(__xfrm_state_destroy); |
7648 |
+ |
7649 |
+@@ -708,7 +713,7 @@ xfrm_dev_state_flush_secctx_check(struct net *net, struct net_device *dev, bool |
7650 |
+ } |
7651 |
+ #endif |
7652 |
+ |
7653 |
+-int xfrm_state_flush(struct net *net, u8 proto, bool task_valid) |
7654 |
++int xfrm_state_flush(struct net *net, u8 proto, bool task_valid, bool sync) |
7655 |
+ { |
7656 |
+ int i, err = 0, cnt = 0; |
7657 |
+ |
7658 |
+@@ -730,7 +735,10 @@ restart: |
7659 |
+ err = xfrm_state_delete(x); |
7660 |
+ xfrm_audit_state_delete(x, err ? 0 : 1, |
7661 |
+ task_valid); |
7662 |
+- xfrm_state_put(x); |
7663 |
++ if (sync) |
7664 |
++ xfrm_state_put_sync(x); |
7665 |
++ else |
7666 |
++ xfrm_state_put(x); |
7667 |
+ if (!err) |
7668 |
+ cnt++; |
7669 |
+ |
7670 |
+@@ -2217,7 +2225,7 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x) |
7671 |
+ if (atomic_read(&t->tunnel_users) == 2) |
7672 |
+ xfrm_state_delete(t); |
7673 |
+ atomic_dec(&t->tunnel_users); |
7674 |
+- xfrm_state_put(t); |
7675 |
++ xfrm_state_put_sync(t); |
7676 |
+ x->tunnel = NULL; |
7677 |
+ } |
7678 |
+ } |
7679 |
+@@ -2377,8 +2385,8 @@ void xfrm_state_fini(struct net *net) |
7680 |
+ unsigned int sz; |
7681 |
+ |
7682 |
+ flush_work(&net->xfrm.state_hash_work); |
7683 |
+- xfrm_state_flush(net, IPSEC_PROTO_ANY, false); |
7684 |
+ flush_work(&xfrm_state_gc_work); |
7685 |
++ xfrm_state_flush(net, IPSEC_PROTO_ANY, false, true); |
7686 |
+ |
7687 |
+ WARN_ON(!list_empty(&net->xfrm.state_all)); |
7688 |
+ |
7689 |
+diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c |
7690 |
+index ab557827aac0..7e4904b93004 100644 |
7691 |
+--- a/net/xfrm/xfrm_user.c |
7692 |
++++ b/net/xfrm/xfrm_user.c |
7693 |
+@@ -1932,7 +1932,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, |
7694 |
+ struct xfrm_usersa_flush *p = nlmsg_data(nlh); |
7695 |
+ int err; |
7696 |
+ |
7697 |
+- err = xfrm_state_flush(net, p->proto, true); |
7698 |
++ err = xfrm_state_flush(net, p->proto, true, false); |
7699 |
+ if (err) { |
7700 |
+ if (err == -ESRCH) /* empty table */ |
7701 |
+ return 0; |
7702 |
+diff --git a/sound/drivers/opl3/opl3_voice.h b/sound/drivers/opl3/opl3_voice.h |
7703 |
+index 5b02bd49fde4..4e4ecc21760b 100644 |
7704 |
+--- a/sound/drivers/opl3/opl3_voice.h |
7705 |
++++ b/sound/drivers/opl3/opl3_voice.h |
7706 |
+@@ -41,7 +41,7 @@ void snd_opl3_timer_func(struct timer_list *t); |
7707 |
+ |
7708 |
+ /* Prototypes for opl3_drums.c */ |
7709 |
+ void snd_opl3_load_drums(struct snd_opl3 *opl3); |
7710 |
+-void snd_opl3_drum_switch(struct snd_opl3 *opl3, int note, int on_off, int vel, struct snd_midi_channel *chan); |
7711 |
++void snd_opl3_drum_switch(struct snd_opl3 *opl3, int note, int vel, int on_off, struct snd_midi_channel *chan); |
7712 |
+ |
7713 |
+ /* Prototypes for opl3_oss.c */ |
7714 |
+ #if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS) |
7715 |
+diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c |
7716 |
+index d77dcba276b5..1eb8b61a185b 100644 |
7717 |
+--- a/sound/isa/sb/sb8.c |
7718 |
++++ b/sound/isa/sb/sb8.c |
7719 |
+@@ -111,6 +111,10 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev) |
7720 |
+ |
7721 |
+ /* block the 0x388 port to avoid PnP conflicts */ |
7722 |
+ acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); |
7723 |
++ if (!acard->fm_res) { |
7724 |
++ err = -EBUSY; |
7725 |
++ goto _err; |
7726 |
++ } |
7727 |
+ |
7728 |
+ if (port[dev] != SNDRV_AUTO_PORT) { |
7729 |
+ if ((err = snd_sbdsp_create(card, port[dev], irq[dev], |
7730 |
+diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c |
7731 |
+index 907cf1a46712..3ef2b27ebbe8 100644 |
7732 |
+--- a/sound/pci/echoaudio/echoaudio.c |
7733 |
++++ b/sound/pci/echoaudio/echoaudio.c |
7734 |
+@@ -1954,6 +1954,11 @@ static int snd_echo_create(struct snd_card *card, |
7735 |
+ } |
7736 |
+ chip->dsp_registers = (volatile u32 __iomem *) |
7737 |
+ ioremap_nocache(chip->dsp_registers_phys, sz); |
7738 |
++ if (!chip->dsp_registers) { |
7739 |
++ dev_err(chip->card->dev, "ioremap failed\n"); |
7740 |
++ snd_echo_free(chip); |
7741 |
++ return -ENOMEM; |
7742 |
++ } |
7743 |
+ |
7744 |
+ if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, |
7745 |
+ KBUILD_MODNAME, chip)) { |
7746 |
+diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c |
7747 |
+index b9d832bde23e..bd60eb7168fa 100644 |
7748 |
+--- a/sound/pci/hda/patch_realtek.c |
7749 |
++++ b/sound/pci/hda/patch_realtek.c |
7750 |
+@@ -5604,6 +5604,7 @@ enum { |
7751 |
+ ALC298_FIXUP_TPT470_DOCK, |
7752 |
+ ALC255_FIXUP_DUMMY_LINEOUT_VERB, |
7753 |
+ ALC255_FIXUP_DELL_HEADSET_MIC, |
7754 |
++ ALC256_FIXUP_HUAWEI_MBXP_PINS, |
7755 |
+ ALC295_FIXUP_HP_X360, |
7756 |
+ ALC221_FIXUP_HP_HEADSET_MIC, |
7757 |
+ ALC285_FIXUP_LENOVO_HEADPHONE_NOISE, |
7758 |
+@@ -5892,6 +5893,22 @@ static const struct hda_fixup alc269_fixups[] = { |
7759 |
+ .chained = true, |
7760 |
+ .chain_id = ALC269_FIXUP_HEADSET_MIC |
7761 |
+ }, |
7762 |
++ [ALC256_FIXUP_HUAWEI_MBXP_PINS] = { |
7763 |
++ .type = HDA_FIXUP_PINS, |
7764 |
++ .v.pins = (const struct hda_pintbl[]) { |
7765 |
++ {0x12, 0x90a60130}, |
7766 |
++ {0x13, 0x40000000}, |
7767 |
++ {0x14, 0x90170110}, |
7768 |
++ {0x18, 0x411111f0}, |
7769 |
++ {0x19, 0x04a11040}, |
7770 |
++ {0x1a, 0x411111f0}, |
7771 |
++ {0x1b, 0x90170112}, |
7772 |
++ {0x1d, 0x40759a05}, |
7773 |
++ {0x1e, 0x411111f0}, |
7774 |
++ {0x21, 0x04211020}, |
7775 |
++ { } |
7776 |
++ }, |
7777 |
++ }, |
7778 |
+ [ALC269_FIXUP_ASUS_X101_FUNC] = { |
7779 |
+ .type = HDA_FIXUP_FUNC, |
7780 |
+ .v.func = alc269_fixup_x101_headset_mic, |
7781 |
+@@ -6885,6 +6902,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
7782 |
+ SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), |
7783 |
+ SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
7784 |
+ SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
7785 |
++ SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MBXP", ALC256_FIXUP_HUAWEI_MBXP_PINS), |
7786 |
+ SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ |
7787 |
+ |
7788 |
+ #if 0 |
7789 |
+diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c |
7790 |
+index 592efb370c44..f4dc3d445aae 100644 |
7791 |
+--- a/sound/soc/soc-ops.c |
7792 |
++++ b/sound/soc/soc-ops.c |
7793 |
+@@ -373,7 +373,7 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, |
7794 |
+ unsigned int rshift = mc->rshift; |
7795 |
+ int max = mc->max; |
7796 |
+ int min = mc->min; |
7797 |
+- unsigned int mask = (1 << (fls(min + max) - 1)) - 1; |
7798 |
++ unsigned int mask = (1U << (fls(min + max) - 1)) - 1; |
7799 |
+ unsigned int val; |
7800 |
+ int ret; |
7801 |
+ |
7802 |
+@@ -418,7 +418,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, |
7803 |
+ unsigned int rshift = mc->rshift; |
7804 |
+ int max = mc->max; |
7805 |
+ int min = mc->min; |
7806 |
+- unsigned int mask = (1 << (fls(min + max) - 1)) - 1; |
7807 |
++ unsigned int mask = (1U << (fls(min + max) - 1)) - 1; |
7808 |
+ int err = 0; |
7809 |
+ unsigned int val, val_mask, val2 = 0; |
7810 |
+ |
7811 |
+diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt |
7812 |
+index 32f4a898e3f2..05c10eb56a0c 100644 |
7813 |
+--- a/tools/perf/Documentation/perf-config.txt |
7814 |
++++ b/tools/perf/Documentation/perf-config.txt |
7815 |
+@@ -114,7 +114,7 @@ Given a $HOME/.perfconfig like this: |
7816 |
+ |
7817 |
+ [report] |
7818 |
+ # Defaults |
7819 |
+- sort-order = comm,dso,symbol |
7820 |
++ sort_order = comm,dso,symbol |
7821 |
+ percent-limit = 0 |
7822 |
+ queue-size = 0 |
7823 |
+ children = true |
7824 |
+diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c |
7825 |
+index d21d8751e749..33eefc33e0ea 100644 |
7826 |
+--- a/tools/perf/builtin-top.c |
7827 |
++++ b/tools/perf/builtin-top.c |
7828 |
+@@ -1491,8 +1491,9 @@ int cmd_top(int argc, const char **argv) |
7829 |
+ annotation_config__init(); |
7830 |
+ |
7831 |
+ symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); |
7832 |
+- if (symbol__init(NULL) < 0) |
7833 |
+- return -1; |
7834 |
++ status = symbol__init(NULL); |
7835 |
++ if (status < 0) |
7836 |
++ goto out_delete_evlist; |
7837 |
+ |
7838 |
+ sort__setup_elide(stdout); |
7839 |
+ |
7840 |
+diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c |
7841 |
+index d0406116c905..926a8e1b5e94 100644 |
7842 |
+--- a/tools/perf/tests/evsel-tp-sched.c |
7843 |
++++ b/tools/perf/tests/evsel-tp-sched.c |
7844 |
+@@ -85,5 +85,6 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtes |
7845 |
+ if (perf_evsel__test_field(evsel, "target_cpu", 4, true)) |
7846 |
+ ret = -1; |
7847 |
+ |
7848 |
++ perf_evsel__delete(evsel); |
7849 |
+ return ret; |
7850 |
+ } |
7851 |
+diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c |
7852 |
+index 01f0706995a9..9acc1e80b936 100644 |
7853 |
+--- a/tools/perf/tests/expr.c |
7854 |
++++ b/tools/perf/tests/expr.c |
7855 |
+@@ -19,7 +19,7 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused) |
7856 |
+ const char *p; |
7857 |
+ const char **other; |
7858 |
+ double val; |
7859 |
+- int ret; |
7860 |
++ int i, ret; |
7861 |
+ struct parse_ctx ctx; |
7862 |
+ int num_other; |
7863 |
+ |
7864 |
+@@ -56,6 +56,9 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused) |
7865 |
+ TEST_ASSERT_VAL("find other", !strcmp(other[1], "BAZ")); |
7866 |
+ TEST_ASSERT_VAL("find other", !strcmp(other[2], "BOZO")); |
7867 |
+ TEST_ASSERT_VAL("find other", other[3] == NULL); |
7868 |
++ |
7869 |
++ for (i = 0; i < num_other; i++) |
7870 |
++ free((void *)other[i]); |
7871 |
+ free((void *)other); |
7872 |
+ |
7873 |
+ return 0; |
7874 |
+diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c |
7875 |
+index c531e6deb104..493ecb611540 100644 |
7876 |
+--- a/tools/perf/tests/openat-syscall-all-cpus.c |
7877 |
++++ b/tools/perf/tests/openat-syscall-all-cpus.c |
7878 |
+@@ -45,7 +45,7 @@ int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int |
7879 |
+ if (IS_ERR(evsel)) { |
7880 |
+ tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat"); |
7881 |
+ pr_debug("%s\n", errbuf); |
7882 |
+- goto out_thread_map_delete; |
7883 |
++ goto out_cpu_map_delete; |
7884 |
+ } |
7885 |
+ |
7886 |
+ if (perf_evsel__open(evsel, cpus, threads) < 0) { |
7887 |
+@@ -119,6 +119,8 @@ out_close_fd: |
7888 |
+ perf_evsel__close_fd(evsel); |
7889 |
+ out_evsel_delete: |
7890 |
+ perf_evsel__delete(evsel); |
7891 |
++out_cpu_map_delete: |
7892 |
++ cpu_map__put(cpus); |
7893 |
+ out_thread_map_delete: |
7894 |
+ thread_map__put(threads); |
7895 |
+ return err; |
7896 |
+diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c |
7897 |
+index 04b1d53e4bf9..1d352621bd48 100644 |
7898 |
+--- a/tools/perf/util/build-id.c |
7899 |
++++ b/tools/perf/util/build-id.c |
7900 |
+@@ -183,6 +183,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size) |
7901 |
+ return bf; |
7902 |
+ } |
7903 |
+ |
7904 |
++/* The caller is responsible to free the returned buffer. */ |
7905 |
+ char *build_id_cache__origname(const char *sbuild_id) |
7906 |
+ { |
7907 |
+ char *linkname; |
7908 |
+diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c |
7909 |
+index 5ac157056cdf..9bb742accfa5 100644 |
7910 |
+--- a/tools/perf/util/config.c |
7911 |
++++ b/tools/perf/util/config.c |
7912 |
+@@ -628,11 +628,10 @@ static int collect_config(const char *var, const char *value, |
7913 |
+ } |
7914 |
+ |
7915 |
+ ret = set_value(item, value); |
7916 |
+- return ret; |
7917 |
+ |
7918 |
+ out_free: |
7919 |
+ free(key); |
7920 |
+- return -1; |
7921 |
++ return ret; |
7922 |
+ } |
7923 |
+ |
7924 |
+ int perf_config_set__collect(struct perf_config_set *set, const char *file_name, |
7925 |
+diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c |
7926 |
+index e7dbdcc8d465..b65ad5a273eb 100644 |
7927 |
+--- a/tools/perf/util/evsel.c |
7928 |
++++ b/tools/perf/util/evsel.c |
7929 |
+@@ -1274,6 +1274,7 @@ void perf_evsel__exit(struct perf_evsel *evsel) |
7930 |
+ { |
7931 |
+ assert(list_empty(&evsel->node)); |
7932 |
+ assert(evsel->evlist == NULL); |
7933 |
++ perf_evsel__free_counts(evsel); |
7934 |
+ perf_evsel__free_fd(evsel); |
7935 |
+ perf_evsel__free_id(evsel); |
7936 |
+ perf_evsel__free_config_terms(evsel); |
7937 |
+diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c |
7938 |
+index 828cb9794c76..e1e94b44d588 100644 |
7939 |
+--- a/tools/perf/util/hist.c |
7940 |
++++ b/tools/perf/util/hist.c |
7941 |
+@@ -1048,8 +1048,10 @@ int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al, |
7942 |
+ |
7943 |
+ err = sample__resolve_callchain(iter->sample, &callchain_cursor, &iter->parent, |
7944 |
+ iter->evsel, al, max_stack_depth); |
7945 |
+- if (err) |
7946 |
++ if (err) { |
7947 |
++ map__put(alm); |
7948 |
+ return err; |
7949 |
++ } |
7950 |
+ |
7951 |
+ err = iter->ops->prepare_entry(iter, al); |
7952 |
+ if (err) |
7953 |
+diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c |
7954 |
+index ebb18a9bc460..1a7c76d2baa8 100644 |
7955 |
+--- a/tools/perf/util/parse-events.c |
7956 |
++++ b/tools/perf/util/parse-events.c |
7957 |
+@@ -2263,6 +2263,7 @@ static bool is_event_supported(u8 type, unsigned config) |
7958 |
+ perf_evsel__delete(evsel); |
7959 |
+ } |
7960 |
+ |
7961 |
++ thread_map__put(tmap); |
7962 |
+ return ret; |
7963 |
+ } |
7964 |
+ |
7965 |
+@@ -2333,6 +2334,7 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob, |
7966 |
+ printf(" %-50s [%s]\n", buf, "SDT event"); |
7967 |
+ free(buf); |
7968 |
+ } |
7969 |
++ free(path); |
7970 |
+ } else |
7971 |
+ printf(" %-50s [%s]\n", nd->s, "SDT event"); |
7972 |
+ if (nd2) { |
7973 |
+diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c |
7974 |
+index 980bd9d20646..83964f796edb 100644 |
7975 |
+--- a/tools/power/x86/turbostat/turbostat.c |
7976 |
++++ b/tools/power/x86/turbostat/turbostat.c |
7977 |
+@@ -5054,6 +5054,9 @@ int fork_it(char **argv) |
7978 |
+ signal(SIGQUIT, SIG_IGN); |
7979 |
+ if (waitpid(child_pid, &status, 0) == -1) |
7980 |
+ err(status, "waitpid"); |
7981 |
++ |
7982 |
++ if (WIFEXITED(status)) |
7983 |
++ status = WEXITSTATUS(status); |
7984 |
+ } |
7985 |
+ /* |
7986 |
+ * n.b. fork_it() does not check for errors from for_all_cpus() |
7987 |
+diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c |
7988 |
+index 4204359c9fee..8159fd98680b 100644 |
7989 |
+--- a/tools/usb/usbip/libsrc/vhci_driver.c |
7990 |
++++ b/tools/usb/usbip/libsrc/vhci_driver.c |
7991 |
+@@ -150,7 +150,7 @@ static int get_nports(struct udev_device *hc_device) |
7992 |
+ |
7993 |
+ static int vhci_hcd_filter(const struct dirent *dirent) |
7994 |
+ { |
7995 |
+- return strcmp(dirent->d_name, "vhci_hcd") >= 0; |
7996 |
++ return !strncmp(dirent->d_name, "vhci_hcd.", 9); |
7997 |
+ } |
7998 |
+ |
7999 |
+ static int get_ncontrollers(void) |