/[linux-patches]/genpatches-2.6/tags/3.0-30/1008_linux-3.0.9.patch
Gentoo

Contents of /genpatches-2.6/tags/3.0-30/1008_linux-3.0.9.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2206 - (hide annotations) (download)
Mon Sep 17 18:58:14 2012 UTC (5 years, 9 months ago) by mpagano
File size: 377426 byte(s)
3.0-30 release
1 psomas 2009 diff --git a/Documentation/hwspinlock.txt b/Documentation/hwspinlock.txt
2     index 7dcd1a4..6996681 100644
3     --- a/Documentation/hwspinlock.txt
4     +++ b/Documentation/hwspinlock.txt
5     @@ -39,23 +39,20 @@ independent, drivers.
6     in case an unused hwspinlock isn't available. Users of this
7     API will usually want to communicate the lock's id to the remote core
8     before it can be used to achieve synchronization.
9     - Can be called from an atomic context (this function will not sleep) but
10     - not from within interrupt context.
11     + Should be called from a process context (might sleep).
12    
13     struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
14     - assign a specific hwspinlock id and return its address, or NULL
15     if that hwspinlock is already in use. Usually board code will
16     be calling this function in order to reserve specific hwspinlock
17     ids for predefined purposes.
18     - Can be called from an atomic context (this function will not sleep) but
19     - not from within interrupt context.
20     + Should be called from a process context (might sleep).
21    
22     int hwspin_lock_free(struct hwspinlock *hwlock);
23     - free a previously-assigned hwspinlock; returns 0 on success, or an
24     appropriate error code on failure (e.g. -EINVAL if the hwspinlock
25     is already free).
26     - Can be called from an atomic context (this function will not sleep) but
27     - not from within interrupt context.
28     + Should be called from a process context (might sleep).
29    
30     int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout);
31     - lock a previously-assigned hwspinlock with a timeout limit (specified in
32     @@ -232,15 +229,14 @@ int hwspinlock_example2(void)
33    
34     int hwspin_lock_register(struct hwspinlock *hwlock);
35     - to be called from the underlying platform-specific implementation, in
36     - order to register a new hwspinlock instance. Can be called from an atomic
37     - context (this function will not sleep) but not from within interrupt
38     - context. Returns 0 on success, or appropriate error code on failure.
39     + order to register a new hwspinlock instance. Should be called from
40     + a process context (this function might sleep).
41     + Returns 0 on success, or appropriate error code on failure.
42    
43     struct hwspinlock *hwspin_lock_unregister(unsigned int id);
44     - to be called from the underlying vendor-specific implementation, in order
45     to unregister an existing (and unused) hwspinlock instance.
46     - Can be called from an atomic context (will not sleep) but not from
47     - within interrupt context.
48     + Should be called from a process context (this function might sleep).
49     Returns the address of hwspinlock on success, or NULL on error (e.g.
50     if the hwspinlock is sill in use).
51    
52     diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
53     index b24875b..6ade987 100644
54     --- a/Documentation/power/runtime_pm.txt
55     +++ b/Documentation/power/runtime_pm.txt
56     @@ -708,6 +708,16 @@ will behave normally, not taking the autosuspend delay into account.
57     Similarly, if the power.use_autosuspend field isn't set then the autosuspend
58     helper functions will behave just like the non-autosuspend counterparts.
59    
60     +Under some circumstances a driver or subsystem may want to prevent a device
61     +from autosuspending immediately, even though the usage counter is zero and the
62     +autosuspend delay time has expired. If the ->runtime_suspend() callback
63     +returns -EAGAIN or -EBUSY, and if the next autosuspend delay expiration time is
64     +in the future (as it normally would be if the callback invoked
65     +pm_runtime_mark_last_busy()), the PM core will automatically reschedule the
66     +autosuspend. The ->runtime_suspend() callback can't do this rescheduling
67     +itself because no suspend requests of any kind are accepted while the device is
68     +suspending (i.e., while the callback is running).
69     +
70     The implementation is well suited for asynchronous use in interrupt contexts.
71     However such use inevitably involves races, because the PM core can't
72     synchronize ->runtime_suspend() callbacks with the arrival of I/O requests.
73     diff --git a/Documentation/stable_kernel_rules.txt b/Documentation/stable_kernel_rules.txt
74     index e213f45..21fd05c 100644
75     --- a/Documentation/stable_kernel_rules.txt
76     +++ b/Documentation/stable_kernel_rules.txt
77     @@ -24,10 +24,10 @@ Rules on what kind of patches are accepted, and which ones are not, into the
78     Procedure for submitting patches to the -stable tree:
79    
80     - Send the patch, after verifying that it follows the above rules, to
81     - stable@kernel.org. You must note the upstream commit ID in the changelog
82     - of your submission.
83     + stable@vger.kernel.org. You must note the upstream commit ID in the
84     + changelog of your submission.
85     - To have the patch automatically included in the stable tree, add the tag
86     - Cc: stable@kernel.org
87     + Cc: stable@vger.kernel.org
88     in the sign-off area. Once the patch is merged it will be applied to
89     the stable tree without anything else needing to be done by the author
90     or subsystem maintainer.
91     @@ -35,10 +35,10 @@ Procedure for submitting patches to the -stable tree:
92     cherry-picked than this can be specified in the following format in
93     the sign-off area:
94    
95     - Cc: <stable@kernel.org> # .32.x: a1f84a3: sched: Check for idle
96     - Cc: <stable@kernel.org> # .32.x: 1b9508f: sched: Rate-limit newidle
97     - Cc: <stable@kernel.org> # .32.x: fd21073: sched: Fix affinity logic
98     - Cc: <stable@kernel.org> # .32.x
99     + Cc: <stable@vger.kernel.org> # .32.x: a1f84a3: sched: Check for idle
100     + Cc: <stable@vger.kernel.org> # .32.x: 1b9508f: sched: Rate-limit newidle
101     + Cc: <stable@vger.kernel.org> # .32.x: fd21073: sched: Fix affinity logic
102     + Cc: <stable@vger.kernel.org> # .32.x
103     Signed-off-by: Ingo Molnar <mingo@elte.hu>
104    
105     The tag sequence has the meaning of:
106     diff --git a/MAINTAINERS b/MAINTAINERS
107     index 187282d..34e2418 100644
108     --- a/MAINTAINERS
109     +++ b/MAINTAINERS
110     @@ -1221,7 +1221,7 @@ F: Documentation/aoe/
111     F: drivers/block/aoe/
112    
113     ATHEROS ATH GENERIC UTILITIES
114     -M: "Luis R. Rodriguez" <lrodriguez@atheros.com>
115     +M: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>
116     L: linux-wireless@vger.kernel.org
117     S: Supported
118     F: drivers/net/wireless/ath/*
119     @@ -1229,7 +1229,7 @@ F: drivers/net/wireless/ath/*
120     ATHEROS ATH5K WIRELESS DRIVER
121     M: Jiri Slaby <jirislaby@gmail.com>
122     M: Nick Kossifidis <mickflemm@gmail.com>
123     -M: "Luis R. Rodriguez" <lrodriguez@atheros.com>
124     +M: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>
125     M: Bob Copeland <me@bobcopeland.com>
126     L: linux-wireless@vger.kernel.org
127     L: ath5k-devel@lists.ath5k.org
128     @@ -1238,10 +1238,10 @@ S: Maintained
129     F: drivers/net/wireless/ath/ath5k/
130    
131     ATHEROS ATH9K WIRELESS DRIVER
132     -M: "Luis R. Rodriguez" <lrodriguez@atheros.com>
133     -M: Jouni Malinen <jmalinen@atheros.com>
134     -M: Vasanthakumar Thiagarajan <vasanth@atheros.com>
135     -M: Senthil Balasubramanian <senthilkumar@atheros.com>
136     +M: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>
137     +M: Jouni Malinen <jouni@qca.qualcomm.com>
138     +M: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
139     +M: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
140     L: linux-wireless@vger.kernel.org
141     L: ath9k-devel@lists.ath9k.org
142     W: http://wireless.kernel.org/en/users/Drivers/ath9k
143     @@ -1269,7 +1269,7 @@ F: drivers/input/misc/ati_remote2.c
144     ATLX ETHERNET DRIVERS
145     M: Jay Cliburn <jcliburn@gmail.com>
146     M: Chris Snook <chris.snook@gmail.com>
147     -M: Jie Yang <jie.yang@atheros.com>
148     +M: Jie Yang <yangjie@qca.qualcomm.com>
149     L: netdev@vger.kernel.org
150     W: http://sourceforge.net/projects/atl1
151     W: http://atl1.sourceforge.net
152     diff --git a/Makefile b/Makefile
153     index 9f6e3cd..438c11a 100644
154     --- a/Makefile
155     +++ b/Makefile
156     @@ -1,6 +1,6 @@
157     VERSION = 3
158     PATCHLEVEL = 0
159     -SUBLEVEL = 8
160     +SUBLEVEL = 9
161     EXTRAVERSION =
162     NAME = Sneaky Weasel
163    
164     diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
165     index 1da23bb..8aa104a 100644
166     --- a/arch/arm/mach-ux500/cpu.c
167     +++ b/arch/arm/mach-ux500/cpu.c
168     @@ -99,7 +99,27 @@ static void ux500_l2x0_inv_all(void)
169     ux500_cache_sync();
170     }
171    
172     -static int ux500_l2x0_init(void)
173     +static int __init ux500_l2x0_unlock(void)
174     +{
175     + int i;
176     +
177     + /*
178     + * Unlock Data and Instruction Lock if locked. Ux500 U-Boot versions
179     + * apparently locks both caches before jumping to the kernel. The
180     + * l2x0 core will not touch the unlock registers if the l2x0 is
181     + * already enabled, so we do it right here instead. The PL310 has
182     + * 8 sets of registers, one per possible CPU.
183     + */
184     + for (i = 0; i < 8; i++) {
185     + writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_D_BASE +
186     + i * L2X0_LOCKDOWN_STRIDE);
187     + writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_I_BASE +
188     + i * L2X0_LOCKDOWN_STRIDE);
189     + }
190     + return 0;
191     +}
192     +
193     +static int __init ux500_l2x0_init(void)
194     {
195     if (cpu_is_u5500())
196     l2x0_base = __io_address(U5500_L2CC_BASE);
197     @@ -108,6 +128,9 @@ static int ux500_l2x0_init(void)
198     else
199     ux500_unknown_soc();
200    
201     + /* Unlock before init */
202     + ux500_l2x0_unlock();
203     +
204     /* 64KB way size, 8 way associativity, force WA */
205     l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
206    
207     diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
208     index ebbce33..4509956 100644
209     --- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
210     +++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
211     @@ -89,11 +89,11 @@ typedef u64 iomux_v3_cfg_t;
212     #define PAD_CTL_HYS (1 << 8)
213    
214     #define PAD_CTL_PKE (1 << 7)
215     -#define PAD_CTL_PUE (1 << 6)
216     -#define PAD_CTL_PUS_100K_DOWN (0 << 4)
217     -#define PAD_CTL_PUS_47K_UP (1 << 4)
218     -#define PAD_CTL_PUS_100K_UP (2 << 4)
219     -#define PAD_CTL_PUS_22K_UP (3 << 4)
220     +#define PAD_CTL_PUE (1 << 6 | PAD_CTL_PKE)
221     +#define PAD_CTL_PUS_100K_DOWN (0 << 4 | PAD_CTL_PUE)
222     +#define PAD_CTL_PUS_47K_UP (1 << 4 | PAD_CTL_PUE)
223     +#define PAD_CTL_PUS_100K_UP (2 << 4 | PAD_CTL_PUE)
224     +#define PAD_CTL_PUS_22K_UP (3 << 4 | PAD_CTL_PUE)
225    
226     #define PAD_CTL_ODE (1 << 3)
227    
228     diff --git a/arch/powerpc/include/asm/sparsemem.h b/arch/powerpc/include/asm/sparsemem.h
229     index 54a47ea..0c5fa31 100644
230     --- a/arch/powerpc/include/asm/sparsemem.h
231     +++ b/arch/powerpc/include/asm/sparsemem.h
232     @@ -16,7 +16,7 @@
233     #endif /* CONFIG_SPARSEMEM */
234    
235     #ifdef CONFIG_MEMORY_HOTPLUG
236     -extern void create_section_mapping(unsigned long start, unsigned long end);
237     +extern int create_section_mapping(unsigned long start, unsigned long end);
238     extern int remove_section_mapping(unsigned long start, unsigned long end);
239     #ifdef CONFIG_NUMA
240     extern int hot_add_scn_to_nid(unsigned long scn_addr);
241     diff --git a/arch/powerpc/mm/gup.c b/arch/powerpc/mm/gup.c
242     index fec1320..d7efdbf 100644
243     --- a/arch/powerpc/mm/gup.c
244     +++ b/arch/powerpc/mm/gup.c
245     @@ -16,16 +16,6 @@
246    
247     #ifdef __HAVE_ARCH_PTE_SPECIAL
248    
249     -static inline void get_huge_page_tail(struct page *page)
250     -{
251     - /*
252     - * __split_huge_page_refcount() cannot run
253     - * from under us.
254     - */
255     - VM_BUG_ON(atomic_read(&page->_count) < 0);
256     - atomic_inc(&page->_count);
257     -}
258     -
259     /*
260     * The performance critical leaf functions are made noinline otherwise gcc
261     * inlines everything into a single function which results in too much
262     @@ -57,8 +47,6 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
263     put_page(page);
264     return 0;
265     }
266     - if (PageTail(page))
267     - get_huge_page_tail(page);
268     pages[*nr] = page;
269     (*nr)++;
270    
271     diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
272     index 26b2872..07f9e9f 100644
273     --- a/arch/powerpc/mm/hash_utils_64.c
274     +++ b/arch/powerpc/mm/hash_utils_64.c
275     @@ -534,11 +534,11 @@ static unsigned long __init htab_get_table_size(void)
276     }
277    
278     #ifdef CONFIG_MEMORY_HOTPLUG
279     -void create_section_mapping(unsigned long start, unsigned long end)
280     +int create_section_mapping(unsigned long start, unsigned long end)
281     {
282     - BUG_ON(htab_bolt_mapping(start, end, __pa(start),
283     + return htab_bolt_mapping(start, end, __pa(start),
284     pgprot_val(PAGE_KERNEL), mmu_linear_psize,
285     - mmu_kernel_ssize));
286     + mmu_kernel_ssize);
287     }
288    
289     int remove_section_mapping(unsigned long start, unsigned long end)
290     diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
291     index 0b9a5c1..da5eb38 100644
292     --- a/arch/powerpc/mm/hugetlbpage.c
293     +++ b/arch/powerpc/mm/hugetlbpage.c
294     @@ -390,7 +390,7 @@ static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long add
295     {
296     unsigned long mask;
297     unsigned long pte_end;
298     - struct page *head, *page;
299     + struct page *head, *page, *tail;
300     pte_t pte;
301     int refs;
302    
303     @@ -413,6 +413,7 @@ static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long add
304     head = pte_page(pte);
305    
306     page = head + ((addr & (sz-1)) >> PAGE_SHIFT);
307     + tail = page;
308     do {
309     VM_BUG_ON(compound_head(page) != head);
310     pages[*nr] = page;
311     @@ -428,10 +429,20 @@ static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long add
312    
313     if (unlikely(pte_val(pte) != pte_val(*ptep))) {
314     /* Could be optimized better */
315     - while (*nr) {
316     - put_page(page);
317     - (*nr)--;
318     - }
319     + *nr -= refs;
320     + while (refs--)
321     + put_page(head);
322     + return 0;
323     + }
324     +
325     + /*
326     + * Any tail page need their mapcount reference taken before we
327     + * return.
328     + */
329     + while (refs--) {
330     + if (PageTail(tail))
331     + get_huge_page_tail(tail);
332     + tail++;
333     }
334    
335     return 1;
336     diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
337     index 29d4dde..278ec8e 100644
338     --- a/arch/powerpc/mm/mem.c
339     +++ b/arch/powerpc/mm/mem.c
340     @@ -123,7 +123,8 @@ int arch_add_memory(int nid, u64 start, u64 size)
341     pgdata = NODE_DATA(nid);
342    
343     start = (unsigned long)__va(start);
344     - create_section_mapping(start, start + size);
345     + if (create_section_mapping(start, start + size))
346     + return -EINVAL;
347    
348     /* this should work for most non-highmem platforms */
349     zone = pgdata->node_zones;
350     diff --git a/arch/powerpc/mm/mmu_context_hash64.c b/arch/powerpc/mm/mmu_context_hash64.c
351     index 3bafc3d..4ff587e 100644
352     --- a/arch/powerpc/mm/mmu_context_hash64.c
353     +++ b/arch/powerpc/mm/mmu_context_hash64.c
354     @@ -136,8 +136,8 @@ int use_cop(unsigned long acop, struct mm_struct *mm)
355     if (!mm || !acop)
356     return -EINVAL;
357    
358     - /* We need to make sure mm_users doesn't change */
359     - down_read(&mm->mmap_sem);
360     + /* The page_table_lock ensures mm_users won't change under us */
361     + spin_lock(&mm->page_table_lock);
362     spin_lock(mm->context.cop_lockp);
363    
364     if (mm->context.cop_pid == COP_PID_NONE) {
365     @@ -164,7 +164,7 @@ int use_cop(unsigned long acop, struct mm_struct *mm)
366    
367     out:
368     spin_unlock(mm->context.cop_lockp);
369     - up_read(&mm->mmap_sem);
370     + spin_unlock(&mm->page_table_lock);
371    
372     return ret;
373     }
374     @@ -185,8 +185,8 @@ void drop_cop(unsigned long acop, struct mm_struct *mm)
375     if (WARN_ON_ONCE(!mm))
376     return;
377    
378     - /* We need to make sure mm_users doesn't change */
379     - down_read(&mm->mmap_sem);
380     + /* The page_table_lock ensures mm_users won't change under us */
381     + spin_lock(&mm->page_table_lock);
382     spin_lock(mm->context.cop_lockp);
383    
384     mm->context.acop &= ~acop;
385     @@ -213,7 +213,7 @@ void drop_cop(unsigned long acop, struct mm_struct *mm)
386     }
387    
388     spin_unlock(mm->context.cop_lockp);
389     - up_read(&mm->mmap_sem);
390     + spin_unlock(&mm->page_table_lock);
391     }
392     EXPORT_SYMBOL_GPL(drop_cop);
393    
394     diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
395     index 2164006..2c1ae7a 100644
396     --- a/arch/powerpc/mm/numa.c
397     +++ b/arch/powerpc/mm/numa.c
398     @@ -1214,11 +1214,12 @@ int hot_add_node_scn_to_nid(unsigned long scn_addr)
399     break;
400     }
401    
402     - of_node_put(memory);
403     if (nid >= 0)
404     break;
405     }
406    
407     + of_node_put(memory);
408     +
409     return nid;
410     }
411    
412     diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
413     index 57ceb92..82766e5 100644
414     --- a/arch/powerpc/platforms/pseries/dlpar.c
415     +++ b/arch/powerpc/platforms/pseries/dlpar.c
416     @@ -112,6 +112,7 @@ void dlpar_free_cc_nodes(struct device_node *dn)
417     dlpar_free_one_cc_node(dn);
418     }
419    
420     +#define COMPLETE 0
421     #define NEXT_SIBLING 1
422     #define NEXT_CHILD 2
423     #define NEXT_PROPERTY 3
424     @@ -158,6 +159,9 @@ struct device_node *dlpar_configure_connector(u32 drc_index)
425     spin_unlock(&rtas_data_buf_lock);
426    
427     switch (rc) {
428     + case COMPLETE:
429     + break;
430     +
431     case NEXT_SIBLING:
432     dn = dlpar_parse_cc_node(ccwa);
433     if (!dn)
434     diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
435     index 46b55cf..3608704 100644
436     --- a/arch/powerpc/platforms/pseries/eeh.c
437     +++ b/arch/powerpc/platforms/pseries/eeh.c
438     @@ -1338,7 +1338,7 @@ static const struct file_operations proc_eeh_operations = {
439     static int __init eeh_init_proc(void)
440     {
441     if (machine_is(pseries))
442     - proc_create("ppc64/eeh", 0, NULL, &proc_eeh_operations);
443     + proc_create("powerpc/eeh", 0, NULL, &proc_eeh_operations);
444     return 0;
445     }
446     __initcall(eeh_init_proc);
447     diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
448     index ef86ad2..ae0e14b 100644
449     --- a/arch/s390/kernel/ptrace.c
450     +++ b/arch/s390/kernel/ptrace.c
451     @@ -47,29 +47,31 @@ enum s390_regset {
452    
453     void update_per_regs(struct task_struct *task)
454     {
455     - static const struct per_regs per_single_step = {
456     - .control = PER_EVENT_IFETCH,
457     - .start = 0,
458     - .end = PSW_ADDR_INSN,
459     - };
460     struct pt_regs *regs = task_pt_regs(task);
461     struct thread_struct *thread = &task->thread;
462     - const struct per_regs *new;
463     - struct per_regs old;
464     + struct per_regs old, new;
465    
466     - /* TIF_SINGLE_STEP overrides the user specified PER registers. */
467     - new = test_tsk_thread_flag(task, TIF_SINGLE_STEP) ?
468     - &per_single_step : &thread->per_user;
469     + /* Copy user specified PER registers */
470     + new.control = thread->per_user.control;
471     + new.start = thread->per_user.start;
472     + new.end = thread->per_user.end;
473     +
474     + /* merge TIF_SINGLE_STEP into user specified PER registers. */
475     + if (test_tsk_thread_flag(task, TIF_SINGLE_STEP)) {
476     + new.control |= PER_EVENT_IFETCH;
477     + new.start = 0;
478     + new.end = PSW_ADDR_INSN;
479     + }
480    
481     /* Take care of the PER enablement bit in the PSW. */
482     - if (!(new->control & PER_EVENT_MASK)) {
483     + if (!(new.control & PER_EVENT_MASK)) {
484     regs->psw.mask &= ~PSW_MASK_PER;
485     return;
486     }
487     regs->psw.mask |= PSW_MASK_PER;
488     __ctl_store(old, 9, 11);
489     - if (memcmp(new, &old, sizeof(struct per_regs)) != 0)
490     - __ctl_load(*new, 9, 11);
491     + if (memcmp(&new, &old, sizeof(struct per_regs)) != 0)
492     + __ctl_load(new, 9, 11);
493     }
494    
495     void user_enable_single_step(struct task_struct *task)
496     diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
497     index 67345ae..2ada634 100644
498     --- a/arch/s390/kvm/kvm-s390.c
499     +++ b/arch/s390/kvm/kvm-s390.c
500     @@ -301,11 +301,17 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
501     struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
502     unsigned int id)
503     {
504     - struct kvm_vcpu *vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
505     - int rc = -ENOMEM;
506     + struct kvm_vcpu *vcpu;
507     + int rc = -EINVAL;
508     +
509     + if (id >= KVM_MAX_VCPUS)
510     + goto out;
511     +
512     + rc = -ENOMEM;
513    
514     + vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
515     if (!vcpu)
516     - goto out_nomem;
517     + goto out;
518    
519     vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
520     get_zeroed_page(GFP_KERNEL);
521     @@ -341,7 +347,7 @@ out_free_sie_block:
522     free_page((unsigned long)(vcpu->arch.sie_block));
523     out_free_cpu:
524     kfree(vcpu);
525     -out_nomem:
526     +out:
527     return ERR_PTR(rc);
528     }
529    
530     diff --git a/arch/s390/mm/gup.c b/arch/s390/mm/gup.c
531     index 45b405c..65cb06e 100644
532     --- a/arch/s390/mm/gup.c
533     +++ b/arch/s390/mm/gup.c
534     @@ -52,7 +52,7 @@ static inline int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
535     unsigned long end, int write, struct page **pages, int *nr)
536     {
537     unsigned long mask, result;
538     - struct page *head, *page;
539     + struct page *head, *page, *tail;
540     int refs;
541    
542     result = write ? 0 : _SEGMENT_ENTRY_RO;
543     @@ -64,6 +64,7 @@ static inline int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
544     refs = 0;
545     head = pmd_page(pmd);
546     page = head + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
547     + tail = page;
548     do {
549     VM_BUG_ON(compound_head(page) != head);
550     pages[*nr] = page;
551     @@ -81,6 +82,17 @@ static inline int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
552     *nr -= refs;
553     while (refs--)
554     put_page(head);
555     + return 0;
556     + }
557     +
558     + /*
559     + * Any tail page need their mapcount reference taken before we
560     + * return.
561     + */
562     + while (refs--) {
563     + if (PageTail(tail))
564     + get_huge_page_tail(tail);
565     + tail++;
566     }
567    
568     return 1;
569     diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
570     index 37a23c22..458893f 100644
571     --- a/arch/s390/mm/pgtable.c
572     +++ b/arch/s390/mm/pgtable.c
573     @@ -291,8 +291,9 @@ void page_table_free_rcu(struct mmu_gather *tlb, unsigned long *table)
574    
575     void __tlb_remove_table(void *_table)
576     {
577     - void *table = (void *)((unsigned long) _table & PAGE_MASK);
578     - unsigned type = (unsigned long) _table & ~PAGE_MASK;
579     + const unsigned long mask = (FRAG_MASK << 4) | FRAG_MASK;
580     + void *table = (void *)((unsigned long) _table & ~mask);
581     + unsigned type = (unsigned long) _table & mask;
582    
583     if (type)
584     __page_table_free_rcu(table, type);
585     diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
586     index 620f5b7..0491e40 100644
587     --- a/arch/um/drivers/ubd_kern.c
588     +++ b/arch/um/drivers/ubd_kern.c
589     @@ -513,8 +513,37 @@ __uml_exitcall(kill_io_thread);
590     static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out)
591     {
592     char *file;
593     + int fd;
594     + int err;
595     +
596     + __u32 version;
597     + __u32 align;
598     + char *backing_file;
599     + time_t mtime;
600     + unsigned long long size;
601     + int sector_size;
602     + int bitmap_offset;
603     +
604     + if (ubd_dev->file && ubd_dev->cow.file) {
605     + file = ubd_dev->cow.file;
606     +
607     + goto out;
608     + }
609    
610     - file = ubd_dev->cow.file ? ubd_dev->cow.file : ubd_dev->file;
611     + fd = os_open_file(ubd_dev->file, global_openflags, 0);
612     + if (fd < 0)
613     + return fd;
614     +
615     + err = read_cow_header(file_reader, &fd, &version, &backing_file, \
616     + &mtime, &size, &sector_size, &align, &bitmap_offset);
617     + os_close_file(fd);
618     +
619     + if(err == -EINVAL)
620     + file = ubd_dev->file;
621     + else
622     + file = backing_file;
623     +
624     +out:
625     return os_file_size(file, size_out);
626     }
627    
628     diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
629     index 4a0b7c7..244ac77 100644
630     --- a/arch/x86/include/asm/apic.h
631     +++ b/arch/x86/include/asm/apic.h
632     @@ -495,7 +495,7 @@ static inline void default_wait_for_init_deassert(atomic_t *deassert)
633     return;
634     }
635    
636     -extern struct apic *generic_bigsmp_probe(void);
637     +extern void generic_bigsmp_probe(void);
638    
639    
640     #ifdef CONFIG_X86_LOCAL_APIC
641     diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
642     index a291c40..5d62d65 100644
643     --- a/arch/x86/include/asm/uv/uv_bau.h
644     +++ b/arch/x86/include/asm/uv/uv_bau.h
645     @@ -55,6 +55,7 @@
646     #define UV_BAU_TUNABLES_DIR "sgi_uv"
647     #define UV_BAU_TUNABLES_FILE "bau_tunables"
648     #define WHITESPACE " \t\n"
649     +#define uv_mmask ((1UL << uv_hub_info->m_val) - 1)
650     #define uv_physnodeaddr(x) ((__pa((unsigned long)(x)) & uv_mmask))
651     #define cpubit_isset(cpu, bau_local_cpumask) \
652     test_bit((cpu), (bau_local_cpumask).bits)
653     diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
654     index f26544a..54a13aa 100644
655     --- a/arch/x86/include/asm/uv/uv_hub.h
656     +++ b/arch/x86/include/asm/uv/uv_hub.h
657     @@ -46,6 +46,13 @@
658     * PNODE - the low N bits of the GNODE. The PNODE is the most useful variant
659     * of the nasid for socket usage.
660     *
661     + * GPA - (global physical address) a socket physical address converted
662     + * so that it can be used by the GRU as a global address. Socket
663     + * physical addresses 1) need additional NASID (node) bits added
664     + * to the high end of the address, and 2) unaliased if the
665     + * partition does not have a physical address 0. In addition, on
666     + * UV2 rev 1, GPAs need the gnode left shifted to bits 39 or 40.
667     + *
668     *
669     * NumaLink Global Physical Address Format:
670     * +--------------------------------+---------------------+
671     @@ -141,6 +148,8 @@ struct uv_hub_info_s {
672     unsigned int gnode_extra;
673     unsigned char hub_revision;
674     unsigned char apic_pnode_shift;
675     + unsigned char m_shift;
676     + unsigned char n_lshift;
677     unsigned long gnode_upper;
678     unsigned long lowmem_remap_top;
679     unsigned long lowmem_remap_base;
680     @@ -177,6 +186,16 @@ static inline int is_uv2_hub(void)
681     return uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE;
682     }
683    
684     +static inline int is_uv2_1_hub(void)
685     +{
686     + return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE;
687     +}
688     +
689     +static inline int is_uv2_2_hub(void)
690     +{
691     + return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE + 1;
692     +}
693     +
694     union uvh_apicid {
695     unsigned long v;
696     struct uvh_apicid_s {
697     @@ -276,7 +295,10 @@ static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr)
698     {
699     if (paddr < uv_hub_info->lowmem_remap_top)
700     paddr |= uv_hub_info->lowmem_remap_base;
701     - return paddr | uv_hub_info->gnode_upper;
702     + paddr |= uv_hub_info->gnode_upper;
703     + paddr = ((paddr << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |
704     + ((paddr >> uv_hub_info->m_val) << uv_hub_info->n_lshift);
705     + return paddr;
706     }
707    
708    
709     @@ -300,16 +322,19 @@ static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa)
710     unsigned long remap_base = uv_hub_info->lowmem_remap_base;
711     unsigned long remap_top = uv_hub_info->lowmem_remap_top;
712    
713     + gpa = ((gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |
714     + ((gpa >> uv_hub_info->n_lshift) << uv_hub_info->m_val);
715     + gpa = gpa & uv_hub_info->gpa_mask;
716     if (paddr >= remap_base && paddr < remap_base + remap_top)
717     paddr -= remap_base;
718     return paddr;
719     }
720    
721    
722     -/* gnode -> pnode */
723     +/* gpa -> pnode */
724     static inline unsigned long uv_gpa_to_gnode(unsigned long gpa)
725     {
726     - return gpa >> uv_hub_info->m_val;
727     + return gpa >> uv_hub_info->n_lshift;
728     }
729    
730     /* gpa -> pnode */
731     @@ -320,6 +345,12 @@ static inline int uv_gpa_to_pnode(unsigned long gpa)
732     return uv_gpa_to_gnode(gpa) & n_mask;
733     }
734    
735     +/* gpa -> node offset*/
736     +static inline unsigned long uv_gpa_to_offset(unsigned long gpa)
737     +{
738     + return (gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift;
739     +}
740     +
741     /* pnode, offset --> socket virtual */
742     static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset)
743     {
744     diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
745     index d3d9d50..bfd75ff 100644
746     --- a/arch/x86/kernel/amd_iommu.c
747     +++ b/arch/x86/kernel/amd_iommu.c
748     @@ -1203,7 +1203,7 @@ static int alloc_new_range(struct dma_ops_domain *dma_dom,
749     if (!pte || !IOMMU_PTE_PRESENT(*pte))
750     continue;
751    
752     - dma_ops_reserve_addresses(dma_dom, i << PAGE_SHIFT, 1);
753     + dma_ops_reserve_addresses(dma_dom, i >> PAGE_SHIFT, 1);
754     }
755    
756     update_domain(&dma_dom->domain);
757     diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
758     index efd737e..521bead 100644
759     --- a/arch/x86/kernel/apic/bigsmp_32.c
760     +++ b/arch/x86/kernel/apic/bigsmp_32.c
761     @@ -255,12 +255,24 @@ static struct apic apic_bigsmp = {
762     .x86_32_early_logical_apicid = bigsmp_early_logical_apicid,
763     };
764    
765     -struct apic * __init generic_bigsmp_probe(void)
766     +void __init generic_bigsmp_probe(void)
767     {
768     - if (probe_bigsmp())
769     - return &apic_bigsmp;
770     + unsigned int cpu;
771    
772     - return NULL;
773     + if (!probe_bigsmp())
774     + return;
775     +
776     + apic = &apic_bigsmp;
777     +
778     + for_each_possible_cpu(cpu) {
779     + if (early_per_cpu(x86_cpu_to_logical_apicid,
780     + cpu) == BAD_APICID)
781     + continue;
782     + early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
783     + bigsmp_early_logical_apicid(cpu);
784     + }
785     +
786     + pr_info("Overriding APIC driver with %s\n", apic_bigsmp.name);
787     }
788    
789     apic_driver(apic_bigsmp);
790     diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
791     index b5254ad..0787bb3 100644
792     --- a/arch/x86/kernel/apic/probe_32.c
793     +++ b/arch/x86/kernel/apic/probe_32.c
794     @@ -200,14 +200,8 @@ void __init default_setup_apic_routing(void)
795     * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
796     */
797    
798     - if (!cmdline_apic && apic == &apic_default) {
799     - struct apic *bigsmp = generic_bigsmp_probe();
800     - if (bigsmp) {
801     - apic = bigsmp;
802     - printk(KERN_INFO "Overriding APIC driver with %s\n",
803     - apic->name);
804     - }
805     - }
806     + if (!cmdline_apic && apic == &apic_default)
807     + generic_bigsmp_probe();
808     #endif
809    
810     if (apic->setup_apic_routing)
811     diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
812     index 34b1859..cfeb978 100644
813     --- a/arch/x86/kernel/apic/x2apic_uv_x.c
814     +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
815     @@ -832,6 +832,10 @@ void __init uv_system_init(void)
816     uv_cpu_hub_info(cpu)->apic_pnode_shift = uvh_apicid.s.pnode_shift;
817     uv_cpu_hub_info(cpu)->hub_revision = uv_hub_info->hub_revision;
818    
819     + uv_cpu_hub_info(cpu)->m_shift = 64 - m_val;
820     + uv_cpu_hub_info(cpu)->n_lshift = is_uv2_1_hub() ?
821     + (m_val == 40 ? 40 : 39) : m_val;
822     +
823     pnode = uv_apicid_to_pnode(apicid);
824     blade = boot_pnode_to_blade(pnode);
825     lcpu = uv_blade_info[blade].nr_possible_cpus;
826     @@ -862,8 +866,7 @@ void __init uv_system_init(void)
827     if (uv_node_to_blade[nid] >= 0)
828     continue;
829     paddr = node_start_pfn(nid) << PAGE_SHIFT;
830     - paddr = uv_soc_phys_ram_to_gpa(paddr);
831     - pnode = (paddr >> m_val) & pnode_mask;
832     + pnode = uv_gpa_to_pnode(uv_soc_phys_ram_to_gpa(paddr));
833     blade = boot_pnode_to_blade(pnode);
834     uv_node_to_blade[nid] = blade;
835     }
836     diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
837     index f1a6244..794bc95 100644
838     --- a/arch/x86/kernel/kprobes.c
839     +++ b/arch/x86/kernel/kprobes.c
840     @@ -75,8 +75,10 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
841     /*
842     * Undefined/reserved opcodes, conditional jump, Opcode Extension
843     * Groups, and some special opcodes can not boost.
844     + * This is non-const to keep gcc from statically optimizing it out, as
845     + * variable_test_bit makes gcc think only *(unsigned long*) is used.
846     */
847     -static const u32 twobyte_is_boostable[256 / 32] = {
848     +static u32 twobyte_is_boostable[256 / 32] = {
849     /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
850     /* ---------------------------------------------- */
851     W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
852     diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
853     index dbe34b9..ea30585 100644
854     --- a/arch/x86/mm/gup.c
855     +++ b/arch/x86/mm/gup.c
856     @@ -108,16 +108,6 @@ static inline void get_head_page_multiple(struct page *page, int nr)
857     SetPageReferenced(page);
858     }
859    
860     -static inline void get_huge_page_tail(struct page *page)
861     -{
862     - /*
863     - * __split_huge_page_refcount() cannot run
864     - * from under us.
865     - */
866     - VM_BUG_ON(atomic_read(&page->_count) < 0);
867     - atomic_inc(&page->_count);
868     -}
869     -
870     static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr,
871     unsigned long end, int write, struct page **pages, int *nr)
872     {
873     diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
874     index 68e467f..82cff4a 100644
875     --- a/arch/x86/platform/uv/tlb_uv.c
876     +++ b/arch/x86/platform/uv/tlb_uv.c
877     @@ -115,9 +115,6 @@ early_param("nobau", setup_nobau);
878    
879     /* base pnode in this partition */
880     static int uv_base_pnode __read_mostly;
881     -/* position of pnode (which is nasid>>1): */
882     -static int uv_nshift __read_mostly;
883     -static unsigned long uv_mmask __read_mostly;
884    
885     static DEFINE_PER_CPU(struct ptc_stats, ptcstats);
886     static DEFINE_PER_CPU(struct bau_control, bau_control);
887     @@ -1426,7 +1423,7 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
888     {
889     int i;
890     int cpu;
891     - unsigned long pa;
892     + unsigned long gpa;
893     unsigned long m;
894     unsigned long n;
895     size_t dsize;
896     @@ -1442,9 +1439,9 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
897     bau_desc = kmalloc_node(dsize, GFP_KERNEL, node);
898     BUG_ON(!bau_desc);
899    
900     - pa = uv_gpa(bau_desc); /* need the real nasid*/
901     - n = pa >> uv_nshift;
902     - m = pa & uv_mmask;
903     + gpa = uv_gpa(bau_desc);
904     + n = uv_gpa_to_gnode(gpa);
905     + m = uv_gpa_to_offset(gpa);
906    
907     /* the 14-bit pnode */
908     write_mmr_descriptor_base(pnode, (n << UV_DESC_PSHIFT | m));
909     @@ -1516,9 +1513,9 @@ static void pq_init(int node, int pnode)
910     bcp->queue_last = pqp + (DEST_Q_SIZE - 1);
911     }
912     /*
913     - * need the pnode of where the memory was really allocated
914     + * need the gnode of where the memory was really allocated
915     */
916     - pn = uv_gpa(pqp) >> uv_nshift;
917     + pn = uv_gpa_to_gnode(uv_gpa(pqp));
918     first = uv_physnodeaddr(pqp);
919     pn_first = ((unsigned long)pn << UV_PAYLOADQ_PNODE_SHIFT) | first;
920     last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
921     @@ -1812,8 +1809,6 @@ static int __init uv_bau_init(void)
922     zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu));
923     }
924    
925     - uv_nshift = uv_hub_info->m_val;
926     - uv_mmask = (1UL << uv_hub_info->m_val) - 1;
927     nuvhubs = uv_num_possible_blades();
928     spin_lock_init(&disable_lock);
929     congested_cycles = usec_2_cycles(congested_respns_us);
930     diff --git a/block/genhd.c b/block/genhd.c
931     index 3608289..8c0829a 100644
932     --- a/block/genhd.c
933     +++ b/block/genhd.c
934     @@ -611,6 +611,12 @@ void add_disk(struct gendisk *disk)
935     register_disk(disk);
936     blk_register_queue(disk);
937    
938     + /*
939     + * Take an extra ref on queue which will be put on disk_release()
940     + * so that it sticks around as long as @disk is there.
941     + */
942     + WARN_ON_ONCE(blk_get_queue(disk->queue));
943     +
944     retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj,
945     "bdi");
946     WARN_ON(retval);
947     @@ -1103,6 +1109,8 @@ static void disk_release(struct device *dev)
948     disk_replace_part_tbl(disk, NULL);
949     free_part_stats(&disk->part0);
950     free_part_info(&disk->part0);
951     + if (disk->queue)
952     + blk_put_queue(disk->queue);
953     kfree(disk);
954     }
955     struct class block_class = {
956     diff --git a/crypto/cryptd.c b/crypto/cryptd.c
957     index e46d21a..671d4d6 100644
958     --- a/crypto/cryptd.c
959     +++ b/crypto/cryptd.c
960     @@ -945,7 +945,7 @@ static void __exit cryptd_exit(void)
961     crypto_unregister_template(&cryptd_tmpl);
962     }
963    
964     -module_init(cryptd_init);
965     +subsys_initcall(cryptd_init);
966     module_exit(cryptd_exit);
967    
968     MODULE_LICENSE("GPL");
969     diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c
970     index 7489b89..f151afe 100644
971     --- a/drivers/acpi/atomicio.c
972     +++ b/drivers/acpi/atomicio.c
973     @@ -76,7 +76,7 @@ static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr,
974     {
975     struct acpi_iomap *map;
976    
977     - map = __acpi_find_iomap(paddr, size);
978     + map = __acpi_find_iomap(paddr, size/8);
979     if (map)
980     return map->vaddr + (paddr - map->paddr);
981     else
982     diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
983     index 6f6e771..6da6deb 100644
984     --- a/drivers/ata/ata_piix.c
985     +++ b/drivers/ata/ata_piix.c
986     @@ -113,6 +113,8 @@ enum {
987     PIIX_PATA_FLAGS = ATA_FLAG_SLAVE_POSS,
988     PIIX_SATA_FLAGS = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR,
989    
990     + PIIX_FLAG_PIO16 = (1 << 30), /*support 16bit PIO only*/
991     +
992     PIIX_80C_PRI = (1 << 5) | (1 << 4),
993     PIIX_80C_SEC = (1 << 7) | (1 << 6),
994    
995     @@ -147,6 +149,7 @@ enum piix_controller_ids {
996     ich8m_apple_sata, /* locks up on second port enable */
997     tolapai_sata,
998     piix_pata_vmw, /* PIIX4 for VMware, spurious DMA_ERR */
999     + ich8_sata_snb,
1000     };
1001    
1002     struct piix_map_db {
1003     @@ -177,6 +180,7 @@ static int piix_sidpr_scr_write(struct ata_link *link,
1004     static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
1005     unsigned hints);
1006     static bool piix_irq_check(struct ata_port *ap);
1007     +static int piix_port_start(struct ata_port *ap);
1008     #ifdef CONFIG_PM
1009     static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
1010     static int piix_pci_device_resume(struct pci_dev *pdev);
1011     @@ -298,21 +302,21 @@ static const struct pci_device_id piix_pci_tbl[] = {
1012     /* SATA Controller IDE (PCH) */
1013     { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1014     /* SATA Controller IDE (CPT) */
1015     - { 0x8086, 0x1c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1016     + { 0x8086, 0x1c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1017     /* SATA Controller IDE (CPT) */
1018     - { 0x8086, 0x1c01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1019     + { 0x8086, 0x1c01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1020     /* SATA Controller IDE (CPT) */
1021     { 0x8086, 0x1c08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
1022     /* SATA Controller IDE (CPT) */
1023     { 0x8086, 0x1c09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
1024     /* SATA Controller IDE (PBG) */
1025     - { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1026     + { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1027     /* SATA Controller IDE (PBG) */
1028     { 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
1029     /* SATA Controller IDE (Panther Point) */
1030     - { 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1031     + { 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1032     /* SATA Controller IDE (Panther Point) */
1033     - { 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1034     + { 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1035     /* SATA Controller IDE (Panther Point) */
1036     { 0x8086, 0x1e08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
1037     /* SATA Controller IDE (Panther Point) */
1038     @@ -338,6 +342,7 @@ static struct scsi_host_template piix_sht = {
1039     static struct ata_port_operations piix_sata_ops = {
1040     .inherits = &ata_bmdma32_port_ops,
1041     .sff_irq_check = piix_irq_check,
1042     + .port_start = piix_port_start,
1043     };
1044    
1045     static struct ata_port_operations piix_pata_ops = {
1046     @@ -478,6 +483,7 @@ static const struct piix_map_db *piix_map_db_table[] = {
1047     [ich8_2port_sata] = &ich8_2port_map_db,
1048     [ich8m_apple_sata] = &ich8m_apple_map_db,
1049     [tolapai_sata] = &tolapai_map_db,
1050     + [ich8_sata_snb] = &ich8_map_db,
1051     };
1052    
1053     static struct ata_port_info piix_port_info[] = {
1054     @@ -606,6 +612,19 @@ static struct ata_port_info piix_port_info[] = {
1055     .port_ops = &piix_vmw_ops,
1056     },
1057    
1058     + /*
1059     + * some Sandybridge chipsets have broken 32 mode up to now,
1060     + * see https://bugzilla.kernel.org/show_bug.cgi?id=40592
1061     + */
1062     + [ich8_sata_snb] =
1063     + {
1064     + .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR | PIIX_FLAG_PIO16,
1065     + .pio_mask = ATA_PIO4,
1066     + .mwdma_mask = ATA_MWDMA2,
1067     + .udma_mask = ATA_UDMA6,
1068     + .port_ops = &piix_sata_ops,
1069     + },
1070     +
1071     };
1072    
1073     static struct pci_bits piix_enable_bits[] = {
1074     @@ -649,6 +668,14 @@ static const struct ich_laptop ich_laptop[] = {
1075     { 0, }
1076     };
1077    
1078     +static int piix_port_start(struct ata_port *ap)
1079     +{
1080     + if (!(ap->flags & PIIX_FLAG_PIO16))
1081     + ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE;
1082     +
1083     + return ata_bmdma_port_start(ap);
1084     +}
1085     +
1086     /**
1087     * ich_pata_cable_detect - Probe host controller cable detect info
1088     * @ap: Port for which cable detect info is desired
1089     diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
1090     index 0d4587b..1023392 100644
1091     --- a/drivers/base/power/runtime.c
1092     +++ b/drivers/base/power/runtime.c
1093     @@ -278,6 +278,9 @@ static int rpm_callback(int (*cb)(struct device *), struct device *dev)
1094     * If a deferred resume was requested while the callback was running then carry
1095     * it out; otherwise send an idle notification for the device (if the suspend
1096     * failed) or for its parent (if the suspend succeeded).
1097     + * If ->runtime_suspend failed with -EAGAIN or -EBUSY, and if the RPM_AUTO
1098     + * flag is set and the next autosuspend-delay expiration time is in the
1099     + * future, schedule another autosuspend attempt.
1100     *
1101     * This function must be called under dev->power.lock with interrupts disabled.
1102     */
1103     @@ -389,10 +392,21 @@ static int rpm_suspend(struct device *dev, int rpmflags)
1104     if (retval) {
1105     __update_runtime_status(dev, RPM_ACTIVE);
1106     dev->power.deferred_resume = 0;
1107     - if (retval == -EAGAIN || retval == -EBUSY)
1108     + if (retval == -EAGAIN || retval == -EBUSY) {
1109     dev->power.runtime_error = 0;
1110     - else
1111     +
1112     + /*
1113     + * If the callback routine failed an autosuspend, and
1114     + * if the last_busy time has been updated so that there
1115     + * is a new autosuspend expiration time, automatically
1116     + * reschedule another autosuspend.
1117     + */
1118     + if ((rpmflags & RPM_AUTO) &&
1119     + pm_runtime_autosuspend_expiration(dev) != 0)
1120     + goto repeat;
1121     + } else {
1122     pm_runtime_cancel_pending(dev);
1123     + }
1124     } else {
1125     no_callback:
1126     __update_runtime_status(dev, RPM_SUSPENDED);
1127     diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
1128     index 8f4ef65..c2f9b3e 100644
1129     --- a/drivers/block/cciss.c
1130     +++ b/drivers/block/cciss.c
1131     @@ -4533,6 +4533,13 @@ static int cciss_controller_hard_reset(struct pci_dev *pdev,
1132     pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
1133     pmcsr |= PCI_D0;
1134     pci_write_config_word(pdev, pos + PCI_PM_CTRL, pmcsr);
1135     +
1136     + /*
1137     + * The P600 requires a small delay when changing states.
1138     + * Otherwise we may think the board did not reset and we bail.
1139     + * This for kdump only and is particular to the P600.
1140     + */
1141     + msleep(500);
1142     }
1143     return 0;
1144     }
1145     diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
1146     index 5cf2993..54139d0 100644
1147     --- a/drivers/block/xen-blkback/blkback.c
1148     +++ b/drivers/block/xen-blkback/blkback.c
1149     @@ -667,7 +667,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
1150    
1151     if (operation == READ)
1152     blkif->st_rd_sect += preq.nr_sects;
1153     - else if (operation == WRITE || operation == WRITE_FLUSH)
1154     + else if (operation & WRITE)
1155     blkif->st_wr_sect += preq.nr_sects;
1156    
1157     return 0;
1158     diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
1159     index 6bacef3..db7cb81 100644
1160     --- a/drivers/bluetooth/ath3k.c
1161     +++ b/drivers/bluetooth/ath3k.c
1162     @@ -63,6 +63,7 @@ static struct usb_device_id ath3k_table[] = {
1163     /* Atheros AR3011 with sflash firmware*/
1164     { USB_DEVICE(0x0CF3, 0x3002) },
1165     { USB_DEVICE(0x13d3, 0x3304) },
1166     + { USB_DEVICE(0x0930, 0x0215) },
1167    
1168     /* Atheros AR9285 Malbec with sflash firmware */
1169     { USB_DEVICE(0x03F0, 0x311D) },
1170     @@ -375,6 +376,11 @@ static int ath3k_probe(struct usb_interface *intf,
1171    
1172     /* load patch and sysconfig files for AR3012 */
1173     if (id->driver_info & BTUSB_ATH3012) {
1174     +
1175     + /* New firmware with patch and sysconfig files already loaded */
1176     + if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x0001)
1177     + return -ENODEV;
1178     +
1179     ret = ath3k_load_patch(udev);
1180     if (ret < 0) {
1181     BT_ERR("Loading patch file failed");
1182     diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1183     index c2de895..b9af6db 100644
1184     --- a/drivers/bluetooth/btusb.c
1185     +++ b/drivers/bluetooth/btusb.c
1186     @@ -54,11 +54,15 @@ static struct usb_driver btusb_driver;
1187     #define BTUSB_BCM92035 0x10
1188     #define BTUSB_BROKEN_ISOC 0x20
1189     #define BTUSB_WRONG_SCO_MTU 0x40
1190     +#define BTUSB_ATH3012 0x80
1191    
1192     static struct usb_device_id btusb_table[] = {
1193     /* Generic Bluetooth USB device */
1194     { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
1195    
1196     + /* Broadcom SoftSailing reporting vendor specific */
1197     + { USB_DEVICE(0x05ac, 0x21e1) },
1198     +
1199     /* Apple MacBookPro 7,1 */
1200     { USB_DEVICE(0x05ac, 0x8213) },
1201    
1202     @@ -71,9 +75,15 @@ static struct usb_device_id btusb_table[] = {
1203     /* Apple MacBookAir3,1, MacBookAir3,2 */
1204     { USB_DEVICE(0x05ac, 0x821b) },
1205    
1206     + /* Apple MacBookAir4,1 */
1207     + { USB_DEVICE(0x05ac, 0x821f) },
1208     +
1209     /* Apple MacBookPro8,2 */
1210     { USB_DEVICE(0x05ac, 0x821a) },
1211    
1212     + /* Apple MacMini5,1 */
1213     + { USB_DEVICE(0x05ac, 0x8281) },
1214     +
1215     /* AVM BlueFRITZ! USB v2.0 */
1216     { USB_DEVICE(0x057c, 0x3800) },
1217    
1218     @@ -105,12 +115,13 @@ static struct usb_device_id blacklist_table[] = {
1219     /* Atheros 3011 with sflash firmware */
1220     { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
1221     { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
1222     + { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
1223    
1224     /* Atheros AR9285 Malbec with sflash firmware */
1225     { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
1226    
1227     /* Atheros 3012 with sflash firmware */
1228     - { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_IGNORE },
1229     + { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
1230    
1231     /* Atheros AR5BBU12 with sflash firmware */
1232     { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
1233     @@ -914,6 +925,15 @@ static int btusb_probe(struct usb_interface *intf,
1234     if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER)
1235     return -ENODEV;
1236    
1237     + if (id->driver_info & BTUSB_ATH3012) {
1238     + struct usb_device *udev = interface_to_usbdev(intf);
1239     +
1240     + /* Old firmware would otherwise let ath3k driver load
1241     + * patch and sysconfig files */
1242     + if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
1243     + return -ENODEV;
1244     + }
1245     +
1246     data = kzalloc(sizeof(*data), GFP_KERNEL);
1247     if (!data)
1248     return -ENOMEM;
1249     diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
1250     index e2aced6..14264a8 100644
1251     --- a/drivers/gpu/drm/i915/intel_dp.c
1252     +++ b/drivers/gpu/drm/i915/intel_dp.c
1253     @@ -1658,6 +1658,31 @@ g4x_dp_detect(struct intel_dp *intel_dp)
1254     return status;
1255     }
1256    
1257     +static struct edid *
1258     +intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
1259     +{
1260     + struct intel_dp *intel_dp = intel_attached_dp(connector);
1261     + struct edid *edid;
1262     +
1263     + ironlake_edp_panel_vdd_on(intel_dp);
1264     + edid = drm_get_edid(connector, adapter);
1265     + ironlake_edp_panel_vdd_off(intel_dp);
1266     + return edid;
1267     +}
1268     +
1269     +static int
1270     +intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *adapter)
1271     +{
1272     + struct intel_dp *intel_dp = intel_attached_dp(connector);
1273     + int ret;
1274     +
1275     + ironlake_edp_panel_vdd_on(intel_dp);
1276     + ret = intel_ddc_get_modes(connector, adapter);
1277     + ironlake_edp_panel_vdd_off(intel_dp);
1278     + return ret;
1279     +}
1280     +
1281     +
1282     /**
1283     * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect DP connection.
1284     *
1285     @@ -1684,7 +1709,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)
1286     if (intel_dp->force_audio) {
1287     intel_dp->has_audio = intel_dp->force_audio > 0;
1288     } else {
1289     - edid = drm_get_edid(connector, &intel_dp->adapter);
1290     + edid = intel_dp_get_edid(connector, &intel_dp->adapter);
1291     if (edid) {
1292     intel_dp->has_audio = drm_detect_monitor_audio(edid);
1293     connector->display_info.raw_edid = NULL;
1294     @@ -1705,7 +1730,7 @@ static int intel_dp_get_modes(struct drm_connector *connector)
1295     /* We should parse the EDID data and find out if it has an audio sink
1296     */
1297    
1298     - ret = intel_ddc_get_modes(connector, &intel_dp->adapter);
1299     + ret = intel_dp_get_edid_modes(connector, &intel_dp->adapter);
1300     if (ret) {
1301     if (is_edp(intel_dp) && !dev_priv->panel_fixed_mode) {
1302     struct drm_display_mode *newmode;
1303     @@ -1741,7 +1766,7 @@ intel_dp_detect_audio(struct drm_connector *connector)
1304     struct edid *edid;
1305     bool has_audio = false;
1306    
1307     - edid = drm_get_edid(connector, &intel_dp->adapter);
1308     + edid = intel_dp_get_edid(connector, &intel_dp->adapter);
1309     if (edid) {
1310     has_audio = drm_detect_monitor_audio(edid);
1311    
1312     diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
1313     index 05f500c..f8aa821 100644
1314     --- a/drivers/gpu/drm/i915/intel_panel.c
1315     +++ b/drivers/gpu/drm/i915/intel_panel.c
1316     @@ -226,7 +226,7 @@ static void intel_pch_panel_set_backlight(struct drm_device *dev, u32 level)
1317     I915_WRITE(BLC_PWM_CPU_CTL, val | level);
1318     }
1319    
1320     -void intel_panel_set_backlight(struct drm_device *dev, u32 level)
1321     +static void intel_panel_actually_set_backlight(struct drm_device *dev, u32 level)
1322     {
1323     struct drm_i915_private *dev_priv = dev->dev_private;
1324     u32 tmp;
1325     @@ -254,16 +254,21 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level)
1326     I915_WRITE(BLC_PWM_CTL, tmp | level);
1327     }
1328    
1329     -void intel_panel_disable_backlight(struct drm_device *dev)
1330     +void intel_panel_set_backlight(struct drm_device *dev, u32 level)
1331     {
1332     struct drm_i915_private *dev_priv = dev->dev_private;
1333    
1334     - if (dev_priv->backlight_enabled) {
1335     - dev_priv->backlight_level = intel_panel_get_backlight(dev);
1336     - dev_priv->backlight_enabled = false;
1337     - }
1338     + dev_priv->backlight_level = level;
1339     + if (dev_priv->backlight_enabled)
1340     + intel_panel_actually_set_backlight(dev, level);
1341     +}
1342     +
1343     +void intel_panel_disable_backlight(struct drm_device *dev)
1344     +{
1345     + struct drm_i915_private *dev_priv = dev->dev_private;
1346    
1347     - intel_panel_set_backlight(dev, 0);
1348     + dev_priv->backlight_enabled = false;
1349     + intel_panel_actually_set_backlight(dev, 0);
1350     }
1351    
1352     void intel_panel_enable_backlight(struct drm_device *dev)
1353     @@ -273,8 +278,8 @@ void intel_panel_enable_backlight(struct drm_device *dev)
1354     if (dev_priv->backlight_level == 0)
1355     dev_priv->backlight_level = intel_panel_get_max_backlight(dev);
1356    
1357     - intel_panel_set_backlight(dev, dev_priv->backlight_level);
1358     dev_priv->backlight_enabled = true;
1359     + intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
1360     }
1361    
1362     void intel_panel_setup_backlight(struct drm_device *dev)
1363     diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
1364     index 79e8ebc..b5628ce 100644
1365     --- a/drivers/gpu/drm/radeon/atombios_dp.c
1366     +++ b/drivers/gpu/drm/radeon/atombios_dp.c
1367     @@ -553,6 +553,7 @@ static void radeon_dp_set_panel_mode(struct drm_encoder *encoder,
1368     {
1369     struct drm_device *dev = encoder->dev;
1370     struct radeon_device *rdev = dev->dev_private;
1371     + struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1372     int panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
1373    
1374     if (!ASIC_IS_DCE4(rdev))
1375     @@ -560,10 +561,20 @@ static void radeon_dp_set_panel_mode(struct drm_encoder *encoder,
1376    
1377     if (radeon_connector_encoder_is_dp_bridge(connector))
1378     panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
1379     + else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
1380     + u8 tmp = radeon_read_dpcd_reg(radeon_connector, DP_EDP_CONFIGURATION_CAP);
1381     + if (tmp & 1)
1382     + panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
1383     + }
1384    
1385     atombios_dig_encoder_setup(encoder,
1386     ATOM_ENCODER_CMD_SETUP_PANEL_MODE,
1387     panel_mode);
1388     +
1389     + if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) &&
1390     + (panel_mode == DP_PANEL_MODE_INTERNAL_DP2_MODE)) {
1391     + radeon_write_dpcd_reg(radeon_connector, DP_EDP_CONFIGURATION_SET, 1);
1392     + }
1393     }
1394    
1395     void radeon_dp_set_link_config(struct drm_connector *connector,
1396     diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
1397     index ea7a24e..f1bdb58 100644
1398     --- a/drivers/gpu/drm/radeon/evergreen.c
1399     +++ b/drivers/gpu/drm/radeon/evergreen.c
1400     @@ -353,6 +353,7 @@ void evergreen_hpd_init(struct radeon_device *rdev)
1401     default:
1402     break;
1403     }
1404     + radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
1405     }
1406     if (rdev->irq.installed)
1407     evergreen_irq_set(rdev);
1408     diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
1409     index 7fcdbbb..c9a0dae 100644
1410     --- a/drivers/gpu/drm/radeon/r100.c
1411     +++ b/drivers/gpu/drm/radeon/r100.c
1412     @@ -434,6 +434,7 @@ void r100_hpd_init(struct radeon_device *rdev)
1413     default:
1414     break;
1415     }
1416     + radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
1417     }
1418     if (rdev->irq.installed)
1419     r100_irq_set(rdev);
1420     diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
1421     index 1dea9d6..1a4ed43 100644
1422     --- a/drivers/gpu/drm/radeon/r600.c
1423     +++ b/drivers/gpu/drm/radeon/r600.c
1424     @@ -762,13 +762,14 @@ void r600_hpd_init(struct radeon_device *rdev)
1425     struct drm_device *dev = rdev->ddev;
1426     struct drm_connector *connector;
1427    
1428     - if (ASIC_IS_DCE3(rdev)) {
1429     - u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) | DC_HPDx_RX_INT_TIMER(0xfa);
1430     - if (ASIC_IS_DCE32(rdev))
1431     - tmp |= DC_HPDx_EN;
1432     + list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1433     + struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1434     +
1435     + if (ASIC_IS_DCE3(rdev)) {
1436     + u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) | DC_HPDx_RX_INT_TIMER(0xfa);
1437     + if (ASIC_IS_DCE32(rdev))
1438     + tmp |= DC_HPDx_EN;
1439    
1440     - list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1441     - struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1442     switch (radeon_connector->hpd.hpd) {
1443     case RADEON_HPD_1:
1444     WREG32(DC_HPD1_CONTROL, tmp);
1445     @@ -798,10 +799,7 @@ void r600_hpd_init(struct radeon_device *rdev)
1446     default:
1447     break;
1448     }
1449     - }
1450     - } else {
1451     - list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1452     - struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1453     + } else {
1454     switch (radeon_connector->hpd.hpd) {
1455     case RADEON_HPD_1:
1456     WREG32(DC_HOT_PLUG_DETECT1_CONTROL, DC_HOT_PLUG_DETECTx_EN);
1457     @@ -819,6 +817,7 @@ void r600_hpd_init(struct radeon_device *rdev)
1458     break;
1459     }
1460     }
1461     + radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
1462     }
1463     if (rdev->irq.installed)
1464     r600_irq_set(rdev);
1465     diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
1466     index 0bb4ddf..59d72d0 100644
1467     --- a/drivers/gpu/drm/radeon/radeon.h
1468     +++ b/drivers/gpu/drm/radeon/radeon.h
1469     @@ -93,6 +93,7 @@ extern int radeon_audio;
1470     extern int radeon_disp_priority;
1471     extern int radeon_hw_i2c;
1472     extern int radeon_pcie_gen2;
1473     +extern int radeon_msi;
1474    
1475     /*
1476     * Copy from radeon_drv.h so we don't have to include both and have conflicting
1477     diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
1478     index cd3c86c..859df6b 100644
1479     --- a/drivers/gpu/drm/radeon/radeon_combios.c
1480     +++ b/drivers/gpu/drm/radeon/radeon_combios.c
1481     @@ -620,8 +620,8 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde
1482     i2c.y_data_mask = 0x80;
1483     } else {
1484     /* default masks for ddc pads */
1485     - i2c.mask_clk_mask = RADEON_GPIO_EN_1;
1486     - i2c.mask_data_mask = RADEON_GPIO_EN_0;
1487     + i2c.mask_clk_mask = RADEON_GPIO_MASK_1;
1488     + i2c.mask_data_mask = RADEON_GPIO_MASK_0;
1489     i2c.a_clk_mask = RADEON_GPIO_A_1;
1490     i2c.a_data_mask = RADEON_GPIO_A_0;
1491     i2c.en_clk_mask = RADEON_GPIO_EN_1;
1492     diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
1493     index 05b8b2c..2109c17 100644
1494     --- a/drivers/gpu/drm/radeon/radeon_connectors.c
1495     +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
1496     @@ -715,6 +715,7 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
1497     dret = radeon_ddc_probe(radeon_connector,
1498     radeon_connector->requires_extended_probe);
1499     if (dret) {
1500     + radeon_connector->detected_by_load = false;
1501     if (radeon_connector->edid) {
1502     kfree(radeon_connector->edid);
1503     radeon_connector->edid = NULL;
1504     @@ -741,12 +742,21 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
1505     } else {
1506    
1507     /* if we aren't forcing don't do destructive polling */
1508     - if (!force)
1509     - return connector->status;
1510     + if (!force) {
1511     + /* only return the previous status if we last
1512     + * detected a monitor via load.
1513     + */
1514     + if (radeon_connector->detected_by_load)
1515     + return connector->status;
1516     + else
1517     + return ret;
1518     + }
1519    
1520     if (radeon_connector->dac_load_detect && encoder) {
1521     encoder_funcs = encoder->helper_private;
1522     ret = encoder_funcs->detect(encoder, connector);
1523     + if (ret != connector_status_disconnected)
1524     + radeon_connector->detected_by_load = true;
1525     }
1526     }
1527    
1528     @@ -888,6 +898,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1529     dret = radeon_ddc_probe(radeon_connector,
1530     radeon_connector->requires_extended_probe);
1531     if (dret) {
1532     + radeon_connector->detected_by_load = false;
1533     if (radeon_connector->edid) {
1534     kfree(radeon_connector->edid);
1535     radeon_connector->edid = NULL;
1536     @@ -950,8 +961,18 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1537     if ((ret == connector_status_connected) && (radeon_connector->use_digital == true))
1538     goto out;
1539    
1540     + /* DVI-D and HDMI-A are digital only */
1541     + if ((connector->connector_type == DRM_MODE_CONNECTOR_DVID) ||
1542     + (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA))
1543     + goto out;
1544     +
1545     + /* if we aren't forcing don't do destructive polling */
1546     if (!force) {
1547     - ret = connector->status;
1548     + /* only return the previous status if we last
1549     + * detected a monitor via load.
1550     + */
1551     + if (radeon_connector->detected_by_load)
1552     + ret = connector->status;
1553     goto out;
1554     }
1555    
1556     @@ -976,6 +997,8 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1557     if (ret == connector_status_connected) {
1558     radeon_connector->use_digital = false;
1559     }
1560     + if (ret != connector_status_disconnected)
1561     + radeon_connector->detected_by_load = true;
1562     }
1563     break;
1564     }
1565     diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
1566     index 73dfbe8..60e1605 100644
1567     --- a/drivers/gpu/drm/radeon/radeon_drv.c
1568     +++ b/drivers/gpu/drm/radeon/radeon_drv.c
1569     @@ -117,6 +117,7 @@ int radeon_audio = 0;
1570     int radeon_disp_priority = 0;
1571     int radeon_hw_i2c = 0;
1572     int radeon_pcie_gen2 = 0;
1573     +int radeon_msi = -1;
1574    
1575     MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
1576     module_param_named(no_wb, radeon_no_wb, int, 0444);
1577     @@ -163,6 +164,9 @@ module_param_named(hw_i2c, radeon_hw_i2c, int, 0444);
1578     MODULE_PARM_DESC(pcie_gen2, "PCIE Gen2 mode (1 = enable)");
1579     module_param_named(pcie_gen2, radeon_pcie_gen2, int, 0444);
1580    
1581     +MODULE_PARM_DESC(msi, "MSI support (1 = enable, 0 = disable, -1 = auto)");
1582     +module_param_named(msi, radeon_msi, int, 0444);
1583     +
1584     static int radeon_suspend(struct drm_device *dev, pm_message_t state)
1585     {
1586     drm_radeon_private_t *dev_priv = dev->dev_private;
1587     diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
1588     index 9ec830c..fecc1aa 100644
1589     --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
1590     +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
1591     @@ -108,6 +108,46 @@ void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
1592     radeon_irq_set(rdev);
1593     }
1594    
1595     +static bool radeon_msi_ok(struct radeon_device *rdev)
1596     +{
1597     + /* RV370/RV380 was first asic with MSI support */
1598     + if (rdev->family < CHIP_RV380)
1599     + return false;
1600     +
1601     + /* MSIs don't work on AGP */
1602     + if (rdev->flags & RADEON_IS_AGP)
1603     + return false;
1604     +
1605     + /* force MSI on */
1606     + if (radeon_msi == 1)
1607     + return true;
1608     + else if (radeon_msi == 0)
1609     + return false;
1610     +
1611     + /* Quirks */
1612     + /* HP RS690 only seems to work with MSIs. */
1613     + if ((rdev->pdev->device == 0x791f) &&
1614     + (rdev->pdev->subsystem_vendor == 0x103c) &&
1615     + (rdev->pdev->subsystem_device == 0x30c2))
1616     + return true;
1617     +
1618     + /* Dell RS690 only seems to work with MSIs. */
1619     + if ((rdev->pdev->device == 0x791f) &&
1620     + (rdev->pdev->subsystem_vendor == 0x1028) &&
1621     + (rdev->pdev->subsystem_device == 0x01fd))
1622     + return true;
1623     +
1624     + if (rdev->flags & RADEON_IS_IGP) {
1625     + /* APUs work fine with MSIs */
1626     + if (rdev->family >= CHIP_PALM)
1627     + return true;
1628     + /* lots of IGPs have problems with MSIs */
1629     + return false;
1630     + }
1631     +
1632     + return true;
1633     +}
1634     +
1635     int radeon_irq_kms_init(struct radeon_device *rdev)
1636     {
1637     int i;
1638     @@ -124,12 +164,8 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
1639     }
1640     /* enable msi */
1641     rdev->msi_enabled = 0;
1642     - /* MSIs don't seem to work reliably on all IGP
1643     - * chips. Disable MSI on them for now.
1644     - */
1645     - if ((rdev->family >= CHIP_RV380) &&
1646     - ((!(rdev->flags & RADEON_IS_IGP)) || (rdev->family >= CHIP_PALM)) &&
1647     - (!(rdev->flags & RADEON_IS_AGP))) {
1648     +
1649     + if (radeon_msi_ok(rdev)) {
1650     int ret = pci_enable_msi(rdev->pdev);
1651     if (!ret) {
1652     rdev->msi_enabled = 1;
1653     diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
1654     index 68820f5..ed0178f 100644
1655     --- a/drivers/gpu/drm/radeon/radeon_mode.h
1656     +++ b/drivers/gpu/drm/radeon/radeon_mode.h
1657     @@ -447,6 +447,7 @@ struct radeon_connector {
1658     struct edid *edid;
1659     void *con_priv;
1660     bool dac_load_detect;
1661     + bool detected_by_load; /* if the connection status was determined by load */
1662     uint16_t connector_object_id;
1663     struct radeon_hpd hpd;
1664     struct radeon_router router;
1665     diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
1666     index 1f5850e..aea28c3 100644
1667     --- a/drivers/gpu/drm/radeon/rs600.c
1668     +++ b/drivers/gpu/drm/radeon/rs600.c
1669     @@ -287,6 +287,7 @@ void rs600_hpd_init(struct radeon_device *rdev)
1670     default:
1671     break;
1672     }
1673     + radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
1674     }
1675     if (rdev->irq.installed)
1676     rs600_irq_set(rdev);
1677     diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
1678     index 36ca465..7e0acf4 100644
1679     --- a/drivers/hid/Kconfig
1680     +++ b/drivers/hid/Kconfig
1681     @@ -69,7 +69,7 @@ config HID_ACRUX
1682     Say Y here if you want to enable support for ACRUX game controllers.
1683    
1684     config HID_ACRUX_FF
1685     - tristate "ACRUX force feedback support"
1686     + bool "ACRUX force feedback support"
1687     depends on HID_ACRUX
1688     select INPUT_FF_MEMLESS
1689     ---help---
1690     @@ -314,6 +314,7 @@ config HID_MULTITOUCH
1691     - Hanvon dual touch panels
1692     - Ilitek dual touch panels
1693     - IrTouch Infrared USB panels
1694     + - LG Display panels (Dell ST2220Tc)
1695     - Lumio CrystalTouch panels
1696     - MosArt dual-touch panels
1697     - PenMount dual touch panels
1698     diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
1699     index b85744f..299d238 100644
1700     --- a/drivers/hid/hid-apple.c
1701     +++ b/drivers/hid/hid-apple.c
1702     @@ -444,11 +444,20 @@ static const struct hid_device_id apple_devices[] = {
1703     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
1704     .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
1705     APPLE_RDESC_JIS },
1706     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
1707     + .driver_data = APPLE_HAS_FN },
1708     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
1709     + .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1710     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
1711     + .driver_data = APPLE_HAS_FN },
1712     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
1713     .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
1714     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
1715     .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
1716     APPLE_ISO_KEYBOARD },
1717     + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
1718     + .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
1719     + APPLE_ISO_KEYBOARD },
1720     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
1721     .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
1722     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
1723     @@ -487,6 +496,24 @@ static const struct hid_device_id apple_devices[] = {
1724     .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1725     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
1726     .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
1727     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
1728     + .driver_data = APPLE_HAS_FN },
1729     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
1730     + .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1731     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
1732     + .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
1733     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
1734     + .driver_data = APPLE_HAS_FN },
1735     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
1736     + .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1737     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
1738     + .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
1739     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
1740     + .driver_data = APPLE_HAS_FN },
1741     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
1742     + .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1743     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
1744     + .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
1745     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
1746     .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
1747     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
1748     diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1749     index 6f3289a..4f81d20 100644
1750     --- a/drivers/hid/hid-core.c
1751     +++ b/drivers/hid/hid-core.c
1752     @@ -1340,9 +1340,22 @@ static const struct hid_device_id hid_have_special_driver[] = {
1753     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1754     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1755     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
1756     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
1757     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
1758     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
1759     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
1760     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
1761     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
1762     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
1763     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
1764     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
1765     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) },
1766     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) },
1767     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) },
1768     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1769     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1770     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
1771     + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
1772     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1773     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1774     { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) },
1775     @@ -1395,6 +1408,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1776     { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
1777     { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
1778     { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) },
1779     + { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) },
1780     { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
1781     { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
1782     { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
1783     @@ -1883,6 +1897,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
1784     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1785     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1786     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
1787     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
1788     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
1789     + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
1790     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1791     { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1792     { }
1793     diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
1794     index c946d90..c97003c 100644
1795     --- a/drivers/hid/hid-ids.h
1796     +++ b/drivers/hid/hid-ids.h
1797     @@ -109,9 +109,22 @@
1798     #define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
1799     #define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
1800     #define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
1801     +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI 0x0249
1802     +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO 0x024a
1803     +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS 0x024b
1804     +#define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c
1805     +#define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d
1806     +#define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e
1807     +#define USB_DEVICE_ID_APPLE_ALU_REVB_ANSI 0x024f
1808     +#define USB_DEVICE_ID_APPLE_ALU_REVB_ISO 0x0250
1809     +#define USB_DEVICE_ID_APPLE_ALU_REVB_JIS 0x0251
1810     +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252
1811     +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253
1812     +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254
1813     #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
1814     #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
1815     #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
1816     +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256
1817     #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
1818     #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
1819     #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241
1820     @@ -274,6 +287,7 @@
1821     #define USB_DEVICE_ID_PENPOWER 0x00f4
1822    
1823     #define USB_VENDOR_ID_GREENASIA 0x0e8f
1824     +#define USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD 0x3013
1825    
1826     #define USB_VENDOR_ID_GRETAGMACBETH 0x0971
1827     #define USB_DEVICE_ID_GRETAGMACBETH_HUEY 0x2005
1828     @@ -416,6 +430,9 @@
1829     #define USB_DEVICE_ID_LD_HYBRID 0x2090
1830     #define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0
1831    
1832     +#define USB_VENDOR_ID_LG 0x1fd2
1833     +#define USB_DEVICE_ID_LG_MULTITOUCH 0x0064
1834     +
1835     #define USB_VENDOR_ID_LOGITECH 0x046d
1836     #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
1837     #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110
1838     diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
1839     index 62cac4d..685d8e4 100644
1840     --- a/drivers/hid/hid-multitouch.c
1841     +++ b/drivers/hid/hid-multitouch.c
1842     @@ -672,6 +672,11 @@ static const struct hid_device_id mt_devices[] = {
1843     HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS,
1844     USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },
1845    
1846     + /* LG Display panels */
1847     + { .driver_data = MT_CLS_DEFAULT,
1848     + HID_USB_DEVICE(USB_VENDOR_ID_LG,
1849     + USB_DEVICE_ID_LG_MULTITOUCH) },
1850     +
1851     /* Lumio panels */
1852     { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
1853     HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
1854     diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
1855     index 4bdb5d4..3146fdc 100644
1856     --- a/drivers/hid/usbhid/hid-quirks.c
1857     +++ b/drivers/hid/usbhid/hid-quirks.c
1858     @@ -47,6 +47,7 @@ static const struct hid_blacklist {
1859     { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL },
1860    
1861     { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH, HID_QUIRK_MULTI_INPUT },
1862     + { USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT },
1863     { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
1864     { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
1865     { USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS, HID_QUIRK_MULTI_INPUT },
1866     diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
1867     index 0070d54..f642194 100644
1868     --- a/drivers/hwmon/coretemp.c
1869     +++ b/drivers/hwmon/coretemp.c
1870     @@ -50,14 +50,13 @@
1871     #ifdef CONFIG_SMP
1872     #define TO_PHYS_ID(cpu) cpu_data(cpu).phys_proc_id
1873     #define TO_CORE_ID(cpu) cpu_data(cpu).cpu_core_id
1874     -#define TO_ATTR_NO(cpu) (TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO)
1875     #define for_each_sibling(i, cpu) for_each_cpu(i, cpu_sibling_mask(cpu))
1876     #else
1877     #define TO_PHYS_ID(cpu) (cpu)
1878     #define TO_CORE_ID(cpu) (cpu)
1879     -#define TO_ATTR_NO(cpu) (cpu)
1880     #define for_each_sibling(i, cpu) for (i = 0; false; )
1881     #endif
1882     +#define TO_ATTR_NO(cpu) (TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO)
1883    
1884     /*
1885     * Per-Core Temperature Data
1886     diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
1887     index 36d7f27..4b2fc50 100644
1888     --- a/drivers/hwmon/w83627ehf.c
1889     +++ b/drivers/hwmon/w83627ehf.c
1890     @@ -1756,7 +1756,17 @@ static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data,
1891     diode = 0x70;
1892     }
1893     for (i = 0; i < 3; i++) {
1894     - if ((tmp & (0x02 << i)))
1895     + const char *label = NULL;
1896     +
1897     + if (data->temp_label)
1898     + label = data->temp_label[data->temp_src[i]];
1899     +
1900     + /* Digital source overrides analog type */
1901     + if (label && strncmp(label, "PECI", 4) == 0)
1902     + data->temp_type[i] = 6;
1903     + else if (label && strncmp(label, "AMD", 3) == 0)
1904     + data->temp_type[i] = 5;
1905     + else if ((tmp & (0x02 << i)))
1906     data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 3;
1907     else
1908     data->temp_type[i] = 4; /* thermistor */
1909     diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
1910     index 43a6271..12f7c83 100644
1911     --- a/drivers/hwspinlock/hwspinlock_core.c
1912     +++ b/drivers/hwspinlock/hwspinlock_core.c
1913     @@ -26,6 +26,7 @@
1914     #include <linux/radix-tree.h>
1915     #include <linux/hwspinlock.h>
1916     #include <linux/pm_runtime.h>
1917     +#include <linux/mutex.h>
1918    
1919     #include "hwspinlock_internal.h"
1920    
1921     @@ -52,10 +53,12 @@
1922     static RADIX_TREE(hwspinlock_tree, GFP_KERNEL);
1923    
1924     /*
1925     - * Synchronization of access to the tree is achieved using this spinlock,
1926     + * Synchronization of access to the tree is achieved using this mutex,
1927     * as the radix-tree API requires that users provide all synchronisation.
1928     + * A mutex is needed because we're using non-atomic radix tree allocations.
1929     */
1930     -static DEFINE_SPINLOCK(hwspinlock_tree_lock);
1931     +static DEFINE_MUTEX(hwspinlock_tree_lock);
1932     +
1933    
1934     /**
1935     * __hwspin_trylock() - attempt to lock a specific hwspinlock
1936     @@ -261,8 +264,7 @@ EXPORT_SYMBOL_GPL(__hwspin_unlock);
1937     * This function should be called from the underlying platform-specific
1938     * implementation, to register a new hwspinlock instance.
1939     *
1940     - * Can be called from an atomic context (will not sleep) but not from
1941     - * within interrupt context.
1942     + * Should be called from a process context (might sleep)
1943     *
1944     * Returns 0 on success, or an appropriate error code on failure
1945     */
1946     @@ -279,7 +281,7 @@ int hwspin_lock_register(struct hwspinlock *hwlock)
1947    
1948     spin_lock_init(&hwlock->lock);
1949    
1950     - spin_lock(&hwspinlock_tree_lock);
1951     + mutex_lock(&hwspinlock_tree_lock);
1952    
1953     ret = radix_tree_insert(&hwspinlock_tree, hwlock->id, hwlock);
1954     if (ret)
1955     @@ -293,7 +295,7 @@ int hwspin_lock_register(struct hwspinlock *hwlock)
1956     WARN_ON(tmp != hwlock);
1957    
1958     out:
1959     - spin_unlock(&hwspinlock_tree_lock);
1960     + mutex_unlock(&hwspinlock_tree_lock);
1961     return ret;
1962     }
1963     EXPORT_SYMBOL_GPL(hwspin_lock_register);
1964     @@ -305,8 +307,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_register);
1965     * This function should be called from the underlying platform-specific
1966     * implementation, to unregister an existing (and unused) hwspinlock.
1967     *
1968     - * Can be called from an atomic context (will not sleep) but not from
1969     - * within interrupt context.
1970     + * Should be called from a process context (might sleep)
1971     *
1972     * Returns the address of hwspinlock @id on success, or NULL on failure
1973     */
1974     @@ -315,7 +316,7 @@ struct hwspinlock *hwspin_lock_unregister(unsigned int id)
1975     struct hwspinlock *hwlock = NULL;
1976     int ret;
1977    
1978     - spin_lock(&hwspinlock_tree_lock);
1979     + mutex_lock(&hwspinlock_tree_lock);
1980    
1981     /* make sure the hwspinlock is not in use (tag is set) */
1982     ret = radix_tree_tag_get(&hwspinlock_tree, id, HWSPINLOCK_UNUSED);
1983     @@ -331,7 +332,7 @@ struct hwspinlock *hwspin_lock_unregister(unsigned int id)
1984     }
1985    
1986     out:
1987     - spin_unlock(&hwspinlock_tree_lock);
1988     + mutex_unlock(&hwspinlock_tree_lock);
1989     return hwlock;
1990     }
1991     EXPORT_SYMBOL_GPL(hwspin_lock_unregister);
1992     @@ -400,9 +401,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_get_id);
1993     * to the remote core before it can be used for synchronization (to get the
1994     * id of a given hwlock, use hwspin_lock_get_id()).
1995     *
1996     - * Can be called from an atomic context (will not sleep) but not from
1997     - * within interrupt context (simply because there is no use case for
1998     - * that yet).
1999     + * Should be called from a process context (might sleep)
2000     *
2001     * Returns the address of the assigned hwspinlock, or NULL on error
2002     */
2003     @@ -411,7 +410,7 @@ struct hwspinlock *hwspin_lock_request(void)
2004     struct hwspinlock *hwlock;
2005     int ret;
2006    
2007     - spin_lock(&hwspinlock_tree_lock);
2008     + mutex_lock(&hwspinlock_tree_lock);
2009    
2010     /* look for an unused lock */
2011     ret = radix_tree_gang_lookup_tag(&hwspinlock_tree, (void **)&hwlock,
2012     @@ -431,7 +430,7 @@ struct hwspinlock *hwspin_lock_request(void)
2013     hwlock = NULL;
2014    
2015     out:
2016     - spin_unlock(&hwspinlock_tree_lock);
2017     + mutex_unlock(&hwspinlock_tree_lock);
2018     return hwlock;
2019     }
2020     EXPORT_SYMBOL_GPL(hwspin_lock_request);
2021     @@ -445,9 +444,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_request);
2022     * Usually early board code will be calling this function in order to
2023     * reserve specific hwspinlock ids for predefined purposes.
2024     *
2025     - * Can be called from an atomic context (will not sleep) but not from
2026     - * within interrupt context (simply because there is no use case for
2027     - * that yet).
2028     + * Should be called from a process context (might sleep)
2029     *
2030     * Returns the address of the assigned hwspinlock, or NULL on error
2031     */
2032     @@ -456,7 +453,7 @@ struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
2033     struct hwspinlock *hwlock;
2034     int ret;
2035    
2036     - spin_lock(&hwspinlock_tree_lock);
2037     + mutex_lock(&hwspinlock_tree_lock);
2038    
2039     /* make sure this hwspinlock exists */
2040     hwlock = radix_tree_lookup(&hwspinlock_tree, id);
2041     @@ -482,7 +479,7 @@ struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
2042     hwlock = NULL;
2043    
2044     out:
2045     - spin_unlock(&hwspinlock_tree_lock);
2046     + mutex_unlock(&hwspinlock_tree_lock);
2047     return hwlock;
2048     }
2049     EXPORT_SYMBOL_GPL(hwspin_lock_request_specific);
2050     @@ -495,9 +492,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_request_specific);
2051     * Should only be called with an @hwlock that was retrieved from
2052     * an earlier call to omap_hwspin_lock_request{_specific}.
2053     *
2054     - * Can be called from an atomic context (will not sleep) but not from
2055     - * within interrupt context (simply because there is no use case for
2056     - * that yet).
2057     + * Should be called from a process context (might sleep)
2058     *
2059     * Returns 0 on success, or an appropriate error code on failure
2060     */
2061     @@ -511,7 +506,7 @@ int hwspin_lock_free(struct hwspinlock *hwlock)
2062     return -EINVAL;
2063     }
2064    
2065     - spin_lock(&hwspinlock_tree_lock);
2066     + mutex_lock(&hwspinlock_tree_lock);
2067    
2068     /* make sure the hwspinlock is used */
2069     ret = radix_tree_tag_get(&hwspinlock_tree, hwlock->id,
2070     @@ -538,7 +533,7 @@ int hwspin_lock_free(struct hwspinlock *hwlock)
2071     module_put(hwlock->owner);
2072    
2073     out:
2074     - spin_unlock(&hwspinlock_tree_lock);
2075     + mutex_unlock(&hwspinlock_tree_lock);
2076     return ret;
2077     }
2078     EXPORT_SYMBOL_GPL(hwspin_lock_free);
2079     diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
2080     index dc3d3d8..661b692 100644
2081     --- a/drivers/leds/led-class.c
2082     +++ b/drivers/leds/led-class.c
2083     @@ -267,9 +267,14 @@ void led_blink_set(struct led_classdev *led_cdev,
2084     unsigned long *delay_on,
2085     unsigned long *delay_off)
2086     {
2087     + del_timer_sync(&led_cdev->blink_timer);
2088     +
2089     if (led_cdev->blink_set &&
2090     - !led_cdev->blink_set(led_cdev, delay_on, delay_off))
2091     + !led_cdev->blink_set(led_cdev, delay_on, delay_off)) {
2092     + led_cdev->blink_delay_on = *delay_on;
2093     + led_cdev->blink_delay_off = *delay_off;
2094     return;
2095     + }
2096    
2097     /* blink with 1 Hz as default if nothing specified */
2098     if (!*delay_on && !*delay_off)
2099     diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
2100     index 2581ba1..e509147 100644
2101     --- a/drivers/md/raid5.c
2102     +++ b/drivers/md/raid5.c
2103     @@ -3369,7 +3369,7 @@ static void handle_stripe6(struct stripe_head *sh)
2104     /* Not in-sync */;
2105     else if (test_bit(In_sync, &rdev->flags))
2106     set_bit(R5_Insync, &dev->flags);
2107     - else {
2108     + else if (!test_bit(Faulty, &rdev->flags)) {
2109     /* in sync if before recovery_offset */
2110     if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset)
2111     set_bit(R5_Insync, &dev->flags);
2112     diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
2113     index 5eb91b4..a224e94 100644
2114     --- a/drivers/media/dvb/dvb-usb/dib0700_core.c
2115     +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
2116     @@ -30,6 +30,11 @@ int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
2117     struct dib0700_state *st = d->priv;
2118     int ret;
2119    
2120     + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2121     + deb_info("could not acquire lock");
2122     + return 0;
2123     + }
2124     +
2125     ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
2126     REQUEST_GET_VERSION,
2127     USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
2128     @@ -46,6 +51,7 @@ int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
2129     if (fwtype != NULL)
2130     *fwtype = (st->buf[12] << 24) | (st->buf[13] << 16) |
2131     (st->buf[14] << 8) | st->buf[15];
2132     + mutex_unlock(&d->usb_mutex);
2133     return ret;
2134     }
2135    
2136     @@ -108,7 +114,12 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
2137     int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
2138     {
2139     struct dib0700_state *st = d->priv;
2140     - s16 ret;
2141     + int ret;
2142     +
2143     + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2144     + deb_info("could not acquire lock");
2145     + return 0;
2146     + }
2147    
2148     st->buf[0] = REQUEST_SET_GPIO;
2149     st->buf[1] = gpio;
2150     @@ -116,6 +127,7 @@ int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_
2151    
2152     ret = dib0700_ctrl_wr(d, st->buf, 3);
2153    
2154     + mutex_unlock(&d->usb_mutex);
2155     return ret;
2156     }
2157    
2158     @@ -125,6 +137,11 @@ static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
2159     int ret;
2160    
2161     if (st->fw_version >= 0x10201) {
2162     + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2163     + deb_info("could not acquire lock");
2164     + return 0;
2165     + }
2166     +
2167     st->buf[0] = REQUEST_SET_USB_XFER_LEN;
2168     st->buf[1] = (nb_ts_packets >> 8) & 0xff;
2169     st->buf[2] = nb_ts_packets & 0xff;
2170     @@ -132,6 +149,7 @@ static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
2171     deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
2172    
2173     ret = dib0700_ctrl_wr(d, st->buf, 3);
2174     + mutex_unlock(&d->usb_mutex);
2175     } else {
2176     deb_info("this firmware does not allow to change the USB xfer len\n");
2177     ret = -EIO;
2178     @@ -208,6 +226,10 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
2179    
2180     } else {
2181     /* Write request */
2182     + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2183     + deb_info("could not acquire lock");
2184     + return 0;
2185     + }
2186     st->buf[0] = REQUEST_NEW_I2C_WRITE;
2187     st->buf[1] = msg[i].addr << 1;
2188     st->buf[2] = (en_start << 7) | (en_stop << 6) |
2189     @@ -227,6 +249,7 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
2190     USB_TYPE_VENDOR | USB_DIR_OUT,
2191     0, 0, st->buf, msg[i].len + 4,
2192     USB_CTRL_GET_TIMEOUT);
2193     + mutex_unlock(&d->usb_mutex);
2194     if (result < 0) {
2195     deb_info("i2c write error (status = %d)\n", result);
2196     break;
2197     @@ -249,6 +272,10 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
2198    
2199     if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
2200     return -EAGAIN;
2201     + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2202     + deb_info("could not acquire lock");
2203     + return 0;
2204     + }
2205    
2206     for (i = 0; i < num; i++) {
2207     /* fill in the address */
2208     @@ -279,6 +306,7 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
2209     break;
2210     }
2211     }
2212     + mutex_unlock(&d->usb_mutex);
2213     mutex_unlock(&d->i2c_mutex);
2214    
2215     return i;
2216     @@ -337,7 +365,12 @@ static int dib0700_set_clock(struct dvb_usb_device *d, u8 en_pll,
2217     u16 pll_loopdiv, u16 free_div, u16 dsuScaler)
2218     {
2219     struct dib0700_state *st = d->priv;
2220     - s16 ret;
2221     + int ret;
2222     +
2223     + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2224     + deb_info("could not acquire lock");
2225     + return 0;
2226     + }
2227    
2228     st->buf[0] = REQUEST_SET_CLOCK;
2229     st->buf[1] = (en_pll << 7) | (pll_src << 6) |
2230     @@ -352,6 +385,7 @@ static int dib0700_set_clock(struct dvb_usb_device *d, u8 en_pll,
2231     st->buf[9] = dsuScaler & 0xff; /* LSB */
2232    
2233     ret = dib0700_ctrl_wr(d, st->buf, 10);
2234     + mutex_unlock(&d->usb_mutex);
2235    
2236     return ret;
2237     }
2238     @@ -360,10 +394,16 @@ int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz)
2239     {
2240     struct dib0700_state *st = d->priv;
2241     u16 divider;
2242     + int ret;
2243    
2244     if (scl_kHz == 0)
2245     return -EINVAL;
2246    
2247     + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2248     + deb_info("could not acquire lock");
2249     + return 0;
2250     + }
2251     +
2252     st->buf[0] = REQUEST_SET_I2C_PARAM;
2253     divider = (u16) (30000 / scl_kHz);
2254     st->buf[1] = 0;
2255     @@ -379,7 +419,11 @@ int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz)
2256     deb_info("setting I2C speed: %04x %04x %04x (%d kHz).",
2257     (st->buf[2] << 8) | (st->buf[3]), (st->buf[4] << 8) |
2258     st->buf[5], (st->buf[6] << 8) | st->buf[7], scl_kHz);
2259     - return dib0700_ctrl_wr(d, st->buf, 8);
2260     +
2261     + ret = dib0700_ctrl_wr(d, st->buf, 8);
2262     + mutex_unlock(&d->usb_mutex);
2263     +
2264     + return ret;
2265     }
2266    
2267    
2268     @@ -515,6 +559,11 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
2269     }
2270     }
2271    
2272     + if (mutex_lock_interruptible(&adap->dev->usb_mutex) < 0) {
2273     + deb_info("could not acquire lock");
2274     + return 0;
2275     + }
2276     +
2277     st->buf[0] = REQUEST_ENABLE_VIDEO;
2278     /* this bit gives a kind of command,
2279     * rather than enabling something or not */
2280     @@ -548,7 +597,10 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
2281    
2282     deb_info("data for streaming: %x %x\n", st->buf[1], st->buf[2]);
2283    
2284     - return dib0700_ctrl_wr(adap->dev, st->buf, 4);
2285     + ret = dib0700_ctrl_wr(adap->dev, st->buf, 4);
2286     + mutex_unlock(&adap->dev->usb_mutex);
2287     +
2288     + return ret;
2289     }
2290    
2291     int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
2292     @@ -557,6 +609,11 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
2293     struct dib0700_state *st = d->priv;
2294     int new_proto, ret;
2295    
2296     + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2297     + deb_info("could not acquire lock");
2298     + return 0;
2299     + }
2300     +
2301     st->buf[0] = REQUEST_SET_RC;
2302     st->buf[1] = 0;
2303     st->buf[2] = 0;
2304     @@ -567,23 +624,29 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
2305     else if (rc_type == RC_TYPE_NEC)
2306     new_proto = 0;
2307     else if (rc_type == RC_TYPE_RC6) {
2308     - if (st->fw_version < 0x10200)
2309     - return -EINVAL;
2310     + if (st->fw_version < 0x10200) {
2311     + ret = -EINVAL;
2312     + goto out;
2313     + }
2314    
2315     new_proto = 2;
2316     - } else
2317     - return -EINVAL;
2318     + } else {
2319     + ret = -EINVAL;
2320     + goto out;
2321     + }
2322    
2323     st->buf[1] = new_proto;
2324    
2325     ret = dib0700_ctrl_wr(d, st->buf, 3);
2326     if (ret < 0) {
2327     err("ir protocol setup failed");
2328     - return ret;
2329     + goto out;
2330     }
2331    
2332     d->props.rc.core.protocol = rc_type;
2333    
2334     +out:
2335     + mutex_unlock(&d->usb_mutex);
2336     return ret;
2337     }
2338    
2339     diff --git a/drivers/media/dvb/frontends/dib0070.c b/drivers/media/dvb/frontends/dib0070.c
2340     index 1d47d4d..dc1cb17 100644
2341     --- a/drivers/media/dvb/frontends/dib0070.c
2342     +++ b/drivers/media/dvb/frontends/dib0070.c
2343     @@ -27,6 +27,7 @@
2344     #include <linux/kernel.h>
2345     #include <linux/slab.h>
2346     #include <linux/i2c.h>
2347     +#include <linux/mutex.h>
2348    
2349     #include "dvb_frontend.h"
2350    
2351     @@ -78,10 +79,18 @@ struct dib0070_state {
2352     struct i2c_msg msg[2];
2353     u8 i2c_write_buffer[3];
2354     u8 i2c_read_buffer[2];
2355     + struct mutex i2c_buffer_lock;
2356     };
2357    
2358     -static uint16_t dib0070_read_reg(struct dib0070_state *state, u8 reg)
2359     +static u16 dib0070_read_reg(struct dib0070_state *state, u8 reg)
2360     {
2361     + u16 ret;
2362     +
2363     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2364     + dprintk("could not acquire lock");
2365     + return 0;
2366     + }
2367     +
2368     state->i2c_write_buffer[0] = reg;
2369    
2370     memset(state->msg, 0, 2 * sizeof(struct i2c_msg));
2371     @@ -96,13 +105,23 @@ static uint16_t dib0070_read_reg(struct dib0070_state *state, u8 reg)
2372    
2373     if (i2c_transfer(state->i2c, state->msg, 2) != 2) {
2374     printk(KERN_WARNING "DiB0070 I2C read failed\n");
2375     - return 0;
2376     - }
2377     - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2378     + ret = 0;
2379     + } else
2380     + ret = (state->i2c_read_buffer[0] << 8)
2381     + | state->i2c_read_buffer[1];
2382     +
2383     + mutex_unlock(&state->i2c_buffer_lock);
2384     + return ret;
2385     }
2386    
2387     static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
2388     {
2389     + int ret;
2390     +
2391     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2392     + dprintk("could not acquire lock");
2393     + return -EINVAL;
2394     + }
2395     state->i2c_write_buffer[0] = reg;
2396     state->i2c_write_buffer[1] = val >> 8;
2397     state->i2c_write_buffer[2] = val & 0xff;
2398     @@ -115,9 +134,12 @@ static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
2399    
2400     if (i2c_transfer(state->i2c, state->msg, 1) != 1) {
2401     printk(KERN_WARNING "DiB0070 I2C write failed\n");
2402     - return -EREMOTEIO;
2403     - }
2404     - return 0;
2405     + ret = -EREMOTEIO;
2406     + } else
2407     + ret = 0;
2408     +
2409     + mutex_unlock(&state->i2c_buffer_lock);
2410     + return ret;
2411     }
2412    
2413     #define HARD_RESET(state) do { \
2414     @@ -734,6 +756,7 @@ struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe, struct i2c_adapter
2415     state->cfg = cfg;
2416     state->i2c = i2c;
2417     state->fe = fe;
2418     + mutex_init(&state->i2c_buffer_lock);
2419     fe->tuner_priv = state;
2420    
2421     if (dib0070_reset(fe) != 0)
2422     diff --git a/drivers/media/dvb/frontends/dib0090.c b/drivers/media/dvb/frontends/dib0090.c
2423     index c9c935a..b174d1c 100644
2424     --- a/drivers/media/dvb/frontends/dib0090.c
2425     +++ b/drivers/media/dvb/frontends/dib0090.c
2426     @@ -27,6 +27,7 @@
2427     #include <linux/kernel.h>
2428     #include <linux/slab.h>
2429     #include <linux/i2c.h>
2430     +#include <linux/mutex.h>
2431    
2432     #include "dvb_frontend.h"
2433    
2434     @@ -196,6 +197,7 @@ struct dib0090_state {
2435     struct i2c_msg msg[2];
2436     u8 i2c_write_buffer[3];
2437     u8 i2c_read_buffer[2];
2438     + struct mutex i2c_buffer_lock;
2439     };
2440    
2441     struct dib0090_fw_state {
2442     @@ -208,10 +210,18 @@ struct dib0090_fw_state {
2443     struct i2c_msg msg;
2444     u8 i2c_write_buffer[2];
2445     u8 i2c_read_buffer[2];
2446     + struct mutex i2c_buffer_lock;
2447     };
2448    
2449     static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg)
2450     {
2451     + u16 ret;
2452     +
2453     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2454     + dprintk("could not acquire lock");
2455     + return 0;
2456     + }
2457     +
2458     state->i2c_write_buffer[0] = reg;
2459    
2460     memset(state->msg, 0, 2 * sizeof(struct i2c_msg));
2461     @@ -226,14 +236,24 @@ static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg)
2462    
2463     if (i2c_transfer(state->i2c, state->msg, 2) != 2) {
2464     printk(KERN_WARNING "DiB0090 I2C read failed\n");
2465     - return 0;
2466     - }
2467     + ret = 0;
2468     + } else
2469     + ret = (state->i2c_read_buffer[0] << 8)
2470     + | state->i2c_read_buffer[1];
2471    
2472     - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2473     + mutex_unlock(&state->i2c_buffer_lock);
2474     + return ret;
2475     }
2476    
2477     static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val)
2478     {
2479     + int ret;
2480     +
2481     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2482     + dprintk("could not acquire lock");
2483     + return -EINVAL;
2484     + }
2485     +
2486     state->i2c_write_buffer[0] = reg & 0xff;
2487     state->i2c_write_buffer[1] = val >> 8;
2488     state->i2c_write_buffer[2] = val & 0xff;
2489     @@ -246,13 +266,23 @@ static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val)
2490    
2491     if (i2c_transfer(state->i2c, state->msg, 1) != 1) {
2492     printk(KERN_WARNING "DiB0090 I2C write failed\n");
2493     - return -EREMOTEIO;
2494     - }
2495     - return 0;
2496     + ret = -EREMOTEIO;
2497     + } else
2498     + ret = 0;
2499     +
2500     + mutex_unlock(&state->i2c_buffer_lock);
2501     + return ret;
2502     }
2503    
2504     static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg)
2505     {
2506     + u16 ret;
2507     +
2508     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2509     + dprintk("could not acquire lock");
2510     + return 0;
2511     + }
2512     +
2513     state->i2c_write_buffer[0] = reg;
2514    
2515     memset(&state->msg, 0, sizeof(struct i2c_msg));
2516     @@ -262,13 +292,24 @@ static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg)
2517     state->msg.len = 2;
2518     if (i2c_transfer(state->i2c, &state->msg, 1) != 1) {
2519     printk(KERN_WARNING "DiB0090 I2C read failed\n");
2520     - return 0;
2521     - }
2522     - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2523     + ret = 0;
2524     + } else
2525     + ret = (state->i2c_read_buffer[0] << 8)
2526     + | state->i2c_read_buffer[1];
2527     +
2528     + mutex_unlock(&state->i2c_buffer_lock);
2529     + return ret;
2530     }
2531    
2532     static int dib0090_fw_write_reg(struct dib0090_fw_state *state, u8 reg, u16 val)
2533     {
2534     + int ret;
2535     +
2536     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2537     + dprintk("could not acquire lock");
2538     + return -EINVAL;
2539     + }
2540     +
2541     state->i2c_write_buffer[0] = val >> 8;
2542     state->i2c_write_buffer[1] = val & 0xff;
2543    
2544     @@ -279,9 +320,12 @@ static int dib0090_fw_write_reg(struct dib0090_fw_state *state, u8 reg, u16 val)
2545     state->msg.len = 2;
2546     if (i2c_transfer(state->i2c, &state->msg, 1) != 1) {
2547     printk(KERN_WARNING "DiB0090 I2C write failed\n");
2548     - return -EREMOTEIO;
2549     - }
2550     - return 0;
2551     + ret = -EREMOTEIO;
2552     + } else
2553     + ret = 0;
2554     +
2555     + mutex_unlock(&state->i2c_buffer_lock);
2556     + return ret;
2557     }
2558    
2559     #define HARD_RESET(state) do { if (cfg->reset) { if (cfg->sleep) cfg->sleep(fe, 0); msleep(10); cfg->reset(fe, 1); msleep(10); cfg->reset(fe, 0); msleep(10); } } while (0)
2560     @@ -2440,6 +2484,7 @@ struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapte
2561     st->config = config;
2562     st->i2c = i2c;
2563     st->fe = fe;
2564     + mutex_init(&st->i2c_buffer_lock);
2565     fe->tuner_priv = st;
2566    
2567     if (config->wbd == NULL)
2568     @@ -2471,6 +2516,7 @@ struct dvb_frontend *dib0090_fw_register(struct dvb_frontend *fe, struct i2c_ada
2569     st->config = config;
2570     st->i2c = i2c;
2571     st->fe = fe;
2572     + mutex_init(&st->i2c_buffer_lock);
2573     fe->tuner_priv = st;
2574    
2575     if (dib0090_fw_reset_digital(fe, st->config) != 0)
2576     diff --git a/drivers/media/dvb/frontends/dib7000m.c b/drivers/media/dvb/frontends/dib7000m.c
2577     index 79cb1c2..dbb76d7 100644
2578     --- a/drivers/media/dvb/frontends/dib7000m.c
2579     +++ b/drivers/media/dvb/frontends/dib7000m.c
2580     @@ -11,6 +11,7 @@
2581     #include <linux/kernel.h>
2582     #include <linux/slab.h>
2583     #include <linux/i2c.h>
2584     +#include <linux/mutex.h>
2585    
2586     #include "dvb_frontend.h"
2587    
2588     @@ -55,6 +56,7 @@ struct dib7000m_state {
2589     struct i2c_msg msg[2];
2590     u8 i2c_write_buffer[4];
2591     u8 i2c_read_buffer[2];
2592     + struct mutex i2c_buffer_lock;
2593     };
2594    
2595     enum dib7000m_power_mode {
2596     @@ -69,6 +71,13 @@ enum dib7000m_power_mode {
2597    
2598     static u16 dib7000m_read_word(struct dib7000m_state *state, u16 reg)
2599     {
2600     + u16 ret;
2601     +
2602     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2603     + dprintk("could not acquire lock");
2604     + return 0;
2605     + }
2606     +
2607     state->i2c_write_buffer[0] = (reg >> 8) | 0x80;
2608     state->i2c_write_buffer[1] = reg & 0xff;
2609    
2610     @@ -85,11 +94,21 @@ static u16 dib7000m_read_word(struct dib7000m_state *state, u16 reg)
2611     if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2)
2612     dprintk("i2c read error on %d",reg);
2613    
2614     - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2615     + ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2616     + mutex_unlock(&state->i2c_buffer_lock);
2617     +
2618     + return ret;
2619     }
2620    
2621     static int dib7000m_write_word(struct dib7000m_state *state, u16 reg, u16 val)
2622     {
2623     + int ret;
2624     +
2625     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2626     + dprintk("could not acquire lock");
2627     + return -EINVAL;
2628     + }
2629     +
2630     state->i2c_write_buffer[0] = (reg >> 8) & 0xff;
2631     state->i2c_write_buffer[1] = reg & 0xff;
2632     state->i2c_write_buffer[2] = (val >> 8) & 0xff;
2633     @@ -101,7 +120,10 @@ static int dib7000m_write_word(struct dib7000m_state *state, u16 reg, u16 val)
2634     state->msg[0].buf = state->i2c_write_buffer;
2635     state->msg[0].len = 4;
2636    
2637     - return i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ? -EREMOTEIO : 0;
2638     + ret = (i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ?
2639     + -EREMOTEIO : 0);
2640     + mutex_unlock(&state->i2c_buffer_lock);
2641     + return ret;
2642     }
2643     static void dib7000m_write_tab(struct dib7000m_state *state, u16 *buf)
2644     {
2645     @@ -1385,6 +1407,7 @@ struct dvb_frontend * dib7000m_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr,
2646     demod = &st->demod;
2647     demod->demodulator_priv = st;
2648     memcpy(&st->demod.ops, &dib7000m_ops, sizeof(struct dvb_frontend_ops));
2649     + mutex_init(&st->i2c_buffer_lock);
2650    
2651     st->timf_default = cfg->bw->timf;
2652    
2653     diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c
2654     index 0c9f40c..292bc19 100644
2655     --- a/drivers/media/dvb/frontends/dib7000p.c
2656     +++ b/drivers/media/dvb/frontends/dib7000p.c
2657     @@ -10,6 +10,7 @@
2658     #include <linux/kernel.h>
2659     #include <linux/slab.h>
2660     #include <linux/i2c.h>
2661     +#include <linux/mutex.h>
2662    
2663     #include "dvb_math.h"
2664     #include "dvb_frontend.h"
2665     @@ -68,6 +69,7 @@ struct dib7000p_state {
2666     struct i2c_msg msg[2];
2667     u8 i2c_write_buffer[4];
2668     u8 i2c_read_buffer[2];
2669     + struct mutex i2c_buffer_lock;
2670     };
2671    
2672     enum dib7000p_power_mode {
2673     @@ -81,6 +83,13 @@ static int dib7090_set_diversity_in(struct dvb_frontend *fe, int onoff);
2674    
2675     static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg)
2676     {
2677     + u16 ret;
2678     +
2679     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2680     + dprintk("could not acquire lock");
2681     + return 0;
2682     + }
2683     +
2684     state->i2c_write_buffer[0] = reg >> 8;
2685     state->i2c_write_buffer[1] = reg & 0xff;
2686    
2687     @@ -97,11 +106,20 @@ static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg)
2688     if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2)
2689     dprintk("i2c read error on %d", reg);
2690    
2691     - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2692     + ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2693     + mutex_unlock(&state->i2c_buffer_lock);
2694     + return ret;
2695     }
2696    
2697     static int dib7000p_write_word(struct dib7000p_state *state, u16 reg, u16 val)
2698     {
2699     + int ret;
2700     +
2701     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2702     + dprintk("could not acquire lock");
2703     + return -EINVAL;
2704     + }
2705     +
2706     state->i2c_write_buffer[0] = (reg >> 8) & 0xff;
2707     state->i2c_write_buffer[1] = reg & 0xff;
2708     state->i2c_write_buffer[2] = (val >> 8) & 0xff;
2709     @@ -113,7 +131,10 @@ static int dib7000p_write_word(struct dib7000p_state *state, u16 reg, u16 val)
2710     state->msg[0].buf = state->i2c_write_buffer;
2711     state->msg[0].len = 4;
2712    
2713     - return i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ? -EREMOTEIO : 0;
2714     + ret = (i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ?
2715     + -EREMOTEIO : 0);
2716     + mutex_unlock(&state->i2c_buffer_lock);
2717     + return ret;
2718     }
2719    
2720     static void dib7000p_write_tab(struct dib7000p_state *state, u16 * buf)
2721     @@ -1646,6 +1667,7 @@ int dib7000p_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defau
2722     return -ENOMEM;
2723    
2724     dpst->i2c_adap = i2c;
2725     + mutex_init(&dpst->i2c_buffer_lock);
2726    
2727     for (k = no_of_demods - 1; k >= 0; k--) {
2728     dpst->cfg = cfg[k];
2729     @@ -2324,6 +2346,7 @@ struct dvb_frontend *dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr,
2730     demod = &st->demod;
2731     demod->demodulator_priv = st;
2732     memcpy(&st->demod.ops, &dib7000p_ops, sizeof(struct dvb_frontend_ops));
2733     + mutex_init(&st->i2c_buffer_lock);
2734    
2735     dib7000p_write_word(st, 1287, 0x0003); /* sram lead in, rdy */
2736    
2737     @@ -2333,8 +2356,9 @@ struct dvb_frontend *dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr,
2738     st->version = dib7000p_read_word(st, 897);
2739    
2740     /* FIXME: make sure the dev.parent field is initialized, or else
2741     - request_firmware() will hit an OOPS (this should be moved somewhere
2742     - more common) */
2743     + request_firmware() will hit an OOPS (this should be moved somewhere
2744     + more common) */
2745     + st->i2c_master.gated_tuner_i2c_adap.dev.parent = i2c_adap->dev.parent;
2746    
2747     dibx000_init_i2c_master(&st->i2c_master, DIB7000P, st->i2c_adap, st->i2c_addr);
2748    
2749     diff --git a/drivers/media/dvb/frontends/dib8000.c b/drivers/media/dvb/frontends/dib8000.c
2750     index 7d2ea11..fe284d5 100644
2751     --- a/drivers/media/dvb/frontends/dib8000.c
2752     +++ b/drivers/media/dvb/frontends/dib8000.c
2753     @@ -10,6 +10,8 @@
2754     #include <linux/kernel.h>
2755     #include <linux/slab.h>
2756     #include <linux/i2c.h>
2757     +#include <linux/mutex.h>
2758     +
2759     #include "dvb_math.h"
2760    
2761     #include "dvb_frontend.h"
2762     @@ -37,6 +39,7 @@ struct i2c_device {
2763     u8 addr;
2764     u8 *i2c_write_buffer;
2765     u8 *i2c_read_buffer;
2766     + struct mutex *i2c_buffer_lock;
2767     };
2768    
2769     struct dib8000_state {
2770     @@ -77,6 +80,7 @@ struct dib8000_state {
2771     struct i2c_msg msg[2];
2772     u8 i2c_write_buffer[4];
2773     u8 i2c_read_buffer[2];
2774     + struct mutex i2c_buffer_lock;
2775     };
2776    
2777     enum dib8000_power_mode {
2778     @@ -86,24 +90,39 @@ enum dib8000_power_mode {
2779    
2780     static u16 dib8000_i2c_read16(struct i2c_device *i2c, u16 reg)
2781     {
2782     + u16 ret;
2783     struct i2c_msg msg[2] = {
2784     - {.addr = i2c->addr >> 1, .flags = 0,
2785     - .buf = i2c->i2c_write_buffer, .len = 2},
2786     - {.addr = i2c->addr >> 1, .flags = I2C_M_RD,
2787     - .buf = i2c->i2c_read_buffer, .len = 2},
2788     + {.addr = i2c->addr >> 1, .flags = 0, .len = 2},
2789     + {.addr = i2c->addr >> 1, .flags = I2C_M_RD, .len = 2},
2790     };
2791    
2792     + if (mutex_lock_interruptible(i2c->i2c_buffer_lock) < 0) {
2793     + dprintk("could not acquire lock");
2794     + return 0;
2795     + }
2796     +
2797     + msg[0].buf = i2c->i2c_write_buffer;
2798     msg[0].buf[0] = reg >> 8;
2799     msg[0].buf[1] = reg & 0xff;
2800     + msg[1].buf = i2c->i2c_read_buffer;
2801    
2802     if (i2c_transfer(i2c->adap, msg, 2) != 2)
2803     dprintk("i2c read error on %d", reg);
2804    
2805     - return (msg[1].buf[0] << 8) | msg[1].buf[1];
2806     + ret = (msg[1].buf[0] << 8) | msg[1].buf[1];
2807     + mutex_unlock(i2c->i2c_buffer_lock);
2808     + return ret;
2809     }
2810    
2811     static u16 dib8000_read_word(struct dib8000_state *state, u16 reg)
2812     {
2813     + u16 ret;
2814     +
2815     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2816     + dprintk("could not acquire lock");
2817     + return 0;
2818     + }
2819     +
2820     state->i2c_write_buffer[0] = reg >> 8;
2821     state->i2c_write_buffer[1] = reg & 0xff;
2822    
2823     @@ -120,7 +139,10 @@ static u16 dib8000_read_word(struct dib8000_state *state, u16 reg)
2824     if (i2c_transfer(state->i2c.adap, state->msg, 2) != 2)
2825     dprintk("i2c read error on %d", reg);
2826    
2827     - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2828     + ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2829     + mutex_unlock(&state->i2c_buffer_lock);
2830     +
2831     + return ret;
2832     }
2833    
2834     static u32 dib8000_read32(struct dib8000_state *state, u16 reg)
2835     @@ -135,22 +157,35 @@ static u32 dib8000_read32(struct dib8000_state *state, u16 reg)
2836    
2837     static int dib8000_i2c_write16(struct i2c_device *i2c, u16 reg, u16 val)
2838     {
2839     - struct i2c_msg msg = {.addr = i2c->addr >> 1, .flags = 0,
2840     - .buf = i2c->i2c_write_buffer, .len = 4};
2841     + struct i2c_msg msg = {.addr = i2c->addr >> 1, .flags = 0, .len = 4};
2842     int ret = 0;
2843    
2844     + if (mutex_lock_interruptible(i2c->i2c_buffer_lock) < 0) {
2845     + dprintk("could not acquire lock");
2846     + return -EINVAL;
2847     + }
2848     +
2849     + msg.buf = i2c->i2c_write_buffer;
2850     msg.buf[0] = (reg >> 8) & 0xff;
2851     msg.buf[1] = reg & 0xff;
2852     msg.buf[2] = (val >> 8) & 0xff;
2853     msg.buf[3] = val & 0xff;
2854    
2855     ret = i2c_transfer(i2c->adap, &msg, 1) != 1 ? -EREMOTEIO : 0;
2856     + mutex_unlock(i2c->i2c_buffer_lock);
2857    
2858     return ret;
2859     }
2860    
2861     static int dib8000_write_word(struct dib8000_state *state, u16 reg, u16 val)
2862     {
2863     + int ret;
2864     +
2865     + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2866     + dprintk("could not acquire lock");
2867     + return -EINVAL;
2868     + }
2869     +
2870     state->i2c_write_buffer[0] = (reg >> 8) & 0xff;
2871     state->i2c_write_buffer[1] = reg & 0xff;
2872     state->i2c_write_buffer[2] = (val >> 8) & 0xff;
2873     @@ -162,7 +197,11 @@ static int dib8000_write_word(struct dib8000_state *state, u16 reg, u16 val)
2874     state->msg[0].buf = state->i2c_write_buffer;
2875     state->msg[0].len = 4;
2876    
2877     - return i2c_transfer(state->i2c.adap, state->msg, 1) != 1 ? -EREMOTEIO : 0;
2878     + ret = (i2c_transfer(state->i2c.adap, state->msg, 1) != 1 ?
2879     + -EREMOTEIO : 0);
2880     + mutex_unlock(&state->i2c_buffer_lock);
2881     +
2882     + return ret;
2883     }
2884    
2885     static const s16 coeff_2k_sb_1seg_dqpsk[8] = {
2886     @@ -2434,8 +2473,15 @@ int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, u8 defau
2887     if (!client.i2c_read_buffer) {
2888     dprintk("%s: not enough memory", __func__);
2889     ret = -ENOMEM;
2890     - goto error_memory;
2891     + goto error_memory_read;
2892     + }
2893     + client.i2c_buffer_lock = kzalloc(sizeof(struct mutex), GFP_KERNEL);
2894     + if (!client.i2c_buffer_lock) {
2895     + dprintk("%s: not enough memory", __func__);
2896     + ret = -ENOMEM;
2897     + goto error_memory_lock;
2898     }
2899     + mutex_init(client.i2c_buffer_lock);
2900    
2901     for (k = no_of_demods - 1; k >= 0; k--) {
2902     /* designated i2c address */
2903     @@ -2476,8 +2522,10 @@ int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, u8 defau
2904     }
2905    
2906     error:
2907     + kfree(client.i2c_buffer_lock);
2908     +error_memory_lock:
2909     kfree(client.i2c_read_buffer);
2910     -error_memory:
2911     +error_memory_read:
2912     kfree(client.i2c_write_buffer);
2913    
2914     return ret;
2915     @@ -2581,6 +2629,8 @@ struct dvb_frontend *dib8000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, s
2916     state->i2c.addr = i2c_addr;
2917     state->i2c.i2c_write_buffer = state->i2c_write_buffer;
2918     state->i2c.i2c_read_buffer = state->i2c_read_buffer;
2919     + mutex_init(&state->i2c_buffer_lock);
2920     + state->i2c.i2c_buffer_lock = &state->i2c_buffer_lock;
2921     state->gpio_val = cfg->gpio_val;
2922     state->gpio_dir = cfg->gpio_dir;
2923    
2924     diff --git a/drivers/media/dvb/frontends/dib9000.c b/drivers/media/dvb/frontends/dib9000.c
2925     index a085588..b931074 100644
2926     --- a/drivers/media/dvb/frontends/dib9000.c
2927     +++ b/drivers/media/dvb/frontends/dib9000.c
2928     @@ -38,6 +38,15 @@ struct i2c_device {
2929     #define DibInitLock(lock) mutex_init(lock)
2930     #define DibFreeLock(lock)
2931    
2932     +struct dib9000_pid_ctrl {
2933     +#define DIB9000_PID_FILTER_CTRL 0
2934     +#define DIB9000_PID_FILTER 1
2935     + u8 cmd;
2936     + u8 id;
2937     + u16 pid;
2938     + u8 onoff;
2939     +};
2940     +
2941     struct dib9000_state {
2942     struct i2c_device i2c;
2943    
2944     @@ -99,6 +108,10 @@ struct dib9000_state {
2945     struct i2c_msg msg[2];
2946     u8 i2c_write_buffer[255];
2947     u8 i2c_read_buffer[255];
2948     + DIB_LOCK demod_lock;
2949     + u8 get_frontend_internal;
2950     + struct dib9000_pid_ctrl pid_ctrl[10];
2951     + s8 pid_ctrl_index; /* -1: empty list; -2: do not use the list */
2952     };
2953    
2954     static const u32 fe_info[44] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2955     @@ -1743,19 +1756,56 @@ EXPORT_SYMBOL(dib9000_set_gpio);
2956     int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
2957     {
2958     struct dib9000_state *state = fe->demodulator_priv;
2959     - u16 val = dib9000_read_word(state, 294 + 1) & 0xffef;
2960     + u16 val;
2961     + int ret;
2962     +
2963     + if ((state->pid_ctrl_index != -2) && (state->pid_ctrl_index < 9)) {
2964     + /* postpone the pid filtering cmd */
2965     + dprintk("pid filter cmd postpone");
2966     + state->pid_ctrl_index++;
2967     + state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER_CTRL;
2968     + state->pid_ctrl[state->pid_ctrl_index].onoff = onoff;
2969     + return 0;
2970     + }
2971     +
2972     + DibAcquireLock(&state->demod_lock);
2973     +
2974     + val = dib9000_read_word(state, 294 + 1) & 0xffef;
2975     val |= (onoff & 0x1) << 4;
2976    
2977     dprintk("PID filter enabled %d", onoff);
2978     - return dib9000_write_word(state, 294 + 1, val);
2979     + ret = dib9000_write_word(state, 294 + 1, val);
2980     + DibReleaseLock(&state->demod_lock);
2981     + return ret;
2982     +
2983     }
2984     EXPORT_SYMBOL(dib9000_fw_pid_filter_ctrl);
2985    
2986     int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
2987     {
2988     struct dib9000_state *state = fe->demodulator_priv;
2989     + int ret;
2990     +
2991     + if (state->pid_ctrl_index != -2) {
2992     + /* postpone the pid filtering cmd */
2993     + dprintk("pid filter postpone");
2994     + if (state->pid_ctrl_index < 9) {
2995     + state->pid_ctrl_index++;
2996     + state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER;
2997     + state->pid_ctrl[state->pid_ctrl_index].id = id;
2998     + state->pid_ctrl[state->pid_ctrl_index].pid = pid;
2999     + state->pid_ctrl[state->pid_ctrl_index].onoff = onoff;
3000     + } else
3001     + dprintk("can not add any more pid ctrl cmd");
3002     + return 0;
3003     + }
3004     +
3005     + DibAcquireLock(&state->demod_lock);
3006     dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff);
3007     - return dib9000_write_word(state, 300 + 1 + id, onoff ? (1 << 13) | pid : 0);
3008     + ret = dib9000_write_word(state, 300 + 1 + id,
3009     + onoff ? (1 << 13) | pid : 0);
3010     + DibReleaseLock(&state->demod_lock);
3011     + return ret;
3012     }
3013     EXPORT_SYMBOL(dib9000_fw_pid_filter);
3014    
3015     @@ -1778,6 +1828,7 @@ static void dib9000_release(struct dvb_frontend *demod)
3016     DibFreeLock(&state->platform.risc.mbx_lock);
3017     DibFreeLock(&state->platform.risc.mem_lock);
3018     DibFreeLock(&state->platform.risc.mem_mbx_lock);
3019     + DibFreeLock(&state->demod_lock);
3020     dibx000_exit_i2c_master(&st->i2c_master);
3021    
3022     i2c_del_adapter(&st->tuner_adap);
3023     @@ -1795,14 +1846,19 @@ static int dib9000_sleep(struct dvb_frontend *fe)
3024     {
3025     struct dib9000_state *state = fe->demodulator_priv;
3026     u8 index_frontend;
3027     - int ret;
3028     + int ret = 0;
3029    
3030     + DibAcquireLock(&state->demod_lock);
3031     for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3032     ret = state->fe[index_frontend]->ops.sleep(state->fe[index_frontend]);
3033     if (ret < 0)
3034     - return ret;
3035     + goto error;
3036     }
3037     - return dib9000_mbx_send(state, OUT_MSG_FE_SLEEP, NULL, 0);
3038     + ret = dib9000_mbx_send(state, OUT_MSG_FE_SLEEP, NULL, 0);
3039     +
3040     +error:
3041     + DibReleaseLock(&state->demod_lock);
3042     + return ret;
3043     }
3044    
3045     static int dib9000_fe_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings *tune)
3046     @@ -1816,7 +1872,10 @@ static int dib9000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3047     struct dib9000_state *state = fe->demodulator_priv;
3048     u8 index_frontend, sub_index_frontend;
3049     fe_status_t stat;
3050     - int ret;
3051     + int ret = 0;
3052     +
3053     + if (state->get_frontend_internal == 0)
3054     + DibAcquireLock(&state->demod_lock);
3055    
3056     for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3057     state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat);
3058     @@ -1846,14 +1905,15 @@ static int dib9000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3059     state->fe[index_frontend]->dtv_property_cache.rolloff;
3060     }
3061     }
3062     - return 0;
3063     + ret = 0;
3064     + goto return_value;
3065     }
3066     }
3067    
3068     /* get the channel from master chip */
3069     ret = dib9000_fw_get_channel(fe, fep);
3070     if (ret != 0)
3071     - return ret;
3072     + goto return_value;
3073    
3074     /* synchronize the cache with the other frontends */
3075     for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3076     @@ -1866,8 +1926,12 @@ static int dib9000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3077     state->fe[index_frontend]->dtv_property_cache.code_rate_LP = fe->dtv_property_cache.code_rate_LP;
3078     state->fe[index_frontend]->dtv_property_cache.rolloff = fe->dtv_property_cache.rolloff;
3079     }
3080     + ret = 0;
3081    
3082     - return 0;
3083     +return_value:
3084     + if (state->get_frontend_internal == 0)
3085     + DibReleaseLock(&state->demod_lock);
3086     + return ret;
3087     }
3088    
3089     static int dib9000_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state)
3090     @@ -1912,6 +1976,10 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3091     dprintk("dib9000: must specify bandwidth ");
3092     return 0;
3093     }
3094     +
3095     + state->pid_ctrl_index = -1; /* postpone the pid filtering cmd */
3096     + DibAcquireLock(&state->demod_lock);
3097     +
3098     fe->dtv_property_cache.delivery_system = SYS_DVBT;
3099    
3100     /* set the master status */
3101     @@ -1974,13 +2042,18 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3102     /* check the tune result */
3103     if (exit_condition == 1) { /* tune failed */
3104     dprintk("tune failed");
3105     + DibReleaseLock(&state->demod_lock);
3106     + /* tune failed; put all the pid filtering cmd to junk */
3107     + state->pid_ctrl_index = -1;
3108     return 0;
3109     }
3110    
3111     dprintk("tune success on frontend%i", index_frontend_success);
3112    
3113     /* synchronize all the channel cache */
3114     + state->get_frontend_internal = 1;
3115     dib9000_get_frontend(state->fe[0], fep);
3116     + state->get_frontend_internal = 0;
3117    
3118     /* retune the other frontends with the found channel */
3119     channel_status.status = CHANNEL_STATUS_PARAMETERS_SET;
3120     @@ -2025,6 +2098,28 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3121     /* turn off the diversity for the last frontend */
3122     dib9000_fw_set_diversity_in(state->fe[index_frontend - 1], 0);
3123    
3124     + DibReleaseLock(&state->demod_lock);
3125     + if (state->pid_ctrl_index >= 0) {
3126     + u8 index_pid_filter_cmd;
3127     + u8 pid_ctrl_index = state->pid_ctrl_index;
3128     +
3129     + state->pid_ctrl_index = -2;
3130     + for (index_pid_filter_cmd = 0;
3131     + index_pid_filter_cmd <= pid_ctrl_index;
3132     + index_pid_filter_cmd++) {
3133     + if (state->pid_ctrl[index_pid_filter_cmd].cmd == DIB9000_PID_FILTER_CTRL)
3134     + dib9000_fw_pid_filter_ctrl(state->fe[0],
3135     + state->pid_ctrl[index_pid_filter_cmd].onoff);
3136     + else if (state->pid_ctrl[index_pid_filter_cmd].cmd == DIB9000_PID_FILTER)
3137     + dib9000_fw_pid_filter(state->fe[0],
3138     + state->pid_ctrl[index_pid_filter_cmd].id,
3139     + state->pid_ctrl[index_pid_filter_cmd].pid,
3140     + state->pid_ctrl[index_pid_filter_cmd].onoff);
3141     + }
3142     + }
3143     + /* do not postpone any more the pid filtering */
3144     + state->pid_ctrl_index = -2;
3145     +
3146     return 0;
3147     }
3148    
3149     @@ -2041,6 +2136,7 @@ static int dib9000_read_status(struct dvb_frontend *fe, fe_status_t * stat)
3150     u8 index_frontend;
3151     u16 lock = 0, lock_slave = 0;
3152    
3153     + DibAcquireLock(&state->demod_lock);
3154     for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++)
3155     lock_slave |= dib9000_read_lock(state->fe[index_frontend]);
3156    
3157     @@ -2059,6 +2155,8 @@ static int dib9000_read_status(struct dvb_frontend *fe, fe_status_t * stat)
3158     if ((lock & 0x0008) || (lock_slave & 0x0008))
3159     *stat |= FE_HAS_LOCK;
3160    
3161     + DibReleaseLock(&state->demod_lock);
3162     +
3163     return 0;
3164     }
3165    
3166     @@ -2066,10 +2164,14 @@ static int dib9000_read_ber(struct dvb_frontend *fe, u32 * ber)
3167     {
3168     struct dib9000_state *state = fe->demodulator_priv;
3169     u16 *c;
3170     + int ret = 0;
3171    
3172     + DibAcquireLock(&state->demod_lock);
3173     DibAcquireLock(&state->platform.risc.mem_mbx_lock);
3174     - if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0)
3175     - return -EIO;
3176     + if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
3177     + ret = -EIO;
3178     + goto error;
3179     + }
3180     dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR,
3181     state->i2c_read_buffer, 16 * 2);
3182     DibReleaseLock(&state->platform.risc.mem_mbx_lock);
3183     @@ -2077,7 +2179,10 @@ static int dib9000_read_ber(struct dvb_frontend *fe, u32 * ber)
3184     c = (u16 *)state->i2c_read_buffer;
3185    
3186     *ber = c[10] << 16 | c[11];
3187     - return 0;
3188     +
3189     +error:
3190     + DibReleaseLock(&state->demod_lock);
3191     + return ret;
3192     }
3193    
3194     static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
3195     @@ -2086,7 +2191,9 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
3196     u8 index_frontend;
3197     u16 *c = (u16 *)state->i2c_read_buffer;
3198     u16 val;
3199     + int ret = 0;
3200    
3201     + DibAcquireLock(&state->demod_lock);
3202     *strength = 0;
3203     for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3204     state->fe[index_frontend]->ops.read_signal_strength(state->fe[index_frontend], &val);
3205     @@ -2097,8 +2204,10 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
3206     }
3207    
3208     DibAcquireLock(&state->platform.risc.mem_mbx_lock);
3209     - if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0)
3210     - return -EIO;
3211     + if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
3212     + ret = -EIO;
3213     + goto error;
3214     + }
3215     dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2);
3216     DibReleaseLock(&state->platform.risc.mem_mbx_lock);
3217    
3218     @@ -2107,7 +2216,10 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
3219     *strength = 65535;
3220     else
3221     *strength += val;
3222     - return 0;
3223     +
3224     +error:
3225     + DibReleaseLock(&state->demod_lock);
3226     + return ret;
3227     }
3228    
3229     static u32 dib9000_get_snr(struct dvb_frontend *fe)
3230     @@ -2151,6 +2263,7 @@ static int dib9000_read_snr(struct dvb_frontend *fe, u16 * snr)
3231     u8 index_frontend;
3232     u32 snr_master;
3233    
3234     + DibAcquireLock(&state->demod_lock);
3235     snr_master = dib9000_get_snr(fe);
3236     for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++)
3237     snr_master += dib9000_get_snr(state->fe[index_frontend]);
3238     @@ -2161,6 +2274,8 @@ static int dib9000_read_snr(struct dvb_frontend *fe, u16 * snr)
3239     } else
3240     *snr = 0;
3241    
3242     + DibReleaseLock(&state->demod_lock);
3243     +
3244     return 0;
3245     }
3246    
3247     @@ -2168,15 +2283,22 @@ static int dib9000_read_unc_blocks(struct dvb_frontend *fe, u32 * unc)
3248     {
3249     struct dib9000_state *state = fe->demodulator_priv;
3250     u16 *c = (u16 *)state->i2c_read_buffer;
3251     + int ret = 0;
3252    
3253     + DibAcquireLock(&state->demod_lock);
3254     DibAcquireLock(&state->platform.risc.mem_mbx_lock);
3255     - if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0)
3256     - return -EIO;
3257     + if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
3258     + ret = -EIO;
3259     + goto error;
3260     + }
3261     dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2);
3262     DibReleaseLock(&state->platform.risc.mem_mbx_lock);
3263    
3264     *unc = c[12];
3265     - return 0;
3266     +
3267     +error:
3268     + DibReleaseLock(&state->demod_lock);
3269     + return ret;
3270     }
3271    
3272     int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, u8 first_addr)
3273     @@ -2322,6 +2444,10 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c
3274     DibInitLock(&st->platform.risc.mbx_lock);
3275     DibInitLock(&st->platform.risc.mem_lock);
3276     DibInitLock(&st->platform.risc.mem_mbx_lock);
3277     + DibInitLock(&st->demod_lock);
3278     + st->get_frontend_internal = 0;
3279     +
3280     + st->pid_ctrl_index = -2;
3281    
3282     st->fe[0] = fe;
3283     fe->demodulator_priv = st;
3284     diff --git a/drivers/media/dvb/frontends/dibx000_common.c b/drivers/media/dvb/frontends/dibx000_common.c
3285     index dc5d17a..774d507 100644
3286     --- a/drivers/media/dvb/frontends/dibx000_common.c
3287     +++ b/drivers/media/dvb/frontends/dibx000_common.c
3288     @@ -1,4 +1,5 @@
3289     #include <linux/i2c.h>
3290     +#include <linux/mutex.h>
3291    
3292     #include "dibx000_common.h"
3293    
3294     @@ -10,6 +11,13 @@ MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
3295    
3296     static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
3297     {
3298     + int ret;
3299     +
3300     + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3301     + dprintk("could not acquire lock");
3302     + return -EINVAL;
3303     + }
3304     +
3305     mst->i2c_write_buffer[0] = (reg >> 8) & 0xff;
3306     mst->i2c_write_buffer[1] = reg & 0xff;
3307     mst->i2c_write_buffer[2] = (val >> 8) & 0xff;
3308     @@ -21,11 +29,21 @@ static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
3309     mst->msg[0].buf = mst->i2c_write_buffer;
3310     mst->msg[0].len = 4;
3311    
3312     - return i2c_transfer(mst->i2c_adap, mst->msg, 1) != 1 ? -EREMOTEIO : 0;
3313     + ret = i2c_transfer(mst->i2c_adap, mst->msg, 1) != 1 ? -EREMOTEIO : 0;
3314     + mutex_unlock(&mst->i2c_buffer_lock);
3315     +
3316     + return ret;
3317     }
3318    
3319     static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg)
3320     {
3321     + u16 ret;
3322     +
3323     + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3324     + dprintk("could not acquire lock");
3325     + return 0;
3326     + }
3327     +
3328     mst->i2c_write_buffer[0] = reg >> 8;
3329     mst->i2c_write_buffer[1] = reg & 0xff;
3330    
3331     @@ -42,7 +60,10 @@ static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg)
3332     if (i2c_transfer(mst->i2c_adap, mst->msg, 2) != 2)
3333     dprintk("i2c read error on %d", reg);
3334    
3335     - return (mst->i2c_read_buffer[0] << 8) | mst->i2c_read_buffer[1];
3336     + ret = (mst->i2c_read_buffer[0] << 8) | mst->i2c_read_buffer[1];
3337     + mutex_unlock(&mst->i2c_buffer_lock);
3338     +
3339     + return ret;
3340     }
3341    
3342     static int dibx000_is_i2c_done(struct dibx000_i2c_master *mst)
3343     @@ -257,6 +278,7 @@ static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap,
3344     struct i2c_msg msg[], int num)
3345     {
3346     struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
3347     + int ret;
3348    
3349     if (num > 32) {
3350     dprintk("%s: too much I2C message to be transmitted (%i).\
3351     @@ -264,10 +286,15 @@ static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap,
3352     return -ENOMEM;
3353     }
3354    
3355     - memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
3356     -
3357     dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_6_7);
3358    
3359     + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3360     + dprintk("could not acquire lock");
3361     + return -EINVAL;
3362     + }
3363     +
3364     + memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
3365     +
3366     /* open the gate */
3367     dibx000_i2c_gate_ctrl(mst, &mst->i2c_write_buffer[0], msg[0].addr, 1);
3368     mst->msg[0].addr = mst->i2c_addr;
3369     @@ -282,7 +309,11 @@ static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap,
3370     mst->msg[num + 1].buf = &mst->i2c_write_buffer[4];
3371     mst->msg[num + 1].len = 4;
3372    
3373     - return i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ? num : -EIO;
3374     + ret = (i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ?
3375     + num : -EIO);
3376     +
3377     + mutex_unlock(&mst->i2c_buffer_lock);
3378     + return ret;
3379     }
3380    
3381     static struct i2c_algorithm dibx000_i2c_gated_gpio67_algo = {
3382     @@ -294,6 +325,7 @@ static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
3383     struct i2c_msg msg[], int num)
3384     {
3385     struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
3386     + int ret;
3387    
3388     if (num > 32) {
3389     dprintk("%s: too much I2C message to be transmitted (%i).\
3390     @@ -301,10 +333,14 @@ static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
3391     return -ENOMEM;
3392     }
3393    
3394     - memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
3395     -
3396     dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER);
3397    
3398     + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3399     + dprintk("could not acquire lock");
3400     + return -EINVAL;
3401     + }
3402     + memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
3403     +
3404     /* open the gate */
3405     dibx000_i2c_gate_ctrl(mst, &mst->i2c_write_buffer[0], msg[0].addr, 1);
3406     mst->msg[0].addr = mst->i2c_addr;
3407     @@ -319,7 +355,10 @@ static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
3408     mst->msg[num + 1].buf = &mst->i2c_write_buffer[4];
3409     mst->msg[num + 1].len = 4;
3410    
3411     - return i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ? num : -EIO;
3412     + ret = (i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ?
3413     + num : -EIO);
3414     + mutex_unlock(&mst->i2c_buffer_lock);
3415     + return ret;
3416     }
3417    
3418     static struct i2c_algorithm dibx000_i2c_gated_tuner_algo = {
3419     @@ -390,8 +429,18 @@ static int i2c_adapter_init(struct i2c_adapter *i2c_adap,
3420     int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev,
3421     struct i2c_adapter *i2c_adap, u8 i2c_addr)
3422     {
3423     - u8 tx[4];
3424     - struct i2c_msg m = {.addr = i2c_addr >> 1,.buf = tx,.len = 4 };
3425     + int ret;
3426     +
3427     + mutex_init(&mst->i2c_buffer_lock);
3428     + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3429     + dprintk("could not acquire lock");
3430     + return -EINVAL;
3431     + }
3432     + memset(mst->msg, 0, sizeof(struct i2c_msg));
3433     + mst->msg[0].addr = i2c_addr >> 1;
3434     + mst->msg[0].flags = 0;
3435     + mst->msg[0].buf = mst->i2c_write_buffer;
3436     + mst->msg[0].len = 4;
3437    
3438     mst->device_rev = device_rev;
3439     mst->i2c_adap = i2c_adap;
3440     @@ -431,9 +480,12 @@ int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev,
3441     "DiBX000: could not initialize the master i2c_adapter\n");
3442    
3443     /* initialize the i2c-master by closing the gate */
3444     - dibx000_i2c_gate_ctrl(mst, tx, 0, 0);
3445     + dibx000_i2c_gate_ctrl(mst, mst->i2c_write_buffer, 0, 0);
3446     +
3447     + ret = (i2c_transfer(i2c_adap, mst->msg, 1) == 1);
3448     + mutex_unlock(&mst->i2c_buffer_lock);
3449    
3450     - return i2c_transfer(i2c_adap, &m, 1) == 1;
3451     + return ret;
3452     }
3453    
3454     EXPORT_SYMBOL(dibx000_init_i2c_master);
3455     diff --git a/drivers/media/dvb/frontends/dibx000_common.h b/drivers/media/dvb/frontends/dibx000_common.h
3456     index f031165..5e01147 100644
3457     --- a/drivers/media/dvb/frontends/dibx000_common.h
3458     +++ b/drivers/media/dvb/frontends/dibx000_common.h
3459     @@ -33,6 +33,7 @@ struct dibx000_i2c_master {
3460     struct i2c_msg msg[34];
3461     u8 i2c_write_buffer[8];
3462     u8 i2c_read_buffer[2];
3463     + struct mutex i2c_buffer_lock;
3464     };
3465    
3466     extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst,
3467     diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
3468     index 3c315f9..2b5cd21 100644
3469     --- a/drivers/media/video/cx23885/cx23885-dvb.c
3470     +++ b/drivers/media/video/cx23885/cx23885-dvb.c
3471     @@ -843,7 +843,7 @@ static int dvb_register(struct cx23885_tsport *port)
3472     static struct xc2028_ctrl ctl = {
3473     .fname = XC3028L_DEFAULT_FIRMWARE,
3474     .max_len = 64,
3475     - .demod = 5000,
3476     + .demod = XC3028_FE_DIBCOM52,
3477     /* This is true for all demods with
3478     v36 firmware? */
3479     .type = XC2028_D2633,
3480     diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
3481     index b6eae48..1f962dc 100644
3482     --- a/drivers/media/video/uvc/uvc_driver.c
3483     +++ b/drivers/media/video/uvc/uvc_driver.c
3484     @@ -1960,7 +1960,7 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
3485    
3486     list_for_each_entry(stream, &dev->streams, list) {
3487     if (stream->intf == intf)
3488     - return uvc_video_resume(stream);
3489     + return uvc_video_resume(stream, reset);
3490     }
3491    
3492     uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface "
3493     diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
3494     index 4999479..6f147de 100644
3495     --- a/drivers/media/video/uvc/uvc_video.c
3496     +++ b/drivers/media/video/uvc/uvc_video.c
3497     @@ -1104,10 +1104,18 @@ int uvc_video_suspend(struct uvc_streaming *stream)
3498     * buffers, making sure userspace applications are notified of the problem
3499     * instead of waiting forever.
3500     */
3501     -int uvc_video_resume(struct uvc_streaming *stream)
3502     +int uvc_video_resume(struct uvc_streaming *stream, int reset)
3503     {
3504     int ret;
3505    
3506     + /* If the bus has been reset on resume, set the alternate setting to 0.
3507     + * This should be the default value, but some devices crash or otherwise
3508     + * misbehave if they don't receive a SET_INTERFACE request before any
3509     + * other video control request.
3510     + */
3511     + if (reset)
3512     + usb_set_interface(stream->dev->udev, stream->intfnum, 0);
3513     +
3514     stream->frozen = 0;
3515    
3516     ret = uvc_commit_video(stream, &stream->ctrl);
3517     diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
3518     index 20107fd..2a38d5e 100644
3519     --- a/drivers/media/video/uvc/uvcvideo.h
3520     +++ b/drivers/media/video/uvc/uvcvideo.h
3521     @@ -639,7 +639,7 @@ extern void uvc_mc_cleanup_entity(struct uvc_entity *entity);
3522     /* Video */
3523     extern int uvc_video_init(struct uvc_streaming *stream);
3524     extern int uvc_video_suspend(struct uvc_streaming *stream);
3525     -extern int uvc_video_resume(struct uvc_streaming *stream);
3526     +extern int uvc_video_resume(struct uvc_streaming *stream, int reset);
3527     extern int uvc_video_enable(struct uvc_streaming *stream, int enable);
3528     extern int uvc_probe_video(struct uvc_streaming *stream,
3529     struct uvc_streaming_control *probe);
3530     diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
3531     index 38089b2..75db30e6 100644
3532     --- a/drivers/mmc/core/core.c
3533     +++ b/drivers/mmc/core/core.c
3534     @@ -1057,7 +1057,7 @@ static void mmc_power_up(struct mmc_host *host)
3535     mmc_host_clk_release(host);
3536     }
3537    
3538     -static void mmc_power_off(struct mmc_host *host)
3539     +void mmc_power_off(struct mmc_host *host)
3540     {
3541     mmc_host_clk_hold(host);
3542    
3543     @@ -1147,8 +1147,7 @@ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
3544     }
3545    
3546     /*
3547     - * Remove the current bus handler from a host. Assumes that there are
3548     - * no interesting cards left, so the bus is powered down.
3549     + * Remove the current bus handler from a host.
3550     */
3551     void mmc_detach_bus(struct mmc_host *host)
3552     {
3553     @@ -1165,8 +1164,6 @@ void mmc_detach_bus(struct mmc_host *host)
3554    
3555     spin_unlock_irqrestore(&host->lock, flags);
3556    
3557     - mmc_power_off(host);
3558     -
3559     mmc_bus_put(host);
3560     }
3561    
3562     @@ -1675,6 +1672,7 @@ void mmc_stop_host(struct mmc_host *host)
3563    
3564     mmc_claim_host(host);
3565     mmc_detach_bus(host);
3566     + mmc_power_off(host);
3567     mmc_release_host(host);
3568     mmc_bus_put(host);
3569     return;
3570     @@ -1796,6 +1794,7 @@ int mmc_suspend_host(struct mmc_host *host)
3571     host->bus_ops->remove(host);
3572     mmc_claim_host(host);
3573     mmc_detach_bus(host);
3574     + mmc_power_off(host);
3575     mmc_release_host(host);
3576     host->pm_flags = 0;
3577     err = 0;
3578     @@ -1883,6 +1882,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,
3579     host->bus_ops->remove(host);
3580    
3581     mmc_detach_bus(host);
3582     + mmc_power_off(host);
3583     mmc_release_host(host);
3584     host->pm_flags = 0;
3585     break;
3586     diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
3587     index d9411ed..14664f1 100644
3588     --- a/drivers/mmc/core/core.h
3589     +++ b/drivers/mmc/core/core.h
3590     @@ -43,6 +43,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage,
3591     bool cmd11);
3592     void mmc_set_timing(struct mmc_host *host, unsigned int timing);
3593     void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type);
3594     +void mmc_power_off(struct mmc_host *host);
3595    
3596     static inline void mmc_delay(unsigned int ms)
3597     {
3598     diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
3599     index aa7d1d7..20b42c8 100644
3600     --- a/drivers/mmc/core/mmc.c
3601     +++ b/drivers/mmc/core/mmc.c
3602     @@ -359,6 +359,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
3603     * card has the Enhanced area enabled. If so, export enhanced
3604     * area offset and size to user by adding sysfs interface.
3605     */
3606     + card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT];
3607     if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) &&
3608     (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) {
3609     u8 hc_erase_grp_sz =
3610     @@ -405,6 +406,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
3611     if (card->ext_csd.rev >= 5)
3612     card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM];
3613    
3614     + card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT];
3615     if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
3616     card->erased_byte = 0xFF;
3617     else
3618     @@ -891,6 +893,7 @@ static void mmc_detect(struct mmc_host *host)
3619    
3620     mmc_claim_host(host);
3621     mmc_detach_bus(host);
3622     + mmc_power_off(host);
3623     mmc_release_host(host);
3624     }
3625     }
3626     diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
3627     index ff27741..bd8805c 100644
3628     --- a/drivers/mmc/core/sd.c
3629     +++ b/drivers/mmc/core/sd.c
3630     @@ -1008,6 +1008,7 @@ static void mmc_sd_detect(struct mmc_host *host)
3631    
3632     mmc_claim_host(host);
3633     mmc_detach_bus(host);
3634     + mmc_power_off(host);
3635     mmc_release_host(host);
3636     }
3637     }
3638     diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
3639     index 262fff0..ac492ac 100644
3640     --- a/drivers/mmc/core/sdio.c
3641     +++ b/drivers/mmc/core/sdio.c
3642     @@ -597,6 +597,7 @@ out:
3643    
3644     mmc_claim_host(host);
3645     mmc_detach_bus(host);
3646     + mmc_power_off(host);
3647     mmc_release_host(host);
3648     }
3649     }
3650     diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
3651     index 3f92731..9f8658e 100644
3652     --- a/drivers/mtd/mtdchar.c
3653     +++ b/drivers/mtd/mtdchar.c
3654     @@ -320,6 +320,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
3655     ops.mode = MTD_OOB_RAW;
3656     ops.datbuf = kbuf;
3657     ops.oobbuf = NULL;
3658     + ops.ooboffs = 0;
3659     ops.len = len;
3660    
3661     ret = mtd->write_oob(mtd, *ppos, &ops);
3662     diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
3663     index a46e9bb..86f05f4 100644
3664     --- a/drivers/mtd/nand/nand_base.c
3665     +++ b/drivers/mtd/nand/nand_base.c
3666     @@ -2097,14 +2097,22 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
3667    
3668     /**
3669     * nand_fill_oob - [Internal] Transfer client buffer to oob
3670     - * @chip: nand chip structure
3671     + * @mtd: MTD device structure
3672     * @oob: oob data buffer
3673     * @len: oob data write length
3674     * @ops: oob ops structure
3675     */
3676     -static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob, size_t len,
3677     - struct mtd_oob_ops *ops)
3678     +static uint8_t *nand_fill_oob(struct mtd_info *mtd, uint8_t *oob, size_t len,
3679     + struct mtd_oob_ops *ops)
3680     {
3681     + struct nand_chip *chip = mtd->priv;
3682     +
3683     + /*
3684     + * Initialise to all 0xFF, to avoid the possibility of left over OOB
3685     + * data from a previous OOB read.
3686     + */
3687     + memset(chip->oob_poi, 0xff, mtd->oobsize);
3688     +
3689     switch (ops->mode) {
3690    
3691     case MTD_OOB_PLACE:
3692     @@ -2201,10 +2209,6 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
3693     (chip->pagebuf << chip->page_shift) < (to + ops->len))
3694     chip->pagebuf = -1;
3695    
3696     - /* If we're not given explicit OOB data, let it be 0xFF */
3697     - if (likely(!oob))
3698     - memset(chip->oob_poi, 0xff, mtd->oobsize);
3699     -
3700     /* Don't allow multipage oob writes with offset */
3701     if (oob && ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen))
3702     return -EINVAL;
3703     @@ -2226,8 +2230,11 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
3704    
3705     if (unlikely(oob)) {
3706     size_t len = min(oobwritelen, oobmaxlen);
3707     - oob = nand_fill_oob(chip, oob, len, ops);
3708     + oob = nand_fill_oob(mtd, oob, len, ops);
3709     oobwritelen -= len;
3710     + } else {
3711     + /* We still need to erase leftover OOB data */
3712     + memset(chip->oob_poi, 0xff, mtd->oobsize);
3713     }
3714    
3715     ret = chip->write_page(mtd, chip, wbuf, page, cached,
3716     @@ -2401,10 +2408,8 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
3717     if (page == chip->pagebuf)
3718     chip->pagebuf = -1;
3719    
3720     - memset(chip->oob_poi, 0xff, mtd->oobsize);
3721     - nand_fill_oob(chip, ops->oobbuf, ops->ooblen, ops);
3722     + nand_fill_oob(mtd, ops->oobbuf, ops->ooblen, ops);
3723     status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask);
3724     - memset(chip->oob_poi, 0xff, mtd->oobsize);
3725    
3726     if (status)
3727     return status;
3728     diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
3729     index 1fb3b3a..30689cc 100644
3730     --- a/drivers/mtd/nand/pxa3xx_nand.c
3731     +++ b/drivers/mtd/nand/pxa3xx_nand.c
3732     @@ -685,6 +685,8 @@ static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,
3733     * OOB, ignore such double bit errors
3734     */
3735     if (is_buf_blank(buf, mtd->writesize))
3736     + info->retcode = ERR_NONE;
3737     + else
3738     mtd->ecc_stats.failed++;
3739     }
3740    
3741     @@ -813,7 +815,7 @@ static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info)
3742     info->page_size = ndcr & NDCR_PAGE_SZ ? 2048 : 512;
3743     /* set info fields needed to read id */
3744     info->read_id_bytes = (info->page_size == 2048) ? 4 : 2;
3745     - info->reg_ndcr = ndcr;
3746     + info->reg_ndcr = ndcr & ~NDCR_INT_MASK;
3747     info->cmdset = &default_cmdset;
3748    
3749     info->ndtr0cs0 = nand_readl(info, NDTR0CS0);
3750     @@ -882,7 +884,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
3751     struct pxa3xx_nand_info *info = mtd->priv;
3752     struct platform_device *pdev = info->pdev;
3753     struct pxa3xx_nand_platform_data *pdata = pdev->dev.platform_data;
3754     - struct nand_flash_dev pxa3xx_flash_ids[2] = { {NULL,}, {NULL,} };
3755     + struct nand_flash_dev pxa3xx_flash_ids[2], *def = NULL;
3756     const struct pxa3xx_nand_flash *f = NULL;
3757     struct nand_chip *chip = mtd->priv;
3758     uint32_t id = -1;
3759     @@ -942,8 +944,10 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
3760     pxa3xx_flash_ids[0].erasesize = f->page_size * f->page_per_block;
3761     if (f->flash_width == 16)
3762     pxa3xx_flash_ids[0].options = NAND_BUSWIDTH_16;
3763     + pxa3xx_flash_ids[1].name = NULL;
3764     + def = pxa3xx_flash_ids;
3765     KEEP_CONFIG:
3766     - if (nand_scan_ident(mtd, 1, pxa3xx_flash_ids))
3767     + if (nand_scan_ident(mtd, 1, def))
3768     return -ENODEV;
3769     /* calculate addressing information */
3770     info->col_addr_cycles = (mtd->writesize >= 2048) ? 2 : 1;
3771     @@ -954,9 +958,9 @@ KEEP_CONFIG:
3772     info->row_addr_cycles = 2;
3773     mtd->name = mtd_names[0];
3774     chip->ecc.mode = NAND_ECC_HW;
3775     - chip->ecc.size = f->page_size;
3776     + chip->ecc.size = info->page_size;
3777    
3778     - chip->options = (f->flash_width == 16) ? NAND_BUSWIDTH_16 : 0;
3779     + chip->options = (info->reg_ndcr & NDCR_DWIDTH_M) ? NAND_BUSWIDTH_16 : 0;
3780     chip->options |= NAND_NO_AUTOINCR;
3781     chip->options |= NAND_NO_READRDY;
3782    
3783     diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
3784     index 7a87d07..4938bd0 100644
3785     --- a/drivers/mtd/redboot.c
3786     +++ b/drivers/mtd/redboot.c
3787     @@ -297,6 +297,9 @@ static struct mtd_part_parser redboot_parser = {
3788     .name = "RedBoot",
3789     };
3790    
3791     +/* mtd parsers will request the module by parser name */
3792     +MODULE_ALIAS("RedBoot");
3793     +
3794     static int __init redboot_parser_init(void)
3795     {
3796     return register_mtd_parser(&redboot_parser);
3797     diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
3798     index 9ea2f21..2065cb4 100644
3799     --- a/drivers/net/bonding/bond_main.c
3800     +++ b/drivers/net/bonding/bond_main.c
3801     @@ -1500,6 +1500,8 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
3802     struct sk_buff *skb = *pskb;
3803     struct slave *slave;
3804     struct bonding *bond;
3805     + void (*recv_probe)(struct sk_buff *, struct bonding *,
3806     + struct slave *);
3807    
3808     skb = skb_share_check(skb, GFP_ATOMIC);
3809     if (unlikely(!skb))
3810     @@ -1513,11 +1515,12 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
3811     if (bond->params.arp_interval)
3812     slave->dev->last_rx = jiffies;
3813    
3814     - if (bond->recv_probe) {
3815     + recv_probe = ACCESS_ONCE(bond->recv_probe);
3816     + if (recv_probe) {
3817     struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
3818    
3819     if (likely(nskb)) {
3820     - bond->recv_probe(nskb, bond, slave);
3821     + recv_probe(nskb, bond, slave);
3822     dev_kfree_skb(nskb);
3823     }
3824     }
3825     diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
3826     index 2f433fb..51fba5f 100644
3827     --- a/drivers/net/enic/enic_main.c
3828     +++ b/drivers/net/enic/enic_main.c
3829     @@ -1718,8 +1718,12 @@ static void enic_poll_controller(struct net_device *netdev)
3830     enic_isr_msix_rq(enic->msix_entry[intr].vector,
3831     &enic->napi[i]);
3832     }
3833     - intr = enic_msix_wq_intr(enic, i);
3834     - enic_isr_msix_wq(enic->msix_entry[intr].vector, enic);
3835     +
3836     + for (i = 0; i < enic->wq_count; i++) {
3837     + intr = enic_msix_wq_intr(enic, i);
3838     + enic_isr_msix_wq(enic->msix_entry[intr].vector, enic);
3839     + }
3840     +
3841     break;
3842     case VNIC_DEV_INTR_MODE_MSI:
3843     enic_isr_msi(enic->pdev->irq, enic);
3844     diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
3845     index 2f3c48d..ab4723d 100644
3846     --- a/drivers/net/macvlan.c
3847     +++ b/drivers/net/macvlan.c
3848     @@ -239,7 +239,7 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
3849     dest = macvlan_hash_lookup(port, eth->h_dest);
3850     if (dest && dest->mode == MACVLAN_MODE_BRIDGE) {
3851     /* send to lowerdev first for its network taps */
3852     - vlan->forward(vlan->lowerdev, skb);
3853     + dev_forward_skb(vlan->lowerdev, skb);
3854    
3855     return NET_XMIT_SUCCESS;
3856     }
3857     diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
3858     index dfc8272..4840ab7 100644
3859     --- a/drivers/net/netconsole.c
3860     +++ b/drivers/net/netconsole.c
3861     @@ -307,6 +307,11 @@ static ssize_t store_enabled(struct netconsole_target *nt,
3862     return err;
3863     if (enabled < 0 || enabled > 1)
3864     return -EINVAL;
3865     + if (enabled == nt->enabled) {
3866     + printk(KERN_INFO "netconsole: network logging has already %s\n",
3867     + nt->enabled ? "started" : "stopped");
3868     + return -EINVAL;
3869     + }
3870    
3871     if (enabled) { /* 1 */
3872    
3873     diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
3874     index cb6e0b4..364cd67 100644
3875     --- a/drivers/net/phy/dp83640.c
3876     +++ b/drivers/net/phy/dp83640.c
3877     @@ -875,6 +875,7 @@ static void dp83640_remove(struct phy_device *phydev)
3878     struct dp83640_clock *clock;
3879     struct list_head *this, *next;
3880     struct dp83640_private *tmp, *dp83640 = phydev->priv;
3881     + struct sk_buff *skb;
3882    
3883     if (phydev->addr == BROADCAST_ADDR)
3884     return;
3885     @@ -882,6 +883,12 @@ static void dp83640_remove(struct phy_device *phydev)
3886     enable_status_frames(phydev, false);
3887     cancel_work_sync(&dp83640->ts_work);
3888    
3889     + while ((skb = skb_dequeue(&dp83640->rx_queue)) != NULL)
3890     + kfree_skb(skb);
3891     +
3892     + while ((skb = skb_dequeue(&dp83640->tx_queue)) != NULL)
3893     + skb_complete_tx_timestamp(skb, NULL);
3894     +
3895     clock = dp83640_clock_get(dp83640->clock);
3896    
3897     if (dp83640 == clock->chosen) {
3898     @@ -1060,7 +1067,7 @@ static void dp83640_txtstamp(struct phy_device *phydev,
3899     struct dp83640_private *dp83640 = phydev->priv;
3900    
3901     if (!dp83640->hwts_tx_en) {
3902     - kfree_skb(skb);
3903     + skb_complete_tx_timestamp(skb, NULL);
3904     return;
3905     }
3906     skb_queue_tail(&dp83640->tx_queue, skb);
3907     diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
3908     index ca4694e..1f421d7 100644
3909     --- a/drivers/net/rionet.c
3910