1 |
commit: 785c46db0215ad62c979861e60bdeccd37f198ce |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 17 23:59:04 2016 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 17 23:59:04 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=785c46db |
7 |
|
8 |
Linux patch 3.14.61 |
9 |
|
10 |
0000_README | 4 + |
11 |
1060_linux-3.14.61.patch | 2765 ++++++++++++++++++++++++++++++++++++++++++++++ |
12 |
2 files changed, 2769 insertions(+) |
13 |
|
14 |
diff --git a/0000_README b/0000_README |
15 |
index 03a61a1..d9cdf76 100644 |
16 |
--- a/0000_README |
17 |
+++ b/0000_README |
18 |
@@ -282,6 +282,10 @@ Patch: 1059_linux-3.14.60.patch |
19 |
From: http://www.kernel.org |
20 |
Desc: Linux 3.14.60 |
21 |
|
22 |
+Patch: 1060_linux-3.14.61.patch |
23 |
+From: http://www.kernel.org |
24 |
+Desc: Linux 3.14.61 |
25 |
+ |
26 |
Patch: 1500_XATTR_USER_PREFIX.patch |
27 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
28 |
Desc: Support for namespace user.pax.* on tmpfs. |
29 |
|
30 |
diff --git a/1060_linux-3.14.61.patch b/1060_linux-3.14.61.patch |
31 |
new file mode 100644 |
32 |
index 0000000..9b42d08 |
33 |
--- /dev/null |
34 |
+++ b/1060_linux-3.14.61.patch |
35 |
@@ -0,0 +1,2765 @@ |
36 |
+diff --git a/Makefile b/Makefile |
37 |
+index 502255cebc9a..fbf4ec689957 100644 |
38 |
+--- a/Makefile |
39 |
++++ b/Makefile |
40 |
+@@ -1,6 +1,6 @@ |
41 |
+ VERSION = 3 |
42 |
+ PATCHLEVEL = 14 |
43 |
+-SUBLEVEL = 60 |
44 |
++SUBLEVEL = 61 |
45 |
+ EXTRAVERSION = |
46 |
+ NAME = Remembering Coco |
47 |
+ |
48 |
+diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h |
49 |
+index 294d251ca7b2..2ae13ce592e8 100644 |
50 |
+--- a/arch/parisc/include/uapi/asm/mman.h |
51 |
++++ b/arch/parisc/include/uapi/asm/mman.h |
52 |
+@@ -46,16 +46,6 @@ |
53 |
+ #define MADV_DONTFORK 10 /* don't inherit across fork */ |
54 |
+ #define MADV_DOFORK 11 /* do inherit across fork */ |
55 |
+ |
56 |
+-/* The range 12-64 is reserved for page size specification. */ |
57 |
+-#define MADV_4K_PAGES 12 /* Use 4K pages */ |
58 |
+-#define MADV_16K_PAGES 14 /* Use 16K pages */ |
59 |
+-#define MADV_64K_PAGES 16 /* Use 64K pages */ |
60 |
+-#define MADV_256K_PAGES 18 /* Use 256K pages */ |
61 |
+-#define MADV_1M_PAGES 20 /* Use 1 Megabyte pages */ |
62 |
+-#define MADV_4M_PAGES 22 /* Use 4 Megabyte pages */ |
63 |
+-#define MADV_16M_PAGES 24 /* Use 16 Megabyte pages */ |
64 |
+-#define MADV_64M_PAGES 26 /* Use 64 Megabyte pages */ |
65 |
+- |
66 |
+ #define MADV_MERGEABLE 65 /* KSM may merge identical pages */ |
67 |
+ #define MADV_UNMERGEABLE 66 /* KSM may not merge identical pages */ |
68 |
+ |
69 |
+diff --git a/arch/parisc/include/uapi/asm/siginfo.h b/arch/parisc/include/uapi/asm/siginfo.h |
70 |
+index d7034728f377..1c75565d984b 100644 |
71 |
+--- a/arch/parisc/include/uapi/asm/siginfo.h |
72 |
++++ b/arch/parisc/include/uapi/asm/siginfo.h |
73 |
+@@ -1,6 +1,10 @@ |
74 |
+ #ifndef _PARISC_SIGINFO_H |
75 |
+ #define _PARISC_SIGINFO_H |
76 |
+ |
77 |
++#if defined(__LP64__) |
78 |
++#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) |
79 |
++#endif |
80 |
++ |
81 |
+ #include <asm-generic/siginfo.h> |
82 |
+ |
83 |
+ #undef NSIGTRAP |
84 |
+diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c |
85 |
+index 1cba8f29bb49..78bb6dd88e03 100644 |
86 |
+--- a/arch/parisc/kernel/signal.c |
87 |
++++ b/arch/parisc/kernel/signal.c |
88 |
+@@ -442,6 +442,55 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, |
89 |
+ regs->gr[28]); |
90 |
+ } |
91 |
+ |
92 |
++/* |
93 |
++ * Check how the syscall number gets loaded into %r20 within |
94 |
++ * the delay branch in userspace and adjust as needed. |
95 |
++ */ |
96 |
++ |
97 |
++static void check_syscallno_in_delay_branch(struct pt_regs *regs) |
98 |
++{ |
99 |
++ u32 opcode, source_reg; |
100 |
++ u32 __user *uaddr; |
101 |
++ int err; |
102 |
++ |
103 |
++ /* Usually we don't have to restore %r20 (the system call number) |
104 |
++ * because it gets loaded in the delay slot of the branch external |
105 |
++ * instruction via the ldi instruction. |
106 |
++ * In some cases a register-to-register copy instruction might have |
107 |
++ * been used instead, in which case we need to copy the syscall |
108 |
++ * number into the source register before returning to userspace. |
109 |
++ */ |
110 |
++ |
111 |
++ /* A syscall is just a branch, so all we have to do is fiddle the |
112 |
++ * return pointer so that the ble instruction gets executed again. |
113 |
++ */ |
114 |
++ regs->gr[31] -= 8; /* delayed branching */ |
115 |
++ |
116 |
++ /* Get assembler opcode of code in delay branch */ |
117 |
++ uaddr = (unsigned int *) ((regs->gr[31] & ~3) + 4); |
118 |
++ err = get_user(opcode, uaddr); |
119 |
++ if (err) |
120 |
++ return; |
121 |
++ |
122 |
++ /* Check if delay branch uses "ldi int,%r20" */ |
123 |
++ if ((opcode & 0xffff0000) == 0x34140000) |
124 |
++ return; /* everything ok, just return */ |
125 |
++ |
126 |
++ /* Check if delay branch uses "nop" */ |
127 |
++ if (opcode == INSN_NOP) |
128 |
++ return; |
129 |
++ |
130 |
++ /* Check if delay branch uses "copy %rX,%r20" */ |
131 |
++ if ((opcode & 0xffe0ffff) == 0x08000254) { |
132 |
++ source_reg = (opcode >> 16) & 31; |
133 |
++ regs->gr[source_reg] = regs->gr[20]; |
134 |
++ return; |
135 |
++ } |
136 |
++ |
137 |
++ pr_warn("syscall restart: %s (pid %d): unexpected opcode 0x%08x\n", |
138 |
++ current->comm, task_pid_nr(current), opcode); |
139 |
++} |
140 |
++ |
141 |
+ static inline void |
142 |
+ syscall_restart(struct pt_regs *regs, struct k_sigaction *ka) |
143 |
+ { |
144 |
+@@ -464,10 +513,7 @@ syscall_restart(struct pt_regs *regs, struct k_sigaction *ka) |
145 |
+ } |
146 |
+ /* fallthrough */ |
147 |
+ case -ERESTARTNOINTR: |
148 |
+- /* A syscall is just a branch, so all |
149 |
+- * we have to do is fiddle the return pointer. |
150 |
+- */ |
151 |
+- regs->gr[31] -= 8; /* delayed branching */ |
152 |
++ check_syscallno_in_delay_branch(regs); |
153 |
+ break; |
154 |
+ } |
155 |
+ } |
156 |
+@@ -516,15 +562,9 @@ insert_restart_trampoline(struct pt_regs *regs) |
157 |
+ } |
158 |
+ case -ERESTARTNOHAND: |
159 |
+ case -ERESTARTSYS: |
160 |
+- case -ERESTARTNOINTR: { |
161 |
+- /* Hooray for delayed branching. We don't |
162 |
+- * have to restore %r20 (the system call |
163 |
+- * number) because it gets loaded in the delay |
164 |
+- * slot of the branch external instruction. |
165 |
+- */ |
166 |
+- regs->gr[31] -= 8; |
167 |
++ case -ERESTARTNOINTR: |
168 |
++ check_syscallno_in_delay_branch(regs); |
169 |
+ return; |
170 |
+- } |
171 |
+ default: |
172 |
+ break; |
173 |
+ } |
174 |
+diff --git a/arch/sh/include/uapi/asm/unistd_64.h b/arch/sh/include/uapi/asm/unistd_64.h |
175 |
+index e6820c86e8c7..47ebd5b5ed55 100644 |
176 |
+--- a/arch/sh/include/uapi/asm/unistd_64.h |
177 |
++++ b/arch/sh/include/uapi/asm/unistd_64.h |
178 |
+@@ -278,7 +278,7 @@ |
179 |
+ #define __NR_fsetxattr 256 |
180 |
+ #define __NR_getxattr 257 |
181 |
+ #define __NR_lgetxattr 258 |
182 |
+-#define __NR_fgetxattr 269 |
183 |
++#define __NR_fgetxattr 259 |
184 |
+ #define __NR_listxattr 260 |
185 |
+ #define __NR_llistxattr 261 |
186 |
+ #define __NR_flistxattr 262 |
187 |
+diff --git a/crypto/af_alg.c b/crypto/af_alg.c |
188 |
+index 1de4beeb25f8..1971f3ccb09a 100644 |
189 |
+--- a/crypto/af_alg.c |
190 |
++++ b/crypto/af_alg.c |
191 |
+@@ -125,6 +125,23 @@ int af_alg_release(struct socket *sock) |
192 |
+ } |
193 |
+ EXPORT_SYMBOL_GPL(af_alg_release); |
194 |
+ |
195 |
++void af_alg_release_parent(struct sock *sk) |
196 |
++{ |
197 |
++ struct alg_sock *ask = alg_sk(sk); |
198 |
++ bool last; |
199 |
++ |
200 |
++ sk = ask->parent; |
201 |
++ ask = alg_sk(sk); |
202 |
++ |
203 |
++ lock_sock(sk); |
204 |
++ last = !--ask->refcnt; |
205 |
++ release_sock(sk); |
206 |
++ |
207 |
++ if (last) |
208 |
++ sock_put(sk); |
209 |
++} |
210 |
++EXPORT_SYMBOL_GPL(af_alg_release_parent); |
211 |
++ |
212 |
+ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
213 |
+ { |
214 |
+ struct sock *sk = sock->sk; |
215 |
+@@ -132,6 +149,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
216 |
+ struct sockaddr_alg *sa = (void *)uaddr; |
217 |
+ const struct af_alg_type *type; |
218 |
+ void *private; |
219 |
++ int err; |
220 |
+ |
221 |
+ if (sock->state == SS_CONNECTED) |
222 |
+ return -EINVAL; |
223 |
+@@ -157,16 +175,22 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
224 |
+ return PTR_ERR(private); |
225 |
+ } |
226 |
+ |
227 |
++ err = -EBUSY; |
228 |
+ lock_sock(sk); |
229 |
++ if (ask->refcnt) |
230 |
++ goto unlock; |
231 |
+ |
232 |
+ swap(ask->type, type); |
233 |
+ swap(ask->private, private); |
234 |
+ |
235 |
++ err = 0; |
236 |
++ |
237 |
++unlock: |
238 |
+ release_sock(sk); |
239 |
+ |
240 |
+ alg_do_release(type, private); |
241 |
+ |
242 |
+- return 0; |
243 |
++ return err; |
244 |
+ } |
245 |
+ |
246 |
+ static int alg_setkey(struct sock *sk, char __user *ukey, |
247 |
+@@ -199,11 +223,15 @@ static int alg_setsockopt(struct socket *sock, int level, int optname, |
248 |
+ struct sock *sk = sock->sk; |
249 |
+ struct alg_sock *ask = alg_sk(sk); |
250 |
+ const struct af_alg_type *type; |
251 |
+- int err = -ENOPROTOOPT; |
252 |
++ int err = -EBUSY; |
253 |
+ |
254 |
+ lock_sock(sk); |
255 |
++ if (ask->refcnt) |
256 |
++ goto unlock; |
257 |
++ |
258 |
+ type = ask->type; |
259 |
+ |
260 |
++ err = -ENOPROTOOPT; |
261 |
+ if (level != SOL_ALG || !type) |
262 |
+ goto unlock; |
263 |
+ |
264 |
+@@ -247,14 +275,13 @@ int af_alg_accept(struct sock *sk, struct socket *newsock) |
265 |
+ security_sk_clone(sk, sk2); |
266 |
+ |
267 |
+ err = type->accept(ask->private, sk2); |
268 |
+- if (err) { |
269 |
+- sk_free(sk2); |
270 |
++ if (err) |
271 |
+ goto unlock; |
272 |
+- } |
273 |
+ |
274 |
+ sk2->sk_family = PF_ALG; |
275 |
+ |
276 |
+- sock_hold(sk); |
277 |
++ if (!ask->refcnt++) |
278 |
++ sock_hold(sk); |
279 |
+ alg_sk(sk2)->parent = sk; |
280 |
+ alg_sk(sk2)->type = type; |
281 |
+ |
282 |
+diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c |
283 |
+index 850246206b12..c542c0d88afd 100644 |
284 |
+--- a/crypto/algif_hash.c |
285 |
++++ b/crypto/algif_hash.c |
286 |
+@@ -51,7 +51,8 @@ static int hash_sendmsg(struct kiocb *unused, struct socket *sock, |
287 |
+ |
288 |
+ lock_sock(sk); |
289 |
+ if (!ctx->more) { |
290 |
+- err = crypto_ahash_init(&ctx->req); |
291 |
++ err = af_alg_wait_for_completion(crypto_ahash_init(&ctx->req), |
292 |
++ &ctx->completion); |
293 |
+ if (err) |
294 |
+ goto unlock; |
295 |
+ } |
296 |
+@@ -131,6 +132,7 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page, |
297 |
+ } else { |
298 |
+ if (!ctx->more) { |
299 |
+ err = crypto_ahash_init(&ctx->req); |
300 |
++ err = af_alg_wait_for_completion(err, &ctx->completion); |
301 |
+ if (err) |
302 |
+ goto unlock; |
303 |
+ } |
304 |
+@@ -192,9 +194,14 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags) |
305 |
+ struct sock *sk2; |
306 |
+ struct alg_sock *ask2; |
307 |
+ struct hash_ctx *ctx2; |
308 |
++ bool more; |
309 |
+ int err; |
310 |
+ |
311 |
+- err = crypto_ahash_export(req, state); |
312 |
++ lock_sock(sk); |
313 |
++ more = ctx->more; |
314 |
++ err = more ? crypto_ahash_export(req, state) : 0; |
315 |
++ release_sock(sk); |
316 |
++ |
317 |
+ if (err) |
318 |
+ return err; |
319 |
+ |
320 |
+@@ -205,7 +212,10 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags) |
321 |
+ sk2 = newsock->sk; |
322 |
+ ask2 = alg_sk(sk2); |
323 |
+ ctx2 = ask2->private; |
324 |
+- ctx2->more = 1; |
325 |
++ ctx2->more = more; |
326 |
++ |
327 |
++ if (!more) |
328 |
++ return err; |
329 |
+ |
330 |
+ err = crypto_ahash_import(&ctx2->req, state); |
331 |
+ if (err) { |
332 |
+diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c |
333 |
+index c7666f401381..a3dfc0d83107 100644 |
334 |
+--- a/crypto/crypto_user.c |
335 |
++++ b/crypto/crypto_user.c |
336 |
+@@ -477,6 +477,7 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
337 |
+ if (link->dump == NULL) |
338 |
+ return -EINVAL; |
339 |
+ |
340 |
++ down_read(&crypto_alg_sem); |
341 |
+ list_for_each_entry(alg, &crypto_alg_list, cra_list) |
342 |
+ dump_alloc += CRYPTO_REPORT_MAXSIZE; |
343 |
+ |
344 |
+@@ -486,8 +487,11 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
345 |
+ .done = link->done, |
346 |
+ .min_dump_alloc = dump_alloc, |
347 |
+ }; |
348 |
+- return netlink_dump_start(crypto_nlsk, skb, nlh, &c); |
349 |
++ err = netlink_dump_start(crypto_nlsk, skb, nlh, &c); |
350 |
+ } |
351 |
++ up_read(&crypto_alg_sem); |
352 |
++ |
353 |
++ return err; |
354 |
+ } |
355 |
+ |
356 |
+ err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX, |
357 |
+diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c |
358 |
+index cc5f102bebf3..111614b48f96 100644 |
359 |
+--- a/drivers/ata/ahci.c |
360 |
++++ b/drivers/ata/ahci.c |
361 |
+@@ -249,6 +249,26 @@ static const struct pci_device_id ahci_pci_tbl[] = { |
362 |
+ { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ |
363 |
+ { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */ |
364 |
+ { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */ |
365 |
++ { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */ |
366 |
++ { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */ |
367 |
++ { PCI_VDEVICE(INTEL, 0x19b2), board_ahci }, /* DNV AHCI */ |
368 |
++ { PCI_VDEVICE(INTEL, 0x19b3), board_ahci }, /* DNV AHCI */ |
369 |
++ { PCI_VDEVICE(INTEL, 0x19b4), board_ahci }, /* DNV AHCI */ |
370 |
++ { PCI_VDEVICE(INTEL, 0x19b5), board_ahci }, /* DNV AHCI */ |
371 |
++ { PCI_VDEVICE(INTEL, 0x19b6), board_ahci }, /* DNV AHCI */ |
372 |
++ { PCI_VDEVICE(INTEL, 0x19b7), board_ahci }, /* DNV AHCI */ |
373 |
++ { PCI_VDEVICE(INTEL, 0x19bE), board_ahci }, /* DNV AHCI */ |
374 |
++ { PCI_VDEVICE(INTEL, 0x19bF), board_ahci }, /* DNV AHCI */ |
375 |
++ { PCI_VDEVICE(INTEL, 0x19c0), board_ahci }, /* DNV AHCI */ |
376 |
++ { PCI_VDEVICE(INTEL, 0x19c1), board_ahci }, /* DNV AHCI */ |
377 |
++ { PCI_VDEVICE(INTEL, 0x19c2), board_ahci }, /* DNV AHCI */ |
378 |
++ { PCI_VDEVICE(INTEL, 0x19c3), board_ahci }, /* DNV AHCI */ |
379 |
++ { PCI_VDEVICE(INTEL, 0x19c4), board_ahci }, /* DNV AHCI */ |
380 |
++ { PCI_VDEVICE(INTEL, 0x19c5), board_ahci }, /* DNV AHCI */ |
381 |
++ { PCI_VDEVICE(INTEL, 0x19c6), board_ahci }, /* DNV AHCI */ |
382 |
++ { PCI_VDEVICE(INTEL, 0x19c7), board_ahci }, /* DNV AHCI */ |
383 |
++ { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */ |
384 |
++ { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */ |
385 |
+ { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */ |
386 |
+ { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */ |
387 |
+ { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */ |
388 |
+diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c |
389 |
+index b65d79cd43d5..8b24a7bb573b 100644 |
390 |
+--- a/drivers/ata/libahci.c |
391 |
++++ b/drivers/ata/libahci.c |
392 |
+@@ -487,8 +487,8 @@ void ahci_save_initial_config(struct device *dev, |
393 |
+ } |
394 |
+ } |
395 |
+ |
396 |
+- /* fabricate port_map from cap.nr_ports */ |
397 |
+- if (!port_map) { |
398 |
++ /* fabricate port_map from cap.nr_ports for < AHCI 1.3 */ |
399 |
++ if (!port_map && vers < 0x10300) { |
400 |
+ port_map = (1 << ahci_nr_ports(cap)) - 1; |
401 |
+ dev_warn(dev, "forcing PORTS_IMPL to 0x%x\n", port_map); |
402 |
+ |
403 |
+@@ -1253,6 +1253,15 @@ static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp, |
404 |
+ ata_tf_to_fis(tf, pmp, is_cmd, fis); |
405 |
+ ahci_fill_cmd_slot(pp, 0, cmd_fis_len | flags | (pmp << 12)); |
406 |
+ |
407 |
++ /* set port value for softreset of Port Multiplier */ |
408 |
++ if (pp->fbs_enabled && pp->fbs_last_dev != pmp) { |
409 |
++ tmp = readl(port_mmio + PORT_FBS); |
410 |
++ tmp &= ~(PORT_FBS_DEV_MASK | PORT_FBS_DEC); |
411 |
++ tmp |= pmp << PORT_FBS_DEV_OFFSET; |
412 |
++ writel(tmp, port_mmio + PORT_FBS); |
413 |
++ pp->fbs_last_dev = pmp; |
414 |
++ } |
415 |
++ |
416 |
+ /* issue & wait */ |
417 |
+ writel(1, port_mmio + PORT_CMD_ISSUE); |
418 |
+ |
419 |
+diff --git a/drivers/base/memory.c b/drivers/base/memory.c |
420 |
+index bece691cb5d9..3e2a3059b1f8 100644 |
421 |
+--- a/drivers/base/memory.c |
422 |
++++ b/drivers/base/memory.c |
423 |
+@@ -311,6 +311,10 @@ static int memory_subsys_offline(struct device *dev) |
424 |
+ if (mem->state == MEM_OFFLINE) |
425 |
+ return 0; |
426 |
+ |
427 |
++ /* Can't offline block with non-present sections */ |
428 |
++ if (mem->section_count != sections_per_block) |
429 |
++ return -EINVAL; |
430 |
++ |
431 |
+ return memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE); |
432 |
+ } |
433 |
+ |
434 |
+diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c |
435 |
+index 643bba7d6f81..9eab751efeea 100644 |
436 |
+--- a/drivers/char/tpm/tpm_ibmvtpm.c |
437 |
++++ b/drivers/char/tpm/tpm_ibmvtpm.c |
438 |
+@@ -490,7 +490,7 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq, |
439 |
+ } |
440 |
+ ibmvtpm->rtce_size = be16_to_cpu(crq->len); |
441 |
+ ibmvtpm->rtce_buf = kmalloc(ibmvtpm->rtce_size, |
442 |
+- GFP_KERNEL); |
443 |
++ GFP_ATOMIC); |
444 |
+ if (!ibmvtpm->rtce_buf) { |
445 |
+ dev_err(ibmvtpm->dev, "Failed to allocate memory for rtce buffer\n"); |
446 |
+ return; |
447 |
+diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c |
448 |
+index deabd2c8772d..ced6d61c1787 100644 |
449 |
+--- a/drivers/hid/usbhid/hid-core.c |
450 |
++++ b/drivers/hid/usbhid/hid-core.c |
451 |
+@@ -492,8 +492,6 @@ static void hid_ctrl(struct urb *urb) |
452 |
+ struct usbhid_device *usbhid = hid->driver_data; |
453 |
+ int unplug = 0, status = urb->status; |
454 |
+ |
455 |
+- spin_lock(&usbhid->lock); |
456 |
+- |
457 |
+ switch (status) { |
458 |
+ case 0: /* success */ |
459 |
+ if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) |
460 |
+@@ -513,6 +511,8 @@ static void hid_ctrl(struct urb *urb) |
461 |
+ hid_warn(urb->dev, "ctrl urb status %d received\n", status); |
462 |
+ } |
463 |
+ |
464 |
++ spin_lock(&usbhid->lock); |
465 |
++ |
466 |
+ if (unplug) { |
467 |
+ usbhid->ctrltail = usbhid->ctrlhead; |
468 |
+ } else { |
469 |
+diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c |
470 |
+index 422a9fdeb53e..6eb9dc9ef8f3 100644 |
471 |
+--- a/drivers/md/dm-mpath.c |
472 |
++++ b/drivers/md/dm-mpath.c |
473 |
+@@ -1626,11 +1626,8 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd, |
474 |
+ /* |
475 |
+ * Only pass ioctls through if the device sizes match exactly. |
476 |
+ */ |
477 |
+- if (!bdev || ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT) { |
478 |
+- int err = scsi_verify_blk_ioctl(NULL, cmd); |
479 |
+- if (err) |
480 |
+- r = err; |
481 |
+- } |
482 |
++ if (!r && ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT) |
483 |
++ r = scsi_verify_blk_ioctl(NULL, cmd); |
484 |
+ |
485 |
+ if (r == -ENOTCONN && !fatal_signal_pending(current)) |
486 |
+ queue_work(kmultipathd, &m->process_queued_ios); |
487 |
+diff --git a/drivers/md/persistent-data/dm-btree.c b/drivers/md/persistent-data/dm-btree.c |
488 |
+index d6e47033b5e0..7ba85e2b146b 100644 |
489 |
+--- a/drivers/md/persistent-data/dm-btree.c |
490 |
++++ b/drivers/md/persistent-data/dm-btree.c |
491 |
+@@ -471,8 +471,10 @@ static int btree_split_sibling(struct shadow_spine *s, dm_block_t root, |
492 |
+ |
493 |
+ r = insert_at(sizeof(__le64), pn, parent_index + 1, |
494 |
+ le64_to_cpu(rn->keys[0]), &location); |
495 |
+- if (r) |
496 |
++ if (r) { |
497 |
++ unlock_block(s->info, right); |
498 |
+ return r; |
499 |
++ } |
500 |
+ |
501 |
+ if (key < le64_to_cpu(rn->keys[0])) { |
502 |
+ unlock_block(s->info, right); |
503 |
+diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c |
504 |
+index dd67c8a400cc..6bac4a53da1d 100644 |
505 |
+--- a/drivers/media/pci/saa7134/saa7134-alsa.c |
506 |
++++ b/drivers/media/pci/saa7134/saa7134-alsa.c |
507 |
+@@ -1145,6 +1145,8 @@ static int alsa_device_init(struct saa7134_dev *dev) |
508 |
+ |
509 |
+ static int alsa_device_exit(struct saa7134_dev *dev) |
510 |
+ { |
511 |
++ if (!snd_saa7134_cards[dev->nr]) |
512 |
++ return 1; |
513 |
+ |
514 |
+ snd_card_free(snd_saa7134_cards[dev->nr]); |
515 |
+ snd_saa7134_cards[dev->nr] = NULL; |
516 |
+@@ -1194,7 +1196,8 @@ static void saa7134_alsa_exit(void) |
517 |
+ int idx; |
518 |
+ |
519 |
+ for (idx = 0; idx < SNDRV_CARDS; idx++) { |
520 |
+- snd_card_free(snd_saa7134_cards[idx]); |
521 |
++ if (snd_saa7134_cards[idx]) |
522 |
++ snd_card_free(snd_saa7134_cards[idx]); |
523 |
+ } |
524 |
+ |
525 |
+ saa7134_dmasound_init = NULL; |
526 |
+diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
527 |
+index fca336b65351..2bece37d0228 100644 |
528 |
+--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
529 |
++++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
530 |
+@@ -264,7 +264,7 @@ static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_ |
531 |
+ |
532 |
+ struct v4l2_standard32 { |
533 |
+ __u32 index; |
534 |
+- __u32 id[2]; /* __u64 would get the alignment wrong */ |
535 |
++ compat_u64 id; |
536 |
+ __u8 name[24]; |
537 |
+ struct v4l2_fract frameperiod; /* Frames, not fields */ |
538 |
+ __u32 framelines; |
539 |
+@@ -284,7 +284,7 @@ static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 |
540 |
+ { |
541 |
+ if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard32)) || |
542 |
+ put_user(kp->index, &up->index) || |
543 |
+- copy_to_user(up->id, &kp->id, sizeof(__u64)) || |
544 |
++ put_user(kp->id, &up->id) || |
545 |
+ copy_to_user(up->name, kp->name, 24) || |
546 |
+ copy_to_user(&up->frameperiod, &kp->frameperiod, sizeof(kp->frameperiod)) || |
547 |
+ put_user(kp->framelines, &up->framelines) || |
548 |
+@@ -576,10 +576,10 @@ struct v4l2_input32 { |
549 |
+ __u32 type; /* Type of input */ |
550 |
+ __u32 audioset; /* Associated audios (bitfield) */ |
551 |
+ __u32 tuner; /* Associated tuner */ |
552 |
+- v4l2_std_id std; |
553 |
++ compat_u64 std; |
554 |
+ __u32 status; |
555 |
+ __u32 reserved[4]; |
556 |
+-} __attribute__ ((packed)); |
557 |
++}; |
558 |
+ |
559 |
+ /* The 64-bit v4l2_input struct has extra padding at the end of the struct. |
560 |
+ Otherwise it is identical to the 32-bit version. */ |
561 |
+@@ -719,6 +719,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext |
562 |
+ struct v4l2_event32 { |
563 |
+ __u32 type; |
564 |
+ union { |
565 |
++ compat_s64 value64; |
566 |
+ __u8 data[64]; |
567 |
+ } u; |
568 |
+ __u32 pending; |
569 |
+diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c |
570 |
+index 33d3871d1e13..63aeac93a95e 100644 |
571 |
+--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c |
572 |
++++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c |
573 |
+@@ -117,7 +117,8 @@ static void vb2_dc_prepare(void *buf_priv) |
574 |
+ if (!sgt || buf->db_attach) |
575 |
+ return; |
576 |
+ |
577 |
+- dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); |
578 |
++ dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents, |
579 |
++ buf->dma_dir); |
580 |
+ } |
581 |
+ |
582 |
+ static void vb2_dc_finish(void *buf_priv) |
583 |
+@@ -129,7 +130,7 @@ static void vb2_dc_finish(void *buf_priv) |
584 |
+ if (!sgt || buf->db_attach) |
585 |
+ return; |
586 |
+ |
587 |
+- dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); |
588 |
++ dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir); |
589 |
+ } |
590 |
+ |
591 |
+ /*********************************************/ |
592 |
+diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c |
593 |
+index 3c7d6d7623c1..e638993ac626 100644 |
594 |
+--- a/drivers/mtd/mtdpart.c |
595 |
++++ b/drivers/mtd/mtdpart.c |
596 |
+@@ -635,8 +635,10 @@ int add_mtd_partitions(struct mtd_info *master, |
597 |
+ |
598 |
+ for (i = 0; i < nbparts; i++) { |
599 |
+ slave = allocate_partition(master, parts + i, i, cur_offset); |
600 |
+- if (IS_ERR(slave)) |
601 |
++ if (IS_ERR(slave)) { |
602 |
++ del_mtd_partitions(master); |
603 |
+ return PTR_ERR(slave); |
604 |
++ } |
605 |
+ |
606 |
+ mutex_lock(&mtd_partitions_mutex); |
607 |
+ list_add(&slave->list, &mtd_partitions); |
608 |
+diff --git a/drivers/net/wireless/ti/wlcore/io.h b/drivers/net/wireless/ti/wlcore/io.h |
609 |
+index 07e3d6a049ad..e11c1adf2aad 100644 |
610 |
+--- a/drivers/net/wireless/ti/wlcore/io.h |
611 |
++++ b/drivers/net/wireless/ti/wlcore/io.h |
612 |
+@@ -203,19 +203,23 @@ static inline int __must_check wlcore_write_reg(struct wl1271 *wl, int reg, |
613 |
+ |
614 |
+ static inline void wl1271_power_off(struct wl1271 *wl) |
615 |
+ { |
616 |
+- int ret; |
617 |
++ int ret = 0; |
618 |
+ |
619 |
+ if (!test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags)) |
620 |
+ return; |
621 |
+ |
622 |
+- ret = wl->if_ops->power(wl->dev, false); |
623 |
++ if (wl->if_ops->power) |
624 |
++ ret = wl->if_ops->power(wl->dev, false); |
625 |
+ if (!ret) |
626 |
+ clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); |
627 |
+ } |
628 |
+ |
629 |
+ static inline int wl1271_power_on(struct wl1271 *wl) |
630 |
+ { |
631 |
+- int ret = wl->if_ops->power(wl->dev, true); |
632 |
++ int ret = 0; |
633 |
++ |
634 |
++ if (wl->if_ops->power) |
635 |
++ ret = wl->if_ops->power(wl->dev, true); |
636 |
+ if (ret == 0) |
637 |
+ set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); |
638 |
+ |
639 |
+diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c |
640 |
+index b2c018dccf18..c675163b0d40 100644 |
641 |
+--- a/drivers/net/wireless/ti/wlcore/spi.c |
642 |
++++ b/drivers/net/wireless/ti/wlcore/spi.c |
643 |
+@@ -72,7 +72,10 @@ |
644 |
+ */ |
645 |
+ #define SPI_AGGR_BUFFER_SIZE (4 * PAGE_SIZE) |
646 |
+ |
647 |
+-#define WSPI_MAX_NUM_OF_CHUNKS (SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) |
648 |
++/* Maximum number of SPI write chunks */ |
649 |
++#define WSPI_MAX_NUM_OF_CHUNKS \ |
650 |
++ ((SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) + 1) |
651 |
++ |
652 |
+ |
653 |
+ struct wl12xx_spi_glue { |
654 |
+ struct device *dev; |
655 |
+@@ -270,9 +273,10 @@ static int __must_check wl12xx_spi_raw_write(struct device *child, int addr, |
656 |
+ void *buf, size_t len, bool fixed) |
657 |
+ { |
658 |
+ struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); |
659 |
+- struct spi_transfer t[2 * (WSPI_MAX_NUM_OF_CHUNKS + 1)]; |
660 |
++ /* SPI write buffers - 2 for each chunk */ |
661 |
++ struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS]; |
662 |
+ struct spi_message m; |
663 |
+- u32 commands[WSPI_MAX_NUM_OF_CHUNKS]; |
664 |
++ u32 commands[WSPI_MAX_NUM_OF_CHUNKS]; /* 1 command per chunk */ |
665 |
+ u32 *cmd; |
666 |
+ u32 chunk_len; |
667 |
+ int i; |
668 |
+diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c |
669 |
+index 38901665c770..f16c43dd6d04 100644 |
670 |
+--- a/drivers/pci/bus.c |
671 |
++++ b/drivers/pci/bus.c |
672 |
+@@ -147,6 +147,8 @@ static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res, |
673 |
+ type_mask |= IORESOURCE_IO | IORESOURCE_MEM; |
674 |
+ |
675 |
+ pci_bus_for_each_resource(bus, r, i) { |
676 |
++ resource_size_t min_used = min; |
677 |
++ |
678 |
+ if (!r) |
679 |
+ continue; |
680 |
+ |
681 |
+@@ -170,12 +172,12 @@ static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res, |
682 |
+ * overrides "min". |
683 |
+ */ |
684 |
+ if (avail.start) |
685 |
+- min = avail.start; |
686 |
++ min_used = avail.start; |
687 |
+ |
688 |
+ max = avail.end; |
689 |
+ |
690 |
+ /* Ok, try it out.. */ |
691 |
+- ret = allocate_resource(r, res, size, min, max, |
692 |
++ ret = allocate_resource(r, res, size, min_used, max, |
693 |
+ align, alignf, alignf_data); |
694 |
+ if (ret == 0) |
695 |
+ return 0; |
696 |
+diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c |
697 |
+index 9d30809bb407..916af5096f57 100644 |
698 |
+--- a/drivers/remoteproc/remoteproc_debugfs.c |
699 |
++++ b/drivers/remoteproc/remoteproc_debugfs.c |
700 |
+@@ -156,7 +156,7 @@ rproc_recovery_write(struct file *filp, const char __user *user_buf, |
701 |
+ char buf[10]; |
702 |
+ int ret; |
703 |
+ |
704 |
+- if (count > sizeof(buf)) |
705 |
++ if (count < 1 || count > sizeof(buf)) |
706 |
+ return count; |
707 |
+ |
708 |
+ ret = copy_from_user(buf, user_buf, count); |
709 |
+diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c |
710 |
+index 5f8c6d2f4df7..0e46e8d1d7bc 100644 |
711 |
+--- a/drivers/spi/spi-atmel.c |
712 |
++++ b/drivers/spi/spi-atmel.c |
713 |
+@@ -593,7 +593,8 @@ static int atmel_spi_next_xfer_dma_submit(struct spi_master *master, |
714 |
+ |
715 |
+ *plen = len; |
716 |
+ |
717 |
+- if (atmel_spi_dma_slave_config(as, &slave_config, 8)) |
718 |
++ if (atmel_spi_dma_slave_config(as, &slave_config, |
719 |
++ xfer->bits_per_word)) |
720 |
+ goto err_exit; |
721 |
+ |
722 |
+ /* Send both scatterlists */ |
723 |
+diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c |
724 |
+index 3d09265b5133..1454a0c42aac 100644 |
725 |
+--- a/drivers/spi/spi-ti-qspi.c |
726 |
++++ b/drivers/spi/spi-ti-qspi.c |
727 |
+@@ -364,11 +364,10 @@ static int ti_qspi_start_transfer_one(struct spi_master *master, |
728 |
+ |
729 |
+ mutex_unlock(&qspi->list_lock); |
730 |
+ |
731 |
++ ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG); |
732 |
+ m->status = status; |
733 |
+ spi_finalize_current_message(master); |
734 |
+ |
735 |
+- ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG); |
736 |
+- |
737 |
+ return status; |
738 |
+ } |
739 |
+ |
740 |
+diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c |
741 |
+index d88492152be1..72ed3d147687 100644 |
742 |
+--- a/drivers/spi/spi.c |
743 |
++++ b/drivers/spi/spi.c |
744 |
+@@ -1268,7 +1268,7 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size) |
745 |
+ master->bus_num = -1; |
746 |
+ master->num_chipselect = 1; |
747 |
+ master->dev.class = &spi_master_class; |
748 |
+- master->dev.parent = get_device(dev); |
749 |
++ master->dev.parent = dev; |
750 |
+ spi_master_set_devdata(master, &master[1]); |
751 |
+ |
752 |
+ return master; |
753 |
+diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c |
754 |
+index 143deb62467d..12446e9a4435 100644 |
755 |
+--- a/drivers/tty/tty_buffer.c |
756 |
++++ b/drivers/tty/tty_buffer.c |
757 |
+@@ -411,7 +411,7 @@ receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count) |
758 |
+ count = disc->ops->receive_buf2(tty, p, f, count); |
759 |
+ else { |
760 |
+ count = min_t(int, count, tty->receive_room); |
761 |
+- if (count) |
762 |
++ if (count && disc->ops->receive_buf) |
763 |
+ disc->ops->receive_buf(tty, p, f, count); |
764 |
+ } |
765 |
+ head->read += count; |
766 |
+diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c |
767 |
+index 39988fa91294..b17df1000250 100644 |
768 |
+--- a/drivers/tty/tty_io.c |
769 |
++++ b/drivers/tty/tty_io.c |
770 |
+@@ -2581,6 +2581,28 @@ static int tiocsetd(struct tty_struct *tty, int __user *p) |
771 |
+ } |
772 |
+ |
773 |
+ /** |
774 |
++ * tiocgetd - get line discipline |
775 |
++ * @tty: tty device |
776 |
++ * @p: pointer to user data |
777 |
++ * |
778 |
++ * Retrieves the line discipline id directly from the ldisc. |
779 |
++ * |
780 |
++ * Locking: waits for ldisc reference (in case the line discipline |
781 |
++ * is changing or the tty is being hungup) |
782 |
++ */ |
783 |
++ |
784 |
++static int tiocgetd(struct tty_struct *tty, int __user *p) |
785 |
++{ |
786 |
++ struct tty_ldisc *ld; |
787 |
++ int ret; |
788 |
++ |
789 |
++ ld = tty_ldisc_ref_wait(tty); |
790 |
++ ret = put_user(ld->ops->num, p); |
791 |
++ tty_ldisc_deref(ld); |
792 |
++ return ret; |
793 |
++} |
794 |
++ |
795 |
++/** |
796 |
+ * send_break - performed time break |
797 |
+ * @tty: device to break on |
798 |
+ * @duration: timeout in mS |
799 |
+@@ -2794,7 +2816,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
800 |
+ case TIOCGSID: |
801 |
+ return tiocgsid(tty, real_tty, p); |
802 |
+ case TIOCGETD: |
803 |
+- return put_user(tty->ldisc->ops->num, (int __user *)p); |
804 |
++ return tiocgetd(tty, p); |
805 |
+ case TIOCSETD: |
806 |
+ return tiocsetd(tty, p); |
807 |
+ case TIOCVHANGUP: |
808 |
+diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c |
809 |
+index fa114bcedabf..648e7eccdde9 100644 |
810 |
+--- a/drivers/usb/core/hub.c |
811 |
++++ b/drivers/usb/core/hub.c |
812 |
+@@ -5225,7 +5225,6 @@ static int usb_reset_and_verify_device(struct usb_device *udev) |
813 |
+ usb_set_usb2_hardware_lpm(udev, 0); |
814 |
+ |
815 |
+ bos = udev->bos; |
816 |
+- udev->bos = NULL; |
817 |
+ |
818 |
+ /* Disable LPM and LTM while we reset the device and reinstall the alt |
819 |
+ * settings. Device-initiated LPM settings, and system exit latency |
820 |
+@@ -5334,8 +5333,11 @@ done: |
821 |
+ usb_set_usb2_hardware_lpm(udev, 1); |
822 |
+ usb_unlocked_enable_lpm(udev); |
823 |
+ usb_enable_ltm(udev); |
824 |
+- usb_release_bos_descriptor(udev); |
825 |
+- udev->bos = bos; |
826 |
++ /* release the new BOS descriptor allocated by hub_port_init() */ |
827 |
++ if (udev->bos != bos) { |
828 |
++ usb_release_bos_descriptor(udev); |
829 |
++ udev->bos = bos; |
830 |
++ } |
831 |
+ return 0; |
832 |
+ |
833 |
+ re_enumerate: |
834 |
+diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c |
835 |
+index 5c957658a04a..7f01f165e77b 100644 |
836 |
+--- a/drivers/usb/host/xhci-hub.c |
837 |
++++ b/drivers/usb/host/xhci-hub.c |
838 |
+@@ -612,8 +612,30 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, |
839 |
+ if ((raw_port_status & PORT_RESET) || |
840 |
+ !(raw_port_status & PORT_PE)) |
841 |
+ return 0xffffffff; |
842 |
+- if (time_after_eq(jiffies, |
843 |
+- bus_state->resume_done[wIndex])) { |
844 |
++ /* did port event handler already start resume timing? */ |
845 |
++ if (!bus_state->resume_done[wIndex]) { |
846 |
++ /* If not, maybe we are in a host initated resume? */ |
847 |
++ if (test_bit(wIndex, &bus_state->resuming_ports)) { |
848 |
++ /* Host initated resume doesn't time the resume |
849 |
++ * signalling using resume_done[]. |
850 |
++ * It manually sets RESUME state, sleeps 20ms |
851 |
++ * and sets U0 state. This should probably be |
852 |
++ * changed, but not right now. |
853 |
++ */ |
854 |
++ } else { |
855 |
++ /* port resume was discovered now and here, |
856 |
++ * start resume timing |
857 |
++ */ |
858 |
++ unsigned long timeout = jiffies + |
859 |
++ msecs_to_jiffies(USB_RESUME_TIMEOUT); |
860 |
++ |
861 |
++ set_bit(wIndex, &bus_state->resuming_ports); |
862 |
++ bus_state->resume_done[wIndex] = timeout; |
863 |
++ mod_timer(&hcd->rh_timer, timeout); |
864 |
++ } |
865 |
++ /* Has resume been signalled for USB_RESUME_TIME yet? */ |
866 |
++ } else if (time_after_eq(jiffies, |
867 |
++ bus_state->resume_done[wIndex])) { |
868 |
+ int time_left; |
869 |
+ |
870 |
+ xhci_dbg(xhci, "Resume USB2 port %d\n", |
871 |
+@@ -654,13 +676,24 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, |
872 |
+ } else { |
873 |
+ /* |
874 |
+ * The resume has been signaling for less than |
875 |
+- * 20ms. Report the port status as SUSPEND, |
876 |
+- * let the usbcore check port status again |
877 |
+- * and clear resume signaling later. |
878 |
++ * USB_RESUME_TIME. Report the port status as SUSPEND, |
879 |
++ * let the usbcore check port status again and clear |
880 |
++ * resume signaling later. |
881 |
+ */ |
882 |
+ status |= USB_PORT_STAT_SUSPEND; |
883 |
+ } |
884 |
+ } |
885 |
++ /* |
886 |
++ * Clear stale usb2 resume signalling variables in case port changed |
887 |
++ * state during resume signalling. For example on error |
888 |
++ */ |
889 |
++ if ((bus_state->resume_done[wIndex] || |
890 |
++ test_bit(wIndex, &bus_state->resuming_ports)) && |
891 |
++ (raw_port_status & PORT_PLS_MASK) != XDEV_U3 && |
892 |
++ (raw_port_status & PORT_PLS_MASK) != XDEV_RESUME) { |
893 |
++ bus_state->resume_done[wIndex] = 0; |
894 |
++ clear_bit(wIndex, &bus_state->resuming_ports); |
895 |
++ } |
896 |
+ if ((raw_port_status & PORT_PLS_MASK) == XDEV_U0 |
897 |
+ && (raw_port_status & PORT_POWER) |
898 |
+ && (bus_state->suspended_ports & (1 << wIndex))) { |
899 |
+@@ -989,6 +1022,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, |
900 |
+ if ((temp & PORT_PE) == 0) |
901 |
+ goto error; |
902 |
+ |
903 |
++ set_bit(wIndex, &bus_state->resuming_ports); |
904 |
+ xhci_set_link_state(xhci, port_array, wIndex, |
905 |
+ XDEV_RESUME); |
906 |
+ spin_unlock_irqrestore(&xhci->lock, flags); |
907 |
+@@ -996,6 +1030,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, |
908 |
+ spin_lock_irqsave(&xhci->lock, flags); |
909 |
+ xhci_set_link_state(xhci, port_array, wIndex, |
910 |
+ XDEV_U0); |
911 |
++ clear_bit(wIndex, &bus_state->resuming_ports); |
912 |
+ } |
913 |
+ bus_state->port_c_suspend |= 1 << wIndex; |
914 |
+ |
915 |
+diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c |
916 |
+index bd993fe00e0c..3bfe81c6229a 100644 |
917 |
+--- a/drivers/usb/host/xhci-ring.c |
918 |
++++ b/drivers/usb/host/xhci-ring.c |
919 |
+@@ -1768,7 +1768,8 @@ static void handle_port_status(struct xhci_hcd *xhci, |
920 |
+ */ |
921 |
+ bogus_port_status = true; |
922 |
+ goto cleanup; |
923 |
+- } else { |
924 |
++ } else if (!test_bit(faked_port_index, |
925 |
++ &bus_state->resuming_ports)) { |
926 |
+ xhci_dbg(xhci, "resume HS port %d\n", port_id); |
927 |
+ bus_state->resume_done[faked_port_index] = jiffies + |
928 |
+ msecs_to_jiffies(USB_RESUME_TIMEOUT); |
929 |
+diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c |
930 |
+index c8e693c22014..27688e3b0a4c 100644 |
931 |
+--- a/drivers/usb/host/xhci.c |
932 |
++++ b/drivers/usb/host/xhci.c |
933 |
+@@ -4866,6 +4866,9 @@ static int __init xhci_hcd_init(void) |
934 |
+ { |
935 |
+ int retval; |
936 |
+ |
937 |
++ if (usb_disabled()) |
938 |
++ return -ENODEV; |
939 |
++ |
940 |
+ retval = xhci_register_pci(); |
941 |
+ if (retval < 0) { |
942 |
+ pr_debug("Problem registering PCI driver.\n"); |
943 |
+@@ -4894,9 +4897,6 @@ static int __init xhci_hcd_init(void) |
944 |
+ /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */ |
945 |
+ BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8); |
946 |
+ |
947 |
+- if (usb_disabled()) |
948 |
+- return -ENODEV; |
949 |
+- |
950 |
+ return 0; |
951 |
+ unreg_pci: |
952 |
+ xhci_unregister_pci(); |
953 |
+diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c |
954 |
+index b4fc4091e3f8..02e6fe228a63 100644 |
955 |
+--- a/drivers/usb/serial/cp210x.c |
956 |
++++ b/drivers/usb/serial/cp210x.c |
957 |
+@@ -98,6 +98,7 @@ static const struct usb_device_id id_table[] = { |
958 |
+ { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ |
959 |
+ { USB_DEVICE(0x10C4, 0x81AD) }, /* INSYS USB Modem */ |
960 |
+ { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ |
961 |
++ { USB_DEVICE(0x10C4, 0x81D7) }, /* IAI Corp. RCB-CV-USB USB to RS485 Adaptor */ |
962 |
+ { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ |
963 |
+ { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ |
964 |
+ { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */ |
965 |
+diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c |
966 |
+index 7fb81dbbdc8d..b5d8e2544b8f 100644 |
967 |
+--- a/drivers/usb/serial/ftdi_sio.c |
968 |
++++ b/drivers/usb/serial/ftdi_sio.c |
969 |
+@@ -837,6 +837,7 @@ static const struct usb_device_id id_table_combined[] = { |
970 |
+ { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID), |
971 |
+ .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
972 |
+ { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, |
973 |
++ { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_SCU18) }, |
974 |
+ { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, |
975 |
+ |
976 |
+ /* Papouch devices based on FTDI chip */ |
977 |
+diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h |
978 |
+index 2943b97b2a83..7850071c0ae1 100644 |
979 |
+--- a/drivers/usb/serial/ftdi_sio_ids.h |
980 |
++++ b/drivers/usb/serial/ftdi_sio_ids.h |
981 |
+@@ -615,6 +615,7 @@ |
982 |
+ */ |
983 |
+ #define RATOC_VENDOR_ID 0x0584 |
984 |
+ #define RATOC_PRODUCT_ID_USB60F 0xb020 |
985 |
++#define RATOC_PRODUCT_ID_SCU18 0xb03a |
986 |
+ |
987 |
+ /* |
988 |
+ * Infineon Technologies |
989 |
+diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c |
990 |
+index bdbe642e6569..81f6a572f016 100644 |
991 |
+--- a/drivers/usb/serial/option.c |
992 |
++++ b/drivers/usb/serial/option.c |
993 |
+@@ -269,6 +269,8 @@ static void option_instat_callback(struct urb *urb); |
994 |
+ #define TELIT_PRODUCT_CC864_SINGLE 0x1006 |
995 |
+ #define TELIT_PRODUCT_DE910_DUAL 0x1010 |
996 |
+ #define TELIT_PRODUCT_UE910_V2 0x1012 |
997 |
++#define TELIT_PRODUCT_LE922_USBCFG0 0x1042 |
998 |
++#define TELIT_PRODUCT_LE922_USBCFG3 0x1043 |
999 |
+ #define TELIT_PRODUCT_LE920 0x1200 |
1000 |
+ #define TELIT_PRODUCT_LE910 0x1201 |
1001 |
+ |
1002 |
+@@ -623,6 +625,16 @@ static const struct option_blacklist_info telit_le920_blacklist = { |
1003 |
+ .reserved = BIT(1) | BIT(5), |
1004 |
+ }; |
1005 |
+ |
1006 |
++static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = { |
1007 |
++ .sendsetup = BIT(2), |
1008 |
++ .reserved = BIT(0) | BIT(1) | BIT(3), |
1009 |
++}; |
1010 |
++ |
1011 |
++static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = { |
1012 |
++ .sendsetup = BIT(0), |
1013 |
++ .reserved = BIT(1) | BIT(2) | BIT(3), |
1014 |
++}; |
1015 |
++ |
1016 |
+ static const struct usb_device_id option_ids[] = { |
1017 |
+ { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
1018 |
+ { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
1019 |
+@@ -1168,6 +1180,10 @@ static const struct usb_device_id option_ids[] = { |
1020 |
+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, |
1021 |
+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, |
1022 |
+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, |
1023 |
++ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG0), |
1024 |
++ .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, |
1025 |
++ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG3), |
1026 |
++ .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, |
1027 |
+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), |
1028 |
+ .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, |
1029 |
+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), |
1030 |
+@@ -1679,7 +1695,7 @@ static const struct usb_device_id option_ids[] = { |
1031 |
+ { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, |
1032 |
+ { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8), |
1033 |
+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
1034 |
+- { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) }, |
1035 |
++ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) }, |
1036 |
+ { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX), |
1037 |
+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
1038 |
+ { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, |
1039 |
+diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c |
1040 |
+index 60afb39eb73c..337a0be89fcf 100644 |
1041 |
+--- a/drivers/usb/serial/visor.c |
1042 |
++++ b/drivers/usb/serial/visor.c |
1043 |
+@@ -544,6 +544,11 @@ static int treo_attach(struct usb_serial *serial) |
1044 |
+ (serial->num_interrupt_in == 0)) |
1045 |
+ return 0; |
1046 |
+ |
1047 |
++ if (serial->num_bulk_in < 2 || serial->num_interrupt_in < 2) { |
1048 |
++ dev_err(&serial->interface->dev, "missing endpoints\n"); |
1049 |
++ return -ENODEV; |
1050 |
++ } |
1051 |
++ |
1052 |
+ /* |
1053 |
+ * It appears that Treos and Kyoceras want to use the |
1054 |
+ * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, |
1055 |
+@@ -597,8 +602,10 @@ static int clie_5_attach(struct usb_serial *serial) |
1056 |
+ */ |
1057 |
+ |
1058 |
+ /* some sanity check */ |
1059 |
+- if (serial->num_ports < 2) |
1060 |
+- return -1; |
1061 |
++ if (serial->num_bulk_out < 2) { |
1062 |
++ dev_err(&serial->interface->dev, "missing bulk out endpoints\n"); |
1063 |
++ return -ENODEV; |
1064 |
++ } |
1065 |
+ |
1066 |
+ /* port 0 now uses the modified endpoint Address */ |
1067 |
+ port = serial->port[0]; |
1068 |
+diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c |
1069 |
+index 35240a704413..6eb8df76e17c 100644 |
1070 |
+--- a/fs/binfmt_elf.c |
1071 |
++++ b/fs/binfmt_elf.c |
1072 |
+@@ -679,16 +679,16 @@ static int load_elf_binary(struct linux_binprm *bprm) |
1073 |
+ */ |
1074 |
+ would_dump(bprm, interpreter); |
1075 |
+ |
1076 |
+- retval = kernel_read(interpreter, 0, bprm->buf, |
1077 |
+- BINPRM_BUF_SIZE); |
1078 |
+- if (retval != BINPRM_BUF_SIZE) { |
1079 |
++ /* Get the exec headers */ |
1080 |
++ retval = kernel_read(interpreter, 0, |
1081 |
++ (void *)&loc->interp_elf_ex, |
1082 |
++ sizeof(loc->interp_elf_ex)); |
1083 |
++ if (retval != sizeof(loc->interp_elf_ex)) { |
1084 |
+ if (retval >= 0) |
1085 |
+ retval = -EIO; |
1086 |
+ goto out_free_dentry; |
1087 |
+ } |
1088 |
+ |
1089 |
+- /* Get the exec headers */ |
1090 |
+- loc->interp_elf_ex = *((struct elfhdr *)bprm->buf); |
1091 |
+ break; |
1092 |
+ } |
1093 |
+ elf_ppnt++; |
1094 |
+diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h |
1095 |
+index 2a6830a7af33..96fe2c175a73 100644 |
1096 |
+--- a/fs/ext4/ext4.h |
1097 |
++++ b/fs/ext4/ext4.h |
1098 |
+@@ -26,6 +26,7 @@ |
1099 |
+ #include <linux/seqlock.h> |
1100 |
+ #include <linux/mutex.h> |
1101 |
+ #include <linux/timer.h> |
1102 |
++#include <linux/version.h> |
1103 |
+ #include <linux/wait.h> |
1104 |
+ #include <linux/blockgroup_lock.h> |
1105 |
+ #include <linux/percpu_counter.h> |
1106 |
+@@ -724,19 +725,55 @@ struct move_extent { |
1107 |
+ <= (EXT4_GOOD_OLD_INODE_SIZE + \ |
1108 |
+ (einode)->i_extra_isize)) \ |
1109 |
+ |
1110 |
++/* |
1111 |
++ * We use an encoding that preserves the times for extra epoch "00": |
1112 |
++ * |
1113 |
++ * extra msb of adjust for signed |
1114 |
++ * epoch 32-bit 32-bit tv_sec to |
1115 |
++ * bits time decoded 64-bit tv_sec 64-bit tv_sec valid time range |
1116 |
++ * 0 0 1 -0x80000000..-0x00000001 0x000000000 1901-12-13..1969-12-31 |
1117 |
++ * 0 0 0 0x000000000..0x07fffffff 0x000000000 1970-01-01..2038-01-19 |
1118 |
++ * 0 1 1 0x080000000..0x0ffffffff 0x100000000 2038-01-19..2106-02-07 |
1119 |
++ * 0 1 0 0x100000000..0x17fffffff 0x100000000 2106-02-07..2174-02-25 |
1120 |
++ * 1 0 1 0x180000000..0x1ffffffff 0x200000000 2174-02-25..2242-03-16 |
1121 |
++ * 1 0 0 0x200000000..0x27fffffff 0x200000000 2242-03-16..2310-04-04 |
1122 |
++ * 1 1 1 0x280000000..0x2ffffffff 0x300000000 2310-04-04..2378-04-22 |
1123 |
++ * 1 1 0 0x300000000..0x37fffffff 0x300000000 2378-04-22..2446-05-10 |
1124 |
++ * |
1125 |
++ * Note that previous versions of the kernel on 64-bit systems would |
1126 |
++ * incorrectly use extra epoch bits 1,1 for dates between 1901 and |
1127 |
++ * 1970. e2fsck will correct this, assuming that it is run on the |
1128 |
++ * affected filesystem before 2242. |
1129 |
++ */ |
1130 |
++ |
1131 |
+ static inline __le32 ext4_encode_extra_time(struct timespec *time) |
1132 |
+ { |
1133 |
+- return cpu_to_le32((sizeof(time->tv_sec) > 4 ? |
1134 |
+- (time->tv_sec >> 32) & EXT4_EPOCH_MASK : 0) | |
1135 |
+- ((time->tv_nsec << EXT4_EPOCH_BITS) & EXT4_NSEC_MASK)); |
1136 |
++ u32 extra = sizeof(time->tv_sec) > 4 ? |
1137 |
++ ((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK : 0; |
1138 |
++ return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS)); |
1139 |
+ } |
1140 |
+ |
1141 |
+ static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) |
1142 |
+ { |
1143 |
+- if (sizeof(time->tv_sec) > 4) |
1144 |
+- time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) |
1145 |
+- << 32; |
1146 |
+- time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; |
1147 |
++ if (unlikely(sizeof(time->tv_sec) > 4 && |
1148 |
++ (extra & cpu_to_le32(EXT4_EPOCH_MASK)))) { |
1149 |
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,20,0) |
1150 |
++ /* Handle legacy encoding of pre-1970 dates with epoch |
1151 |
++ * bits 1,1. We assume that by kernel version 4.20, |
1152 |
++ * everyone will have run fsck over the affected |
1153 |
++ * filesystems to correct the problem. (This |
1154 |
++ * backwards compatibility may be removed before this |
1155 |
++ * time, at the discretion of the ext4 developers.) |
1156 |
++ */ |
1157 |
++ u64 extra_bits = le32_to_cpu(extra) & EXT4_EPOCH_MASK; |
1158 |
++ if (extra_bits == 3 && ((time->tv_sec) & 0x80000000) != 0) |
1159 |
++ extra_bits = 0; |
1160 |
++ time->tv_sec += extra_bits << 32; |
1161 |
++#else |
1162 |
++ time->tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32; |
1163 |
++#endif |
1164 |
++ } |
1165 |
++ time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; |
1166 |
+ } |
1167 |
+ |
1168 |
+ #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \ |
1169 |
+diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c |
1170 |
+index 2400ad1c3d12..831cb305c63f 100644 |
1171 |
+--- a/fs/ext4/resize.c |
1172 |
++++ b/fs/ext4/resize.c |
1173 |
+@@ -1030,7 +1030,7 @@ exit_free: |
1174 |
+ * do not copy the full number of backups at this time. The resize |
1175 |
+ * which changed s_groups_count will backup again. |
1176 |
+ */ |
1177 |
+-static void update_backups(struct super_block *sb, int blk_off, char *data, |
1178 |
++static void update_backups(struct super_block *sb, sector_t blk_off, char *data, |
1179 |
+ int size, int meta_bg) |
1180 |
+ { |
1181 |
+ struct ext4_sb_info *sbi = EXT4_SB(sb); |
1182 |
+@@ -1055,7 +1055,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data, |
1183 |
+ group = ext4_list_backups(sb, &three, &five, &seven); |
1184 |
+ last = sbi->s_groups_count; |
1185 |
+ } else { |
1186 |
+- group = ext4_meta_bg_first_group(sb, group) + 1; |
1187 |
++ group = ext4_get_group_number(sb, blk_off) + 1; |
1188 |
+ last = (ext4_group_t)(group + EXT4_DESC_PER_BLOCK(sb) - 2); |
1189 |
+ } |
1190 |
+ |
1191 |
+diff --git a/fs/fat/dir.c b/fs/fat/dir.c |
1192 |
+index 3963ede84eb0..75bf5e717ed8 100644 |
1193 |
+--- a/fs/fat/dir.c |
1194 |
++++ b/fs/fat/dir.c |
1195 |
+@@ -614,9 +614,9 @@ parse_record: |
1196 |
+ int status = fat_parse_long(inode, &cpos, &bh, &de, |
1197 |
+ &unicode, &nr_slots); |
1198 |
+ if (status < 0) { |
1199 |
+- ctx->pos = cpos; |
1200 |
++ bh = NULL; |
1201 |
+ ret = status; |
1202 |
+- goto out; |
1203 |
++ goto end_of_dir; |
1204 |
+ } else if (status == PARSE_INVALID) |
1205 |
+ goto record_end; |
1206 |
+ else if (status == PARSE_NOT_LONGNAME) |
1207 |
+@@ -658,8 +658,9 @@ parse_record: |
1208 |
+ fill_len = short_len; |
1209 |
+ |
1210 |
+ start_filldir: |
1211 |
+- if (!fake_offset) |
1212 |
+- ctx->pos = cpos - (nr_slots + 1) * sizeof(struct msdos_dir_entry); |
1213 |
++ ctx->pos = cpos - (nr_slots + 1) * sizeof(struct msdos_dir_entry); |
1214 |
++ if (fake_offset && ctx->pos < 2) |
1215 |
++ ctx->pos = 2; |
1216 |
+ |
1217 |
+ if (!memcmp(de->name, MSDOS_DOT, MSDOS_NAME)) { |
1218 |
+ if (!dir_emit_dot(file, ctx)) |
1219 |
+@@ -685,14 +686,19 @@ record_end: |
1220 |
+ fake_offset = 0; |
1221 |
+ ctx->pos = cpos; |
1222 |
+ goto get_new; |
1223 |
++ |
1224 |
+ end_of_dir: |
1225 |
+- ctx->pos = cpos; |
1226 |
++ if (fake_offset && cpos < 2) |
1227 |
++ ctx->pos = 2; |
1228 |
++ else |
1229 |
++ ctx->pos = cpos; |
1230 |
+ fill_failed: |
1231 |
+ brelse(bh); |
1232 |
+ if (unicode) |
1233 |
+ __putname(unicode); |
1234 |
+ out: |
1235 |
+ mutex_unlock(&sbi->s_lock); |
1236 |
++ |
1237 |
+ return ret; |
1238 |
+ } |
1239 |
+ |
1240 |
+diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c |
1241 |
+index 989f39401547..96e48c67271b 100644 |
1242 |
+--- a/fs/fscache/netfs.c |
1243 |
++++ b/fs/fscache/netfs.c |
1244 |
+@@ -22,6 +22,7 @@ static LIST_HEAD(fscache_netfs_list); |
1245 |
+ int __fscache_register_netfs(struct fscache_netfs *netfs) |
1246 |
+ { |
1247 |
+ struct fscache_netfs *ptr; |
1248 |
++ struct fscache_cookie *cookie; |
1249 |
+ int ret; |
1250 |
+ |
1251 |
+ _enter("{%s}", netfs->name); |
1252 |
+@@ -29,29 +30,25 @@ int __fscache_register_netfs(struct fscache_netfs *netfs) |
1253 |
+ INIT_LIST_HEAD(&netfs->link); |
1254 |
+ |
1255 |
+ /* allocate a cookie for the primary index */ |
1256 |
+- netfs->primary_index = |
1257 |
+- kmem_cache_zalloc(fscache_cookie_jar, GFP_KERNEL); |
1258 |
++ cookie = kmem_cache_zalloc(fscache_cookie_jar, GFP_KERNEL); |
1259 |
+ |
1260 |
+- if (!netfs->primary_index) { |
1261 |
++ if (!cookie) { |
1262 |
+ _leave(" = -ENOMEM"); |
1263 |
+ return -ENOMEM; |
1264 |
+ } |
1265 |
+ |
1266 |
+ /* initialise the primary index cookie */ |
1267 |
+- atomic_set(&netfs->primary_index->usage, 1); |
1268 |
+- atomic_set(&netfs->primary_index->n_children, 0); |
1269 |
+- atomic_set(&netfs->primary_index->n_active, 1); |
1270 |
++ atomic_set(&cookie->usage, 1); |
1271 |
++ atomic_set(&cookie->n_children, 0); |
1272 |
++ atomic_set(&cookie->n_active, 1); |
1273 |
+ |
1274 |
+- netfs->primary_index->def = &fscache_fsdef_netfs_def; |
1275 |
+- netfs->primary_index->parent = &fscache_fsdef_index; |
1276 |
+- netfs->primary_index->netfs_data = netfs; |
1277 |
+- netfs->primary_index->flags = 1 << FSCACHE_COOKIE_ENABLED; |
1278 |
++ cookie->def = &fscache_fsdef_netfs_def; |
1279 |
++ cookie->parent = &fscache_fsdef_index; |
1280 |
++ cookie->netfs_data = netfs; |
1281 |
++ cookie->flags = 1 << FSCACHE_COOKIE_ENABLED; |
1282 |
+ |
1283 |
+- atomic_inc(&netfs->primary_index->parent->usage); |
1284 |
+- atomic_inc(&netfs->primary_index->parent->n_children); |
1285 |
+- |
1286 |
+- spin_lock_init(&netfs->primary_index->lock); |
1287 |
+- INIT_HLIST_HEAD(&netfs->primary_index->backing_objects); |
1288 |
++ spin_lock_init(&cookie->lock); |
1289 |
++ INIT_HLIST_HEAD(&cookie->backing_objects); |
1290 |
+ |
1291 |
+ /* check the netfs type is not already present */ |
1292 |
+ down_write(&fscache_addremove_sem); |
1293 |
+@@ -62,6 +59,10 @@ int __fscache_register_netfs(struct fscache_netfs *netfs) |
1294 |
+ goto already_registered; |
1295 |
+ } |
1296 |
+ |
1297 |
++ atomic_inc(&cookie->parent->usage); |
1298 |
++ atomic_inc(&cookie->parent->n_children); |
1299 |
++ |
1300 |
++ netfs->primary_index = cookie; |
1301 |
+ list_add(&netfs->link, &fscache_netfs_list); |
1302 |
+ ret = 0; |
1303 |
+ |
1304 |
+@@ -71,11 +72,8 @@ int __fscache_register_netfs(struct fscache_netfs *netfs) |
1305 |
+ already_registered: |
1306 |
+ up_write(&fscache_addremove_sem); |
1307 |
+ |
1308 |
+- if (ret < 0) { |
1309 |
+- netfs->primary_index->parent = NULL; |
1310 |
+- __fscache_cookie_put(netfs->primary_index); |
1311 |
+- netfs->primary_index = NULL; |
1312 |
+- } |
1313 |
++ if (ret < 0) |
1314 |
++ kmem_cache_free(fscache_cookie_jar, cookie); |
1315 |
+ |
1316 |
+ _leave(" = %d", ret); |
1317 |
+ return ret; |
1318 |
+diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c |
1319 |
+index ecc57071a1a9..a8c65539fbd2 100644 |
1320 |
+--- a/fs/jbd2/transaction.c |
1321 |
++++ b/fs/jbd2/transaction.c |
1322 |
+@@ -2066,6 +2066,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, |
1323 |
+ |
1324 |
+ if (!buffer_dirty(bh)) { |
1325 |
+ /* bdflush has written it. We can drop it now */ |
1326 |
++ __jbd2_journal_remove_checkpoint(jh); |
1327 |
+ goto zap_buffer; |
1328 |
+ } |
1329 |
+ |
1330 |
+@@ -2095,6 +2096,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, |
1331 |
+ /* The orphan record's transaction has |
1332 |
+ * committed. We can cleanse this buffer */ |
1333 |
+ clear_buffer_jbddirty(bh); |
1334 |
++ __jbd2_journal_remove_checkpoint(jh); |
1335 |
+ goto zap_buffer; |
1336 |
+ } |
1337 |
+ } |
1338 |
+diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c |
1339 |
+index 1dd0bcc75536..96cbbe9e7030 100644 |
1340 |
+--- a/fs/ocfs2/dlm/dlmmaster.c |
1341 |
++++ b/fs/ocfs2/dlm/dlmmaster.c |
1342 |
+@@ -2459,6 +2459,11 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm, |
1343 |
+ spin_lock(&dlm->master_lock); |
1344 |
+ ret = dlm_add_migration_mle(dlm, res, mle, &oldmle, name, |
1345 |
+ namelen, target, dlm->node_num); |
1346 |
++ /* get an extra reference on the mle. |
1347 |
++ * otherwise the assert_master from the new |
1348 |
++ * master will destroy this. |
1349 |
++ */ |
1350 |
++ dlm_get_mle_inuse(mle); |
1351 |
+ spin_unlock(&dlm->master_lock); |
1352 |
+ spin_unlock(&dlm->spinlock); |
1353 |
+ |
1354 |
+@@ -2494,6 +2499,7 @@ fail: |
1355 |
+ if (mle_added) { |
1356 |
+ dlm_mle_detach_hb_events(dlm, mle); |
1357 |
+ dlm_put_mle(mle); |
1358 |
++ dlm_put_mle_inuse(mle); |
1359 |
+ } else if (mle) { |
1360 |
+ kmem_cache_free(dlm_mle_cache, mle); |
1361 |
+ mle = NULL; |
1362 |
+@@ -2511,17 +2517,6 @@ fail: |
1363 |
+ * ensure that all assert_master work is flushed. */ |
1364 |
+ flush_workqueue(dlm->dlm_worker); |
1365 |
+ |
1366 |
+- /* get an extra reference on the mle. |
1367 |
+- * otherwise the assert_master from the new |
1368 |
+- * master will destroy this. |
1369 |
+- * also, make sure that all callers of dlm_get_mle |
1370 |
+- * take both dlm->spinlock and dlm->master_lock */ |
1371 |
+- spin_lock(&dlm->spinlock); |
1372 |
+- spin_lock(&dlm->master_lock); |
1373 |
+- dlm_get_mle_inuse(mle); |
1374 |
+- spin_unlock(&dlm->master_lock); |
1375 |
+- spin_unlock(&dlm->spinlock); |
1376 |
+- |
1377 |
+ /* notify new node and send all lock state */ |
1378 |
+ /* call send_one_lockres with migration flag. |
1379 |
+ * this serves as notice to the target node that a |
1380 |
+@@ -3246,6 +3241,15 @@ top: |
1381 |
+ mle->new_master != dead_node) |
1382 |
+ continue; |
1383 |
+ |
1384 |
++ if (mle->new_master == dead_node && mle->inuse) { |
1385 |
++ mlog(ML_NOTICE, "%s: target %u died during " |
1386 |
++ "migration from %u, the MLE is " |
1387 |
++ "still keep used, ignore it!\n", |
1388 |
++ dlm->name, dead_node, |
1389 |
++ mle->master); |
1390 |
++ continue; |
1391 |
++ } |
1392 |
++ |
1393 |
+ /* If we have reached this point, this mle needs to be |
1394 |
+ * removed from the list and freed. */ |
1395 |
+ dlm_clean_migration_mle(dlm, mle); |
1396 |
+diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c |
1397 |
+index fe29f7978f81..4b93d96d244f 100644 |
1398 |
+--- a/fs/ocfs2/dlm/dlmrecovery.c |
1399 |
++++ b/fs/ocfs2/dlm/dlmrecovery.c |
1400 |
+@@ -2332,6 +2332,8 @@ static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node) |
1401 |
+ break; |
1402 |
+ } |
1403 |
+ } |
1404 |
++ dlm_lockres_clear_refmap_bit(dlm, res, |
1405 |
++ dead_node); |
1406 |
+ spin_unlock(&res->spinlock); |
1407 |
+ continue; |
1408 |
+ } |
1409 |
+diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c |
1410 |
+index cc0aeb9e81a2..5e260e14cdd6 100644 |
1411 |
+--- a/fs/ocfs2/namei.c |
1412 |
++++ b/fs/ocfs2/namei.c |
1413 |
+@@ -340,13 +340,11 @@ static int ocfs2_mknod(struct inode *dir, |
1414 |
+ goto leave; |
1415 |
+ } |
1416 |
+ |
1417 |
+- status = posix_acl_create(dir, &mode, &default_acl, &acl); |
1418 |
++ status = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); |
1419 |
+ if (status) { |
1420 |
+ mlog_errno(status); |
1421 |
+ goto leave; |
1422 |
+ } |
1423 |
+- /* update inode->i_mode after mask with "umask". */ |
1424 |
+- inode->i_mode = mode; |
1425 |
+ |
1426 |
+ handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb, |
1427 |
+ S_ISDIR(mode), |
1428 |
+diff --git a/fs/proc/fd.c b/fs/proc/fd.c |
1429 |
+index 985ea881b5bc..c06a1f97ac22 100644 |
1430 |
+--- a/fs/proc/fd.c |
1431 |
++++ b/fs/proc/fd.c |
1432 |
+@@ -283,11 +283,19 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry, |
1433 |
+ */ |
1434 |
+ int proc_fd_permission(struct inode *inode, int mask) |
1435 |
+ { |
1436 |
+- int rv = generic_permission(inode, mask); |
1437 |
++ struct task_struct *p; |
1438 |
++ int rv; |
1439 |
++ |
1440 |
++ rv = generic_permission(inode, mask); |
1441 |
+ if (rv == 0) |
1442 |
+- return 0; |
1443 |
+- if (task_tgid(current) == proc_pid(inode)) |
1444 |
++ return rv; |
1445 |
++ |
1446 |
++ rcu_read_lock(); |
1447 |
++ p = pid_task(proc_pid(inode), PIDTYPE_PID); |
1448 |
++ if (p && same_thread_group(p, current)) |
1449 |
+ rv = 0; |
1450 |
++ rcu_read_unlock(); |
1451 |
++ |
1452 |
+ return rv; |
1453 |
+ } |
1454 |
+ |
1455 |
+diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c |
1456 |
+index c327d4ee1235..7b3792e5844a 100644 |
1457 |
+--- a/fs/sysv/inode.c |
1458 |
++++ b/fs/sysv/inode.c |
1459 |
+@@ -161,14 +161,8 @@ void sysv_set_inode(struct inode *inode, dev_t rdev) |
1460 |
+ inode->i_fop = &sysv_dir_operations; |
1461 |
+ inode->i_mapping->a_ops = &sysv_aops; |
1462 |
+ } else if (S_ISLNK(inode->i_mode)) { |
1463 |
+- if (inode->i_blocks) { |
1464 |
+- inode->i_op = &sysv_symlink_inode_operations; |
1465 |
+- inode->i_mapping->a_ops = &sysv_aops; |
1466 |
+- } else { |
1467 |
+- inode->i_op = &sysv_fast_symlink_inode_operations; |
1468 |
+- nd_terminate_link(SYSV_I(inode)->i_data, inode->i_size, |
1469 |
+- sizeof(SYSV_I(inode)->i_data) - 1); |
1470 |
+- } |
1471 |
++ inode->i_op = &sysv_symlink_inode_operations; |
1472 |
++ inode->i_mapping->a_ops = &sysv_aops; |
1473 |
+ } else |
1474 |
+ init_special_inode(inode, inode->i_mode, rdev); |
1475 |
+ } |
1476 |
+diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h |
1477 |
+index d61c11170213..2f38daaab3d7 100644 |
1478 |
+--- a/include/crypto/if_alg.h |
1479 |
++++ b/include/crypto/if_alg.h |
1480 |
+@@ -30,6 +30,8 @@ struct alg_sock { |
1481 |
+ |
1482 |
+ struct sock *parent; |
1483 |
+ |
1484 |
++ unsigned int refcnt; |
1485 |
++ |
1486 |
+ const struct af_alg_type *type; |
1487 |
+ void *private; |
1488 |
+ }; |
1489 |
+@@ -64,6 +66,7 @@ int af_alg_register_type(const struct af_alg_type *type); |
1490 |
+ int af_alg_unregister_type(const struct af_alg_type *type); |
1491 |
+ |
1492 |
+ int af_alg_release(struct socket *sock); |
1493 |
++void af_alg_release_parent(struct sock *sk); |
1494 |
+ int af_alg_accept(struct sock *sk, struct socket *newsock); |
1495 |
+ |
1496 |
+ int af_alg_make_sg(struct af_alg_sgl *sgl, void __user *addr, int len, |
1497 |
+@@ -80,11 +83,6 @@ static inline struct alg_sock *alg_sk(struct sock *sk) |
1498 |
+ return (struct alg_sock *)sk; |
1499 |
+ } |
1500 |
+ |
1501 |
+-static inline void af_alg_release_parent(struct sock *sk) |
1502 |
+-{ |
1503 |
+- sock_put(alg_sk(sk)->parent); |
1504 |
+-} |
1505 |
+- |
1506 |
+ static inline void af_alg_init_completion(struct af_alg_completion *completion) |
1507 |
+ { |
1508 |
+ init_completion(&completion->completion); |
1509 |
+diff --git a/include/linux/signal.h b/include/linux/signal.h |
1510 |
+index 2ac423bdb676..53944e50e421 100644 |
1511 |
+--- a/include/linux/signal.h |
1512 |
++++ b/include/linux/signal.h |
1513 |
+@@ -247,7 +247,6 @@ extern int sigprocmask(int, sigset_t *, sigset_t *); |
1514 |
+ extern void set_current_blocked(sigset_t *); |
1515 |
+ extern void __set_current_blocked(const sigset_t *); |
1516 |
+ extern int show_unhandled_signals; |
1517 |
+-extern int sigsuspend(sigset_t *); |
1518 |
+ |
1519 |
+ struct sigaction { |
1520 |
+ #ifndef __ARCH_HAS_IRIX_SIGACTION |
1521 |
+diff --git a/kernel/signal.c b/kernel/signal.c |
1522 |
+index 15c22ee11156..d8db156e5f5c 100644 |
1523 |
+--- a/kernel/signal.c |
1524 |
++++ b/kernel/signal.c |
1525 |
+@@ -3550,7 +3550,7 @@ SYSCALL_DEFINE0(pause) |
1526 |
+ |
1527 |
+ #endif |
1528 |
+ |
1529 |
+-int sigsuspend(sigset_t *set) |
1530 |
++static int sigsuspend(sigset_t *set) |
1531 |
+ { |
1532 |
+ current->saved_sigmask = current->blocked; |
1533 |
+ set_current_blocked(set); |
1534 |
+diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c |
1535 |
+index 2900817ba65c..7c8cef653166 100644 |
1536 |
+--- a/kernel/trace/trace_printk.c |
1537 |
++++ b/kernel/trace/trace_printk.c |
1538 |
+@@ -269,6 +269,7 @@ static const char **find_next(void *v, loff_t *pos) |
1539 |
+ if (*pos < last_index + start_index) |
1540 |
+ return __start___tracepoint_str + (*pos - last_index); |
1541 |
+ |
1542 |
++ start_index += last_index; |
1543 |
+ return find_next_mod_format(start_index, v, fmt, pos); |
1544 |
+ } |
1545 |
+ |
1546 |
+diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h |
1547 |
+index 49b582a225b0..b9897e2be404 100644 |
1548 |
+--- a/scripts/recordmcount.h |
1549 |
++++ b/scripts/recordmcount.h |
1550 |
+@@ -377,7 +377,7 @@ static void nop_mcount(Elf_Shdr const *const relhdr, |
1551 |
+ |
1552 |
+ if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { |
1553 |
+ if (make_nop) |
1554 |
+- ret = make_nop((void *)ehdr, shdr->sh_offset + relp->r_offset); |
1555 |
++ ret = make_nop((void *)ehdr, _w(shdr->sh_offset) + _w(relp->r_offset)); |
1556 |
+ if (warn_on_notrace_sect && !once) { |
1557 |
+ printf("Section %s has mcount callers being ignored\n", |
1558 |
+ txtname); |
1559 |
+diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c |
1560 |
+index 048550aacffc..596a2020fe2c 100644 |
1561 |
+--- a/security/integrity/evm/evm_main.c |
1562 |
++++ b/security/integrity/evm/evm_main.c |
1563 |
+@@ -22,6 +22,7 @@ |
1564 |
+ #include <linux/evm.h> |
1565 |
+ #include <linux/magic.h> |
1566 |
+ #include <crypto/hash.h> |
1567 |
++#include <crypto/algapi.h> |
1568 |
+ #include "evm.h" |
1569 |
+ |
1570 |
+ int evm_initialized; |
1571 |
+@@ -133,7 +134,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry, |
1572 |
+ xattr_value_len, calc.digest); |
1573 |
+ if (rc) |
1574 |
+ break; |
1575 |
+- rc = memcmp(xattr_data->digest, calc.digest, |
1576 |
++ rc = crypto_memneq(xattr_data->digest, calc.digest, |
1577 |
+ sizeof(calc.digest)); |
1578 |
+ if (rc) |
1579 |
+ rc = -EINVAL; |
1580 |
+diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c |
1581 |
+index 7403f348ed14..91525fafe73b 100644 |
1582 |
+--- a/sound/core/compress_offload.c |
1583 |
++++ b/sound/core/compress_offload.c |
1584 |
+@@ -44,6 +44,13 @@ |
1585 |
+ #include <sound/compress_offload.h> |
1586 |
+ #include <sound/compress_driver.h> |
1587 |
+ |
1588 |
++/* struct snd_compr_codec_caps overflows the ioctl bit size for some |
1589 |
++ * architectures, so we need to disable the relevant ioctls. |
1590 |
++ */ |
1591 |
++#if _IOC_SIZEBITS < 14 |
1592 |
++#define COMPR_CODEC_CAPS_OVERFLOW |
1593 |
++#endif |
1594 |
++ |
1595 |
+ /* TODO: |
1596 |
+ * - add substream support for multiple devices in case of |
1597 |
+ * SND_DYNAMIC_MINORS is not used |
1598 |
+@@ -438,6 +445,7 @@ out: |
1599 |
+ return retval; |
1600 |
+ } |
1601 |
+ |
1602 |
++#ifndef COMPR_CODEC_CAPS_OVERFLOW |
1603 |
+ static int |
1604 |
+ snd_compr_get_codec_caps(struct snd_compr_stream *stream, unsigned long arg) |
1605 |
+ { |
1606 |
+@@ -461,6 +469,7 @@ out: |
1607 |
+ kfree(caps); |
1608 |
+ return retval; |
1609 |
+ } |
1610 |
++#endif /* !COMPR_CODEC_CAPS_OVERFLOW */ |
1611 |
+ |
1612 |
+ /* revisit this with snd_pcm_preallocate_xxx */ |
1613 |
+ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream, |
1614 |
+@@ -799,9 +808,11 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) |
1615 |
+ case _IOC_NR(SNDRV_COMPRESS_GET_CAPS): |
1616 |
+ retval = snd_compr_get_caps(stream, arg); |
1617 |
+ break; |
1618 |
++#ifndef COMPR_CODEC_CAPS_OVERFLOW |
1619 |
+ case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS): |
1620 |
+ retval = snd_compr_get_codec_caps(stream, arg); |
1621 |
+ break; |
1622 |
++#endif |
1623 |
+ case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS): |
1624 |
+ retval = snd_compr_set_params(stream, arg); |
1625 |
+ break; |
1626 |
+diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c |
1627 |
+index 4c1cc51772e6..7417f96cea6e 100644 |
1628 |
+--- a/sound/core/oss/pcm_oss.c |
1629 |
++++ b/sound/core/oss/pcm_oss.c |
1630 |
+@@ -834,7 +834,8 @@ static int choose_rate(struct snd_pcm_substream *substream, |
1631 |
+ return snd_pcm_hw_param_near(substream, params, SNDRV_PCM_HW_PARAM_RATE, best_rate, NULL); |
1632 |
+ } |
1633 |
+ |
1634 |
+-static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) |
1635 |
++static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream, |
1636 |
++ bool trylock) |
1637 |
+ { |
1638 |
+ struct snd_pcm_runtime *runtime = substream->runtime; |
1639 |
+ struct snd_pcm_hw_params *params, *sparams; |
1640 |
+@@ -848,7 +849,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) |
1641 |
+ struct snd_mask sformat_mask; |
1642 |
+ struct snd_mask mask; |
1643 |
+ |
1644 |
+- if (mutex_lock_interruptible(&runtime->oss.params_lock)) |
1645 |
++ if (trylock) { |
1646 |
++ if (!(mutex_trylock(&runtime->oss.params_lock))) |
1647 |
++ return -EAGAIN; |
1648 |
++ } else if (mutex_lock_interruptible(&runtime->oss.params_lock)) |
1649 |
+ return -EINTR; |
1650 |
+ sw_params = kmalloc(sizeof(*sw_params), GFP_KERNEL); |
1651 |
+ params = kmalloc(sizeof(*params), GFP_KERNEL); |
1652 |
+@@ -1091,7 +1095,7 @@ static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_fil |
1653 |
+ if (asubstream == NULL) |
1654 |
+ asubstream = substream; |
1655 |
+ if (substream->runtime->oss.params) { |
1656 |
+- err = snd_pcm_oss_change_params(substream); |
1657 |
++ err = snd_pcm_oss_change_params(substream, false); |
1658 |
+ if (err < 0) |
1659 |
+ return err; |
1660 |
+ } |
1661 |
+@@ -1130,7 +1134,7 @@ static int snd_pcm_oss_make_ready(struct snd_pcm_substream *substream) |
1662 |
+ return 0; |
1663 |
+ runtime = substream->runtime; |
1664 |
+ if (runtime->oss.params) { |
1665 |
+- err = snd_pcm_oss_change_params(substream); |
1666 |
++ err = snd_pcm_oss_change_params(substream, false); |
1667 |
+ if (err < 0) |
1668 |
+ return err; |
1669 |
+ } |
1670 |
+@@ -2168,7 +2172,7 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre |
1671 |
+ runtime = substream->runtime; |
1672 |
+ |
1673 |
+ if (runtime->oss.params && |
1674 |
+- (err = snd_pcm_oss_change_params(substream)) < 0) |
1675 |
++ (err = snd_pcm_oss_change_params(substream, false)) < 0) |
1676 |
+ return err; |
1677 |
+ |
1678 |
+ info.fragsize = runtime->oss.period_bytes; |
1679 |
+@@ -2804,7 +2808,12 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area) |
1680 |
+ return -EIO; |
1681 |
+ |
1682 |
+ if (runtime->oss.params) { |
1683 |
+- if ((err = snd_pcm_oss_change_params(substream)) < 0) |
1684 |
++ /* use mutex_trylock() for params_lock for avoiding a deadlock |
1685 |
++ * between mmap_sem and params_lock taken by |
1686 |
++ * copy_from/to_user() in snd_pcm_oss_write/read() |
1687 |
++ */ |
1688 |
++ err = snd_pcm_oss_change_params(substream, true); |
1689 |
++ if (err < 0) |
1690 |
+ return err; |
1691 |
+ } |
1692 |
+ #ifdef CONFIG_SND_PCM_OSS_PLUGINS |
1693 |
+diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c |
1694 |
+index 7b596b5751db..500765f20843 100644 |
1695 |
+--- a/sound/core/rawmidi.c |
1696 |
++++ b/sound/core/rawmidi.c |
1697 |
+@@ -934,31 +934,36 @@ static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream, |
1698 |
+ unsigned long flags; |
1699 |
+ long result = 0, count1; |
1700 |
+ struct snd_rawmidi_runtime *runtime = substream->runtime; |
1701 |
++ unsigned long appl_ptr; |
1702 |
+ |
1703 |
++ spin_lock_irqsave(&runtime->lock, flags); |
1704 |
+ while (count > 0 && runtime->avail) { |
1705 |
+ count1 = runtime->buffer_size - runtime->appl_ptr; |
1706 |
+ if (count1 > count) |
1707 |
+ count1 = count; |
1708 |
+- spin_lock_irqsave(&runtime->lock, flags); |
1709 |
+ if (count1 > (int)runtime->avail) |
1710 |
+ count1 = runtime->avail; |
1711 |
++ |
1712 |
++ /* update runtime->appl_ptr before unlocking for userbuf */ |
1713 |
++ appl_ptr = runtime->appl_ptr; |
1714 |
++ runtime->appl_ptr += count1; |
1715 |
++ runtime->appl_ptr %= runtime->buffer_size; |
1716 |
++ runtime->avail -= count1; |
1717 |
++ |
1718 |
+ if (kernelbuf) |
1719 |
+- memcpy(kernelbuf + result, runtime->buffer + runtime->appl_ptr, count1); |
1720 |
++ memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1); |
1721 |
+ if (userbuf) { |
1722 |
+ spin_unlock_irqrestore(&runtime->lock, flags); |
1723 |
+ if (copy_to_user(userbuf + result, |
1724 |
+- runtime->buffer + runtime->appl_ptr, count1)) { |
1725 |
++ runtime->buffer + appl_ptr, count1)) { |
1726 |
+ return result > 0 ? result : -EFAULT; |
1727 |
+ } |
1728 |
+ spin_lock_irqsave(&runtime->lock, flags); |
1729 |
+ } |
1730 |
+- runtime->appl_ptr += count1; |
1731 |
+- runtime->appl_ptr %= runtime->buffer_size; |
1732 |
+- runtime->avail -= count1; |
1733 |
+- spin_unlock_irqrestore(&runtime->lock, flags); |
1734 |
+ result += count1; |
1735 |
+ count -= count1; |
1736 |
+ } |
1737 |
++ spin_unlock_irqrestore(&runtime->lock, flags); |
1738 |
+ return result; |
1739 |
+ } |
1740 |
+ |
1741 |
+@@ -1161,8 +1166,9 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream, |
1742 |
+ unsigned long flags; |
1743 |
+ long count1, result; |
1744 |
+ struct snd_rawmidi_runtime *runtime = substream->runtime; |
1745 |
++ unsigned long appl_ptr; |
1746 |
+ |
1747 |
+- if (snd_BUG_ON(!kernelbuf && !userbuf)) |
1748 |
++ if (!kernelbuf && !userbuf) |
1749 |
+ return -EINVAL; |
1750 |
+ if (snd_BUG_ON(!runtime->buffer)) |
1751 |
+ return -EINVAL; |
1752 |
+@@ -1181,12 +1187,19 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream, |
1753 |
+ count1 = count; |
1754 |
+ if (count1 > (long)runtime->avail) |
1755 |
+ count1 = runtime->avail; |
1756 |
++ |
1757 |
++ /* update runtime->appl_ptr before unlocking for userbuf */ |
1758 |
++ appl_ptr = runtime->appl_ptr; |
1759 |
++ runtime->appl_ptr += count1; |
1760 |
++ runtime->appl_ptr %= runtime->buffer_size; |
1761 |
++ runtime->avail -= count1; |
1762 |
++ |
1763 |
+ if (kernelbuf) |
1764 |
+- memcpy(runtime->buffer + runtime->appl_ptr, |
1765 |
++ memcpy(runtime->buffer + appl_ptr, |
1766 |
+ kernelbuf + result, count1); |
1767 |
+ else if (userbuf) { |
1768 |
+ spin_unlock_irqrestore(&runtime->lock, flags); |
1769 |
+- if (copy_from_user(runtime->buffer + runtime->appl_ptr, |
1770 |
++ if (copy_from_user(runtime->buffer + appl_ptr, |
1771 |
+ userbuf + result, count1)) { |
1772 |
+ spin_lock_irqsave(&runtime->lock, flags); |
1773 |
+ result = result > 0 ? result : -EFAULT; |
1774 |
+@@ -1194,9 +1207,6 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream, |
1775 |
+ } |
1776 |
+ spin_lock_irqsave(&runtime->lock, flags); |
1777 |
+ } |
1778 |
+- runtime->appl_ptr += count1; |
1779 |
+- runtime->appl_ptr %= runtime->buffer_size; |
1780 |
+- runtime->avail -= count1; |
1781 |
+ result += count1; |
1782 |
+ count -= count1; |
1783 |
+ } |
1784 |
+diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c |
1785 |
+index c5b773a1eea9..4a09c3085ca4 100644 |
1786 |
+--- a/sound/core/seq/oss/seq_oss_synth.c |
1787 |
++++ b/sound/core/seq/oss/seq_oss_synth.c |
1788 |
+@@ -310,7 +310,7 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp) |
1789 |
+ struct seq_oss_synth *rec; |
1790 |
+ struct seq_oss_synthinfo *info; |
1791 |
+ |
1792 |
+- if (snd_BUG_ON(dp->max_synthdev >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS)) |
1793 |
++ if (snd_BUG_ON(dp->max_synthdev > SNDRV_SEQ_OSS_MAX_SYNTH_DEVS)) |
1794 |
+ return; |
1795 |
+ for (i = 0; i < dp->max_synthdev; i++) { |
1796 |
+ info = &dp->synths[i]; |
1797 |
+diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c |
1798 |
+index ecfbf5f39d38..08865dcbf5f1 100644 |
1799 |
+--- a/sound/core/seq/seq_clientmgr.c |
1800 |
++++ b/sound/core/seq/seq_clientmgr.c |
1801 |
+@@ -678,6 +678,9 @@ static int deliver_to_subscribers(struct snd_seq_client *client, |
1802 |
+ else |
1803 |
+ down_read(&grp->list_mutex); |
1804 |
+ list_for_each_entry(subs, &grp->list_head, src_list) { |
1805 |
++ /* both ports ready? */ |
1806 |
++ if (atomic_read(&subs->ref_count) != 2) |
1807 |
++ continue; |
1808 |
+ event->dest = subs->info.dest; |
1809 |
+ if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP) |
1810 |
+ /* convert time according to flag with subscription */ |
1811 |
+diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c |
1812 |
+index 9516e5ce3aad..67c91d226552 100644 |
1813 |
+--- a/sound/core/seq/seq_ports.c |
1814 |
++++ b/sound/core/seq/seq_ports.c |
1815 |
+@@ -175,10 +175,6 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, |
1816 |
+ } |
1817 |
+ |
1818 |
+ /* */ |
1819 |
+-enum group_type { |
1820 |
+- SRC_LIST, DEST_LIST |
1821 |
+-}; |
1822 |
+- |
1823 |
+ static int subscribe_port(struct snd_seq_client *client, |
1824 |
+ struct snd_seq_client_port *port, |
1825 |
+ struct snd_seq_port_subs_info *grp, |
1826 |
+@@ -205,6 +201,20 @@ static struct snd_seq_client_port *get_client_port(struct snd_seq_addr *addr, |
1827 |
+ return NULL; |
1828 |
+ } |
1829 |
+ |
1830 |
++static void delete_and_unsubscribe_port(struct snd_seq_client *client, |
1831 |
++ struct snd_seq_client_port *port, |
1832 |
++ struct snd_seq_subscribers *subs, |
1833 |
++ bool is_src, bool ack); |
1834 |
++ |
1835 |
++static inline struct snd_seq_subscribers * |
1836 |
++get_subscriber(struct list_head *p, bool is_src) |
1837 |
++{ |
1838 |
++ if (is_src) |
1839 |
++ return list_entry(p, struct snd_seq_subscribers, src_list); |
1840 |
++ else |
1841 |
++ return list_entry(p, struct snd_seq_subscribers, dest_list); |
1842 |
++} |
1843 |
++ |
1844 |
+ /* |
1845 |
+ * remove all subscribers on the list |
1846 |
+ * this is called from port_delete, for each src and dest list. |
1847 |
+@@ -212,7 +222,7 @@ static struct snd_seq_client_port *get_client_port(struct snd_seq_addr *addr, |
1848 |
+ static void clear_subscriber_list(struct snd_seq_client *client, |
1849 |
+ struct snd_seq_client_port *port, |
1850 |
+ struct snd_seq_port_subs_info *grp, |
1851 |
+- int grptype) |
1852 |
++ int is_src) |
1853 |
+ { |
1854 |
+ struct list_head *p, *n; |
1855 |
+ |
1856 |
+@@ -221,15 +231,13 @@ static void clear_subscriber_list(struct snd_seq_client *client, |
1857 |
+ struct snd_seq_client *c; |
1858 |
+ struct snd_seq_client_port *aport; |
1859 |
+ |
1860 |
+- if (grptype == SRC_LIST) { |
1861 |
+- subs = list_entry(p, struct snd_seq_subscribers, src_list); |
1862 |
++ subs = get_subscriber(p, is_src); |
1863 |
++ if (is_src) |
1864 |
+ aport = get_client_port(&subs->info.dest, &c); |
1865 |
+- } else { |
1866 |
+- subs = list_entry(p, struct snd_seq_subscribers, dest_list); |
1867 |
++ else |
1868 |
+ aport = get_client_port(&subs->info.sender, &c); |
1869 |
+- } |
1870 |
+- list_del(p); |
1871 |
+- unsubscribe_port(client, port, grp, &subs->info, 0); |
1872 |
++ delete_and_unsubscribe_port(client, port, subs, is_src, false); |
1873 |
++ |
1874 |
+ if (!aport) { |
1875 |
+ /* looks like the connected port is being deleted. |
1876 |
+ * we decrease the counter, and when both ports are deleted |
1877 |
+@@ -237,21 +245,14 @@ static void clear_subscriber_list(struct snd_seq_client *client, |
1878 |
+ */ |
1879 |
+ if (atomic_dec_and_test(&subs->ref_count)) |
1880 |
+ kfree(subs); |
1881 |
+- } else { |
1882 |
+- /* ok we got the connected port */ |
1883 |
+- struct snd_seq_port_subs_info *agrp; |
1884 |
+- agrp = (grptype == SRC_LIST) ? &aport->c_dest : &aport->c_src; |
1885 |
+- down_write(&agrp->list_mutex); |
1886 |
+- if (grptype == SRC_LIST) |
1887 |
+- list_del(&subs->dest_list); |
1888 |
+- else |
1889 |
+- list_del(&subs->src_list); |
1890 |
+- up_write(&agrp->list_mutex); |
1891 |
+- unsubscribe_port(c, aport, agrp, &subs->info, 1); |
1892 |
+- kfree(subs); |
1893 |
+- snd_seq_port_unlock(aport); |
1894 |
+- snd_seq_client_unlock(c); |
1895 |
++ continue; |
1896 |
+ } |
1897 |
++ |
1898 |
++ /* ok we got the connected port */ |
1899 |
++ delete_and_unsubscribe_port(c, aport, subs, !is_src, true); |
1900 |
++ kfree(subs); |
1901 |
++ snd_seq_port_unlock(aport); |
1902 |
++ snd_seq_client_unlock(c); |
1903 |
+ } |
1904 |
+ } |
1905 |
+ |
1906 |
+@@ -264,8 +265,8 @@ static int port_delete(struct snd_seq_client *client, |
1907 |
+ snd_use_lock_sync(&port->use_lock); |
1908 |
+ |
1909 |
+ /* clear subscribers info */ |
1910 |
+- clear_subscriber_list(client, port, &port->c_src, SRC_LIST); |
1911 |
+- clear_subscriber_list(client, port, &port->c_dest, DEST_LIST); |
1912 |
++ clear_subscriber_list(client, port, &port->c_src, true); |
1913 |
++ clear_subscriber_list(client, port, &port->c_dest, false); |
1914 |
+ |
1915 |
+ if (port->private_free) |
1916 |
+ port->private_free(port->private_data); |
1917 |
+@@ -484,85 +485,120 @@ static int match_subs_info(struct snd_seq_port_subscribe *r, |
1918 |
+ return 0; |
1919 |
+ } |
1920 |
+ |
1921 |
+- |
1922 |
+-/* connect two ports */ |
1923 |
+-int snd_seq_port_connect(struct snd_seq_client *connector, |
1924 |
+- struct snd_seq_client *src_client, |
1925 |
+- struct snd_seq_client_port *src_port, |
1926 |
+- struct snd_seq_client *dest_client, |
1927 |
+- struct snd_seq_client_port *dest_port, |
1928 |
+- struct snd_seq_port_subscribe *info) |
1929 |
++static int check_and_subscribe_port(struct snd_seq_client *client, |
1930 |
++ struct snd_seq_client_port *port, |
1931 |
++ struct snd_seq_subscribers *subs, |
1932 |
++ bool is_src, bool exclusive, bool ack) |
1933 |
+ { |
1934 |
+- struct snd_seq_port_subs_info *src = &src_port->c_src; |
1935 |
+- struct snd_seq_port_subs_info *dest = &dest_port->c_dest; |
1936 |
+- struct snd_seq_subscribers *subs, *s; |
1937 |
+- int err, src_called = 0; |
1938 |
+- unsigned long flags; |
1939 |
+- int exclusive; |
1940 |
++ struct snd_seq_port_subs_info *grp; |
1941 |
++ struct list_head *p; |
1942 |
++ struct snd_seq_subscribers *s; |
1943 |
++ int err; |
1944 |
+ |
1945 |
+- subs = kzalloc(sizeof(*subs), GFP_KERNEL); |
1946 |
+- if (! subs) |
1947 |
+- return -ENOMEM; |
1948 |
+- |
1949 |
+- subs->info = *info; |
1950 |
+- atomic_set(&subs->ref_count, 2); |
1951 |
+- |
1952 |
+- down_write(&src->list_mutex); |
1953 |
+- down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING); |
1954 |
+- |
1955 |
+- exclusive = info->flags & SNDRV_SEQ_PORT_SUBS_EXCLUSIVE ? 1 : 0; |
1956 |
++ grp = is_src ? &port->c_src : &port->c_dest; |
1957 |
+ err = -EBUSY; |
1958 |
++ down_write(&grp->list_mutex); |
1959 |
+ if (exclusive) { |
1960 |
+- if (! list_empty(&src->list_head) || ! list_empty(&dest->list_head)) |
1961 |
++ if (!list_empty(&grp->list_head)) |
1962 |
+ goto __error; |
1963 |
+ } else { |
1964 |
+- if (src->exclusive || dest->exclusive) |
1965 |
++ if (grp->exclusive) |
1966 |
+ goto __error; |
1967 |
+ /* check whether already exists */ |
1968 |
+- list_for_each_entry(s, &src->list_head, src_list) { |
1969 |
+- if (match_subs_info(info, &s->info)) |
1970 |
+- goto __error; |
1971 |
+- } |
1972 |
+- list_for_each_entry(s, &dest->list_head, dest_list) { |
1973 |
+- if (match_subs_info(info, &s->info)) |
1974 |
++ list_for_each(p, &grp->list_head) { |
1975 |
++ s = get_subscriber(p, is_src); |
1976 |
++ if (match_subs_info(&subs->info, &s->info)) |
1977 |
+ goto __error; |
1978 |
+ } |
1979 |
+ } |
1980 |
+ |
1981 |
+- if ((err = subscribe_port(src_client, src_port, src, info, |
1982 |
+- connector->number != src_client->number)) < 0) |
1983 |
+- goto __error; |
1984 |
+- src_called = 1; |
1985 |
+- |
1986 |
+- if ((err = subscribe_port(dest_client, dest_port, dest, info, |
1987 |
+- connector->number != dest_client->number)) < 0) |
1988 |
++ err = subscribe_port(client, port, grp, &subs->info, ack); |
1989 |
++ if (err < 0) { |
1990 |
++ grp->exclusive = 0; |
1991 |
+ goto __error; |
1992 |
++ } |
1993 |
+ |
1994 |
+ /* add to list */ |
1995 |
+- write_lock_irqsave(&src->list_lock, flags); |
1996 |
+- // write_lock(&dest->list_lock); // no other lock yet |
1997 |
+- list_add_tail(&subs->src_list, &src->list_head); |
1998 |
+- list_add_tail(&subs->dest_list, &dest->list_head); |
1999 |
+- // write_unlock(&dest->list_lock); // no other lock yet |
2000 |
+- write_unlock_irqrestore(&src->list_lock, flags); |
2001 |
++ write_lock_irq(&grp->list_lock); |
2002 |
++ if (is_src) |
2003 |
++ list_add_tail(&subs->src_list, &grp->list_head); |
2004 |
++ else |
2005 |
++ list_add_tail(&subs->dest_list, &grp->list_head); |
2006 |
++ grp->exclusive = exclusive; |
2007 |
++ atomic_inc(&subs->ref_count); |
2008 |
++ write_unlock_irq(&grp->list_lock); |
2009 |
++ err = 0; |
2010 |
++ |
2011 |
++ __error: |
2012 |
++ up_write(&grp->list_mutex); |
2013 |
++ return err; |
2014 |
++} |
2015 |
+ |
2016 |
+- src->exclusive = dest->exclusive = exclusive; |
2017 |
++static void delete_and_unsubscribe_port(struct snd_seq_client *client, |
2018 |
++ struct snd_seq_client_port *port, |
2019 |
++ struct snd_seq_subscribers *subs, |
2020 |
++ bool is_src, bool ack) |
2021 |
++{ |
2022 |
++ struct snd_seq_port_subs_info *grp; |
2023 |
++ |
2024 |
++ grp = is_src ? &port->c_src : &port->c_dest; |
2025 |
++ down_write(&grp->list_mutex); |
2026 |
++ write_lock_irq(&grp->list_lock); |
2027 |
++ if (is_src) |
2028 |
++ list_del(&subs->src_list); |
2029 |
++ else |
2030 |
++ list_del(&subs->dest_list); |
2031 |
++ grp->exclusive = 0; |
2032 |
++ write_unlock_irq(&grp->list_lock); |
2033 |
++ up_write(&grp->list_mutex); |
2034 |
++ |
2035 |
++ unsubscribe_port(client, port, grp, &subs->info, ack); |
2036 |
++} |
2037 |
++ |
2038 |
++/* connect two ports */ |
2039 |
++int snd_seq_port_connect(struct snd_seq_client *connector, |
2040 |
++ struct snd_seq_client *src_client, |
2041 |
++ struct snd_seq_client_port *src_port, |
2042 |
++ struct snd_seq_client *dest_client, |
2043 |
++ struct snd_seq_client_port *dest_port, |
2044 |
++ struct snd_seq_port_subscribe *info) |
2045 |
++{ |
2046 |
++ struct snd_seq_subscribers *subs; |
2047 |
++ bool exclusive; |
2048 |
++ int err; |
2049 |
++ |
2050 |
++ subs = kzalloc(sizeof(*subs), GFP_KERNEL); |
2051 |
++ if (!subs) |
2052 |
++ return -ENOMEM; |
2053 |
++ |
2054 |
++ subs->info = *info; |
2055 |
++ atomic_set(&subs->ref_count, 0); |
2056 |
++ INIT_LIST_HEAD(&subs->src_list); |
2057 |
++ INIT_LIST_HEAD(&subs->dest_list); |
2058 |
++ |
2059 |
++ exclusive = !!(info->flags & SNDRV_SEQ_PORT_SUBS_EXCLUSIVE); |
2060 |
++ |
2061 |
++ err = check_and_subscribe_port(src_client, src_port, subs, true, |
2062 |
++ exclusive, |
2063 |
++ connector->number != src_client->number); |
2064 |
++ if (err < 0) |
2065 |
++ goto error; |
2066 |
++ err = check_and_subscribe_port(dest_client, dest_port, subs, false, |
2067 |
++ exclusive, |
2068 |
++ connector->number != dest_client->number); |
2069 |
++ if (err < 0) |
2070 |
++ goto error_dest; |
2071 |
+ |
2072 |
+- up_write(&dest->list_mutex); |
2073 |
+- up_write(&src->list_mutex); |
2074 |
+ return 0; |
2075 |
+ |
2076 |
+- __error: |
2077 |
+- if (src_called) |
2078 |
+- unsubscribe_port(src_client, src_port, src, info, |
2079 |
+- connector->number != src_client->number); |
2080 |
++ error_dest: |
2081 |
++ delete_and_unsubscribe_port(src_client, src_port, subs, true, |
2082 |
++ connector->number != src_client->number); |
2083 |
++ error: |
2084 |
+ kfree(subs); |
2085 |
+- up_write(&dest->list_mutex); |
2086 |
+- up_write(&src->list_mutex); |
2087 |
+ return err; |
2088 |
+ } |
2089 |
+ |
2090 |
+- |
2091 |
+ /* remove the connection */ |
2092 |
+ int snd_seq_port_disconnect(struct snd_seq_client *connector, |
2093 |
+ struct snd_seq_client *src_client, |
2094 |
+@@ -572,37 +608,28 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector, |
2095 |
+ struct snd_seq_port_subscribe *info) |
2096 |
+ { |
2097 |
+ struct snd_seq_port_subs_info *src = &src_port->c_src; |
2098 |
+- struct snd_seq_port_subs_info *dest = &dest_port->c_dest; |
2099 |
+ struct snd_seq_subscribers *subs; |
2100 |
+ int err = -ENOENT; |
2101 |
+- unsigned long flags; |
2102 |
+ |
2103 |
+ down_write(&src->list_mutex); |
2104 |
+- down_write_nested(&dest->list_mutex, SINGLE_DEPTH_NESTING); |
2105 |
+- |
2106 |
+ /* look for the connection */ |
2107 |
+ list_for_each_entry(subs, &src->list_head, src_list) { |
2108 |
+ if (match_subs_info(info, &subs->info)) { |
2109 |
+- write_lock_irqsave(&src->list_lock, flags); |
2110 |
+- // write_lock(&dest->list_lock); // no lock yet |
2111 |
+- list_del(&subs->src_list); |
2112 |
+- list_del(&subs->dest_list); |
2113 |
+- // write_unlock(&dest->list_lock); |
2114 |
+- write_unlock_irqrestore(&src->list_lock, flags); |
2115 |
+- src->exclusive = dest->exclusive = 0; |
2116 |
+- unsubscribe_port(src_client, src_port, src, info, |
2117 |
+- connector->number != src_client->number); |
2118 |
+- unsubscribe_port(dest_client, dest_port, dest, info, |
2119 |
+- connector->number != dest_client->number); |
2120 |
+- kfree(subs); |
2121 |
++ atomic_dec(&subs->ref_count); /* mark as not ready */ |
2122 |
+ err = 0; |
2123 |
+ break; |
2124 |
+ } |
2125 |
+ } |
2126 |
+- |
2127 |
+- up_write(&dest->list_mutex); |
2128 |
+ up_write(&src->list_mutex); |
2129 |
+- return err; |
2130 |
++ if (err < 0) |
2131 |
++ return err; |
2132 |
++ |
2133 |
++ delete_and_unsubscribe_port(src_client, src_port, subs, true, |
2134 |
++ connector->number != src_client->number); |
2135 |
++ delete_and_unsubscribe_port(dest_client, dest_port, subs, false, |
2136 |
++ connector->number != dest_client->number); |
2137 |
++ kfree(subs); |
2138 |
++ return 0; |
2139 |
+ } |
2140 |
+ |
2141 |
+ |
2142 |
+diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c |
2143 |
+index 24d44b2f61ac..6ec30a98a92a 100644 |
2144 |
+--- a/sound/core/seq/seq_timer.c |
2145 |
++++ b/sound/core/seq/seq_timer.c |
2146 |
+@@ -92,6 +92,9 @@ void snd_seq_timer_delete(struct snd_seq_timer **tmr) |
2147 |
+ |
2148 |
+ void snd_seq_timer_defaults(struct snd_seq_timer * tmr) |
2149 |
+ { |
2150 |
++ unsigned long flags; |
2151 |
++ |
2152 |
++ spin_lock_irqsave(&tmr->lock, flags); |
2153 |
+ /* setup defaults */ |
2154 |
+ tmr->ppq = 96; /* 96 PPQ */ |
2155 |
+ tmr->tempo = 500000; /* 120 BPM */ |
2156 |
+@@ -107,21 +110,25 @@ void snd_seq_timer_defaults(struct snd_seq_timer * tmr) |
2157 |
+ tmr->preferred_resolution = seq_default_timer_resolution; |
2158 |
+ |
2159 |
+ tmr->skew = tmr->skew_base = SKEW_BASE; |
2160 |
++ spin_unlock_irqrestore(&tmr->lock, flags); |
2161 |
+ } |
2162 |
+ |
2163 |
+-void snd_seq_timer_reset(struct snd_seq_timer * tmr) |
2164 |
++static void seq_timer_reset(struct snd_seq_timer *tmr) |
2165 |
+ { |
2166 |
+- unsigned long flags; |
2167 |
+- |
2168 |
+- spin_lock_irqsave(&tmr->lock, flags); |
2169 |
+- |
2170 |
+ /* reset time & songposition */ |
2171 |
+ tmr->cur_time.tv_sec = 0; |
2172 |
+ tmr->cur_time.tv_nsec = 0; |
2173 |
+ |
2174 |
+ tmr->tick.cur_tick = 0; |
2175 |
+ tmr->tick.fraction = 0; |
2176 |
++} |
2177 |
++ |
2178 |
++void snd_seq_timer_reset(struct snd_seq_timer *tmr) |
2179 |
++{ |
2180 |
++ unsigned long flags; |
2181 |
+ |
2182 |
++ spin_lock_irqsave(&tmr->lock, flags); |
2183 |
++ seq_timer_reset(tmr); |
2184 |
+ spin_unlock_irqrestore(&tmr->lock, flags); |
2185 |
+ } |
2186 |
+ |
2187 |
+@@ -140,8 +147,11 @@ static void snd_seq_timer_interrupt(struct snd_timer_instance *timeri, |
2188 |
+ tmr = q->timer; |
2189 |
+ if (tmr == NULL) |
2190 |
+ return; |
2191 |
+- if (!tmr->running) |
2192 |
++ spin_lock_irqsave(&tmr->lock, flags); |
2193 |
++ if (!tmr->running) { |
2194 |
++ spin_unlock_irqrestore(&tmr->lock, flags); |
2195 |
+ return; |
2196 |
++ } |
2197 |
+ |
2198 |
+ resolution *= ticks; |
2199 |
+ if (tmr->skew != tmr->skew_base) { |
2200 |
+@@ -150,8 +160,6 @@ static void snd_seq_timer_interrupt(struct snd_timer_instance *timeri, |
2201 |
+ (((resolution & 0xffff) * tmr->skew) >> 16); |
2202 |
+ } |
2203 |
+ |
2204 |
+- spin_lock_irqsave(&tmr->lock, flags); |
2205 |
+- |
2206 |
+ /* update timer */ |
2207 |
+ snd_seq_inc_time_nsec(&tmr->cur_time, resolution); |
2208 |
+ |
2209 |
+@@ -298,26 +306,30 @@ int snd_seq_timer_open(struct snd_seq_queue *q) |
2210 |
+ t->callback = snd_seq_timer_interrupt; |
2211 |
+ t->callback_data = q; |
2212 |
+ t->flags |= SNDRV_TIMER_IFLG_AUTO; |
2213 |
++ spin_lock_irq(&tmr->lock); |
2214 |
+ tmr->timeri = t; |
2215 |
++ spin_unlock_irq(&tmr->lock); |
2216 |
+ return 0; |
2217 |
+ } |
2218 |
+ |
2219 |
+ int snd_seq_timer_close(struct snd_seq_queue *q) |
2220 |
+ { |
2221 |
+ struct snd_seq_timer *tmr; |
2222 |
++ struct snd_timer_instance *t; |
2223 |
+ |
2224 |
+ tmr = q->timer; |
2225 |
+ if (snd_BUG_ON(!tmr)) |
2226 |
+ return -EINVAL; |
2227 |
+- if (tmr->timeri) { |
2228 |
+- snd_timer_stop(tmr->timeri); |
2229 |
+- snd_timer_close(tmr->timeri); |
2230 |
+- tmr->timeri = NULL; |
2231 |
+- } |
2232 |
++ spin_lock_irq(&tmr->lock); |
2233 |
++ t = tmr->timeri; |
2234 |
++ tmr->timeri = NULL; |
2235 |
++ spin_unlock_irq(&tmr->lock); |
2236 |
++ if (t) |
2237 |
++ snd_timer_close(t); |
2238 |
+ return 0; |
2239 |
+ } |
2240 |
+ |
2241 |
+-int snd_seq_timer_stop(struct snd_seq_timer * tmr) |
2242 |
++static int seq_timer_stop(struct snd_seq_timer *tmr) |
2243 |
+ { |
2244 |
+ if (! tmr->timeri) |
2245 |
+ return -EINVAL; |
2246 |
+@@ -328,6 +340,17 @@ int snd_seq_timer_stop(struct snd_seq_timer * tmr) |
2247 |
+ return 0; |
2248 |
+ } |
2249 |
+ |
2250 |
++int snd_seq_timer_stop(struct snd_seq_timer *tmr) |
2251 |
++{ |
2252 |
++ unsigned long flags; |
2253 |
++ int err; |
2254 |
++ |
2255 |
++ spin_lock_irqsave(&tmr->lock, flags); |
2256 |
++ err = seq_timer_stop(tmr); |
2257 |
++ spin_unlock_irqrestore(&tmr->lock, flags); |
2258 |
++ return err; |
2259 |
++} |
2260 |
++ |
2261 |
+ static int initialize_timer(struct snd_seq_timer *tmr) |
2262 |
+ { |
2263 |
+ struct snd_timer *t; |
2264 |
+@@ -360,13 +383,13 @@ static int initialize_timer(struct snd_seq_timer *tmr) |
2265 |
+ return 0; |
2266 |
+ } |
2267 |
+ |
2268 |
+-int snd_seq_timer_start(struct snd_seq_timer * tmr) |
2269 |
++static int seq_timer_start(struct snd_seq_timer *tmr) |
2270 |
+ { |
2271 |
+ if (! tmr->timeri) |
2272 |
+ return -EINVAL; |
2273 |
+ if (tmr->running) |
2274 |
+- snd_seq_timer_stop(tmr); |
2275 |
+- snd_seq_timer_reset(tmr); |
2276 |
++ seq_timer_stop(tmr); |
2277 |
++ seq_timer_reset(tmr); |
2278 |
+ if (initialize_timer(tmr) < 0) |
2279 |
+ return -EINVAL; |
2280 |
+ snd_timer_start(tmr->timeri, tmr->ticks); |
2281 |
+@@ -375,14 +398,25 @@ int snd_seq_timer_start(struct snd_seq_timer * tmr) |
2282 |
+ return 0; |
2283 |
+ } |
2284 |
+ |
2285 |
+-int snd_seq_timer_continue(struct snd_seq_timer * tmr) |
2286 |
++int snd_seq_timer_start(struct snd_seq_timer *tmr) |
2287 |
++{ |
2288 |
++ unsigned long flags; |
2289 |
++ int err; |
2290 |
++ |
2291 |
++ spin_lock_irqsave(&tmr->lock, flags); |
2292 |
++ err = seq_timer_start(tmr); |
2293 |
++ spin_unlock_irqrestore(&tmr->lock, flags); |
2294 |
++ return err; |
2295 |
++} |
2296 |
++ |
2297 |
++static int seq_timer_continue(struct snd_seq_timer *tmr) |
2298 |
+ { |
2299 |
+ if (! tmr->timeri) |
2300 |
+ return -EINVAL; |
2301 |
+ if (tmr->running) |
2302 |
+ return -EBUSY; |
2303 |
+ if (! tmr->initialized) { |
2304 |
+- snd_seq_timer_reset(tmr); |
2305 |
++ seq_timer_reset(tmr); |
2306 |
+ if (initialize_timer(tmr) < 0) |
2307 |
+ return -EINVAL; |
2308 |
+ } |
2309 |
+@@ -392,11 +426,24 @@ int snd_seq_timer_continue(struct snd_seq_timer * tmr) |
2310 |
+ return 0; |
2311 |
+ } |
2312 |
+ |
2313 |
++int snd_seq_timer_continue(struct snd_seq_timer *tmr) |
2314 |
++{ |
2315 |
++ unsigned long flags; |
2316 |
++ int err; |
2317 |
++ |
2318 |
++ spin_lock_irqsave(&tmr->lock, flags); |
2319 |
++ err = seq_timer_continue(tmr); |
2320 |
++ spin_unlock_irqrestore(&tmr->lock, flags); |
2321 |
++ return err; |
2322 |
++} |
2323 |
++ |
2324 |
+ /* return current 'real' time. use timeofday() to get better granularity. */ |
2325 |
+ snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr) |
2326 |
+ { |
2327 |
+ snd_seq_real_time_t cur_time; |
2328 |
++ unsigned long flags; |
2329 |
+ |
2330 |
++ spin_lock_irqsave(&tmr->lock, flags); |
2331 |
+ cur_time = tmr->cur_time; |
2332 |
+ if (tmr->running) { |
2333 |
+ struct timeval tm; |
2334 |
+@@ -412,7 +459,7 @@ snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr) |
2335 |
+ } |
2336 |
+ snd_seq_sanity_real_time(&cur_time); |
2337 |
+ } |
2338 |
+- |
2339 |
++ spin_unlock_irqrestore(&tmr->lock, flags); |
2340 |
+ return cur_time; |
2341 |
+ } |
2342 |
+ |
2343 |
+diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c |
2344 |
+index 4b50e604276d..0fa691e01384 100644 |
2345 |
+--- a/sound/core/seq/seq_virmidi.c |
2346 |
++++ b/sound/core/seq/seq_virmidi.c |
2347 |
+@@ -254,9 +254,13 @@ static int snd_virmidi_output_open(struct snd_rawmidi_substream *substream) |
2348 |
+ */ |
2349 |
+ static int snd_virmidi_input_close(struct snd_rawmidi_substream *substream) |
2350 |
+ { |
2351 |
++ struct snd_virmidi_dev *rdev = substream->rmidi->private_data; |
2352 |
+ struct snd_virmidi *vmidi = substream->runtime->private_data; |
2353 |
+- snd_midi_event_free(vmidi->parser); |
2354 |
++ |
2355 |
++ write_lock_irq(&rdev->filelist_lock); |
2356 |
+ list_del(&vmidi->list); |
2357 |
++ write_unlock_irq(&rdev->filelist_lock); |
2358 |
++ snd_midi_event_free(vmidi->parser); |
2359 |
+ substream->runtime->private_data = NULL; |
2360 |
+ kfree(vmidi); |
2361 |
+ return 0; |
2362 |
+diff --git a/sound/core/timer.c b/sound/core/timer.c |
2363 |
+index 4e436fe53afa..d90d8f4b85fe 100644 |
2364 |
+--- a/sound/core/timer.c |
2365 |
++++ b/sound/core/timer.c |
2366 |
+@@ -300,8 +300,7 @@ int snd_timer_open(struct snd_timer_instance **ti, |
2367 |
+ return 0; |
2368 |
+ } |
2369 |
+ |
2370 |
+-static int _snd_timer_stop(struct snd_timer_instance *timeri, |
2371 |
+- int keep_flag, int event); |
2372 |
++static int _snd_timer_stop(struct snd_timer_instance *timeri, int event); |
2373 |
+ |
2374 |
+ /* |
2375 |
+ * close a timer instance |
2376 |
+@@ -343,7 +342,7 @@ int snd_timer_close(struct snd_timer_instance *timeri) |
2377 |
+ spin_unlock_irq(&timer->lock); |
2378 |
+ mutex_lock(®ister_mutex); |
2379 |
+ list_del(&timeri->open_list); |
2380 |
+- if (timer && list_empty(&timer->open_list_head) && |
2381 |
++ if (list_empty(&timer->open_list_head) && |
2382 |
+ timer->hw.close) |
2383 |
+ timer->hw.close(timer); |
2384 |
+ /* remove slave links */ |
2385 |
+@@ -415,7 +414,7 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event) |
2386 |
+ spin_lock_irqsave(&timer->lock, flags); |
2387 |
+ list_for_each_entry(ts, &ti->slave_active_head, active_list) |
2388 |
+ if (ts->ccallback) |
2389 |
+- ts->ccallback(ti, event + 100, &tstamp, resolution); |
2390 |
++ ts->ccallback(ts, event + 100, &tstamp, resolution); |
2391 |
+ spin_unlock_irqrestore(&timer->lock, flags); |
2392 |
+ } |
2393 |
+ |
2394 |
+@@ -444,6 +443,10 @@ static int snd_timer_start_slave(struct snd_timer_instance *timeri) |
2395 |
+ unsigned long flags; |
2396 |
+ |
2397 |
+ spin_lock_irqsave(&slave_active_lock, flags); |
2398 |
++ if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING) { |
2399 |
++ spin_unlock_irqrestore(&slave_active_lock, flags); |
2400 |
++ return -EBUSY; |
2401 |
++ } |
2402 |
+ timeri->flags |= SNDRV_TIMER_IFLG_RUNNING; |
2403 |
+ if (timeri->master && timeri->timer) { |
2404 |
+ spin_lock(&timeri->timer->lock); |
2405 |
+@@ -468,23 +471,30 @@ int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks) |
2406 |
+ return -EINVAL; |
2407 |
+ if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) { |
2408 |
+ result = snd_timer_start_slave(timeri); |
2409 |
+- snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_START); |
2410 |
++ if (result >= 0) |
2411 |
++ snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_START); |
2412 |
+ return result; |
2413 |
+ } |
2414 |
+ timer = timeri->timer; |
2415 |
+ if (timer == NULL) |
2416 |
+ return -EINVAL; |
2417 |
+ spin_lock_irqsave(&timer->lock, flags); |
2418 |
++ if (timeri->flags & (SNDRV_TIMER_IFLG_RUNNING | |
2419 |
++ SNDRV_TIMER_IFLG_START)) { |
2420 |
++ result = -EBUSY; |
2421 |
++ goto unlock; |
2422 |
++ } |
2423 |
+ timeri->ticks = timeri->cticks = ticks; |
2424 |
+ timeri->pticks = 0; |
2425 |
+ result = snd_timer_start1(timer, timeri, ticks); |
2426 |
++ unlock: |
2427 |
+ spin_unlock_irqrestore(&timer->lock, flags); |
2428 |
+- snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_START); |
2429 |
++ if (result >= 0) |
2430 |
++ snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_START); |
2431 |
+ return result; |
2432 |
+ } |
2433 |
+ |
2434 |
+-static int _snd_timer_stop(struct snd_timer_instance * timeri, |
2435 |
+- int keep_flag, int event) |
2436 |
++static int _snd_timer_stop(struct snd_timer_instance *timeri, int event) |
2437 |
+ { |
2438 |
+ struct snd_timer *timer; |
2439 |
+ unsigned long flags; |
2440 |
+@@ -493,19 +503,30 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri, |
2441 |
+ return -ENXIO; |
2442 |
+ |
2443 |
+ if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) { |
2444 |
+- if (!keep_flag) { |
2445 |
+- spin_lock_irqsave(&slave_active_lock, flags); |
2446 |
+- timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING; |
2447 |
+- list_del_init(&timeri->ack_list); |
2448 |
+- list_del_init(&timeri->active_list); |
2449 |
++ spin_lock_irqsave(&slave_active_lock, flags); |
2450 |
++ if (!(timeri->flags & SNDRV_TIMER_IFLG_RUNNING)) { |
2451 |
+ spin_unlock_irqrestore(&slave_active_lock, flags); |
2452 |
++ return -EBUSY; |
2453 |
+ } |
2454 |
++ if (timeri->timer) |
2455 |
++ spin_lock(&timeri->timer->lock); |
2456 |
++ timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING; |
2457 |
++ list_del_init(&timeri->ack_list); |
2458 |
++ list_del_init(&timeri->active_list); |
2459 |
++ if (timeri->timer) |
2460 |
++ spin_unlock(&timeri->timer->lock); |
2461 |
++ spin_unlock_irqrestore(&slave_active_lock, flags); |
2462 |
+ goto __end; |
2463 |
+ } |
2464 |
+ timer = timeri->timer; |
2465 |
+ if (!timer) |
2466 |
+ return -EINVAL; |
2467 |
+ spin_lock_irqsave(&timer->lock, flags); |
2468 |
++ if (!(timeri->flags & (SNDRV_TIMER_IFLG_RUNNING | |
2469 |
++ SNDRV_TIMER_IFLG_START))) { |
2470 |
++ spin_unlock_irqrestore(&timer->lock, flags); |
2471 |
++ return -EBUSY; |
2472 |
++ } |
2473 |
+ list_del_init(&timeri->ack_list); |
2474 |
+ list_del_init(&timeri->active_list); |
2475 |
+ if ((timeri->flags & SNDRV_TIMER_IFLG_RUNNING) && |
2476 |
+@@ -520,9 +541,7 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri, |
2477 |
+ } |
2478 |
+ } |
2479 |
+ } |
2480 |
+- if (!keep_flag) |
2481 |
+- timeri->flags &= |
2482 |
+- ~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START); |
2483 |
++ timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START); |
2484 |
+ spin_unlock_irqrestore(&timer->lock, flags); |
2485 |
+ __end: |
2486 |
+ if (event != SNDRV_TIMER_EVENT_RESOLUTION) |
2487 |
+@@ -541,7 +560,7 @@ int snd_timer_stop(struct snd_timer_instance *timeri) |
2488 |
+ unsigned long flags; |
2489 |
+ int err; |
2490 |
+ |
2491 |
+- err = _snd_timer_stop(timeri, 0, SNDRV_TIMER_EVENT_STOP); |
2492 |
++ err = _snd_timer_stop(timeri, SNDRV_TIMER_EVENT_STOP); |
2493 |
+ if (err < 0) |
2494 |
+ return err; |
2495 |
+ timer = timeri->timer; |
2496 |
+@@ -571,10 +590,15 @@ int snd_timer_continue(struct snd_timer_instance *timeri) |
2497 |
+ if (! timer) |
2498 |
+ return -EINVAL; |
2499 |
+ spin_lock_irqsave(&timer->lock, flags); |
2500 |
++ if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING) { |
2501 |
++ result = -EBUSY; |
2502 |
++ goto unlock; |
2503 |
++ } |
2504 |
+ if (!timeri->cticks) |
2505 |
+ timeri->cticks = 1; |
2506 |
+ timeri->pticks = 0; |
2507 |
+ result = snd_timer_start1(timer, timeri, timer->sticks); |
2508 |
++ unlock: |
2509 |
+ spin_unlock_irqrestore(&timer->lock, flags); |
2510 |
+ snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_CONTINUE); |
2511 |
+ return result; |
2512 |
+@@ -585,7 +609,7 @@ int snd_timer_continue(struct snd_timer_instance *timeri) |
2513 |
+ */ |
2514 |
+ int snd_timer_pause(struct snd_timer_instance * timeri) |
2515 |
+ { |
2516 |
+- return _snd_timer_stop(timeri, 0, SNDRV_TIMER_EVENT_PAUSE); |
2517 |
++ return _snd_timer_stop(timeri, SNDRV_TIMER_EVENT_PAUSE); |
2518 |
+ } |
2519 |
+ |
2520 |
+ /* |
2521 |
+@@ -702,8 +726,8 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) |
2522 |
+ ti->cticks = ti->ticks; |
2523 |
+ } else { |
2524 |
+ ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING; |
2525 |
+- if (--timer->running) |
2526 |
+- list_del_init(&ti->active_list); |
2527 |
++ --timer->running; |
2528 |
++ list_del_init(&ti->active_list); |
2529 |
+ } |
2530 |
+ if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) || |
2531 |
+ (ti->flags & SNDRV_TIMER_IFLG_FAST)) |
2532 |
+diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c |
2533 |
+index 915b4d7fbb23..8946cef245fc 100644 |
2534 |
+--- a/sound/drivers/dummy.c |
2535 |
++++ b/sound/drivers/dummy.c |
2536 |
+@@ -109,6 +109,9 @@ struct dummy_timer_ops { |
2537 |
+ snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *); |
2538 |
+ }; |
2539 |
+ |
2540 |
++#define get_dummy_ops(substream) \ |
2541 |
++ (*(const struct dummy_timer_ops **)(substream)->runtime->private_data) |
2542 |
++ |
2543 |
+ struct dummy_model { |
2544 |
+ const char *name; |
2545 |
+ int (*playback_constraints)(struct snd_pcm_runtime *runtime); |
2546 |
+@@ -137,7 +140,6 @@ struct snd_dummy { |
2547 |
+ int iobox; |
2548 |
+ struct snd_kcontrol *cd_volume_ctl; |
2549 |
+ struct snd_kcontrol *cd_switch_ctl; |
2550 |
+- const struct dummy_timer_ops *timer_ops; |
2551 |
+ }; |
2552 |
+ |
2553 |
+ /* |
2554 |
+@@ -231,6 +233,8 @@ struct dummy_model *dummy_models[] = { |
2555 |
+ */ |
2556 |
+ |
2557 |
+ struct dummy_systimer_pcm { |
2558 |
++ /* ops must be the first item */ |
2559 |
++ const struct dummy_timer_ops *timer_ops; |
2560 |
+ spinlock_t lock; |
2561 |
+ struct timer_list timer; |
2562 |
+ unsigned long base_time; |
2563 |
+@@ -368,6 +372,8 @@ static struct dummy_timer_ops dummy_systimer_ops = { |
2564 |
+ */ |
2565 |
+ |
2566 |
+ struct dummy_hrtimer_pcm { |
2567 |
++ /* ops must be the first item */ |
2568 |
++ const struct dummy_timer_ops *timer_ops; |
2569 |
+ ktime_t base_time; |
2570 |
+ ktime_t period_time; |
2571 |
+ atomic_t running; |
2572 |
+@@ -494,31 +500,25 @@ static struct dummy_timer_ops dummy_hrtimer_ops = { |
2573 |
+ |
2574 |
+ static int dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
2575 |
+ { |
2576 |
+- struct snd_dummy *dummy = snd_pcm_substream_chip(substream); |
2577 |
+- |
2578 |
+ switch (cmd) { |
2579 |
+ case SNDRV_PCM_TRIGGER_START: |
2580 |
+ case SNDRV_PCM_TRIGGER_RESUME: |
2581 |
+- return dummy->timer_ops->start(substream); |
2582 |
++ return get_dummy_ops(substream)->start(substream); |
2583 |
+ case SNDRV_PCM_TRIGGER_STOP: |
2584 |
+ case SNDRV_PCM_TRIGGER_SUSPEND: |
2585 |
+- return dummy->timer_ops->stop(substream); |
2586 |
++ return get_dummy_ops(substream)->stop(substream); |
2587 |
+ } |
2588 |
+ return -EINVAL; |
2589 |
+ } |
2590 |
+ |
2591 |
+ static int dummy_pcm_prepare(struct snd_pcm_substream *substream) |
2592 |
+ { |
2593 |
+- struct snd_dummy *dummy = snd_pcm_substream_chip(substream); |
2594 |
+- |
2595 |
+- return dummy->timer_ops->prepare(substream); |
2596 |
++ return get_dummy_ops(substream)->prepare(substream); |
2597 |
+ } |
2598 |
+ |
2599 |
+ static snd_pcm_uframes_t dummy_pcm_pointer(struct snd_pcm_substream *substream) |
2600 |
+ { |
2601 |
+- struct snd_dummy *dummy = snd_pcm_substream_chip(substream); |
2602 |
+- |
2603 |
+- return dummy->timer_ops->pointer(substream); |
2604 |
++ return get_dummy_ops(substream)->pointer(substream); |
2605 |
+ } |
2606 |
+ |
2607 |
+ static struct snd_pcm_hardware dummy_pcm_hardware = { |
2608 |
+@@ -564,17 +564,19 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream) |
2609 |
+ struct snd_dummy *dummy = snd_pcm_substream_chip(substream); |
2610 |
+ struct dummy_model *model = dummy->model; |
2611 |
+ struct snd_pcm_runtime *runtime = substream->runtime; |
2612 |
++ const struct dummy_timer_ops *ops; |
2613 |
+ int err; |
2614 |
+ |
2615 |
+- dummy->timer_ops = &dummy_systimer_ops; |
2616 |
++ ops = &dummy_systimer_ops; |
2617 |
+ #ifdef CONFIG_HIGH_RES_TIMERS |
2618 |
+ if (hrtimer) |
2619 |
+- dummy->timer_ops = &dummy_hrtimer_ops; |
2620 |
++ ops = &dummy_hrtimer_ops; |
2621 |
+ #endif |
2622 |
+ |
2623 |
+- err = dummy->timer_ops->create(substream); |
2624 |
++ err = ops->create(substream); |
2625 |
+ if (err < 0) |
2626 |
+ return err; |
2627 |
++ get_dummy_ops(substream) = ops; |
2628 |
+ |
2629 |
+ runtime->hw = dummy->pcm_hw; |
2630 |
+ if (substream->pcm->device & 1) { |
2631 |
+@@ -596,7 +598,7 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream) |
2632 |
+ err = model->capture_constraints(substream->runtime); |
2633 |
+ } |
2634 |
+ if (err < 0) { |
2635 |
+- dummy->timer_ops->free(substream); |
2636 |
++ get_dummy_ops(substream)->free(substream); |
2637 |
+ return err; |
2638 |
+ } |
2639 |
+ return 0; |
2640 |
+@@ -604,8 +606,7 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream) |
2641 |
+ |
2642 |
+ static int dummy_pcm_close(struct snd_pcm_substream *substream) |
2643 |
+ { |
2644 |
+- struct snd_dummy *dummy = snd_pcm_substream_chip(substream); |
2645 |
+- dummy->timer_ops->free(substream); |
2646 |
++ get_dummy_ops(substream)->free(substream); |
2647 |
+ return 0; |
2648 |
+ } |
2649 |
+ |
2650 |
+diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c |
2651 |
+index 3c90743fa50b..eef182bea2ad 100644 |
2652 |
+--- a/sound/pci/hda/patch_cirrus.c |
2653 |
++++ b/sound/pci/hda/patch_cirrus.c |
2654 |
+@@ -617,6 +617,7 @@ enum { |
2655 |
+ CS4208_MAC_AUTO, |
2656 |
+ CS4208_MBA6, |
2657 |
+ CS4208_MBP11, |
2658 |
++ CS4208_MACMINI, |
2659 |
+ CS4208_GPIO0, |
2660 |
+ }; |
2661 |
+ |
2662 |
+@@ -624,6 +625,7 @@ static const struct hda_model_fixup cs4208_models[] = { |
2663 |
+ { .id = CS4208_GPIO0, .name = "gpio0" }, |
2664 |
+ { .id = CS4208_MBA6, .name = "mba6" }, |
2665 |
+ { .id = CS4208_MBP11, .name = "mbp11" }, |
2666 |
++ { .id = CS4208_MACMINI, .name = "macmini" }, |
2667 |
+ {} |
2668 |
+ }; |
2669 |
+ |
2670 |
+@@ -635,6 +637,7 @@ static const struct snd_pci_quirk cs4208_fixup_tbl[] = { |
2671 |
+ /* codec SSID matching */ |
2672 |
+ static const struct snd_pci_quirk cs4208_mac_fixup_tbl[] = { |
2673 |
+ SND_PCI_QUIRK(0x106b, 0x5e00, "MacBookPro 11,2", CS4208_MBP11), |
2674 |
++ SND_PCI_QUIRK(0x106b, 0x6c00, "MacMini 7,1", CS4208_MACMINI), |
2675 |
+ SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6), |
2676 |
+ SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6), |
2677 |
+ SND_PCI_QUIRK(0x106b, 0x7b00, "MacBookPro 12,1", CS4208_MBP11), |
2678 |
+@@ -667,6 +670,24 @@ static void cs4208_fixup_mac(struct hda_codec *codec, |
2679 |
+ snd_hda_apply_fixup(codec, action); |
2680 |
+ } |
2681 |
+ |
2682 |
++/* MacMini 7,1 has the inverted jack detection */ |
2683 |
++static void cs4208_fixup_macmini(struct hda_codec *codec, |
2684 |
++ const struct hda_fixup *fix, int action) |
2685 |
++{ |
2686 |
++ static const struct hda_pintbl pincfgs[] = { |
2687 |
++ { 0x18, 0x00ab9150 }, /* mic (audio-in) jack: disable detect */ |
2688 |
++ { 0x21, 0x004be140 }, /* SPDIF: disable detect */ |
2689 |
++ { } |
2690 |
++ }; |
2691 |
++ |
2692 |
++ if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
2693 |
++ /* HP pin (0x10) has an inverted detection */ |
2694 |
++ codec->inv_jack_detect = 1; |
2695 |
++ /* disable the bogus Mic and SPDIF jack detections */ |
2696 |
++ snd_hda_apply_pincfgs(codec, pincfgs); |
2697 |
++ } |
2698 |
++} |
2699 |
++ |
2700 |
+ static int cs4208_spdif_sw_put(struct snd_kcontrol *kcontrol, |
2701 |
+ struct snd_ctl_elem_value *ucontrol) |
2702 |
+ { |
2703 |
+@@ -710,6 +731,12 @@ static const struct hda_fixup cs4208_fixups[] = { |
2704 |
+ .chained = true, |
2705 |
+ .chain_id = CS4208_GPIO0, |
2706 |
+ }, |
2707 |
++ [CS4208_MACMINI] = { |
2708 |
++ .type = HDA_FIXUP_FUNC, |
2709 |
++ .v.func = cs4208_fixup_macmini, |
2710 |
++ .chained = true, |
2711 |
++ .chain_id = CS4208_GPIO0, |
2712 |
++ }, |
2713 |
+ [CS4208_GPIO0] = { |
2714 |
+ .type = HDA_FIXUP_FUNC, |
2715 |
+ .v.func = cs4208_fixup_gpio0, |
2716 |
+diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c |
2717 |
+index 611110a3f1a4..55ce39df9cd7 100644 |
2718 |
+--- a/sound/pci/hda/patch_hdmi.c |
2719 |
++++ b/sound/pci/hda/patch_hdmi.c |
2720 |
+@@ -426,7 +426,8 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, |
2721 |
+ eld = &per_pin->sink_eld; |
2722 |
+ |
2723 |
+ mutex_lock(&per_pin->lock); |
2724 |
+- if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) { |
2725 |
++ if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) || |
2726 |
++ eld->eld_size > ELD_MAX_SIZE) { |
2727 |
+ mutex_unlock(&per_pin->lock); |
2728 |
+ snd_BUG(); |
2729 |
+ return -EINVAL; |
2730 |
+diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c |
2731 |
+index bd0b986f7d50..eeb5b68e9e3e 100644 |
2732 |
+--- a/sound/pci/hda/patch_realtek.c |
2733 |
++++ b/sound/pci/hda/patch_realtek.c |
2734 |
+@@ -2266,6 +2266,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
2735 |
+ SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
2736 |
+ SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), |
2737 |
+ SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), |
2738 |
++ SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP), |
2739 |
+ |
2740 |
+ /* All Apple entries are in codec SSIDs */ |
2741 |
+ SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
2742 |
+diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c |
2743 |
+index e28704e1274a..431a89b75ff3 100644 |
2744 |
+--- a/sound/soc/soc-pcm.c |
2745 |
++++ b/sound/soc/soc-pcm.c |
2746 |
+@@ -1404,7 +1404,8 @@ int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) |
2747 |
+ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && |
2748 |
+ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && |
2749 |
+ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) && |
2750 |
+- (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) |
2751 |
++ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && |
2752 |
++ (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) |
2753 |
+ continue; |
2754 |
+ |
2755 |
+ dev_dbg(be->dev, "ASoC: hw_free BE %s\n", |
2756 |
+diff --git a/sound/usb/midi.c b/sound/usb/midi.c |
2757 |
+index 9123fc518f07..424c1e874bd3 100644 |
2758 |
+--- a/sound/usb/midi.c |
2759 |
++++ b/sound/usb/midi.c |
2760 |
+@@ -2365,7 +2365,6 @@ int snd_usbmidi_create(struct snd_card *card, |
2761 |
+ else |
2762 |
+ err = snd_usbmidi_create_endpoints(umidi, endpoints); |
2763 |
+ if (err < 0) { |
2764 |
+- snd_usbmidi_free(umidi); |
2765 |
+ return err; |
2766 |
+ } |
2767 |
+ |
2768 |
+diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c |
2769 |
+index 901f87dea827..9a599b1bc6ba 100644 |
2770 |
+--- a/sound/usb/quirks.c |
2771 |
++++ b/sound/usb/quirks.c |
2772 |
+@@ -1128,8 +1128,12 @@ void snd_usb_set_interface_quirk(struct usb_device *dev) |
2773 |
+ * "Playback Design" products need a 50ms delay after setting the |
2774 |
+ * USB interface. |
2775 |
+ */ |
2776 |
+- if (le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) |
2777 |
++ switch (le16_to_cpu(dev->descriptor.idVendor)) { |
2778 |
++ case 0x23ba: /* Playback Design */ |
2779 |
++ case 0x0644: /* TEAC Corp. */ |
2780 |
+ mdelay(50); |
2781 |
++ break; |
2782 |
++ } |
2783 |
+ } |
2784 |
+ |
2785 |
+ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, |
2786 |
+@@ -1144,6 +1148,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, |
2787 |
+ (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) |
2788 |
+ mdelay(20); |
2789 |
+ |
2790 |
++ /* |
2791 |
++ * "TEAC Corp." products need a 20ms delay after each |
2792 |
++ * class compliant request |
2793 |
++ */ |
2794 |
++ if ((le16_to_cpu(dev->descriptor.idVendor) == 0x0644) && |
2795 |
++ (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) |
2796 |
++ mdelay(20); |
2797 |
++ |
2798 |
+ /* Marantz/Denon devices with USB DAC functionality need a delay |
2799 |
+ * after each class compliant request |
2800 |
+ */ |