Contents of /trunk/kernel26-alx/patches-2.6.31-r1/0101-2.6.31.2-all-fixes.patch
Parent Directory | Revision Log
Revision 965 -
(show annotations)
(download)
Tue Dec 29 19:31:51 2009 UTC (14 years, 9 months ago) by niro
File size: 250217 byte(s)
Tue Dec 29 19:31:51 2009 UTC (14 years, 9 months ago) by niro
File size: 250217 byte(s)
-2.6.31-alx-r1
1 | diff --git a/MAINTAINERS b/MAINTAINERS |
2 | index 8dca9d8..2ccc21c 100644 |
3 | --- a/MAINTAINERS |
4 | +++ b/MAINTAINERS |
5 | @@ -897,6 +897,12 @@ W: http://wireless.kernel.org/en/users/Drivers/ar9170 |
6 | S: Maintained |
7 | F: drivers/net/wireless/ath/ar9170/ |
8 | |
9 | +ATK0110 HWMON DRIVER |
10 | +M: Luca Tettamanti <kronos.it@gmail.com> |
11 | +L: lm-sensors@lm-sensors.org |
12 | +S: Maintained |
13 | +F: drivers/hwmon/asus_atk0110.c |
14 | + |
15 | ATI_REMOTE2 DRIVER |
16 | M: Ville Syrjala <syrjala@sci.fi> |
17 | S: Maintained |
18 | diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c |
19 | index e302dae..8e059e5 100644 |
20 | --- a/arch/alpha/kernel/core_marvel.c |
21 | +++ b/arch/alpha/kernel/core_marvel.c |
22 | @@ -1016,7 +1016,7 @@ marvel_agp_bind_memory(alpha_agp_info *agp, off_t pg_start, struct agp_memory *m |
23 | { |
24 | struct marvel_agp_aperture *aper = agp->aperture.sysdata; |
25 | return iommu_bind(aper->arena, aper->pg_start + pg_start, |
26 | - mem->page_count, mem->memory); |
27 | + mem->page_count, mem->pages); |
28 | } |
29 | |
30 | static int |
31 | diff --git a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c |
32 | index 319fcb7..7668649 100644 |
33 | --- a/arch/alpha/kernel/core_titan.c |
34 | +++ b/arch/alpha/kernel/core_titan.c |
35 | @@ -680,7 +680,7 @@ titan_agp_bind_memory(alpha_agp_info *agp, off_t pg_start, struct agp_memory *me |
36 | { |
37 | struct titan_agp_aperture *aper = agp->aperture.sysdata; |
38 | return iommu_bind(aper->arena, aper->pg_start + pg_start, |
39 | - mem->page_count, mem->memory); |
40 | + mem->page_count, mem->pages); |
41 | } |
42 | |
43 | static int |
44 | diff --git a/arch/alpha/kernel/pci_impl.h b/arch/alpha/kernel/pci_impl.h |
45 | index 00edd04..85457b2 100644 |
46 | --- a/arch/alpha/kernel/pci_impl.h |
47 | +++ b/arch/alpha/kernel/pci_impl.h |
48 | @@ -198,7 +198,7 @@ extern unsigned long size_for_memory(unsigned long max); |
49 | |
50 | extern int iommu_reserve(struct pci_iommu_arena *, long, long); |
51 | extern int iommu_release(struct pci_iommu_arena *, long, long); |
52 | -extern int iommu_bind(struct pci_iommu_arena *, long, long, unsigned long *); |
53 | +extern int iommu_bind(struct pci_iommu_arena *, long, long, struct page **); |
54 | extern int iommu_unbind(struct pci_iommu_arena *, long, long); |
55 | |
56 | |
57 | diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c |
58 | index bfb880a..eadd63b 100644 |
59 | --- a/arch/alpha/kernel/pci_iommu.c |
60 | +++ b/arch/alpha/kernel/pci_iommu.c |
61 | @@ -880,7 +880,7 @@ iommu_release(struct pci_iommu_arena *arena, long pg_start, long pg_count) |
62 | |
63 | int |
64 | iommu_bind(struct pci_iommu_arena *arena, long pg_start, long pg_count, |
65 | - unsigned long *physaddrs) |
66 | + struct page **pages) |
67 | { |
68 | unsigned long flags; |
69 | unsigned long *ptes; |
70 | @@ -900,7 +900,7 @@ iommu_bind(struct pci_iommu_arena *arena, long pg_start, long pg_count, |
71 | } |
72 | |
73 | for(i = 0, j = pg_start; i < pg_count; i++, j++) |
74 | - ptes[j] = mk_iommu_pte(physaddrs[i]); |
75 | + ptes[j] = mk_iommu_pte(page_to_phys(pages[i])); |
76 | |
77 | spin_unlock_irqrestore(&arena->lock, flags); |
78 | |
79 | diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c |
80 | index 2546c06..629e05d 100644 |
81 | --- a/arch/arm/mach-pxa/sharpsl_pm.c |
82 | +++ b/arch/arm/mach-pxa/sharpsl_pm.c |
83 | @@ -678,8 +678,8 @@ static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enab |
84 | dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n"); |
85 | } |
86 | |
87 | - if ((!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_LOCK)) || (sharpsl_fatal_check() < 0) ) |
88 | - { |
89 | + if ((!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_LOCK)) || |
90 | + (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_FATAL))) { |
91 | dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n"); |
92 | corgi_goto_sleep(alarm_time, alarm_enable, state); |
93 | return 1; |
94 | diff --git a/arch/powerpc/include/asm/pte-common.h b/arch/powerpc/include/asm/pte-common.h |
95 | index a7e210b..0cd2e34 100644 |
96 | --- a/arch/powerpc/include/asm/pte-common.h |
97 | +++ b/arch/powerpc/include/asm/pte-common.h |
98 | @@ -176,7 +176,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void); |
99 | #define HAVE_PAGE_AGP |
100 | |
101 | /* Advertise support for _PAGE_SPECIAL */ |
102 | -#ifdef _PAGE_SPECIAL |
103 | +#if _PAGE_SPECIAL != 0 |
104 | #define __HAVE_ARCH_PTE_SPECIAL |
105 | #endif |
106 | |
107 | diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c |
108 | index 627767d..d8e6725 100644 |
109 | --- a/arch/powerpc/mm/pgtable.c |
110 | +++ b/arch/powerpc/mm/pgtable.c |
111 | @@ -30,6 +30,8 @@ |
112 | #include <asm/tlbflush.h> |
113 | #include <asm/tlb.h> |
114 | |
115 | +#include "mmu_decl.h" |
116 | + |
117 | static DEFINE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur); |
118 | static unsigned long pte_freelist_forced_free; |
119 | |
120 | @@ -119,7 +121,7 @@ void pte_free_finish(void) |
121 | /* |
122 | * Handle i/d cache flushing, called from set_pte_at() or ptep_set_access_flags() |
123 | */ |
124 | -static pte_t do_dcache_icache_coherency(pte_t pte) |
125 | +static pte_t do_dcache_icache_coherency(pte_t pte, unsigned long addr) |
126 | { |
127 | unsigned long pfn = pte_pfn(pte); |
128 | struct page *page; |
129 | @@ -128,6 +130,17 @@ static pte_t do_dcache_icache_coherency(pte_t pte) |
130 | return pte; |
131 | page = pfn_to_page(pfn); |
132 | |
133 | +#ifdef CONFIG_8xx |
134 | + /* On 8xx, cache control instructions (particularly |
135 | + * "dcbst" from flush_dcache_icache) fault as write |
136 | + * operation if there is an unpopulated TLB entry |
137 | + * for the address in question. To workaround that, |
138 | + * we invalidate the TLB here, thus avoiding dcbst |
139 | + * misbehaviour. |
140 | + */ |
141 | + _tlbil_va(addr, 0 /* 8xx doesn't care about PID */); |
142 | +#endif |
143 | + |
144 | if (!PageReserved(page) && !test_bit(PG_arch_1, &page->flags)) { |
145 | pr_devel("do_dcache_icache_coherency... flushing\n"); |
146 | flush_dcache_icache_page(page); |
147 | @@ -198,7 +211,7 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte |
148 | */ |
149 | pte = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS); |
150 | if (pte_need_exec_flush(pte, 1)) |
151 | - pte = do_dcache_icache_coherency(pte); |
152 | + pte = do_dcache_icache_coherency(pte, addr); |
153 | |
154 | /* Perform the setting of the PTE */ |
155 | __set_pte_at(mm, addr, ptep, pte, 0); |
156 | @@ -216,7 +229,7 @@ int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address, |
157 | { |
158 | int changed; |
159 | if (!dirty && pte_need_exec_flush(entry, 0)) |
160 | - entry = do_dcache_icache_coherency(entry); |
161 | + entry = do_dcache_icache_coherency(entry, address); |
162 | changed = !pte_same(*(ptep), entry); |
163 | if (changed) { |
164 | if (!(vma->vm_flags & VM_HUGETLB)) |
165 | diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h |
166 | index 83c1bc8..456a304 100644 |
167 | --- a/arch/x86/include/asm/elf.h |
168 | +++ b/arch/x86/include/asm/elf.h |
169 | @@ -299,6 +299,8 @@ do { \ |
170 | |
171 | #ifdef CONFIG_X86_32 |
172 | |
173 | +#define STACK_RND_MASK (0x7ff) |
174 | + |
175 | #define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) |
176 | |
177 | #define ARCH_DLINFO ARCH_DLINFO_IA32(vdso_enabled) |
178 | diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h |
179 | index 77a6850..03a0cbd 100644 |
180 | --- a/arch/x86/include/asm/uv/uv_hub.h |
181 | +++ b/arch/x86/include/asm/uv/uv_hub.h |
182 | @@ -422,7 +422,7 @@ static inline void uv_hub_send_ipi(int pnode, int apicid, int vector) |
183 | unsigned long val; |
184 | |
185 | val = (1UL << UVH_IPI_INT_SEND_SHFT) | |
186 | - ((apicid & 0x3f) << UVH_IPI_INT_APIC_ID_SHFT) | |
187 | + ((apicid) << UVH_IPI_INT_APIC_ID_SHFT) | |
188 | (vector << UVH_IPI_INT_VECTOR_SHFT); |
189 | uv_write_global_mmr64(pnode, UVH_IPI_INT, val); |
190 | } |
191 | diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c |
192 | index 2a50ef8..fde0cd3 100644 |
193 | --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c |
194 | +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c |
195 | @@ -605,9 +605,10 @@ static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, |
196 | return 0; |
197 | } |
198 | |
199 | -static void invalidate_entry(struct powernow_k8_data *data, unsigned int entry) |
200 | +static void invalidate_entry(struct cpufreq_frequency_table *powernow_table, |
201 | + unsigned int entry) |
202 | { |
203 | - data->powernow_table[entry].frequency = CPUFREQ_ENTRY_INVALID; |
204 | + powernow_table[entry].frequency = CPUFREQ_ENTRY_INVALID; |
205 | } |
206 | |
207 | static void print_basics(struct powernow_k8_data *data) |
208 | @@ -914,13 +915,13 @@ static int fill_powernow_table_pstate(struct powernow_k8_data *data, |
209 | "bad value %d.\n", i, index); |
210 | printk(KERN_ERR PFX "Please report to BIOS " |
211 | "manufacturer\n"); |
212 | - invalidate_entry(data, i); |
213 | + invalidate_entry(powernow_table, i); |
214 | continue; |
215 | } |
216 | rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi); |
217 | if (!(hi & HW_PSTATE_VALID_MASK)) { |
218 | dprintk("invalid pstate %d, ignoring\n", index); |
219 | - invalidate_entry(data, i); |
220 | + invalidate_entry(powernow_table, i); |
221 | continue; |
222 | } |
223 | |
224 | @@ -970,7 +971,7 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, |
225 | /* verify frequency is OK */ |
226 | if ((freq > (MAX_FREQ * 1000)) || (freq < (MIN_FREQ * 1000))) { |
227 | dprintk("invalid freq %u kHz, ignoring\n", freq); |
228 | - invalidate_entry(data, i); |
229 | + invalidate_entry(powernow_table, i); |
230 | continue; |
231 | } |
232 | |
233 | @@ -978,7 +979,7 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, |
234 | * BIOSs are using "off" to indicate invalid */ |
235 | if (vid == VID_OFF) { |
236 | dprintk("invalid vid %u, ignoring\n", vid); |
237 | - invalidate_entry(data, i); |
238 | + invalidate_entry(powernow_table, i); |
239 | continue; |
240 | } |
241 | |
242 | @@ -997,7 +998,7 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, |
243 | |
244 | dprintk("double low frequency table entry, " |
245 | "ignoring it.\n"); |
246 | - invalidate_entry(data, i); |
247 | + invalidate_entry(powernow_table, i); |
248 | continue; |
249 | } else |
250 | cntlofreq = i; |
251 | @@ -1009,7 +1010,7 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, |
252 | (unsigned int) |
253 | (data->acpi_data.states[i].core_frequency |
254 | * 1000)); |
255 | - invalidate_entry(data, i); |
256 | + invalidate_entry(powernow_table, i); |
257 | continue; |
258 | } |
259 | } |
260 | diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c |
261 | index a5cdb35..4712293 100644 |
262 | --- a/arch/x86/kvm/mmu.c |
263 | +++ b/arch/x86/kvm/mmu.c |
264 | @@ -2713,12 +2713,6 @@ static int alloc_mmu_pages(struct kvm_vcpu *vcpu) |
265 | |
266 | ASSERT(vcpu); |
267 | |
268 | - if (vcpu->kvm->arch.n_requested_mmu_pages) |
269 | - vcpu->kvm->arch.n_free_mmu_pages = |
270 | - vcpu->kvm->arch.n_requested_mmu_pages; |
271 | - else |
272 | - vcpu->kvm->arch.n_free_mmu_pages = |
273 | - vcpu->kvm->arch.n_alloc_mmu_pages; |
274 | /* |
275 | * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64. |
276 | * Therefore we need to allocate shadow page tables in the first |
277 | diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c |
278 | index b5fa966..6a768ff 100644 |
279 | --- a/arch/x86/kvm/vmx.c |
280 | +++ b/arch/x86/kvm/vmx.c |
281 | @@ -1569,7 +1569,6 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0, |
282 | vcpu->arch.cr0 = cr0; |
283 | vmx_set_cr4(vcpu, vcpu->arch.cr4); |
284 | *hw_cr0 |= X86_CR0_PE | X86_CR0_PG; |
285 | - *hw_cr0 &= ~X86_CR0_WP; |
286 | } else if (!is_paging(vcpu)) { |
287 | /* From nonpaging to paging */ |
288 | vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, |
289 | @@ -1578,9 +1577,10 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0, |
290 | CPU_BASED_CR3_STORE_EXITING)); |
291 | vcpu->arch.cr0 = cr0; |
292 | vmx_set_cr4(vcpu, vcpu->arch.cr4); |
293 | - if (!(vcpu->arch.cr0 & X86_CR0_WP)) |
294 | - *hw_cr0 &= ~X86_CR0_WP; |
295 | } |
296 | + |
297 | + if (!(cr0 & X86_CR0_WP)) |
298 | + *hw_cr0 &= ~X86_CR0_WP; |
299 | } |
300 | |
301 | static void ept_update_paging_mode_cr4(unsigned long *hw_cr4, |
302 | diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c |
303 | index 3d36045..91a077f 100644 |
304 | --- a/arch/x86/kvm/x86.c |
305 | +++ b/arch/x86/kvm/x86.c |
306 | @@ -1448,6 +1448,10 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, |
307 | for (func = 0x80000001; func <= limit && nent < cpuid->nent; ++func) |
308 | do_cpuid_ent(&cpuid_entries[nent], func, 0, |
309 | &nent, cpuid->nent); |
310 | + r = -E2BIG; |
311 | + if (nent >= cpuid->nent) |
312 | + goto out_free; |
313 | + |
314 | r = -EFAULT; |
315 | if (copy_to_user(entries, cpuid_entries, |
316 | nent * sizeof(struct kvm_cpuid_entry2))) |
317 | @@ -3198,6 +3202,9 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu) |
318 | if (!kvm_x86_ops->update_cr8_intercept) |
319 | return; |
320 | |
321 | + if (!vcpu->arch.apic) |
322 | + return; |
323 | + |
324 | if (!vcpu->arch.apic->vapic_addr) |
325 | max_irr = kvm_lapic_find_highest_irr(vcpu); |
326 | else |
327 | @@ -4118,13 +4125,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, |
328 | |
329 | vcpu->arch.cr2 = sregs->cr2; |
330 | mmu_reset_needed |= vcpu->arch.cr3 != sregs->cr3; |
331 | - |
332 | - down_read(&vcpu->kvm->slots_lock); |
333 | - if (gfn_to_memslot(vcpu->kvm, sregs->cr3 >> PAGE_SHIFT)) |
334 | - vcpu->arch.cr3 = sregs->cr3; |
335 | - else |
336 | - set_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests); |
337 | - up_read(&vcpu->kvm->slots_lock); |
338 | + vcpu->arch.cr3 = sregs->cr3; |
339 | |
340 | kvm_set_cr8(vcpu, sregs->cr8); |
341 | |
342 | diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile |
343 | index eefdeee..0088329 100644 |
344 | --- a/arch/x86/mm/Makefile |
345 | +++ b/arch/x86/mm/Makefile |
346 | @@ -1,6 +1,11 @@ |
347 | obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ |
348 | pat.o pgtable.o gup.o |
349 | |
350 | +# Make sure __phys_addr has no stackprotector |
351 | +nostackp := $(call cc-option, -fno-stack-protector) |
352 | +CFLAGS_ioremap.o := $(nostackp) |
353 | +CFLAGS_init.o := $(nostackp) |
354 | + |
355 | obj-$(CONFIG_SMP) += tlb.o |
356 | |
357 | obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o |
358 | diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c |
359 | index 1658296..c8191de 100644 |
360 | --- a/arch/x86/mm/mmap.c |
361 | +++ b/arch/x86/mm/mmap.c |
362 | @@ -29,13 +29,26 @@ |
363 | #include <linux/random.h> |
364 | #include <linux/limits.h> |
365 | #include <linux/sched.h> |
366 | +#include <asm/elf.h> |
367 | + |
368 | +static unsigned int stack_maxrandom_size(void) |
369 | +{ |
370 | + unsigned int max = 0; |
371 | + if ((current->flags & PF_RANDOMIZE) && |
372 | + !(current->personality & ADDR_NO_RANDOMIZE)) { |
373 | + max = ((-1U) & STACK_RND_MASK) << PAGE_SHIFT; |
374 | + } |
375 | + |
376 | + return max; |
377 | +} |
378 | + |
379 | |
380 | /* |
381 | * Top of mmap area (just below the process stack). |
382 | * |
383 | - * Leave an at least ~128 MB hole. |
384 | + * Leave an at least ~128 MB hole with possible stack randomization. |
385 | */ |
386 | -#define MIN_GAP (128*1024*1024) |
387 | +#define MIN_GAP (128*1024*1024UL + stack_maxrandom_size()) |
388 | #define MAX_GAP (TASK_SIZE/6*5) |
389 | |
390 | /* |
391 | diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c |
392 | index e245775..fbb46d6 100644 |
393 | --- a/arch/x86/mm/pageattr.c |
394 | +++ b/arch/x86/mm/pageattr.c |
395 | @@ -143,6 +143,7 @@ void clflush_cache_range(void *vaddr, unsigned int size) |
396 | |
397 | mb(); |
398 | } |
399 | +EXPORT_SYMBOL_GPL(clflush_cache_range); |
400 | |
401 | static void __cpa_flush_all(void *arg) |
402 | { |
403 | diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile |
404 | index 7410640..3bb4fc2 100644 |
405 | --- a/arch/x86/xen/Makefile |
406 | +++ b/arch/x86/xen/Makefile |
407 | @@ -8,6 +8,7 @@ endif |
408 | # Make sure early boot has no stackprotector |
409 | nostackp := $(call cc-option, -fno-stack-protector) |
410 | CFLAGS_enlighten.o := $(nostackp) |
411 | +CFLAGS_mmu.o := $(nostackp) |
412 | |
413 | obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ |
414 | time.o xen-asm.o xen-asm_$(BITS).o \ |
415 | @@ -16,3 +17,4 @@ obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ |
416 | obj-$(CONFIG_SMP) += smp.o |
417 | obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o |
418 | obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o |
419 | + |
420 | diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c |
421 | index eb33aaa..3839a0f 100644 |
422 | --- a/arch/x86/xen/enlighten.c |
423 | +++ b/arch/x86/xen/enlighten.c |
424 | @@ -51,6 +51,7 @@ |
425 | #include <asm/pgtable.h> |
426 | #include <asm/tlbflush.h> |
427 | #include <asm/reboot.h> |
428 | +#include <asm/stackprotector.h> |
429 | |
430 | #include "xen-ops.h" |
431 | #include "mmu.h" |
432 | @@ -330,18 +331,28 @@ static void xen_load_gdt(const struct desc_ptr *dtr) |
433 | unsigned long frames[pages]; |
434 | int f; |
435 | |
436 | - /* A GDT can be up to 64k in size, which corresponds to 8192 |
437 | - 8-byte entries, or 16 4k pages.. */ |
438 | + /* |
439 | + * A GDT can be up to 64k in size, which corresponds to 8192 |
440 | + * 8-byte entries, or 16 4k pages.. |
441 | + */ |
442 | |
443 | BUG_ON(size > 65536); |
444 | BUG_ON(va & ~PAGE_MASK); |
445 | |
446 | for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) { |
447 | int level; |
448 | - pte_t *ptep = lookup_address(va, &level); |
449 | + pte_t *ptep; |
450 | unsigned long pfn, mfn; |
451 | void *virt; |
452 | |
453 | + /* |
454 | + * The GDT is per-cpu and is in the percpu data area. |
455 | + * That can be virtually mapped, so we need to do a |
456 | + * page-walk to get the underlying MFN for the |
457 | + * hypercall. The page can also be in the kernel's |
458 | + * linear range, so we need to RO that mapping too. |
459 | + */ |
460 | + ptep = lookup_address(va, &level); |
461 | BUG_ON(ptep == NULL); |
462 | |
463 | pfn = pte_pfn(*ptep); |
464 | @@ -358,6 +369,44 @@ static void xen_load_gdt(const struct desc_ptr *dtr) |
465 | BUG(); |
466 | } |
467 | |
468 | +/* |
469 | + * load_gdt for early boot, when the gdt is only mapped once |
470 | + */ |
471 | +static __init void xen_load_gdt_boot(const struct desc_ptr *dtr) |
472 | +{ |
473 | + unsigned long va = dtr->address; |
474 | + unsigned int size = dtr->size + 1; |
475 | + unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE; |
476 | + unsigned long frames[pages]; |
477 | + int f; |
478 | + |
479 | + /* |
480 | + * A GDT can be up to 64k in size, which corresponds to 8192 |
481 | + * 8-byte entries, or 16 4k pages.. |
482 | + */ |
483 | + |
484 | + BUG_ON(size > 65536); |
485 | + BUG_ON(va & ~PAGE_MASK); |
486 | + |
487 | + for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) { |
488 | + pte_t pte; |
489 | + unsigned long pfn, mfn; |
490 | + |
491 | + pfn = virt_to_pfn(va); |
492 | + mfn = pfn_to_mfn(pfn); |
493 | + |
494 | + pte = pfn_pte(pfn, PAGE_KERNEL_RO); |
495 | + |
496 | + if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0)) |
497 | + BUG(); |
498 | + |
499 | + frames[f] = mfn; |
500 | + } |
501 | + |
502 | + if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct))) |
503 | + BUG(); |
504 | +} |
505 | + |
506 | static void load_TLS_descriptor(struct thread_struct *t, |
507 | unsigned int cpu, unsigned int i) |
508 | { |
509 | @@ -581,6 +630,29 @@ static void xen_write_gdt_entry(struct desc_struct *dt, int entry, |
510 | preempt_enable(); |
511 | } |
512 | |
513 | +/* |
514 | + * Version of write_gdt_entry for use at early boot-time needed to |
515 | + * update an entry as simply as possible. |
516 | + */ |
517 | +static __init void xen_write_gdt_entry_boot(struct desc_struct *dt, int entry, |
518 | + const void *desc, int type) |
519 | +{ |
520 | + switch (type) { |
521 | + case DESC_LDT: |
522 | + case DESC_TSS: |
523 | + /* ignore */ |
524 | + break; |
525 | + |
526 | + default: { |
527 | + xmaddr_t maddr = virt_to_machine(&dt[entry]); |
528 | + |
529 | + if (HYPERVISOR_update_descriptor(maddr.maddr, *(u64 *)desc)) |
530 | + dt[entry] = *(struct desc_struct *)desc; |
531 | + } |
532 | + |
533 | + } |
534 | +} |
535 | + |
536 | static void xen_load_sp0(struct tss_struct *tss, |
537 | struct thread_struct *thread) |
538 | { |
539 | @@ -965,6 +1037,23 @@ static const struct machine_ops __initdata xen_machine_ops = { |
540 | .emergency_restart = xen_emergency_restart, |
541 | }; |
542 | |
543 | +/* |
544 | + * Set up the GDT and segment registers for -fstack-protector. Until |
545 | + * we do this, we have to be careful not to call any stack-protected |
546 | + * function, which is most of the kernel. |
547 | + */ |
548 | +static void __init xen_setup_stackprotector(void) |
549 | +{ |
550 | + pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry_boot; |
551 | + pv_cpu_ops.load_gdt = xen_load_gdt_boot; |
552 | + |
553 | + setup_stack_canary_segment(0); |
554 | + switch_to_new_gdt(0); |
555 | + |
556 | + pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry; |
557 | + pv_cpu_ops.load_gdt = xen_load_gdt; |
558 | +} |
559 | + |
560 | /* First C function to be called on Xen boot */ |
561 | asmlinkage void __init xen_start_kernel(void) |
562 | { |
563 | @@ -983,14 +1072,34 @@ asmlinkage void __init xen_start_kernel(void) |
564 | pv_apic_ops = xen_apic_ops; |
565 | pv_mmu_ops = xen_mmu_ops; |
566 | |
567 | -#ifdef CONFIG_X86_64 |
568 | /* |
569 | - * Setup percpu state. We only need to do this for 64-bit |
570 | - * because 32-bit already has %fs set properly. |
571 | + * Set up some pagetable state before starting to set any ptes. |
572 | */ |
573 | - load_percpu_segment(0); |
574 | + |
575 | + /* Prevent unwanted bits from being set in PTEs. */ |
576 | + __supported_pte_mask &= ~_PAGE_GLOBAL; |
577 | + if (!xen_initial_domain()) |
578 | + __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD); |
579 | + |
580 | + __supported_pte_mask |= _PAGE_IOMAP; |
581 | + |
582 | +#ifdef CONFIG_X86_64 |
583 | + /* Work out if we support NX */ |
584 | + check_efer(); |
585 | #endif |
586 | |
587 | + xen_setup_features(); |
588 | + |
589 | + /* Get mfn list */ |
590 | + if (!xen_feature(XENFEAT_auto_translated_physmap)) |
591 | + xen_build_dynamic_phys_to_machine(); |
592 | + |
593 | + /* |
594 | + * Set up kernel GDT and segment registers, mainly so that |
595 | + * -fstack-protector code can be executed. |
596 | + */ |
597 | + xen_setup_stackprotector(); |
598 | + |
599 | xen_init_irq_ops(); |
600 | xen_init_cpuid_mask(); |
601 | |
602 | @@ -1001,8 +1110,6 @@ asmlinkage void __init xen_start_kernel(void) |
603 | set_xen_basic_apic_ops(); |
604 | #endif |
605 | |
606 | - xen_setup_features(); |
607 | - |
608 | if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) { |
609 | pv_mmu_ops.ptep_modify_prot_start = xen_ptep_modify_prot_start; |
610 | pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit; |
611 | @@ -1019,22 +1126,8 @@ asmlinkage void __init xen_start_kernel(void) |
612 | |
613 | xen_smp_init(); |
614 | |
615 | - /* Get mfn list */ |
616 | - if (!xen_feature(XENFEAT_auto_translated_physmap)) |
617 | - xen_build_dynamic_phys_to_machine(); |
618 | - |
619 | pgd = (pgd_t *)xen_start_info->pt_base; |
620 | |
621 | - /* Prevent unwanted bits from being set in PTEs. */ |
622 | - __supported_pte_mask &= ~_PAGE_GLOBAL; |
623 | - if (!xen_initial_domain()) |
624 | - __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD); |
625 | - |
626 | -#ifdef CONFIG_X86_64 |
627 | - /* Work out if we support NX */ |
628 | - check_efer(); |
629 | -#endif |
630 | - |
631 | /* Don't do the full vcpu_info placement stuff until we have a |
632 | possible map and a non-dummy shared_info. */ |
633 | per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; |
634 | diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c |
635 | index 429834e..fe03eee 100644 |
636 | --- a/arch/x86/xen/smp.c |
637 | +++ b/arch/x86/xen/smp.c |
638 | @@ -236,6 +236,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle) |
639 | ctxt->user_regs.ss = __KERNEL_DS; |
640 | #ifdef CONFIG_X86_32 |
641 | ctxt->user_regs.fs = __KERNEL_PERCPU; |
642 | + ctxt->user_regs.gs = __KERNEL_STACK_CANARY; |
643 | #else |
644 | ctxt->gs_base_kernel = per_cpu_offset(cpu); |
645 | #endif |
646 | diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c |
647 | index 5601506..36a5141 100644 |
648 | --- a/arch/x86/xen/spinlock.c |
649 | +++ b/arch/x86/xen/spinlock.c |
650 | @@ -187,7 +187,6 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl |
651 | struct xen_spinlock *prev; |
652 | int irq = __get_cpu_var(lock_kicker_irq); |
653 | int ret; |
654 | - unsigned long flags; |
655 | u64 start; |
656 | |
657 | /* If kicker interrupts not initialized yet, just spin */ |
658 | @@ -199,16 +198,12 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl |
659 | /* announce we're spinning */ |
660 | prev = spinning_lock(xl); |
661 | |
662 | - flags = __raw_local_save_flags(); |
663 | - if (irq_enable) { |
664 | - ADD_STATS(taken_slow_irqenable, 1); |
665 | - raw_local_irq_enable(); |
666 | - } |
667 | - |
668 | ADD_STATS(taken_slow, 1); |
669 | ADD_STATS(taken_slow_nested, prev != NULL); |
670 | |
671 | do { |
672 | + unsigned long flags; |
673 | + |
674 | /* clear pending */ |
675 | xen_clear_irq_pending(irq); |
676 | |
677 | @@ -228,6 +223,12 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl |
678 | goto out; |
679 | } |
680 | |
681 | + flags = __raw_local_save_flags(); |
682 | + if (irq_enable) { |
683 | + ADD_STATS(taken_slow_irqenable, 1); |
684 | + raw_local_irq_enable(); |
685 | + } |
686 | + |
687 | /* |
688 | * Block until irq becomes pending. If we're |
689 | * interrupted at this point (after the trylock but |
690 | @@ -238,13 +239,15 @@ static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enabl |
691 | * pending. |
692 | */ |
693 | xen_poll_irq(irq); |
694 | + |
695 | + raw_local_irq_restore(flags); |
696 | + |
697 | ADD_STATS(taken_slow_spurious, !xen_test_irq_pending(irq)); |
698 | } while (!xen_test_irq_pending(irq)); /* check for spurious wakeups */ |
699 | |
700 | kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq)); |
701 | |
702 | out: |
703 | - raw_local_irq_restore(flags); |
704 | unspinning_lock(xl, prev); |
705 | spin_time_accum_blocked(start); |
706 | |
707 | @@ -323,8 +326,13 @@ static void xen_spin_unlock(struct raw_spinlock *lock) |
708 | smp_wmb(); /* make sure no writes get moved after unlock */ |
709 | xl->lock = 0; /* release lock */ |
710 | |
711 | - /* make sure unlock happens before kick */ |
712 | - barrier(); |
713 | + /* |
714 | + * Make sure unlock happens before checking for waiting |
715 | + * spinners. We need a strong barrier to enforce the |
716 | + * write-read ordering to different memory locations, as the |
717 | + * CPU makes no implied guarantees about their ordering. |
718 | + */ |
719 | + mb(); |
720 | |
721 | if (unlikely(xl->spinners)) |
722 | xen_spin_unlock_slow(xl); |
723 | diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c |
724 | index 12158e0..da9d6d2 100644 |
725 | --- a/drivers/acpi/pci_slot.c |
726 | +++ b/drivers/acpi/pci_slot.c |
727 | @@ -57,7 +57,7 @@ ACPI_MODULE_NAME("pci_slot"); |
728 | MY_NAME , ## arg); \ |
729 | } while (0) |
730 | |
731 | -#define SLOT_NAME_SIZE 20 /* Inspired by #define in acpiphp.h */ |
732 | +#define SLOT_NAME_SIZE 21 /* Inspired by #define in acpiphp.h */ |
733 | |
734 | struct acpi_pci_slot { |
735 | acpi_handle root_handle; /* handle of the root bridge */ |
736 | @@ -149,7 +149,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) |
737 | return AE_OK; |
738 | } |
739 | |
740 | - snprintf(name, sizeof(name), "%u", (u32)sun); |
741 | + snprintf(name, sizeof(name), "%llu", sun); |
742 | pci_slot = pci_create_slot(pci_bus, device, name, NULL); |
743 | if (IS_ERR(pci_slot)) { |
744 | err("pci_create_slot returned %ld\n", PTR_ERR(pci_slot)); |
745 | diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c |
746 | index fe3eba5..289c4f8 100644 |
747 | --- a/drivers/ata/ahci.c |
748 | +++ b/drivers/ata/ahci.c |
749 | @@ -2861,8 +2861,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
750 | if (ahci_asus_m2a_vm_32bit_only(pdev)) |
751 | hpriv->flags |= AHCI_HFLAG_32BIT_ONLY; |
752 | |
753 | - if (!(hpriv->flags & AHCI_HFLAG_NO_MSI)) |
754 | - pci_enable_msi(pdev); |
755 | + if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev)) |
756 | + pci_intx(pdev, 1); |
757 | |
758 | /* save initial config */ |
759 | ahci_save_initial_config(pdev, hpriv); |
760 | diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c |
761 | index 33a74f1..567f3f7 100644 |
762 | --- a/drivers/ata/pata_amd.c |
763 | +++ b/drivers/ata/pata_amd.c |
764 | @@ -307,6 +307,9 @@ static unsigned long nv_mode_filter(struct ata_device *dev, |
765 | limit |= ATA_MASK_PIO; |
766 | if (!(limit & (ATA_MASK_MWDMA | ATA_MASK_UDMA))) |
767 | limit |= ATA_MASK_MWDMA | ATA_MASK_UDMA; |
768 | + /* PIO4, MWDMA2, UDMA2 should always be supported regardless of |
769 | + cable detection result */ |
770 | + limit |= ata_pack_xfermask(ATA_PIO4, ATA_MWDMA2, ATA_UDMA2); |
771 | |
772 | ata_port_printk(ap, KERN_DEBUG, "nv_mode_filter: 0x%lx&0x%lx->0x%lx, " |
773 | "BIOS=0x%lx (0x%x) ACPI=0x%lx%s\n", |
774 | diff --git a/drivers/base/base.h b/drivers/base/base.h |
775 | index b528145..1e52c12 100644 |
776 | --- a/drivers/base/base.h |
777 | +++ b/drivers/base/base.h |
778 | @@ -104,7 +104,7 @@ extern int system_bus_init(void); |
779 | extern int cpu_dev_init(void); |
780 | |
781 | extern int bus_add_device(struct device *dev); |
782 | -extern void bus_attach_device(struct device *dev); |
783 | +extern void bus_probe_device(struct device *dev); |
784 | extern void bus_remove_device(struct device *dev); |
785 | |
786 | extern int bus_add_driver(struct device_driver *drv); |
787 | diff --git a/drivers/base/bus.c b/drivers/base/bus.c |
788 | index 4b04a15..973bf2a 100644 |
789 | --- a/drivers/base/bus.c |
790 | +++ b/drivers/base/bus.c |
791 | @@ -459,8 +459,9 @@ static inline void remove_deprecated_bus_links(struct device *dev) { } |
792 | * bus_add_device - add device to bus |
793 | * @dev: device being added |
794 | * |
795 | + * - Add device's bus attributes. |
796 | + * - Create links to device's bus. |
797 | * - Add the device to its bus's list of devices. |
798 | - * - Create link to device's bus. |
799 | */ |
800 | int bus_add_device(struct device *dev) |
801 | { |
802 | @@ -483,6 +484,7 @@ int bus_add_device(struct device *dev) |
803 | error = make_deprecated_bus_links(dev); |
804 | if (error) |
805 | goto out_deprecated; |
806 | + klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices); |
807 | } |
808 | return 0; |
809 | |
810 | @@ -498,24 +500,19 @@ out_put: |
811 | } |
812 | |
813 | /** |
814 | - * bus_attach_device - add device to bus |
815 | - * @dev: device tried to attach to a driver |
816 | + * bus_probe_device - probe drivers for a new device |
817 | + * @dev: device to probe |
818 | * |
819 | - * - Add device to bus's list of devices. |
820 | - * - Try to attach to driver. |
821 | + * - Automatically probe for a driver if the bus allows it. |
822 | */ |
823 | -void bus_attach_device(struct device *dev) |
824 | +void bus_probe_device(struct device *dev) |
825 | { |
826 | struct bus_type *bus = dev->bus; |
827 | - int ret = 0; |
828 | + int ret; |
829 | |
830 | - if (bus) { |
831 | - if (bus->p->drivers_autoprobe) |
832 | - ret = device_attach(dev); |
833 | + if (bus && bus->p->drivers_autoprobe) { |
834 | + ret = device_attach(dev); |
835 | WARN_ON(ret < 0); |
836 | - if (ret >= 0) |
837 | - klist_add_tail(&dev->p->knode_bus, |
838 | - &bus->p->klist_devices); |
839 | } |
840 | } |
841 | |
842 | diff --git a/drivers/base/core.c b/drivers/base/core.c |
843 | index 7ecb193..c34774d 100644 |
844 | --- a/drivers/base/core.c |
845 | +++ b/drivers/base/core.c |
846 | @@ -945,7 +945,7 @@ int device_add(struct device *dev) |
847 | BUS_NOTIFY_ADD_DEVICE, dev); |
848 | |
849 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
850 | - bus_attach_device(dev); |
851 | + bus_probe_device(dev); |
852 | if (parent) |
853 | klist_add_tail(&dev->p->knode_parent, |
854 | &parent->p->klist_children); |
855 | diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c |
856 | index dee0f1f..6cf88b6 100644 |
857 | --- a/drivers/char/agp/intel-agp.c |
858 | +++ b/drivers/char/agp/intel-agp.c |
859 | @@ -679,23 +679,39 @@ static void intel_i830_setup_flush(void) |
860 | if (!intel_private.i8xx_page) |
861 | return; |
862 | |
863 | - /* make page uncached */ |
864 | - map_page_into_agp(intel_private.i8xx_page); |
865 | - |
866 | intel_private.i8xx_flush_page = kmap(intel_private.i8xx_page); |
867 | if (!intel_private.i8xx_flush_page) |
868 | intel_i830_fini_flush(); |
869 | } |
870 | |
871 | +static void |
872 | +do_wbinvd(void *null) |
873 | +{ |
874 | + wbinvd(); |
875 | +} |
876 | + |
877 | +/* The chipset_flush interface needs to get data that has already been |
878 | + * flushed out of the CPU all the way out to main memory, because the GPU |
879 | + * doesn't snoop those buffers. |
880 | + * |
881 | + * The 8xx series doesn't have the same lovely interface for flushing the |
882 | + * chipset write buffers that the later chips do. According to the 865 |
883 | + * specs, it's 64 octwords, or 1KB. So, to get those previous things in |
884 | + * that buffer out, we just fill 1KB and clflush it out, on the assumption |
885 | + * that it'll push whatever was in there out. It appears to work. |
886 | + */ |
887 | static void intel_i830_chipset_flush(struct agp_bridge_data *bridge) |
888 | { |
889 | unsigned int *pg = intel_private.i8xx_flush_page; |
890 | - int i; |
891 | |
892 | - for (i = 0; i < 256; i += 2) |
893 | - *(pg + i) = i; |
894 | + memset(pg, 0, 1024); |
895 | |
896 | - wmb(); |
897 | + if (cpu_has_clflush) { |
898 | + clflush_cache_range(pg, 1024); |
899 | + } else { |
900 | + if (on_each_cpu(do_wbinvd, NULL, 1) != 0) |
901 | + printk(KERN_ERR "Timed out waiting for cache flush.\n"); |
902 | + } |
903 | } |
904 | |
905 | /* The intel i830 automatically initializes the agp aperture during POST. |
906 | diff --git a/drivers/char/pty.c b/drivers/char/pty.c |
907 | index b33d668..53761ce 100644 |
908 | --- a/drivers/char/pty.c |
909 | +++ b/drivers/char/pty.c |
910 | @@ -120,8 +120,10 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) |
911 | /* Stuff the data into the input queue of the other end */ |
912 | c = tty_insert_flip_string(to, buf, c); |
913 | /* And shovel */ |
914 | - tty_flip_buffer_push(to); |
915 | - tty_wakeup(tty); |
916 | + if (c) { |
917 | + tty_flip_buffer_push(to); |
918 | + tty_wakeup(tty); |
919 | + } |
920 | } |
921 | return c; |
922 | } |
923 | diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c |
924 | index a3afa0c..9fc9517 100644 |
925 | --- a/drivers/char/tty_io.c |
926 | +++ b/drivers/char/tty_io.c |
927 | @@ -1184,6 +1184,7 @@ int tty_init_termios(struct tty_struct *tty) |
928 | tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios); |
929 | return 0; |
930 | } |
931 | +EXPORT_SYMBOL_GPL(tty_init_termios); |
932 | |
933 | /** |
934 | * tty_driver_install_tty() - install a tty entry in the driver |
935 | diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c |
936 | index 9769b11..549bd0f 100644 |
937 | --- a/drivers/char/tty_port.c |
938 | +++ b/drivers/char/tty_port.c |
939 | @@ -96,6 +96,14 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) |
940 | } |
941 | EXPORT_SYMBOL(tty_port_tty_set); |
942 | |
943 | +static void tty_port_shutdown(struct tty_port *port) |
944 | +{ |
945 | + if (port->ops->shutdown && |
946 | + test_and_clear_bit(ASYNC_INITIALIZED, &port->flags)) |
947 | + port->ops->shutdown(port); |
948 | + |
949 | +} |
950 | + |
951 | /** |
952 | * tty_port_hangup - hangup helper |
953 | * @port: tty port |
954 | @@ -116,6 +124,7 @@ void tty_port_hangup(struct tty_port *port) |
955 | port->tty = NULL; |
956 | spin_unlock_irqrestore(&port->lock, flags); |
957 | wake_up_interruptible(&port->open_wait); |
958 | + tty_port_shutdown(port); |
959 | } |
960 | EXPORT_SYMBOL(tty_port_hangup); |
961 | |
962 | @@ -296,15 +305,17 @@ int tty_port_close_start(struct tty_port *port, struct tty_struct *tty, struct f |
963 | |
964 | if (port->count) { |
965 | spin_unlock_irqrestore(&port->lock, flags); |
966 | + if (port->ops->drop) |
967 | + port->ops->drop(port); |
968 | return 0; |
969 | } |
970 | - port->flags |= ASYNC_CLOSING; |
971 | + set_bit(ASYNC_CLOSING, &port->flags); |
972 | tty->closing = 1; |
973 | spin_unlock_irqrestore(&port->lock, flags); |
974 | /* Don't block on a stalled port, just pull the chain */ |
975 | if (tty->flow_stopped) |
976 | tty_driver_flush_buffer(tty); |
977 | - if (port->flags & ASYNC_INITIALIZED && |
978 | + if (test_bit(ASYNCB_INITIALIZED, &port->flags) && |
979 | port->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
980 | tty_wait_until_sent(tty, port->closing_wait); |
981 | if (port->drain_delay) { |
982 | @@ -318,6 +329,9 @@ int tty_port_close_start(struct tty_port *port, struct tty_struct *tty, struct f |
983 | timeout = 2 * HZ; |
984 | schedule_timeout_interruptible(timeout); |
985 | } |
986 | + /* Don't call port->drop for the last reference. Callers will want |
987 | + to drop the last active reference in ->shutdown() or the tty |
988 | + shutdown path */ |
989 | return 1; |
990 | } |
991 | EXPORT_SYMBOL(tty_port_close_start); |
992 | @@ -348,3 +362,14 @@ void tty_port_close_end(struct tty_port *port, struct tty_struct *tty) |
993 | spin_unlock_irqrestore(&port->lock, flags); |
994 | } |
995 | EXPORT_SYMBOL(tty_port_close_end); |
996 | + |
997 | +void tty_port_close(struct tty_port *port, struct tty_struct *tty, |
998 | + struct file *filp) |
999 | +{ |
1000 | + if (tty_port_close_start(port, tty, filp) == 0) |
1001 | + return; |
1002 | + tty_port_shutdown(port); |
1003 | + tty_port_close_end(port, tty); |
1004 | + tty_port_tty_set(port, NULL); |
1005 | +} |
1006 | +EXPORT_SYMBOL(tty_port_close); |
1007 | diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c |
1008 | index fc4b68a..c078d99 100644 |
1009 | --- a/drivers/gpu/drm/i915/i915_drv.c |
1010 | +++ b/drivers/gpu/drm/i915/i915_drv.c |
1011 | @@ -94,8 +94,6 @@ static int i915_resume(struct drm_device *dev) |
1012 | struct drm_i915_private *dev_priv = dev->dev_private; |
1013 | int ret = 0; |
1014 | |
1015 | - pci_set_power_state(dev->pdev, PCI_D0); |
1016 | - pci_restore_state(dev->pdev); |
1017 | if (pci_enable_device(dev->pdev)) |
1018 | return -1; |
1019 | pci_set_master(dev->pdev); |
1020 | diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c |
1021 | index 80e5ba4..2b7aeee 100644 |
1022 | --- a/drivers/gpu/drm/i915/i915_gem.c |
1023 | +++ b/drivers/gpu/drm/i915/i915_gem.c |
1024 | @@ -1151,27 +1151,21 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
1025 | mutex_lock(&dev->struct_mutex); |
1026 | if (!obj_priv->gtt_space) { |
1027 | ret = i915_gem_object_bind_to_gtt(obj, obj_priv->gtt_alignment); |
1028 | - if (ret) { |
1029 | - mutex_unlock(&dev->struct_mutex); |
1030 | - return VM_FAULT_SIGBUS; |
1031 | - } |
1032 | - |
1033 | - ret = i915_gem_object_set_to_gtt_domain(obj, write); |
1034 | - if (ret) { |
1035 | - mutex_unlock(&dev->struct_mutex); |
1036 | - return VM_FAULT_SIGBUS; |
1037 | - } |
1038 | + if (ret) |
1039 | + goto unlock; |
1040 | |
1041 | list_add_tail(&obj_priv->list, &dev_priv->mm.inactive_list); |
1042 | + |
1043 | + ret = i915_gem_object_set_to_gtt_domain(obj, write); |
1044 | + if (ret) |
1045 | + goto unlock; |
1046 | } |
1047 | |
1048 | /* Need a new fence register? */ |
1049 | if (obj_priv->tiling_mode != I915_TILING_NONE) { |
1050 | ret = i915_gem_object_get_fence_reg(obj); |
1051 | - if (ret) { |
1052 | - mutex_unlock(&dev->struct_mutex); |
1053 | - return VM_FAULT_SIGBUS; |
1054 | - } |
1055 | + if (ret) |
1056 | + goto unlock; |
1057 | } |
1058 | |
1059 | pfn = ((dev->agp->base + obj_priv->gtt_offset) >> PAGE_SHIFT) + |
1060 | @@ -1179,18 +1173,18 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
1061 | |
1062 | /* Finally, remap it using the new GTT offset */ |
1063 | ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn); |
1064 | - |
1065 | +unlock: |
1066 | mutex_unlock(&dev->struct_mutex); |
1067 | |
1068 | switch (ret) { |
1069 | + case 0: |
1070 | + case -ERESTARTSYS: |
1071 | + return VM_FAULT_NOPAGE; |
1072 | case -ENOMEM: |
1073 | case -EAGAIN: |
1074 | return VM_FAULT_OOM; |
1075 | - case -EFAULT: |
1076 | - case -EINVAL: |
1077 | - return VM_FAULT_SIGBUS; |
1078 | default: |
1079 | - return VM_FAULT_NOPAGE; |
1080 | + return VM_FAULT_SIGBUS; |
1081 | } |
1082 | } |
1083 | |
1084 | @@ -2506,16 +2500,6 @@ i915_gem_clflush_object(struct drm_gem_object *obj) |
1085 | if (obj_priv->pages == NULL) |
1086 | return; |
1087 | |
1088 | - /* XXX: The 865 in particular appears to be weird in how it handles |
1089 | - * cache flushing. We haven't figured it out, but the |
1090 | - * clflush+agp_chipset_flush doesn't appear to successfully get the |
1091 | - * data visible to the PGU, while wbinvd + agp_chipset_flush does. |
1092 | - */ |
1093 | - if (IS_I865G(obj->dev)) { |
1094 | - wbinvd(); |
1095 | - return; |
1096 | - } |
1097 | - |
1098 | drm_clflush_pages(obj_priv->pages, obj->size / PAGE_SIZE); |
1099 | } |
1100 | |
1101 | @@ -3007,6 +2991,16 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj, |
1102 | return -EINVAL; |
1103 | } |
1104 | |
1105 | + if (reloc->delta >= target_obj->size) { |
1106 | + DRM_ERROR("Relocation beyond target object bounds: " |
1107 | + "obj %p target %d delta %d size %d.\n", |
1108 | + obj, reloc->target_handle, |
1109 | + (int) reloc->delta, (int) target_obj->size); |
1110 | + drm_gem_object_unreference(target_obj); |
1111 | + i915_gem_object_unpin(obj); |
1112 | + return -EINVAL; |
1113 | + } |
1114 | + |
1115 | if (reloc->write_domain & I915_GEM_DOMAIN_CPU || |
1116 | reloc->read_domains & I915_GEM_DOMAIN_CPU) { |
1117 | DRM_ERROR("reloc with read/write CPU domains: " |
1118 | @@ -3837,7 +3831,8 @@ void i915_gem_free_object(struct drm_gem_object *obj) |
1119 | |
1120 | i915_gem_object_unbind(obj); |
1121 | |
1122 | - i915_gem_free_mmap_offset(obj); |
1123 | + if (obj_priv->mmap_offset) |
1124 | + i915_gem_free_mmap_offset(obj); |
1125 | |
1126 | kfree(obj_priv->page_cpu_valid); |
1127 | kfree(obj_priv->bit_17); |
1128 | diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c |
1129 | index a2d527b..e774a4a 100644 |
1130 | --- a/drivers/gpu/drm/i915/i915_gem_tiling.c |
1131 | +++ b/drivers/gpu/drm/i915/i915_gem_tiling.c |
1132 | @@ -234,7 +234,13 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev) |
1133 | uint32_t swizzle_y = I915_BIT_6_SWIZZLE_UNKNOWN; |
1134 | bool need_disable; |
1135 | |
1136 | - if (!IS_I9XX(dev)) { |
1137 | + if (IS_IGDNG(dev)) { |
1138 | + /* On IGDNG whatever DRAM config, GPU always do |
1139 | + * same swizzling setup. |
1140 | + */ |
1141 | + swizzle_x = I915_BIT_6_SWIZZLE_9_10; |
1142 | + swizzle_y = I915_BIT_6_SWIZZLE_9; |
1143 | + } else if (!IS_I9XX(dev)) { |
1144 | /* As far as we know, the 865 doesn't have these bit 6 |
1145 | * swizzling issues. |
1146 | */ |
1147 | @@ -317,13 +323,6 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev) |
1148 | } |
1149 | } |
1150 | |
1151 | - /* FIXME: check with memory config on IGDNG */ |
1152 | - if (IS_IGDNG(dev)) { |
1153 | - DRM_ERROR("disable tiling on IGDNG...\n"); |
1154 | - swizzle_x = I915_BIT_6_SWIZZLE_UNKNOWN; |
1155 | - swizzle_y = I915_BIT_6_SWIZZLE_UNKNOWN; |
1156 | - } |
1157 | - |
1158 | dev_priv->mm.bit_6_swizzle_x = swizzle_x; |
1159 | dev_priv->mm.bit_6_swizzle_y = swizzle_y; |
1160 | } |
1161 | diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h |
1162 | index 2955083..106a1ae 100644 |
1163 | --- a/drivers/gpu/drm/i915/i915_reg.h |
1164 | +++ b/drivers/gpu/drm/i915/i915_reg.h |
1165 | @@ -1733,6 +1733,7 @@ |
1166 | #define DISPPLANE_NO_LINE_DOUBLE 0 |
1167 | #define DISPPLANE_STEREO_POLARITY_FIRST 0 |
1168 | #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) |
1169 | +#define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* IGDNG */ |
1170 | #define DISPPLANE_TILED (1<<10) |
1171 | #define DSPAADDR 0x70184 |
1172 | #define DSPASTRIDE 0x70188 |
1173 | @@ -1867,6 +1868,8 @@ |
1174 | #define PF_ENABLE (1<<31) |
1175 | #define PFA_WIN_SZ 0x68074 |
1176 | #define PFB_WIN_SZ 0x68874 |
1177 | +#define PFA_WIN_POS 0x68070 |
1178 | +#define PFB_WIN_POS 0x68870 |
1179 | |
1180 | /* legacy palette */ |
1181 | #define LGC_PALETTE_A 0x4a000 |
1182 | @@ -1913,6 +1916,9 @@ |
1183 | #define GTIIR 0x44018 |
1184 | #define GTIER 0x4401c |
1185 | |
1186 | +#define DISP_ARB_CTL 0x45000 |
1187 | +#define DISP_TILE_SURFACE_SWIZZLING (1<<13) |
1188 | + |
1189 | /* PCH */ |
1190 | |
1191 | /* south display engine interrupt */ |
1192 | diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c |
1193 | index f806fcc..698a0ed 100644 |
1194 | --- a/drivers/gpu/drm/i915/intel_bios.c |
1195 | +++ b/drivers/gpu/drm/i915/intel_bios.c |
1196 | @@ -217,6 +217,9 @@ parse_general_features(struct drm_i915_private *dev_priv, |
1197 | if (IS_I85X(dev_priv->dev)) |
1198 | dev_priv->lvds_ssc_freq = |
1199 | general->ssc_freq ? 66 : 48; |
1200 | + else if (IS_IGDNG(dev_priv->dev)) |
1201 | + dev_priv->lvds_ssc_freq = |
1202 | + general->ssc_freq ? 100 : 120; |
1203 | else |
1204 | dev_priv->lvds_ssc_freq = |
1205 | general->ssc_freq ? 100 : 96; |
1206 | diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c |
1207 | index 590f81c..5ae4c1a 100644 |
1208 | --- a/drivers/gpu/drm/i915/intel_crt.c |
1209 | +++ b/drivers/gpu/drm/i915/intel_crt.c |
1210 | @@ -151,13 +151,10 @@ static bool intel_igdng_crt_detect_hotplug(struct drm_connector *connector) |
1211 | { |
1212 | struct drm_device *dev = connector->dev; |
1213 | struct drm_i915_private *dev_priv = dev->dev_private; |
1214 | - u32 adpa, temp; |
1215 | + u32 adpa; |
1216 | bool ret; |
1217 | |
1218 | - temp = adpa = I915_READ(PCH_ADPA); |
1219 | - |
1220 | - adpa &= ~ADPA_DAC_ENABLE; |
1221 | - I915_WRITE(PCH_ADPA, adpa); |
1222 | + adpa = I915_READ(PCH_ADPA); |
1223 | |
1224 | adpa &= ~ADPA_CRT_HOTPLUG_MASK; |
1225 | |
1226 | @@ -184,8 +181,6 @@ static bool intel_igdng_crt_detect_hotplug(struct drm_connector *connector) |
1227 | else |
1228 | ret = false; |
1229 | |
1230 | - /* restore origin register */ |
1231 | - I915_WRITE(PCH_ADPA, temp); |
1232 | return ret; |
1233 | } |
1234 | |
1235 | diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c |
1236 | index 748ed50..8b5af29 100644 |
1237 | --- a/drivers/gpu/drm/i915/intel_display.c |
1238 | +++ b/drivers/gpu/drm/i915/intel_display.c |
1239 | @@ -818,7 +818,7 @@ intel_igdng_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc, |
1240 | refclk, best_clock); |
1241 | |
1242 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
1243 | - if ((I915_READ(LVDS) & LVDS_CLKB_POWER_MASK) == |
1244 | + if ((I915_READ(PCH_LVDS) & LVDS_CLKB_POWER_MASK) == |
1245 | LVDS_CLKB_POWER_UP) |
1246 | clock.p2 = limit->p2.p2_fast; |
1247 | else |
1248 | @@ -1008,6 +1008,10 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, |
1249 | dspcntr &= ~DISPPLANE_TILED; |
1250 | } |
1251 | |
1252 | + if (IS_IGDNG(dev)) |
1253 | + /* must disable */ |
1254 | + dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; |
1255 | + |
1256 | I915_WRITE(dspcntr_reg, dspcntr); |
1257 | |
1258 | Start = obj_priv->gtt_offset; |
1259 | @@ -1154,6 +1158,7 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode) |
1260 | int transconf_reg = (pipe == 0) ? TRANSACONF : TRANSBCONF; |
1261 | int pf_ctl_reg = (pipe == 0) ? PFA_CTL_1 : PFB_CTL_1; |
1262 | int pf_win_size = (pipe == 0) ? PFA_WIN_SZ : PFB_WIN_SZ; |
1263 | + int pf_win_pos = (pipe == 0) ? PFA_WIN_POS : PFB_WIN_POS; |
1264 | int cpu_htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B; |
1265 | int cpu_hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B; |
1266 | int cpu_hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B; |
1267 | @@ -1205,6 +1210,19 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode) |
1268 | } |
1269 | } |
1270 | |
1271 | + /* Enable panel fitting for LVDS */ |
1272 | + if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
1273 | + temp = I915_READ(pf_ctl_reg); |
1274 | + I915_WRITE(pf_ctl_reg, temp | PF_ENABLE); |
1275 | + |
1276 | + /* currently full aspect */ |
1277 | + I915_WRITE(pf_win_pos, 0); |
1278 | + |
1279 | + I915_WRITE(pf_win_size, |
1280 | + (dev_priv->panel_fixed_mode->hdisplay << 16) | |
1281 | + (dev_priv->panel_fixed_mode->vdisplay)); |
1282 | + } |
1283 | + |
1284 | /* Enable CPU pipe */ |
1285 | temp = I915_READ(pipeconf_reg); |
1286 | if ((temp & PIPEACONF_ENABLE) == 0) { |
1287 | @@ -1858,7 +1876,14 @@ static unsigned long intel_calculate_wm(unsigned long clock_in_khz, |
1288 | { |
1289 | long entries_required, wm_size; |
1290 | |
1291 | - entries_required = (clock_in_khz * pixel_size * latency_ns) / 1000000; |
1292 | + /* |
1293 | + * Note: we need to make sure we don't overflow for various clock & |
1294 | + * latency values. |
1295 | + * clocks go from a few thousand to several hundred thousand. |
1296 | + * latency is usually a few thousand |
1297 | + */ |
1298 | + entries_required = ((clock_in_khz / 1000) * pixel_size * latency_ns) / |
1299 | + 1000; |
1300 | entries_required /= wm->cacheline_size; |
1301 | |
1302 | DRM_DEBUG("FIFO entries required for mode: %d\n", entries_required); |
1303 | @@ -2616,6 +2641,12 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, |
1304 | |
1305 | intel_wait_for_vblank(dev); |
1306 | |
1307 | + if (IS_IGDNG(dev)) { |
1308 | + /* enable address swizzle for tiling buffer */ |
1309 | + temp = I915_READ(DISP_ARB_CTL); |
1310 | + I915_WRITE(DISP_ARB_CTL, temp | DISP_TILE_SURFACE_SWIZZLING); |
1311 | + } |
1312 | + |
1313 | I915_WRITE(dspcntr_reg, dspcntr); |
1314 | |
1315 | /* Flush the plane changes */ |
1316 | diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c |
1317 | index 8df02ef..b7d091b 100644 |
1318 | --- a/drivers/gpu/drm/i915/intel_lvds.c |
1319 | +++ b/drivers/gpu/drm/i915/intel_lvds.c |
1320 | @@ -305,6 +305,10 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, |
1321 | goto out; |
1322 | } |
1323 | |
1324 | + /* full screen scale for now */ |
1325 | + if (IS_IGDNG(dev)) |
1326 | + goto out; |
1327 | + |
1328 | /* 965+ wants fuzzy fitting */ |
1329 | if (IS_I965G(dev)) |
1330 | pfit_control |= (intel_crtc->pipe << PFIT_PIPE_SHIFT) | |
1331 | @@ -332,8 +336,10 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, |
1332 | * to register description and PRM. |
1333 | * Change the value here to see the borders for debugging |
1334 | */ |
1335 | - I915_WRITE(BCLRPAT_A, 0); |
1336 | - I915_WRITE(BCLRPAT_B, 0); |
1337 | + if (!IS_IGDNG(dev)) { |
1338 | + I915_WRITE(BCLRPAT_A, 0); |
1339 | + I915_WRITE(BCLRPAT_B, 0); |
1340 | + } |
1341 | |
1342 | switch (lvds_priv->fitting_mode) { |
1343 | case DRM_MODE_SCALE_NO_SCALE: |
1344 | @@ -582,7 +588,6 @@ static void intel_lvds_mode_set(struct drm_encoder *encoder, |
1345 | * settings. |
1346 | */ |
1347 | |
1348 | - /* No panel fitting yet, fixme */ |
1349 | if (IS_IGDNG(dev)) |
1350 | return; |
1351 | |
1352 | diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c |
1353 | index d3b74ba..66dc1a5 100644 |
1354 | --- a/drivers/gpu/drm/i915/intel_sdvo.c |
1355 | +++ b/drivers/gpu/drm/i915/intel_sdvo.c |
1356 | @@ -114,6 +114,9 @@ struct intel_sdvo_priv { |
1357 | /* DDC bus used by this SDVO output */ |
1358 | uint8_t ddc_bus; |
1359 | |
1360 | + /* Mac mini hack -- use the same DDC as the analog connector */ |
1361 | + struct i2c_adapter *analog_ddc_bus; |
1362 | + |
1363 | int save_sdvo_mult; |
1364 | u16 save_active_outputs; |
1365 | struct intel_sdvo_dtd save_input_dtd_1, save_input_dtd_2; |
1366 | @@ -1478,6 +1481,36 @@ intel_sdvo_multifunc_encoder(struct intel_output *intel_output) |
1367 | return (caps > 1); |
1368 | } |
1369 | |
1370 | +static struct drm_connector * |
1371 | +intel_find_analog_connector(struct drm_device *dev) |
1372 | +{ |
1373 | + struct drm_connector *connector; |
1374 | + struct intel_output *intel_output; |
1375 | + |
1376 | + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
1377 | + intel_output = to_intel_output(connector); |
1378 | + if (intel_output->type == INTEL_OUTPUT_ANALOG) |
1379 | + return connector; |
1380 | + } |
1381 | + return NULL; |
1382 | +} |
1383 | + |
1384 | +static int |
1385 | +intel_analog_is_connected(struct drm_device *dev) |
1386 | +{ |
1387 | + struct drm_connector *analog_connector; |
1388 | + analog_connector = intel_find_analog_connector(dev); |
1389 | + |
1390 | + if (!analog_connector) |
1391 | + return false; |
1392 | + |
1393 | + if (analog_connector->funcs->detect(analog_connector) == |
1394 | + connector_status_disconnected) |
1395 | + return false; |
1396 | + |
1397 | + return true; |
1398 | +} |
1399 | + |
1400 | enum drm_connector_status |
1401 | intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response) |
1402 | { |
1403 | @@ -1488,6 +1521,15 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response) |
1404 | |
1405 | edid = drm_get_edid(&intel_output->base, |
1406 | intel_output->ddc_bus); |
1407 | + |
1408 | + /* when there is no edid and no monitor is connected with VGA |
1409 | + * port, try to use the CRT ddc to read the EDID for DVI-connector |
1410 | + */ |
1411 | + if (edid == NULL && |
1412 | + sdvo_priv->analog_ddc_bus && |
1413 | + !intel_analog_is_connected(intel_output->base.dev)) |
1414 | + edid = drm_get_edid(&intel_output->base, |
1415 | + sdvo_priv->analog_ddc_bus); |
1416 | if (edid != NULL) { |
1417 | /* Don't report the output as connected if it's a DVI-I |
1418 | * connector with a non-digital EDID coming out. |
1419 | @@ -1540,31 +1582,32 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect |
1420 | static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) |
1421 | { |
1422 | struct intel_output *intel_output = to_intel_output(connector); |
1423 | + struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; |
1424 | + int num_modes; |
1425 | |
1426 | /* set the bus switch and get the modes */ |
1427 | - intel_ddc_get_modes(intel_output); |
1428 | + num_modes = intel_ddc_get_modes(intel_output); |
1429 | |
1430 | -#if 0 |
1431 | - struct drm_device *dev = encoder->dev; |
1432 | - struct drm_i915_private *dev_priv = dev->dev_private; |
1433 | - /* Mac mini hack. On this device, I get DDC through the analog, which |
1434 | - * load-detects as disconnected. I fail to DDC through the SDVO DDC, |
1435 | - * but it does load-detect as connected. So, just steal the DDC bits |
1436 | - * from analog when we fail at finding it the right way. |
1437 | + /* |
1438 | + * Mac mini hack. On this device, the DVI-I connector shares one DDC |
1439 | + * link between analog and digital outputs. So, if the regular SDVO |
1440 | + * DDC fails, check to see if the analog output is disconnected, in |
1441 | + * which case we'll look there for the digital DDC data. |
1442 | */ |
1443 | - crt = xf86_config->output[0]; |
1444 | - intel_output = crt->driver_private; |
1445 | - if (intel_output->type == I830_OUTPUT_ANALOG && |
1446 | - crt->funcs->detect(crt) == XF86OutputStatusDisconnected) { |
1447 | - I830I2CInit(pScrn, &intel_output->pDDCBus, GPIOA, "CRTDDC_A"); |
1448 | - edid_mon = xf86OutputGetEDID(crt, intel_output->pDDCBus); |
1449 | - xf86DestroyI2CBusRec(intel_output->pDDCBus, true, true); |
1450 | - } |
1451 | - if (edid_mon) { |
1452 | - xf86OutputSetEDID(output, edid_mon); |
1453 | - modes = xf86OutputGetEDIDModes(output); |
1454 | + if (num_modes == 0 && |
1455 | + sdvo_priv->analog_ddc_bus && |
1456 | + !intel_analog_is_connected(intel_output->base.dev)) { |
1457 | + struct i2c_adapter *digital_ddc_bus; |
1458 | + |
1459 | + /* Switch to the analog ddc bus and try that |
1460 | + */ |
1461 | + digital_ddc_bus = intel_output->ddc_bus; |
1462 | + intel_output->ddc_bus = sdvo_priv->analog_ddc_bus; |
1463 | + |
1464 | + (void) intel_ddc_get_modes(intel_output); |
1465 | + |
1466 | + intel_output->ddc_bus = digital_ddc_bus; |
1467 | } |
1468 | -#endif |
1469 | } |
1470 | |
1471 | /** |
1472 | @@ -1748,6 +1791,8 @@ static void intel_sdvo_destroy(struct drm_connector *connector) |
1473 | intel_i2c_destroy(intel_output->i2c_bus); |
1474 | if (intel_output->ddc_bus) |
1475 | intel_i2c_destroy(intel_output->ddc_bus); |
1476 | + if (sdvo_priv->analog_ddc_bus) |
1477 | + intel_i2c_destroy(sdvo_priv->analog_ddc_bus); |
1478 | |
1479 | if (sdvo_priv->sdvo_lvds_fixed_mode != NULL) |
1480 | drm_mode_destroy(connector->dev, |
1481 | @@ -2074,10 +2119,15 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device) |
1482 | } |
1483 | |
1484 | /* setup the DDC bus. */ |
1485 | - if (output_device == SDVOB) |
1486 | + if (output_device == SDVOB) { |
1487 | intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS"); |
1488 | - else |
1489 | + sdvo_priv->analog_ddc_bus = intel_i2c_create(dev, GPIOA, |
1490 | + "SDVOB/VGA DDC BUS"); |
1491 | + } else { |
1492 | intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS"); |
1493 | + sdvo_priv->analog_ddc_bus = intel_i2c_create(dev, GPIOA, |
1494 | + "SDVOC/VGA DDC BUS"); |
1495 | + } |
1496 | |
1497 | if (intel_output->ddc_bus == NULL) |
1498 | goto err_i2c; |
1499 | @@ -2143,6 +2193,8 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device) |
1500 | return true; |
1501 | |
1502 | err_i2c: |
1503 | + if (sdvo_priv->analog_ddc_bus != NULL) |
1504 | + intel_i2c_destroy(sdvo_priv->analog_ddc_bus); |
1505 | if (intel_output->ddc_bus != NULL) |
1506 | intel_i2c_destroy(intel_output->ddc_bus); |
1507 | if (intel_output->i2c_bus != NULL) |
1508 | diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c |
1509 | index 5eb10c2..047844d 100644 |
1510 | --- a/drivers/hid/hid-core.c |
1511 | +++ b/drivers/hid/hid-core.c |
1512 | @@ -1319,7 +1319,6 @@ static const struct hid_device_id hid_blacklist[] = { |
1513 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, |
1514 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, |
1515 | |
1516 | - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) }, |
1517 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, |
1518 | { } |
1519 | }; |
1520 | diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c |
1521 | index 8ff7e35..f33ac27 100644 |
1522 | --- a/drivers/isdn/gigaset/interface.c |
1523 | +++ b/drivers/isdn/gigaset/interface.c |
1524 | @@ -408,33 +408,28 @@ static int if_write_room(struct tty_struct *tty) |
1525 | return retval; |
1526 | } |
1527 | |
1528 | -/* FIXME: This function does not have error returns */ |
1529 | - |
1530 | static int if_chars_in_buffer(struct tty_struct *tty) |
1531 | { |
1532 | struct cardstate *cs; |
1533 | - int retval = -ENODEV; |
1534 | + int retval = 0; |
1535 | |
1536 | cs = (struct cardstate *) tty->driver_data; |
1537 | if (!cs) { |
1538 | pr_err("%s: no cardstate\n", __func__); |
1539 | - return -ENODEV; |
1540 | + return 0; |
1541 | } |
1542 | |
1543 | gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__); |
1544 | |
1545 | - if (mutex_lock_interruptible(&cs->mutex)) |
1546 | - return -ERESTARTSYS; // FIXME -EINTR? |
1547 | + mutex_lock(&cs->mutex); |
1548 | |
1549 | - if (!cs->connected) { |
1550 | + if (!cs->connected) |
1551 | gig_dbg(DEBUG_IF, "not connected"); |
1552 | - retval = -ENODEV; |
1553 | - } else if (!cs->open_count) |
1554 | + else if (!cs->open_count) |
1555 | dev_warn(cs->dev, "%s: device not opened\n", __func__); |
1556 | - else if (cs->mstate != MS_LOCKED) { |
1557 | + else if (cs->mstate != MS_LOCKED) |
1558 | dev_warn(cs->dev, "can't write to unlocked device\n"); |
1559 | - retval = -EBUSY; |
1560 | - } else |
1561 | + else |
1562 | retval = cs->ops->chars_in_buffer(cs); |
1563 | |
1564 | mutex_unlock(&cs->mutex); |
1565 | diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c |
1566 | index 1c2e544..ffe9306 100644 |
1567 | --- a/drivers/media/video/em28xx/em28xx-cards.c |
1568 | +++ b/drivers/media/video/em28xx/em28xx-cards.c |
1569 | @@ -2170,8 +2170,6 @@ static int em28xx_hint_board(struct em28xx *dev) |
1570 | /* ----------------------------------------------------------------------- */ |
1571 | void em28xx_register_i2c_ir(struct em28xx *dev) |
1572 | { |
1573 | - struct i2c_board_info info; |
1574 | - struct IR_i2c_init_data init_data; |
1575 | const unsigned short addr_list[] = { |
1576 | 0x30, 0x47, I2C_CLIENT_END |
1577 | }; |
1578 | @@ -2179,9 +2177,9 @@ void em28xx_register_i2c_ir(struct em28xx *dev) |
1579 | if (disable_ir) |
1580 | return; |
1581 | |
1582 | - memset(&info, 0, sizeof(struct i2c_board_info)); |
1583 | - memset(&init_data, 0, sizeof(struct IR_i2c_init_data)); |
1584 | - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); |
1585 | + memset(&dev->info, 0, sizeof(&dev->info)); |
1586 | + memset(&dev->init_data, 0, sizeof(dev->init_data)); |
1587 | + strlcpy(dev->info.type, "ir_video", I2C_NAME_SIZE); |
1588 | |
1589 | /* detect & configure */ |
1590 | switch (dev->model) { |
1591 | @@ -2191,19 +2189,19 @@ void em28xx_register_i2c_ir(struct em28xx *dev) |
1592 | break; |
1593 | case (EM2800_BOARD_TERRATEC_CINERGY_200): |
1594 | case (EM2820_BOARD_TERRATEC_CINERGY_250): |
1595 | - init_data.ir_codes = ir_codes_em_terratec; |
1596 | - init_data.get_key = em28xx_get_key_terratec; |
1597 | - init_data.name = "i2c IR (EM28XX Terratec)"; |
1598 | + dev->init_data.ir_codes = ir_codes_em_terratec; |
1599 | + dev->init_data.get_key = em28xx_get_key_terratec; |
1600 | + dev->init_data.name = "i2c IR (EM28XX Terratec)"; |
1601 | break; |
1602 | case (EM2820_BOARD_PINNACLE_USB_2): |
1603 | - init_data.ir_codes = ir_codes_pinnacle_grey; |
1604 | - init_data.get_key = em28xx_get_key_pinnacle_usb_grey; |
1605 | - init_data.name = "i2c IR (EM28XX Pinnacle PCTV)"; |
1606 | + dev->init_data.ir_codes = ir_codes_pinnacle_grey; |
1607 | + dev->init_data.get_key = em28xx_get_key_pinnacle_usb_grey; |
1608 | + dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)"; |
1609 | break; |
1610 | case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2): |
1611 | - init_data.ir_codes = ir_codes_hauppauge_new; |
1612 | - init_data.get_key = em28xx_get_key_em_haup; |
1613 | - init_data.name = "i2c IR (EM2840 Hauppauge)"; |
1614 | + dev->init_data.ir_codes = ir_codes_hauppauge_new; |
1615 | + dev->init_data.get_key = em28xx_get_key_em_haup; |
1616 | + dev->init_data.name = "i2c IR (EM2840 Hauppauge)"; |
1617 | break; |
1618 | case (EM2820_BOARD_MSI_VOX_USB_2): |
1619 | break; |
1620 | @@ -2215,9 +2213,9 @@ void em28xx_register_i2c_ir(struct em28xx *dev) |
1621 | break; |
1622 | } |
1623 | |
1624 | - if (init_data.name) |
1625 | - info.platform_data = &init_data; |
1626 | - i2c_new_probed_device(&dev->i2c_adap, &info, addr_list); |
1627 | + if (dev->init_data.name) |
1628 | + dev->info.platform_data = &dev->init_data; |
1629 | + i2c_new_probed_device(&dev->i2c_adap, &dev->info, addr_list); |
1630 | } |
1631 | |
1632 | void em28xx_card_setup(struct em28xx *dev) |
1633 | diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h |
1634 | index a2add61..cb2a70a 100644 |
1635 | --- a/drivers/media/video/em28xx/em28xx.h |
1636 | +++ b/drivers/media/video/em28xx/em28xx.h |
1637 | @@ -595,6 +595,10 @@ struct em28xx { |
1638 | struct delayed_work sbutton_query_work; |
1639 | |
1640 | struct em28xx_dvb *dvb; |
1641 | + |
1642 | + /* I2C keyboard data */ |
1643 | + struct i2c_board_info info; |
1644 | + struct IR_i2c_init_data init_data; |
1645 | }; |
1646 | |
1647 | struct em28xx_ops { |
1648 | diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c |
1649 | index 6e219c2..69e48ce 100644 |
1650 | --- a/drivers/media/video/saa7134/saa7134-input.c |
1651 | +++ b/drivers/media/video/saa7134/saa7134-input.c |
1652 | @@ -684,8 +684,6 @@ void saa7134_input_fini(struct saa7134_dev *dev) |
1653 | |
1654 | void saa7134_probe_i2c_ir(struct saa7134_dev *dev) |
1655 | { |
1656 | - struct i2c_board_info info; |
1657 | - struct IR_i2c_init_data init_data; |
1658 | const unsigned short addr_list[] = { |
1659 | 0x7a, 0x47, 0x71, 0x2d, |
1660 | I2C_CLIENT_END |
1661 | @@ -705,32 +703,32 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) |
1662 | return; |
1663 | } |
1664 | |
1665 | - memset(&info, 0, sizeof(struct i2c_board_info)); |
1666 | - memset(&init_data, 0, sizeof(struct IR_i2c_init_data)); |
1667 | - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); |
1668 | + memset(&dev->info, 0, sizeof(dev->info)); |
1669 | + memset(&dev->init_data, 0, sizeof(dev->init_data)); |
1670 | + strlcpy(dev->info.type, "ir_video", I2C_NAME_SIZE); |
1671 | |
1672 | switch (dev->board) { |
1673 | case SAA7134_BOARD_PINNACLE_PCTV_110i: |
1674 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
1675 | - init_data.name = "Pinnacle PCTV"; |
1676 | + dev->init_data.name = "Pinnacle PCTV"; |
1677 | if (pinnacle_remote == 0) { |
1678 | - init_data.get_key = get_key_pinnacle_color; |
1679 | - init_data.ir_codes = ir_codes_pinnacle_color; |
1680 | + dev->init_data.get_key = get_key_pinnacle_color; |
1681 | + dev->init_data.ir_codes = ir_codes_pinnacle_color; |
1682 | } else { |
1683 | - init_data.get_key = get_key_pinnacle_grey; |
1684 | - init_data.ir_codes = ir_codes_pinnacle_grey; |
1685 | + dev->init_data.get_key = get_key_pinnacle_grey; |
1686 | + dev->init_data.ir_codes = ir_codes_pinnacle_grey; |
1687 | } |
1688 | break; |
1689 | case SAA7134_BOARD_UPMOST_PURPLE_TV: |
1690 | - init_data.name = "Purple TV"; |
1691 | - init_data.get_key = get_key_purpletv; |
1692 | - init_data.ir_codes = ir_codes_purpletv; |
1693 | + dev->init_data.name = "Purple TV"; |
1694 | + dev->init_data.get_key = get_key_purpletv; |
1695 | + dev->init_data.ir_codes = ir_codes_purpletv; |
1696 | break; |
1697 | case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS: |
1698 | - init_data.name = "MSI TV@nywhere Plus"; |
1699 | - init_data.get_key = get_key_msi_tvanywhere_plus; |
1700 | - init_data.ir_codes = ir_codes_msi_tvanywhere_plus; |
1701 | - info.addr = 0x30; |
1702 | + dev->init_data.name = "MSI TV@nywhere Plus"; |
1703 | + dev->init_data.get_key = get_key_msi_tvanywhere_plus; |
1704 | + dev->init_data.ir_codes = ir_codes_msi_tvanywhere_plus; |
1705 | + dev->info.addr = 0x30; |
1706 | /* MSI TV@nywhere Plus controller doesn't seem to |
1707 | respond to probes unless we read something from |
1708 | an existing device. Weird... |
1709 | @@ -741,9 +739,9 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) |
1710 | (1 == rc) ? "yes" : "no"); |
1711 | break; |
1712 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: |
1713 | - init_data.name = "HVR 1110"; |
1714 | - init_data.get_key = get_key_hvr1110; |
1715 | - init_data.ir_codes = ir_codes_hauppauge_new; |
1716 | + dev->init_data.name = "HVR 1110"; |
1717 | + dev->init_data.get_key = get_key_hvr1110; |
1718 | + dev->init_data.ir_codes = ir_codes_hauppauge_new; |
1719 | break; |
1720 | case SAA7134_BOARD_BEHOLD_607FM_MK3: |
1721 | case SAA7134_BOARD_BEHOLD_607FM_MK5: |
1722 | @@ -757,26 +755,26 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) |
1723 | case SAA7134_BOARD_BEHOLD_M63: |
1724 | case SAA7134_BOARD_BEHOLD_M6_EXTRA: |
1725 | case SAA7134_BOARD_BEHOLD_H6: |
1726 | - init_data.name = "BeholdTV"; |
1727 | - init_data.get_key = get_key_beholdm6xx; |
1728 | - init_data.ir_codes = ir_codes_behold; |
1729 | + dev->init_data.name = "BeholdTV"; |
1730 | + dev->init_data.get_key = get_key_beholdm6xx; |
1731 | + dev->init_data.ir_codes = ir_codes_behold; |
1732 | break; |
1733 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: |
1734 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: |
1735 | - info.addr = 0x40; |
1736 | + dev->info.addr = 0x40; |
1737 | break; |
1738 | } |
1739 | |
1740 | - if (init_data.name) |
1741 | - info.platform_data = &init_data; |
1742 | + if (dev->init_data.name) |
1743 | + dev->info.platform_data = &dev->init_data; |
1744 | /* No need to probe if address is known */ |
1745 | - if (info.addr) { |
1746 | - i2c_new_device(&dev->i2c_adap, &info); |
1747 | + if (dev->info.addr) { |
1748 | + i2c_new_device(&dev->i2c_adap, &dev->info); |
1749 | return; |
1750 | } |
1751 | |
1752 | /* Address not known, fallback to probing */ |
1753 | - i2c_new_probed_device(&dev->i2c_adap, &info, addr_list); |
1754 | + i2c_new_probed_device(&dev->i2c_adap, &dev->info, addr_list); |
1755 | } |
1756 | |
1757 | static int saa7134_rc5_irq(struct saa7134_dev *dev) |
1758 | diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h |
1759 | index fb564f1..4d85f5c 100644 |
1760 | --- a/drivers/media/video/saa7134/saa7134.h |
1761 | +++ b/drivers/media/video/saa7134/saa7134.h |
1762 | @@ -584,6 +584,10 @@ struct saa7134_dev { |
1763 | int nosignal; |
1764 | unsigned int insuspend; |
1765 | |
1766 | + /* I2C keyboard data */ |
1767 | + struct i2c_board_info info; |
1768 | + struct IR_i2c_init_data init_data; |
1769 | + |
1770 | /* SAA7134_MPEG_* */ |
1771 | struct saa7134_ts ts; |
1772 | struct saa7134_dmaqueue ts_q; |
1773 | diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c |
1774 | index 5d0ba4f..9ad7bb4 100644 |
1775 | --- a/drivers/message/fusion/mptbase.c |
1776 | +++ b/drivers/message/fusion/mptbase.c |
1777 | @@ -1015,9 +1015,9 @@ mpt_add_sge_64bit(void *pAddr, u32 flagslength, dma_addr_t dma_addr) |
1778 | { |
1779 | SGESimple64_t *pSge = (SGESimple64_t *) pAddr; |
1780 | pSge->Address.Low = cpu_to_le32 |
1781 | - (lower_32_bits((unsigned long)(dma_addr))); |
1782 | + (lower_32_bits(dma_addr)); |
1783 | pSge->Address.High = cpu_to_le32 |
1784 | - (upper_32_bits((unsigned long)dma_addr)); |
1785 | + (upper_32_bits(dma_addr)); |
1786 | pSge->FlagsLength = cpu_to_le32 |
1787 | ((flagslength | MPT_SGE_FLAGS_64_BIT_ADDRESSING)); |
1788 | } |
1789 | @@ -1038,8 +1038,8 @@ mpt_add_sge_64bit_1078(void *pAddr, u32 flagslength, dma_addr_t dma_addr) |
1790 | u32 tmp; |
1791 | |
1792 | pSge->Address.Low = cpu_to_le32 |
1793 | - (lower_32_bits((unsigned long)(dma_addr))); |
1794 | - tmp = (u32)(upper_32_bits((unsigned long)dma_addr)); |
1795 | + (lower_32_bits(dma_addr)); |
1796 | + tmp = (u32)(upper_32_bits(dma_addr)); |
1797 | |
1798 | /* |
1799 | * 1078 errata workaround for the 36GB limitation |
1800 | @@ -1101,7 +1101,7 @@ mpt_add_chain_64bit(void *pAddr, u8 next, u16 length, dma_addr_t dma_addr) |
1801 | pChain->NextChainOffset = next; |
1802 | |
1803 | pChain->Address.Low = cpu_to_le32(tmp); |
1804 | - tmp = (u32)(upper_32_bits((unsigned long)dma_addr)); |
1805 | + tmp = (u32)(upper_32_bits(dma_addr)); |
1806 | pChain->Address.High = cpu_to_le32(tmp); |
1807 | } |
1808 | |
1809 | diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c |
1810 | index 13e7d7b..dd8b6b3 100644 |
1811 | --- a/drivers/mfd/ab3100-core.c |
1812 | +++ b/drivers/mfd/ab3100-core.c |
1813 | @@ -643,7 +643,7 @@ struct ab3100_init_setting { |
1814 | u8 setting; |
1815 | }; |
1816 | |
1817 | -static const struct ab3100_init_setting __initdata |
1818 | +static const struct ab3100_init_setting __initconst |
1819 | ab3100_init_settings[] = { |
1820 | { |
1821 | .abreg = AB3100_MCA, |
1822 | diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c |
1823 | index 06084db..72f2df1 100644 |
1824 | --- a/drivers/mmc/core/mmc.c |
1825 | +++ b/drivers/mmc/core/mmc.c |
1826 | @@ -180,11 +180,11 @@ static int mmc_read_ext_csd(struct mmc_card *card) |
1827 | |
1828 | err = mmc_send_ext_csd(card, ext_csd); |
1829 | if (err) { |
1830 | - /* |
1831 | - * We all hosts that cannot perform the command |
1832 | - * to fail more gracefully |
1833 | - */ |
1834 | - if (err != -EINVAL) |
1835 | + /* If the host or the card can't do the switch, |
1836 | + * fail more gracefully. */ |
1837 | + if ((err != -EINVAL) |
1838 | + && (err != -ENOSYS) |
1839 | + && (err != -EFAULT)) |
1840 | goto out; |
1841 | |
1842 | /* |
1843 | diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c |
1844 | index cd81c39..65c32bf 100644 |
1845 | --- a/drivers/mmc/core/sd.c |
1846 | +++ b/drivers/mmc/core/sd.c |
1847 | @@ -210,11 +210,11 @@ static int mmc_read_switch(struct mmc_card *card) |
1848 | |
1849 | err = mmc_sd_switch(card, 0, 0, 1, status); |
1850 | if (err) { |
1851 | - /* |
1852 | - * We all hosts that cannot perform the command |
1853 | - * to fail more gracefully |
1854 | - */ |
1855 | - if (err != -EINVAL) |
1856 | + /* If the host or the card can't do the switch, |
1857 | + * fail more gracefully. */ |
1858 | + if ((err != -EINVAL) |
1859 | + && (err != -ENOSYS) |
1860 | + && (err != -EFAULT)) |
1861 | goto out; |
1862 | |
1863 | printk(KERN_WARNING "%s: problem reading switch " |
1864 | diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c |
1865 | index 61ea833..94bb61e 100644 |
1866 | --- a/drivers/mtd/chips/cfi_cmdset_0002.c |
1867 | +++ b/drivers/mtd/chips/cfi_cmdset_0002.c |
1868 | @@ -282,16 +282,6 @@ static void fixup_s29gl032n_sectors(struct mtd_info *mtd, void *param) |
1869 | } |
1870 | } |
1871 | |
1872 | -static void fixup_M29W128G_write_buffer(struct mtd_info *mtd, void *param) |
1873 | -{ |
1874 | - struct map_info *map = mtd->priv; |
1875 | - struct cfi_private *cfi = map->fldrv_priv; |
1876 | - if (cfi->cfiq->BufWriteTimeoutTyp) { |
1877 | - pr_warning("Don't use write buffer on ST flash M29W128G\n"); |
1878 | - cfi->cfiq->BufWriteTimeoutTyp = 0; |
1879 | - } |
1880 | -} |
1881 | - |
1882 | static struct cfi_fixup cfi_fixup_table[] = { |
1883 | { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL }, |
1884 | #ifdef AMD_BOOTLOC_BUG |
1885 | @@ -308,7 +298,6 @@ static struct cfi_fixup cfi_fixup_table[] = { |
1886 | { CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors, NULL, }, |
1887 | { CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors, NULL, }, |
1888 | { CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors, NULL, }, |
1889 | - { CFI_MFR_ST, 0x227E, fixup_M29W128G_write_buffer, NULL, }, |
1890 | #if !FORCE_WORD_WRITE |
1891 | { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, }, |
1892 | #endif |
1893 | diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c |
1894 | index 34d40e2..c5a84fd 100644 |
1895 | --- a/drivers/mtd/chips/cfi_util.c |
1896 | +++ b/drivers/mtd/chips/cfi_util.c |
1897 | @@ -81,6 +81,10 @@ void __xipram cfi_qry_mode_off(uint32_t base, struct map_info *map, |
1898 | { |
1899 | cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); |
1900 | cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); |
1901 | + /* M29W128G flashes require an additional reset command |
1902 | + when exit qry mode */ |
1903 | + if ((cfi->mfr == CFI_MFR_ST) && (cfi->id == 0x227E || cfi->id == 0x7E)) |
1904 | + cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); |
1905 | } |
1906 | EXPORT_SYMBOL_GPL(cfi_qry_mode_off); |
1907 | |
1908 | diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c |
1909 | index 89bf85a..40b5658 100644 |
1910 | --- a/drivers/mtd/nand/ndfc.c |
1911 | +++ b/drivers/mtd/nand/ndfc.c |
1912 | @@ -102,8 +102,8 @@ static int ndfc_calculate_ecc(struct mtd_info *mtd, |
1913 | wmb(); |
1914 | ecc = in_be32(ndfc->ndfcbase + NDFC_ECC); |
1915 | /* The NDFC uses Smart Media (SMC) bytes order */ |
1916 | - ecc_code[0] = p[2]; |
1917 | - ecc_code[1] = p[1]; |
1918 | + ecc_code[0] = p[1]; |
1919 | + ecc_code[1] = p[2]; |
1920 | ecc_code[2] = p[3]; |
1921 | |
1922 | return 0; |
1923 | diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c |
1924 | index 3e164f0..62d6a78 100644 |
1925 | --- a/drivers/mtd/ofpart.c |
1926 | +++ b/drivers/mtd/ofpart.c |
1927 | @@ -46,21 +46,12 @@ int __devinit of_mtd_parse_partitions(struct device *dev, |
1928 | const u32 *reg; |
1929 | int len; |
1930 | |
1931 | - /* check if this is a partition node */ |
1932 | - partname = of_get_property(pp, "name", &len); |
1933 | - if (strcmp(partname, "partition") != 0) { |
1934 | + reg = of_get_property(pp, "reg", &len); |
1935 | + if (!reg) { |
1936 | nr_parts--; |
1937 | continue; |
1938 | } |
1939 | |
1940 | - reg = of_get_property(pp, "reg", &len); |
1941 | - if (!reg || (len != 2 * sizeof(u32))) { |
1942 | - of_node_put(pp); |
1943 | - dev_err(dev, "Invalid 'reg' on %s\n", node->full_name); |
1944 | - kfree(*pparts); |
1945 | - *pparts = NULL; |
1946 | - return -EINVAL; |
1947 | - } |
1948 | (*pparts)[i].offset = reg[0]; |
1949 | (*pparts)[i].size = reg[1]; |
1950 | |
1951 | @@ -75,6 +66,14 @@ int __devinit of_mtd_parse_partitions(struct device *dev, |
1952 | i++; |
1953 | } |
1954 | |
1955 | + if (!i) { |
1956 | + of_node_put(pp); |
1957 | + dev_err(dev, "No valid partition found on %s\n", node->full_name); |
1958 | + kfree(*pparts); |
1959 | + *pparts = NULL; |
1960 | + return -EINVAL; |
1961 | + } |
1962 | + |
1963 | return nr_parts; |
1964 | } |
1965 | EXPORT_SYMBOL(of_mtd_parse_partitions); |
1966 | diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c |
1967 | index a10c1d7..460bb88 100644 |
1968 | --- a/drivers/net/can/vcan.c |
1969 | +++ b/drivers/net/can/vcan.c |
1970 | @@ -80,7 +80,7 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev) |
1971 | skb->dev = dev; |
1972 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
1973 | |
1974 | - netif_rx(skb); |
1975 | + netif_rx_ni(skb); |
1976 | } |
1977 | |
1978 | static int vcan_tx(struct sk_buff *skb, struct net_device *dev) |
1979 | diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c |
1980 | index 1f9ec29..65a43c8 100644 |
1981 | --- a/drivers/net/usb/kaweth.c |
1982 | +++ b/drivers/net/usb/kaweth.c |
1983 | @@ -263,6 +263,7 @@ static int kaweth_control(struct kaweth_device *kaweth, |
1984 | int timeout) |
1985 | { |
1986 | struct usb_ctrlrequest *dr; |
1987 | + int retval; |
1988 | |
1989 | dbg("kaweth_control()"); |
1990 | |
1991 | @@ -278,18 +279,21 @@ static int kaweth_control(struct kaweth_device *kaweth, |
1992 | return -ENOMEM; |
1993 | } |
1994 | |
1995 | - dr->bRequestType= requesttype; |
1996 | + dr->bRequestType = requesttype; |
1997 | dr->bRequest = request; |
1998 | dr->wValue = cpu_to_le16(value); |
1999 | dr->wIndex = cpu_to_le16(index); |
2000 | dr->wLength = cpu_to_le16(size); |
2001 | |
2002 | - return kaweth_internal_control_msg(kaweth->dev, |
2003 | - pipe, |
2004 | - dr, |
2005 | - data, |
2006 | - size, |
2007 | - timeout); |
2008 | + retval = kaweth_internal_control_msg(kaweth->dev, |
2009 | + pipe, |
2010 | + dr, |
2011 | + data, |
2012 | + size, |
2013 | + timeout); |
2014 | + |
2015 | + kfree(dr); |
2016 | + return retval; |
2017 | } |
2018 | |
2019 | /**************************************************************** |
2020 | diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c |
2021 | index 007eb85..1084ca6 100644 |
2022 | --- a/drivers/net/wireless/ath/ar9170/usb.c |
2023 | +++ b/drivers/net/wireless/ath/ar9170/usb.c |
2024 | @@ -64,6 +64,8 @@ static struct usb_device_id ar9170_usb_ids[] = { |
2025 | { USB_DEVICE(0x0cf3, 0x9170) }, |
2026 | /* Atheros TG121N */ |
2027 | { USB_DEVICE(0x0cf3, 0x1001) }, |
2028 | + /* TP-Link TL-WN821N v2 */ |
2029 | + { USB_DEVICE(0x0cf3, 0x1002) }, |
2030 | /* Cace Airpcap NX */ |
2031 | { USB_DEVICE(0xcace, 0x0300) }, |
2032 | /* D-Link DWA 160A */ |
2033 | diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h |
2034 | index 6358233..778baf7 100644 |
2035 | --- a/drivers/net/wireless/ath/ath5k/ath5k.h |
2036 | +++ b/drivers/net/wireless/ath/ath5k/ath5k.h |
2037 | @@ -1164,6 +1164,7 @@ extern void ath5k_unregister_leds(struct ath5k_softc *sc); |
2038 | |
2039 | /* Reset Functions */ |
2040 | extern int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial); |
2041 | +extern int ath5k_hw_on_hold(struct ath5k_hw *ah); |
2042 | extern int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, struct ieee80211_channel *channel, bool change_channel); |
2043 | /* Power management functions */ |
2044 | extern int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration); |
2045 | diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c |
2046 | index c41ef58..605b8f6 100644 |
2047 | --- a/drivers/net/wireless/ath/ath5k/attach.c |
2048 | +++ b/drivers/net/wireless/ath/ath5k/attach.c |
2049 | @@ -145,7 +145,7 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version) |
2050 | goto err_free; |
2051 | |
2052 | /* Bring device out of sleep and reset it's units */ |
2053 | - ret = ath5k_hw_nic_wakeup(ah, CHANNEL_B, true); |
2054 | + ret = ath5k_hw_nic_wakeup(ah, 0, true); |
2055 | if (ret) |
2056 | goto err_free; |
2057 | |
2058 | diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c |
2059 | index ba6d225..753f50e 100644 |
2060 | --- a/drivers/net/wireless/ath/ath5k/base.c |
2061 | +++ b/drivers/net/wireless/ath/ath5k/base.c |
2062 | @@ -666,7 +666,6 @@ ath5k_pci_suspend(struct pci_dev *pdev, pm_message_t state) |
2063 | |
2064 | ath5k_led_off(sc); |
2065 | |
2066 | - free_irq(pdev->irq, sc); |
2067 | pci_save_state(pdev); |
2068 | pci_disable_device(pdev); |
2069 | pci_set_power_state(pdev, PCI_D3hot); |
2070 | @@ -694,18 +693,8 @@ ath5k_pci_resume(struct pci_dev *pdev) |
2071 | */ |
2072 | pci_write_config_byte(pdev, 0x41, 0); |
2073 | |
2074 | - err = request_irq(pdev->irq, ath5k_intr, IRQF_SHARED, "ath", sc); |
2075 | - if (err) { |
2076 | - ATH5K_ERR(sc, "request_irq failed\n"); |
2077 | - goto err_no_irq; |
2078 | - } |
2079 | - |
2080 | ath5k_led_enable(sc); |
2081 | return 0; |
2082 | - |
2083 | -err_no_irq: |
2084 | - pci_disable_device(pdev); |
2085 | - return err; |
2086 | } |
2087 | #endif /* CONFIG_PM */ |
2088 | |
2089 | @@ -2445,27 +2434,29 @@ ath5k_stop_hw(struct ath5k_softc *sc) |
2090 | ret = ath5k_stop_locked(sc); |
2091 | if (ret == 0 && !test_bit(ATH_STAT_INVALID, sc->status)) { |
2092 | /* |
2093 | - * Set the chip in full sleep mode. Note that we are |
2094 | - * careful to do this only when bringing the interface |
2095 | - * completely to a stop. When the chip is in this state |
2096 | - * it must be carefully woken up or references to |
2097 | - * registers in the PCI clock domain may freeze the bus |
2098 | - * (and system). This varies by chip and is mostly an |
2099 | - * issue with newer parts that go to sleep more quickly. |
2100 | - */ |
2101 | - if (sc->ah->ah_mac_srev >= 0x78) { |
2102 | - /* |
2103 | - * XXX |
2104 | - * don't put newer MAC revisions > 7.8 to sleep because |
2105 | - * of the above mentioned problems |
2106 | - */ |
2107 | - ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "mac version > 7.8, " |
2108 | - "not putting device to sleep\n"); |
2109 | - } else { |
2110 | - ATH5K_DBG(sc, ATH5K_DEBUG_RESET, |
2111 | - "putting device to full sleep\n"); |
2112 | - ath5k_hw_set_power(sc->ah, AR5K_PM_FULL_SLEEP, true, 0); |
2113 | - } |
2114 | + * Don't set the card in full sleep mode! |
2115 | + * |
2116 | + * a) When the device is in this state it must be carefully |
2117 | + * woken up or references to registers in the PCI clock |
2118 | + * domain may freeze the bus (and system). This varies |
2119 | + * by chip and is mostly an issue with newer parts |
2120 | + * (madwifi sources mentioned srev >= 0x78) that go to |
2121 | + * sleep more quickly. |
2122 | + * |
2123 | + * b) On older chips full sleep results a weird behaviour |
2124 | + * during wakeup. I tested various cards with srev < 0x78 |
2125 | + * and they don't wake up after module reload, a second |
2126 | + * module reload is needed to bring the card up again. |
2127 | + * |
2128 | + * Until we figure out what's going on don't enable |
2129 | + * full chip reset on any chip (this is what Legacy HAL |
2130 | + * and Sam's HAL do anyway). Instead Perform a full reset |
2131 | + * on the device (same as initial state after attach) and |
2132 | + * leave it idle (keep MAC/BB on warm reset) */ |
2133 | + ret = ath5k_hw_on_hold(sc->ah); |
2134 | + |
2135 | + ATH5K_DBG(sc, ATH5K_DEBUG_RESET, |
2136 | + "putting device to sleep\n"); |
2137 | } |
2138 | ath5k_txbuf_free(sc, sc->bbuf); |
2139 | |
2140 | diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c |
2141 | index bd0a97a..4980621 100644 |
2142 | --- a/drivers/net/wireless/ath/ath5k/reset.c |
2143 | +++ b/drivers/net/wireless/ath/ath5k/reset.c |
2144 | @@ -258,29 +258,35 @@ int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, |
2145 | if (!set_chip) |
2146 | goto commit; |
2147 | |
2148 | - /* Preserve sleep duration */ |
2149 | data = ath5k_hw_reg_read(ah, AR5K_SLEEP_CTL); |
2150 | + |
2151 | + /* If card is down we 'll get 0xffff... so we |
2152 | + * need to clean this up before we write the register |
2153 | + */ |
2154 | if (data & 0xffc00000) |
2155 | data = 0; |
2156 | else |
2157 | - data = data & 0xfffcffff; |
2158 | + /* Preserve sleep duration etc */ |
2159 | + data = data & ~AR5K_SLEEP_CTL_SLE; |
2160 | |
2161 | - ath5k_hw_reg_write(ah, data, AR5K_SLEEP_CTL); |
2162 | + ath5k_hw_reg_write(ah, data | AR5K_SLEEP_CTL_SLE_WAKE, |
2163 | + AR5K_SLEEP_CTL); |
2164 | udelay(15); |
2165 | |
2166 | - for (i = 50; i > 0; i--) { |
2167 | + for (i = 200; i > 0; i--) { |
2168 | /* Check if the chip did wake up */ |
2169 | if ((ath5k_hw_reg_read(ah, AR5K_PCICFG) & |
2170 | AR5K_PCICFG_SPWR_DN) == 0) |
2171 | break; |
2172 | |
2173 | /* Wait a bit and retry */ |
2174 | - udelay(200); |
2175 | - ath5k_hw_reg_write(ah, data, AR5K_SLEEP_CTL); |
2176 | + udelay(50); |
2177 | + ath5k_hw_reg_write(ah, data | AR5K_SLEEP_CTL_SLE_WAKE, |
2178 | + AR5K_SLEEP_CTL); |
2179 | } |
2180 | |
2181 | /* Fail if the chip didn't wake up */ |
2182 | - if (i <= 0) |
2183 | + if (i == 0) |
2184 | return -EIO; |
2185 | |
2186 | break; |
2187 | @@ -297,6 +303,64 @@ commit: |
2188 | } |
2189 | |
2190 | /* |
2191 | + * Put device on hold |
2192 | + * |
2193 | + * Put MAC and Baseband on warm reset and |
2194 | + * keep that state (don't clean sleep control |
2195 | + * register). After this MAC and Baseband are |
2196 | + * disabled and a full reset is needed to come |
2197 | + * back. This way we save as much power as possible |
2198 | + * without puting the card on full sleep. |
2199 | + */ |
2200 | +int ath5k_hw_on_hold(struct ath5k_hw *ah) |
2201 | +{ |
2202 | + struct pci_dev *pdev = ah->ah_sc->pdev; |
2203 | + u32 bus_flags; |
2204 | + int ret; |
2205 | + |
2206 | + /* Make sure device is awake */ |
2207 | + ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); |
2208 | + if (ret) { |
2209 | + ATH5K_ERR(ah->ah_sc, "failed to wakeup the MAC Chip\n"); |
2210 | + return ret; |
2211 | + } |
2212 | + |
2213 | + /* |
2214 | + * Put chipset on warm reset... |
2215 | + * |
2216 | + * Note: puting PCI core on warm reset on PCI-E cards |
2217 | + * results card to hang and always return 0xffff... so |
2218 | + * we ingore that flag for PCI-E cards. On PCI cards |
2219 | + * this flag gets cleared after 64 PCI clocks. |
2220 | + */ |
2221 | + bus_flags = (pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI; |
2222 | + |
2223 | + if (ah->ah_version == AR5K_AR5210) { |
2224 | + ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | |
2225 | + AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_DMA | |
2226 | + AR5K_RESET_CTL_PHY | AR5K_RESET_CTL_PCI); |
2227 | + mdelay(2); |
2228 | + } else { |
2229 | + ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | |
2230 | + AR5K_RESET_CTL_BASEBAND | bus_flags); |
2231 | + } |
2232 | + |
2233 | + if (ret) { |
2234 | + ATH5K_ERR(ah->ah_sc, "failed to put device on warm reset\n"); |
2235 | + return -EIO; |
2236 | + } |
2237 | + |
2238 | + /* ...wakeup again!*/ |
2239 | + ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); |
2240 | + if (ret) { |
2241 | + ATH5K_ERR(ah->ah_sc, "failed to put device on hold\n"); |
2242 | + return ret; |
2243 | + } |
2244 | + |
2245 | + return ret; |
2246 | +} |
2247 | + |
2248 | +/* |
2249 | * Bring up MAC + PHY Chips and program PLL |
2250 | * TODO: Half/Quarter rate support |
2251 | */ |
2252 | @@ -319,6 +383,50 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial) |
2253 | return ret; |
2254 | } |
2255 | |
2256 | + /* |
2257 | + * Put chipset on warm reset... |
2258 | + * |
2259 | + * Note: puting PCI core on warm reset on PCI-E cards |
2260 | + * results card to hang and always return 0xffff... so |
2261 | + * we ingore that flag for PCI-E cards. On PCI cards |
2262 | + * this flag gets cleared after 64 PCI clocks. |
2263 | + */ |
2264 | + bus_flags = (pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI; |
2265 | + |
2266 | + if (ah->ah_version == AR5K_AR5210) { |
2267 | + ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | |
2268 | + AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_DMA | |
2269 | + AR5K_RESET_CTL_PHY | AR5K_RESET_CTL_PCI); |
2270 | + mdelay(2); |
2271 | + } else { |
2272 | + ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | |
2273 | + AR5K_RESET_CTL_BASEBAND | bus_flags); |
2274 | + } |
2275 | + |
2276 | + if (ret) { |
2277 | + ATH5K_ERR(ah->ah_sc, "failed to reset the MAC Chip\n"); |
2278 | + return -EIO; |
2279 | + } |
2280 | + |
2281 | + /* ...wakeup again!...*/ |
2282 | + ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); |
2283 | + if (ret) { |
2284 | + ATH5K_ERR(ah->ah_sc, "failed to resume the MAC Chip\n"); |
2285 | + return ret; |
2286 | + } |
2287 | + |
2288 | + /* ...clear reset control register and pull device out of |
2289 | + * warm reset */ |
2290 | + if (ath5k_hw_nic_reset(ah, 0)) { |
2291 | + ATH5K_ERR(ah->ah_sc, "failed to warm reset the MAC Chip\n"); |
2292 | + return -EIO; |
2293 | + } |
2294 | + |
2295 | + /* On initialization skip PLL programming since we don't have |
2296 | + * a channel / mode set yet */ |
2297 | + if (initial) |
2298 | + return 0; |
2299 | + |
2300 | if (ah->ah_version != AR5K_AR5210) { |
2301 | /* |
2302 | * Get channel mode flags |
2303 | @@ -384,39 +492,6 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial) |
2304 | AR5K_PHY_TURBO); |
2305 | } |
2306 | |
2307 | - /* reseting PCI on PCI-E cards results card to hang |
2308 | - * and always return 0xffff... so we ingore that flag |
2309 | - * for PCI-E cards */ |
2310 | - bus_flags = (pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI; |
2311 | - |
2312 | - /* Reset chipset */ |
2313 | - if (ah->ah_version == AR5K_AR5210) { |
2314 | - ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | |
2315 | - AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_DMA | |
2316 | - AR5K_RESET_CTL_PHY | AR5K_RESET_CTL_PCI); |
2317 | - mdelay(2); |
2318 | - } else { |
2319 | - ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | |
2320 | - AR5K_RESET_CTL_BASEBAND | bus_flags); |
2321 | - } |
2322 | - if (ret) { |
2323 | - ATH5K_ERR(ah->ah_sc, "failed to reset the MAC Chip\n"); |
2324 | - return -EIO; |
2325 | - } |
2326 | - |
2327 | - /* ...wakeup again!*/ |
2328 | - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); |
2329 | - if (ret) { |
2330 | - ATH5K_ERR(ah->ah_sc, "failed to resume the MAC Chip\n"); |
2331 | - return ret; |
2332 | - } |
2333 | - |
2334 | - /* ...final warm reset */ |
2335 | - if (ath5k_hw_nic_reset(ah, 0)) { |
2336 | - ATH5K_ERR(ah->ah_sc, "failed to warm reset the MAC Chip\n"); |
2337 | - return -EIO; |
2338 | - } |
2339 | - |
2340 | if (ah->ah_version != AR5K_AR5210) { |
2341 | |
2342 | /* ...update PLL if needed */ |
2343 | diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c |
2344 | index 7da52f1..d83d430 100644 |
2345 | --- a/drivers/net/wireless/iwlwifi/iwl-1000.c |
2346 | +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c |
2347 | @@ -46,7 +46,7 @@ |
2348 | #include "iwl-5000-hw.h" |
2349 | |
2350 | /* Highest firmware API version supported */ |
2351 | -#define IWL1000_UCODE_API_MAX 2 |
2352 | +#define IWL1000_UCODE_API_MAX 3 |
2353 | |
2354 | /* Lowest firmware API version supported */ |
2355 | #define IWL1000_UCODE_API_MIN 1 |
2356 | @@ -62,12 +62,14 @@ struct iwl_cfg iwl1000_bgn_cfg = { |
2357 | .ucode_api_min = IWL1000_UCODE_API_MIN, |
2358 | .sku = IWL_SKU_G|IWL_SKU_N, |
2359 | .ops = &iwl5000_ops, |
2360 | - .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, |
2361 | + .eeprom_size = OTP_LOW_IMAGE_SIZE, |
2362 | .eeprom_ver = EEPROM_5000_EEPROM_VERSION, |
2363 | .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, |
2364 | .mod_params = &iwl50_mod_params, |
2365 | .valid_tx_ant = ANT_A, |
2366 | .valid_rx_ant = ANT_AB, |
2367 | .need_pll_cfg = true, |
2368 | + .max_ll_items = OTP_MAX_LL_ITEMS_1000, |
2369 | + .shadow_ram_support = false, |
2370 | }; |
2371 | |
2372 | diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c |
2373 | index 46288e7..b73ab6c 100644 |
2374 | --- a/drivers/net/wireless/iwlwifi/iwl-3945.c |
2375 | +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c |
2376 | @@ -2784,11 +2784,50 @@ static int iwl3945_load_bsm(struct iwl_priv *priv) |
2377 | return 0; |
2378 | } |
2379 | |
2380 | +#define IWL3945_UCODE_GET(item) \ |
2381 | +static u32 iwl3945_ucode_get_##item(const struct iwl_ucode_header *ucode,\ |
2382 | + u32 api_ver) \ |
2383 | +{ \ |
2384 | + return le32_to_cpu(ucode->u.v1.item); \ |
2385 | +} |
2386 | + |
2387 | +static u32 iwl3945_ucode_get_header_size(u32 api_ver) |
2388 | +{ |
2389 | + return UCODE_HEADER_SIZE(1); |
2390 | +} |
2391 | +static u32 iwl3945_ucode_get_build(const struct iwl_ucode_header *ucode, |
2392 | + u32 api_ver) |
2393 | +{ |
2394 | + return 0; |
2395 | +} |
2396 | +static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode, |
2397 | + u32 api_ver) |
2398 | +{ |
2399 | + return (u8 *) ucode->u.v1.data; |
2400 | +} |
2401 | + |
2402 | +IWL3945_UCODE_GET(inst_size); |
2403 | +IWL3945_UCODE_GET(data_size); |
2404 | +IWL3945_UCODE_GET(init_size); |
2405 | +IWL3945_UCODE_GET(init_data_size); |
2406 | +IWL3945_UCODE_GET(boot_size); |
2407 | + |
2408 | static struct iwl_hcmd_ops iwl3945_hcmd = { |
2409 | .rxon_assoc = iwl3945_send_rxon_assoc, |
2410 | .commit_rxon = iwl3945_commit_rxon, |
2411 | }; |
2412 | |
2413 | +static struct iwl_ucode_ops iwl3945_ucode = { |
2414 | + .get_header_size = iwl3945_ucode_get_header_size, |
2415 | + .get_build = iwl3945_ucode_get_build, |
2416 | + .get_inst_size = iwl3945_ucode_get_inst_size, |
2417 | + .get_data_size = iwl3945_ucode_get_data_size, |
2418 | + .get_init_size = iwl3945_ucode_get_init_size, |
2419 | + .get_init_data_size = iwl3945_ucode_get_init_data_size, |
2420 | + .get_boot_size = iwl3945_ucode_get_boot_size, |
2421 | + .get_data = iwl3945_ucode_get_data, |
2422 | +}; |
2423 | + |
2424 | static struct iwl_lib_ops iwl3945_lib = { |
2425 | .txq_attach_buf_to_tfd = iwl3945_hw_txq_attach_buf_to_tfd, |
2426 | .txq_free_tfd = iwl3945_hw_txq_free_tfd, |
2427 | @@ -2829,6 +2868,7 @@ static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = { |
2428 | }; |
2429 | |
2430 | static struct iwl_ops iwl3945_ops = { |
2431 | + .ucode = &iwl3945_ucode, |
2432 | .lib = &iwl3945_lib, |
2433 | .hcmd = &iwl3945_hcmd, |
2434 | .utils = &iwl3945_hcmd_utils, |
2435 | diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c |
2436 | index 8f3d4bc..157ee15 100644 |
2437 | --- a/drivers/net/wireless/iwlwifi/iwl-4965.c |
2438 | +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c |
2439 | @@ -2221,12 +2221,50 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv) |
2440 | cancel_work_sync(&priv->txpower_work); |
2441 | } |
2442 | |
2443 | +#define IWL4965_UCODE_GET(item) \ |
2444 | +static u32 iwl4965_ucode_get_##item(const struct iwl_ucode_header *ucode,\ |
2445 | + u32 api_ver) \ |
2446 | +{ \ |
2447 | + return le32_to_cpu(ucode->u.v1.item); \ |
2448 | +} |
2449 | + |
2450 | +static u32 iwl4965_ucode_get_header_size(u32 api_ver) |
2451 | +{ |
2452 | + return UCODE_HEADER_SIZE(1); |
2453 | +} |
2454 | +static u32 iwl4965_ucode_get_build(const struct iwl_ucode_header *ucode, |
2455 | + u32 api_ver) |
2456 | +{ |
2457 | + return 0; |
2458 | +} |
2459 | +static u8 *iwl4965_ucode_get_data(const struct iwl_ucode_header *ucode, |
2460 | + u32 api_ver) |
2461 | +{ |
2462 | + return (u8 *) ucode->u.v1.data; |
2463 | +} |
2464 | + |
2465 | +IWL4965_UCODE_GET(inst_size); |
2466 | +IWL4965_UCODE_GET(data_size); |
2467 | +IWL4965_UCODE_GET(init_size); |
2468 | +IWL4965_UCODE_GET(init_data_size); |
2469 | +IWL4965_UCODE_GET(boot_size); |
2470 | + |
2471 | static struct iwl_hcmd_ops iwl4965_hcmd = { |
2472 | .rxon_assoc = iwl4965_send_rxon_assoc, |
2473 | .commit_rxon = iwl_commit_rxon, |
2474 | .set_rxon_chain = iwl_set_rxon_chain, |
2475 | }; |
2476 | |
2477 | +static struct iwl_ucode_ops iwl4965_ucode = { |
2478 | + .get_header_size = iwl4965_ucode_get_header_size, |
2479 | + .get_build = iwl4965_ucode_get_build, |
2480 | + .get_inst_size = iwl4965_ucode_get_inst_size, |
2481 | + .get_data_size = iwl4965_ucode_get_data_size, |
2482 | + .get_init_size = iwl4965_ucode_get_init_size, |
2483 | + .get_init_data_size = iwl4965_ucode_get_init_data_size, |
2484 | + .get_boot_size = iwl4965_ucode_get_boot_size, |
2485 | + .get_data = iwl4965_ucode_get_data, |
2486 | +}; |
2487 | static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { |
2488 | .get_hcmd_size = iwl4965_get_hcmd_size, |
2489 | .build_addsta_hcmd = iwl4965_build_addsta_hcmd, |
2490 | @@ -2287,6 +2325,7 @@ static struct iwl_lib_ops iwl4965_lib = { |
2491 | }; |
2492 | |
2493 | static struct iwl_ops iwl4965_ops = { |
2494 | + .ucode = &iwl4965_ucode, |
2495 | .lib = &iwl4965_lib, |
2496 | .hcmd = &iwl4965_hcmd, |
2497 | .utils = &iwl4965_hcmd_utils, |
2498 | diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c |
2499 | index b3c648c..a9ea3b5 100644 |
2500 | --- a/drivers/net/wireless/iwlwifi/iwl-5000.c |
2501 | +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c |
2502 | @@ -239,6 +239,13 @@ static void iwl5000_nic_config(struct iwl_priv *priv) |
2503 | APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS, |
2504 | ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS); |
2505 | |
2506 | + if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_1000) { |
2507 | + /* Setting digital SVR for 1000 card to 1.32V */ |
2508 | + iwl_set_bits_mask_prph(priv, APMG_DIGITAL_SVR_REG, |
2509 | + APMG_SVR_DIGITAL_VOLTAGE_1_32, |
2510 | + ~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK); |
2511 | + } |
2512 | + |
2513 | spin_unlock_irqrestore(&priv->lock, flags); |
2514 | } |
2515 | |
2516 | @@ -1426,6 +1433,44 @@ int iwl5000_calc_rssi(struct iwl_priv *priv, |
2517 | return max_rssi - agc - IWL49_RSSI_OFFSET; |
2518 | } |
2519 | |
2520 | +#define IWL5000_UCODE_GET(item) \ |
2521 | +static u32 iwl5000_ucode_get_##item(const struct iwl_ucode_header *ucode,\ |
2522 | + u32 api_ver) \ |
2523 | +{ \ |
2524 | + if (api_ver <= 2) \ |
2525 | + return le32_to_cpu(ucode->u.v1.item); \ |
2526 | + return le32_to_cpu(ucode->u.v2.item); \ |
2527 | +} |
2528 | + |
2529 | +static u32 iwl5000_ucode_get_header_size(u32 api_ver) |
2530 | +{ |
2531 | + if (api_ver <= 2) |
2532 | + return UCODE_HEADER_SIZE(1); |
2533 | + return UCODE_HEADER_SIZE(2); |
2534 | +} |
2535 | + |
2536 | +static u32 iwl5000_ucode_get_build(const struct iwl_ucode_header *ucode, |
2537 | + u32 api_ver) |
2538 | +{ |
2539 | + if (api_ver <= 2) |
2540 | + return 0; |
2541 | + return le32_to_cpu(ucode->u.v2.build); |
2542 | +} |
2543 | + |
2544 | +static u8 *iwl5000_ucode_get_data(const struct iwl_ucode_header *ucode, |
2545 | + u32 api_ver) |
2546 | +{ |
2547 | + if (api_ver <= 2) |
2548 | + return (u8 *) ucode->u.v1.data; |
2549 | + return (u8 *) ucode->u.v2.data; |
2550 | +} |
2551 | + |
2552 | +IWL5000_UCODE_GET(inst_size); |
2553 | +IWL5000_UCODE_GET(data_size); |
2554 | +IWL5000_UCODE_GET(init_size); |
2555 | +IWL5000_UCODE_GET(init_data_size); |
2556 | +IWL5000_UCODE_GET(boot_size); |
2557 | + |
2558 | struct iwl_hcmd_ops iwl5000_hcmd = { |
2559 | .rxon_assoc = iwl5000_send_rxon_assoc, |
2560 | .commit_rxon = iwl_commit_rxon, |
2561 | @@ -1441,6 +1486,17 @@ struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = { |
2562 | .calc_rssi = iwl5000_calc_rssi, |
2563 | }; |
2564 | |
2565 | +struct iwl_ucode_ops iwl5000_ucode = { |
2566 | + .get_header_size = iwl5000_ucode_get_header_size, |
2567 | + .get_build = iwl5000_ucode_get_build, |
2568 | + .get_inst_size = iwl5000_ucode_get_inst_size, |
2569 | + .get_data_size = iwl5000_ucode_get_data_size, |
2570 | + .get_init_size = iwl5000_ucode_get_init_size, |
2571 | + .get_init_data_size = iwl5000_ucode_get_init_data_size, |
2572 | + .get_boot_size = iwl5000_ucode_get_boot_size, |
2573 | + .get_data = iwl5000_ucode_get_data, |
2574 | +}; |
2575 | + |
2576 | struct iwl_lib_ops iwl5000_lib = { |
2577 | .set_hw_params = iwl5000_hw_set_hw_params, |
2578 | .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl, |
2579 | @@ -1542,12 +1598,14 @@ static struct iwl_lib_ops iwl5150_lib = { |
2580 | }; |
2581 | |
2582 | struct iwl_ops iwl5000_ops = { |
2583 | + .ucode = &iwl5000_ucode, |
2584 | .lib = &iwl5000_lib, |
2585 | .hcmd = &iwl5000_hcmd, |
2586 | .utils = &iwl5000_hcmd_utils, |
2587 | }; |
2588 | |
2589 | static struct iwl_ops iwl5150_ops = { |
2590 | + .ucode = &iwl5000_ucode, |
2591 | .lib = &iwl5150_lib, |
2592 | .hcmd = &iwl5000_hcmd, |
2593 | .utils = &iwl5000_hcmd_utils, |
2594 | diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c |
2595 | index bd438d8..e4a405f 100644 |
2596 | --- a/drivers/net/wireless/iwlwifi/iwl-6000.c |
2597 | +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c |
2598 | @@ -46,8 +46,8 @@ |
2599 | #include "iwl-5000-hw.h" |
2600 | |
2601 | /* Highest firmware API version supported */ |
2602 | -#define IWL6000_UCODE_API_MAX 2 |
2603 | -#define IWL6050_UCODE_API_MAX 2 |
2604 | +#define IWL6000_UCODE_API_MAX 3 |
2605 | +#define IWL6050_UCODE_API_MAX 3 |
2606 | |
2607 | /* Lowest firmware API version supported */ |
2608 | #define IWL6000_UCODE_API_MIN 1 |
2609 | @@ -69,6 +69,7 @@ static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = { |
2610 | }; |
2611 | |
2612 | static struct iwl_ops iwl6000_ops = { |
2613 | + .ucode = &iwl5000_ucode, |
2614 | .lib = &iwl5000_lib, |
2615 | .hcmd = &iwl5000_hcmd, |
2616 | .utils = &iwl6000_hcmd_utils, |
2617 | @@ -81,13 +82,15 @@ struct iwl_cfg iwl6000_2ag_cfg = { |
2618 | .ucode_api_min = IWL6000_UCODE_API_MIN, |
2619 | .sku = IWL_SKU_A|IWL_SKU_G, |
2620 | .ops = &iwl6000_ops, |
2621 | - .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, |
2622 | + .eeprom_size = OTP_LOW_IMAGE_SIZE, |
2623 | .eeprom_ver = EEPROM_5000_EEPROM_VERSION, |
2624 | .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, |
2625 | .mod_params = &iwl50_mod_params, |
2626 | .valid_tx_ant = ANT_BC, |
2627 | .valid_rx_ant = ANT_BC, |
2628 | .need_pll_cfg = false, |
2629 | + .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
2630 | + .shadow_ram_support = true, |
2631 | }; |
2632 | |
2633 | struct iwl_cfg iwl6000_2agn_cfg = { |
2634 | @@ -97,13 +100,15 @@ struct iwl_cfg iwl6000_2agn_cfg = { |
2635 | .ucode_api_min = IWL6000_UCODE_API_MIN, |
2636 | .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, |
2637 | .ops = &iwl6000_ops, |
2638 | - .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, |
2639 | + .eeprom_size = OTP_LOW_IMAGE_SIZE, |
2640 | .eeprom_ver = EEPROM_5000_EEPROM_VERSION, |
2641 | .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, |
2642 | .mod_params = &iwl50_mod_params, |
2643 | .valid_tx_ant = ANT_AB, |
2644 | .valid_rx_ant = ANT_AB, |
2645 | .need_pll_cfg = false, |
2646 | + .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
2647 | + .shadow_ram_support = true, |
2648 | }; |
2649 | |
2650 | struct iwl_cfg iwl6050_2agn_cfg = { |
2651 | @@ -113,13 +118,15 @@ struct iwl_cfg iwl6050_2agn_cfg = { |
2652 | .ucode_api_min = IWL6050_UCODE_API_MIN, |
2653 | .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, |
2654 | .ops = &iwl6000_ops, |
2655 | - .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, |
2656 | + .eeprom_size = OTP_LOW_IMAGE_SIZE, |
2657 | .eeprom_ver = EEPROM_5000_EEPROM_VERSION, |
2658 | .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, |
2659 | .mod_params = &iwl50_mod_params, |
2660 | .valid_tx_ant = ANT_AB, |
2661 | .valid_rx_ant = ANT_AB, |
2662 | .need_pll_cfg = false, |
2663 | + .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
2664 | + .shadow_ram_support = true, |
2665 | }; |
2666 | |
2667 | struct iwl_cfg iwl6000_3agn_cfg = { |
2668 | @@ -129,13 +136,15 @@ struct iwl_cfg iwl6000_3agn_cfg = { |
2669 | .ucode_api_min = IWL6000_UCODE_API_MIN, |
2670 | .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, |
2671 | .ops = &iwl6000_ops, |
2672 | - .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, |
2673 | + .eeprom_size = OTP_LOW_IMAGE_SIZE, |
2674 | .eeprom_ver = EEPROM_5000_EEPROM_VERSION, |
2675 | .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, |
2676 | .mod_params = &iwl50_mod_params, |
2677 | .valid_tx_ant = ANT_ABC, |
2678 | .valid_rx_ant = ANT_ABC, |
2679 | .need_pll_cfg = false, |
2680 | + .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
2681 | + .shadow_ram_support = true, |
2682 | }; |
2683 | |
2684 | struct iwl_cfg iwl6050_3agn_cfg = { |
2685 | @@ -145,13 +154,15 @@ struct iwl_cfg iwl6050_3agn_cfg = { |
2686 | .ucode_api_min = IWL6050_UCODE_API_MIN, |
2687 | .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, |
2688 | .ops = &iwl6000_ops, |
2689 | - .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, |
2690 | + .eeprom_size = OTP_LOW_IMAGE_SIZE, |
2691 | .eeprom_ver = EEPROM_5000_EEPROM_VERSION, |
2692 | .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, |
2693 | .mod_params = &iwl50_mod_params, |
2694 | .valid_tx_ant = ANT_ABC, |
2695 | .valid_rx_ant = ANT_ABC, |
2696 | .need_pll_cfg = false, |
2697 | + .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
2698 | + .shadow_ram_support = true, |
2699 | }; |
2700 | |
2701 | MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX)); |
2702 | diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c |
2703 | index 355f50e..2a577ae 100644 |
2704 | --- a/drivers/net/wireless/iwlwifi/iwl-agn.c |
2705 | +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c |
2706 | @@ -1348,7 +1348,7 @@ static void iwl_nic_start(struct iwl_priv *priv) |
2707 | */ |
2708 | static int iwl_read_ucode(struct iwl_priv *priv) |
2709 | { |
2710 | - struct iwl_ucode *ucode; |
2711 | + struct iwl_ucode_header *ucode; |
2712 | int ret = -EINVAL, index; |
2713 | const struct firmware *ucode_raw; |
2714 | const char *name_pre = priv->cfg->fw_name_pre; |
2715 | @@ -1357,7 +1357,8 @@ static int iwl_read_ucode(struct iwl_priv *priv) |
2716 | char buf[25]; |
2717 | u8 *src; |
2718 | size_t len; |
2719 | - u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size; |
2720 | + u32 api_ver, build; |
2721 | + u32 inst_size, data_size, init_size, init_data_size, boot_size; |
2722 | |
2723 | /* Ask kernel firmware_class module to get the boot firmware off disk. |
2724 | * request_firmware() is synchronous, file is in memory on return. */ |
2725 | @@ -1387,23 +1388,26 @@ static int iwl_read_ucode(struct iwl_priv *priv) |
2726 | if (ret < 0) |
2727 | goto error; |
2728 | |
2729 | - /* Make sure that we got at least our header! */ |
2730 | - if (ucode_raw->size < sizeof(*ucode)) { |
2731 | + /* Make sure that we got at least the v1 header! */ |
2732 | + if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) { |
2733 | IWL_ERR(priv, "File size way too small!\n"); |
2734 | ret = -EINVAL; |
2735 | goto err_release; |
2736 | } |
2737 | |
2738 | /* Data from ucode file: header followed by uCode images */ |
2739 | - ucode = (void *)ucode_raw->data; |
2740 | + ucode = (struct iwl_ucode_header *)ucode_raw->data; |
2741 | |
2742 | priv->ucode_ver = le32_to_cpu(ucode->ver); |
2743 | api_ver = IWL_UCODE_API(priv->ucode_ver); |
2744 | - inst_size = le32_to_cpu(ucode->inst_size); |
2745 | - data_size = le32_to_cpu(ucode->data_size); |
2746 | - init_size = le32_to_cpu(ucode->init_size); |
2747 | - init_data_size = le32_to_cpu(ucode->init_data_size); |
2748 | - boot_size = le32_to_cpu(ucode->boot_size); |
2749 | + build = priv->cfg->ops->ucode->get_build(ucode, api_ver); |
2750 | + inst_size = priv->cfg->ops->ucode->get_inst_size(ucode, api_ver); |
2751 | + data_size = priv->cfg->ops->ucode->get_data_size(ucode, api_ver); |
2752 | + init_size = priv->cfg->ops->ucode->get_init_size(ucode, api_ver); |
2753 | + init_data_size = |
2754 | + priv->cfg->ops->ucode->get_init_data_size(ucode, api_ver); |
2755 | + boot_size = priv->cfg->ops->ucode->get_boot_size(ucode, api_ver); |
2756 | + src = priv->cfg->ops->ucode->get_data(ucode, api_ver); |
2757 | |
2758 | /* api_ver should match the api version forming part of the |
2759 | * firmware filename ... but we don't check for that and only rely |
2760 | @@ -1429,6 +1433,9 @@ static int iwl_read_ucode(struct iwl_priv *priv) |
2761 | IWL_UCODE_API(priv->ucode_ver), |
2762 | IWL_UCODE_SERIAL(priv->ucode_ver)); |
2763 | |
2764 | + if (build) |
2765 | + IWL_DEBUG_INFO(priv, "Build %u\n", build); |
2766 | + |
2767 | IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", |
2768 | priv->ucode_ver); |
2769 | IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n", |
2770 | @@ -1443,12 +1450,14 @@ static int iwl_read_ucode(struct iwl_priv *priv) |
2771 | boot_size); |
2772 | |
2773 | /* Verify size of file vs. image size info in file's header */ |
2774 | - if (ucode_raw->size < sizeof(*ucode) + |
2775 | + if (ucode_raw->size != |
2776 | + priv->cfg->ops->ucode->get_header_size(api_ver) + |
2777 | inst_size + data_size + init_size + |
2778 | init_data_size + boot_size) { |
2779 | |
2780 | - IWL_DEBUG_INFO(priv, "uCode file size %d too small\n", |
2781 | - (int)ucode_raw->size); |
2782 | + IWL_DEBUG_INFO(priv, |
2783 | + "uCode file size %d does not match expected size\n", |
2784 | + (int)ucode_raw->size); |
2785 | ret = -EINVAL; |
2786 | goto err_release; |
2787 | } |
2788 | @@ -1528,42 +1537,42 @@ static int iwl_read_ucode(struct iwl_priv *priv) |
2789 | /* Copy images into buffers for card's bus-master reads ... */ |
2790 | |
2791 | /* Runtime instructions (first block of data in file) */ |
2792 | - src = &ucode->data[0]; |
2793 | - len = priv->ucode_code.len; |
2794 | + len = inst_size; |
2795 | IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", len); |
2796 | memcpy(priv->ucode_code.v_addr, src, len); |
2797 | + src += len; |
2798 | + |
2799 | IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", |
2800 | priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); |
2801 | |
2802 | /* Runtime data (2nd block) |
2803 | * NOTE: Copy into backup buffer will be done in iwl_up() */ |
2804 | - src = &ucode->data[inst_size]; |
2805 | - len = priv->ucode_data.len; |
2806 | + len = data_size; |
2807 | IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", len); |
2808 | memcpy(priv->ucode_data.v_addr, src, len); |
2809 | memcpy(priv->ucode_data_backup.v_addr, src, len); |
2810 | + src += len; |
2811 | |
2812 | /* Initialization instructions (3rd block) */ |
2813 | if (init_size) { |
2814 | - src = &ucode->data[inst_size + data_size]; |
2815 | - len = priv->ucode_init.len; |
2816 | + len = init_size; |
2817 | IWL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n", |
2818 | len); |
2819 | memcpy(priv->ucode_init.v_addr, src, len); |
2820 | + src += len; |
2821 | } |
2822 | |
2823 | /* Initialization data (4th block) */ |
2824 | if (init_data_size) { |
2825 | - src = &ucode->data[inst_size + data_size + init_size]; |
2826 | - len = priv->ucode_init_data.len; |
2827 | + len = init_data_size; |
2828 | IWL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n", |
2829 | len); |
2830 | memcpy(priv->ucode_init_data.v_addr, src, len); |
2831 | + src += len; |
2832 | } |
2833 | |
2834 | /* Bootstrap instructions (5th block) */ |
2835 | - src = &ucode->data[inst_size + data_size + init_size + init_data_size]; |
2836 | - len = priv->ucode_boot.len; |
2837 | + len = boot_size; |
2838 | IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", len); |
2839 | memcpy(priv->ucode_boot.v_addr, src, len); |
2840 | |
2841 | @@ -2206,7 +2215,7 @@ static void iwl_mac_stop(struct ieee80211_hw *hw) |
2842 | |
2843 | priv->is_open = 0; |
2844 | |
2845 | - if (iwl_is_ready_rf(priv)) { |
2846 | + if (iwl_is_ready_rf(priv) || test_bit(STATUS_SCAN_HW, &priv->status)) { |
2847 | /* stop mac, cancel any scan request and clear |
2848 | * RXON_FILTER_ASSOC_MSK BIT |
2849 | */ |
2850 | diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h |
2851 | index dabf663..1e51891 100644 |
2852 | --- a/drivers/net/wireless/iwlwifi/iwl-core.h |
2853 | +++ b/drivers/net/wireless/iwlwifi/iwl-core.h |
2854 | @@ -116,6 +116,17 @@ struct iwl_temp_ops { |
2855 | void (*set_ct_kill)(struct iwl_priv *priv); |
2856 | }; |
2857 | |
2858 | +struct iwl_ucode_ops { |
2859 | + u32 (*get_header_size)(u32); |
2860 | + u32 (*get_build)(const struct iwl_ucode_header *, u32); |
2861 | + u32 (*get_inst_size)(const struct iwl_ucode_header *, u32); |
2862 | + u32 (*get_data_size)(const struct iwl_ucode_header *, u32); |
2863 | + u32 (*get_init_size)(const struct iwl_ucode_header *, u32); |
2864 | + u32 (*get_init_data_size)(const struct iwl_ucode_header *, u32); |
2865 | + u32 (*get_boot_size)(const struct iwl_ucode_header *, u32); |
2866 | + u8 * (*get_data)(const struct iwl_ucode_header *, u32); |
2867 | +}; |
2868 | + |
2869 | struct iwl_lib_ops { |
2870 | /* set hw dependent parameters */ |
2871 | int (*set_hw_params)(struct iwl_priv *priv); |
2872 | @@ -171,6 +182,7 @@ struct iwl_lib_ops { |
2873 | }; |
2874 | |
2875 | struct iwl_ops { |
2876 | + const struct iwl_ucode_ops *ucode; |
2877 | const struct iwl_lib_ops *lib; |
2878 | const struct iwl_hcmd_ops *hcmd; |
2879 | const struct iwl_hcmd_utils_ops *utils; |
2880 | @@ -195,6 +207,8 @@ struct iwl_mod_params { |
2881 | * filename is constructed as fw_name_pre<api>.ucode. |
2882 | * @ucode_api_max: Highest version of uCode API supported by driver. |
2883 | * @ucode_api_min: Lowest version of uCode API supported by driver. |
2884 | + * @max_ll_items: max number of OTP blocks |
2885 | + * @shadow_ram_support: shadow support for OTP memory |
2886 | * |
2887 | * We enable the driver to be backward compatible wrt API version. The |
2888 | * driver specifies which APIs it supports (with @ucode_api_max being the |
2889 | @@ -231,6 +245,8 @@ struct iwl_cfg { |
2890 | u8 valid_rx_ant; |
2891 | bool need_pll_cfg; |
2892 | bool use_isr_legacy; |
2893 | + const u16 max_ll_items; |
2894 | + const bool shadow_ram_support; |
2895 | }; |
2896 | |
2897 | /*************************** |
2898 | diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h |
2899 | index 650e20a..e8c8607 100644 |
2900 | --- a/drivers/net/wireless/iwlwifi/iwl-dev.h |
2901 | +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h |
2902 | @@ -66,6 +66,7 @@ extern struct iwl_cfg iwl1000_bgn_cfg; |
2903 | /* shared structures from iwl-5000.c */ |
2904 | extern struct iwl_mod_params iwl50_mod_params; |
2905 | extern struct iwl_ops iwl5000_ops; |
2906 | +extern struct iwl_ucode_ops iwl5000_ucode; |
2907 | extern struct iwl_lib_ops iwl5000_lib; |
2908 | extern struct iwl_hcmd_ops iwl5000_hcmd; |
2909 | extern struct iwl_hcmd_utils_ops iwl5000_hcmd_utils; |
2910 | @@ -525,15 +526,29 @@ struct fw_desc { |
2911 | }; |
2912 | |
2913 | /* uCode file layout */ |
2914 | -struct iwl_ucode { |
2915 | - __le32 ver; /* major/minor/API/serial */ |
2916 | - __le32 inst_size; /* bytes of runtime instructions */ |
2917 | - __le32 data_size; /* bytes of runtime data */ |
2918 | - __le32 init_size; /* bytes of initialization instructions */ |
2919 | - __le32 init_data_size; /* bytes of initialization data */ |
2920 | - __le32 boot_size; /* bytes of bootstrap instructions */ |
2921 | - u8 data[0]; /* data in same order as "size" elements */ |
2922 | +struct iwl_ucode_header { |
2923 | + __le32 ver; /* major/minor/API/serial */ |
2924 | + union { |
2925 | + struct { |
2926 | + __le32 inst_size; /* bytes of runtime code */ |
2927 | + __le32 data_size; /* bytes of runtime data */ |
2928 | + __le32 init_size; /* bytes of init code */ |
2929 | + __le32 init_data_size; /* bytes of init data */ |
2930 | + __le32 boot_size; /* bytes of bootstrap code */ |
2931 | + u8 data[0]; /* in same order as sizes */ |
2932 | + } v1; |
2933 | + struct { |
2934 | + __le32 build; /* build number */ |
2935 | + __le32 inst_size; /* bytes of runtime code */ |
2936 | + __le32 data_size; /* bytes of runtime data */ |
2937 | + __le32 init_size; /* bytes of init code */ |
2938 | + __le32 init_data_size; /* bytes of init data */ |
2939 | + __le32 boot_size; /* bytes of bootstrap code */ |
2940 | + u8 data[0]; /* in same order as sizes */ |
2941 | + } v2; |
2942 | + } u; |
2943 | }; |
2944 | +#define UCODE_HEADER_SIZE(ver) ((ver) == 1 ? 24 : 28) |
2945 | |
2946 | struct iwl4965_ibss_seq { |
2947 | u8 mac[ETH_ALEN]; |
2948 | @@ -820,6 +835,18 @@ enum iwl_nvm_type { |
2949 | NVM_DEVICE_TYPE_OTP, |
2950 | }; |
2951 | |
2952 | +/* |
2953 | + * Two types of OTP memory access modes |
2954 | + * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode, |
2955 | + * based on physical memory addressing |
2956 | + * IWL_OTP_ACCESS_RELATIVE - relative address mode, |
2957 | + * based on logical memory addressing |
2958 | + */ |
2959 | +enum iwl_access_mode { |
2960 | + IWL_OTP_ACCESS_ABSOLUTE, |
2961 | + IWL_OTP_ACCESS_RELATIVE, |
2962 | +}; |
2963 | + |
2964 | /* interrupt statistics */ |
2965 | struct isr_statistics { |
2966 | u32 hw; |
2967 | diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c |
2968 | index 7d7554a..e8c0e82 100644 |
2969 | --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c |
2970 | +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c |
2971 | @@ -152,6 +152,19 @@ int iwlcore_eeprom_verify_signature(struct iwl_priv *priv) |
2972 | } |
2973 | EXPORT_SYMBOL(iwlcore_eeprom_verify_signature); |
2974 | |
2975 | +static void iwl_set_otp_access(struct iwl_priv *priv, enum iwl_access_mode mode) |
2976 | +{ |
2977 | + u32 otpgp; |
2978 | + |
2979 | + otpgp = iwl_read32(priv, CSR_OTP_GP_REG); |
2980 | + if (mode == IWL_OTP_ACCESS_ABSOLUTE) |
2981 | + iwl_clear_bit(priv, CSR_OTP_GP_REG, |
2982 | + CSR_OTP_GP_REG_OTP_ACCESS_MODE); |
2983 | + else |
2984 | + iwl_set_bit(priv, CSR_OTP_GP_REG, |
2985 | + CSR_OTP_GP_REG_OTP_ACCESS_MODE); |
2986 | +} |
2987 | + |
2988 | static int iwlcore_get_nvm_type(struct iwl_priv *priv) |
2989 | { |
2990 | u32 otpgp; |
2991 | @@ -249,6 +262,124 @@ static int iwl_init_otp_access(struct iwl_priv *priv) |
2992 | return ret; |
2993 | } |
2994 | |
2995 | +static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, u16 *eeprom_data) |
2996 | +{ |
2997 | + int ret = 0; |
2998 | + u32 r; |
2999 | + u32 otpgp; |
3000 | + |
3001 | + _iwl_write32(priv, CSR_EEPROM_REG, |
3002 | + CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); |
3003 | + ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG, |
3004 | + CSR_EEPROM_REG_READ_VALID_MSK, |
3005 | + IWL_EEPROM_ACCESS_TIMEOUT); |
3006 | + if (ret < 0) { |
3007 | + IWL_ERR(priv, "Time out reading OTP[%d]\n", addr); |
3008 | + return ret; |
3009 | + } |
3010 | + r = _iwl_read_direct32(priv, CSR_EEPROM_REG); |
3011 | + /* check for ECC errors: */ |
3012 | + otpgp = iwl_read32(priv, CSR_OTP_GP_REG); |
3013 | + if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { |
3014 | + /* stop in this case */ |
3015 | + /* set the uncorrectable OTP ECC bit for acknowledgement */ |
3016 | + iwl_set_bit(priv, CSR_OTP_GP_REG, |
3017 | + CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); |
3018 | + IWL_ERR(priv, "Uncorrectable OTP ECC error, abort OTP read\n"); |
3019 | + return -EINVAL; |
3020 | + } |
3021 | + if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { |
3022 | + /* continue in this case */ |
3023 | + /* set the correctable OTP ECC bit for acknowledgement */ |
3024 | + iwl_set_bit(priv, CSR_OTP_GP_REG, |
3025 | + CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); |
3026 | + IWL_ERR(priv, "Correctable OTP ECC error, continue read\n"); |
3027 | + } |
3028 | + *eeprom_data = le16_to_cpu((__force __le16)(r >> 16)); |
3029 | + return 0; |
3030 | +} |
3031 | + |
3032 | +/* |
3033 | + * iwl_is_otp_empty: check for empty OTP |
3034 | + */ |
3035 | +static bool iwl_is_otp_empty(struct iwl_priv *priv) |
3036 | +{ |
3037 | + u16 next_link_addr = 0, link_value; |
3038 | + bool is_empty = false; |
3039 | + |
3040 | + /* locate the beginning of OTP link list */ |
3041 | + if (!iwl_read_otp_word(priv, next_link_addr, &link_value)) { |
3042 | + if (!link_value) { |
3043 | + IWL_ERR(priv, "OTP is empty\n"); |
3044 | + is_empty = true; |
3045 | + } |
3046 | + } else { |
3047 | + IWL_ERR(priv, "Unable to read first block of OTP list.\n"); |
3048 | + is_empty = true; |
3049 | + } |
3050 | + |
3051 | + return is_empty; |
3052 | +} |
3053 | + |
3054 | + |
3055 | +/* |
3056 | + * iwl_find_otp_image: find EEPROM image in OTP |
3057 | + * finding the OTP block that contains the EEPROM image. |
3058 | + * the last valid block on the link list (the block _before_ the last block) |
3059 | + * is the block we should read and used to configure the device. |
3060 | + * If all the available OTP blocks are full, the last block will be the block |
3061 | + * we should read and used to configure the device. |
3062 | + * only perform this operation if shadow RAM is disabled |
3063 | + */ |
3064 | +static int iwl_find_otp_image(struct iwl_priv *priv, |
3065 | + u16 *validblockaddr) |
3066 | +{ |
3067 | + u16 next_link_addr = 0, link_value = 0, valid_addr; |
3068 | + int ret = 0; |
3069 | + int usedblocks = 0; |
3070 | + |
3071 | + /* set addressing mode to absolute to traverse the link list */ |
3072 | + iwl_set_otp_access(priv, IWL_OTP_ACCESS_ABSOLUTE); |
3073 | + |
3074 | + /* checking for empty OTP or error */ |
3075 | + if (iwl_is_otp_empty(priv)) |
3076 | + return -EINVAL; |
3077 | + |
3078 | + /* |
3079 | + * start traverse link list |
3080 | + * until reach the max number of OTP blocks |
3081 | + * different devices have different number of OTP blocks |
3082 | + */ |
3083 | + do { |
3084 | + /* save current valid block address |
3085 | + * check for more block on the link list |
3086 | + */ |
3087 | + valid_addr = next_link_addr; |
3088 | + next_link_addr = link_value; |
3089 | + IWL_DEBUG_INFO(priv, "OTP blocks %d addr 0x%x\n", |
3090 | + usedblocks, next_link_addr); |
3091 | + if (iwl_read_otp_word(priv, next_link_addr, &link_value)) |
3092 | + return -EINVAL; |
3093 | + if (!link_value) { |
3094 | + /* |
3095 | + * reach the end of link list, |
3096 | + * set address point to the starting address |
3097 | + * of the image |
3098 | + */ |
3099 | + goto done; |
3100 | + } |
3101 | + /* more in the link list, continue */ |
3102 | + usedblocks++; |
3103 | + } while (usedblocks < priv->cfg->max_ll_items); |
3104 | + /* OTP full, use last block */ |
3105 | + IWL_DEBUG_INFO(priv, "OTP is full, use last block\n"); |
3106 | +done: |
3107 | + *validblockaddr = valid_addr; |
3108 | + /* skip first 2 bytes (link list pointer) */ |
3109 | + *validblockaddr += 2; |
3110 | + return ret; |
3111 | +} |
3112 | + |
3113 | /** |
3114 | * iwl_eeprom_init - read EEPROM contents |
3115 | * |
3116 | @@ -263,14 +394,13 @@ int iwl_eeprom_init(struct iwl_priv *priv) |
3117 | int sz; |
3118 | int ret; |
3119 | u16 addr; |
3120 | - u32 otpgp; |
3121 | + u16 validblockaddr = 0; |
3122 | + u16 cache_addr = 0; |
3123 | |
3124 | priv->nvm_device_type = iwlcore_get_nvm_type(priv); |
3125 | |
3126 | /* allocate eeprom */ |
3127 | - if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
3128 | - priv->cfg->eeprom_size = |
3129 | - OTP_BLOCK_SIZE * OTP_LOWER_BLOCKS_TOTAL; |
3130 | + IWL_DEBUG_INFO(priv, "NVM size = %d\n", priv->cfg->eeprom_size); |
3131 | sz = priv->cfg->eeprom_size; |
3132 | priv->eeprom = kzalloc(sz, GFP_KERNEL); |
3133 | if (!priv->eeprom) { |
3134 | @@ -298,46 +428,31 @@ int iwl_eeprom_init(struct iwl_priv *priv) |
3135 | if (ret) { |
3136 | IWL_ERR(priv, "Failed to initialize OTP access.\n"); |
3137 | ret = -ENOENT; |
3138 | - goto err; |
3139 | + goto done; |
3140 | } |
3141 | _iwl_write32(priv, CSR_EEPROM_GP, |
3142 | iwl_read32(priv, CSR_EEPROM_GP) & |
3143 | ~CSR_EEPROM_GP_IF_OWNER_MSK); |
3144 | - /* clear */ |
3145 | - _iwl_write32(priv, CSR_OTP_GP_REG, |
3146 | - iwl_read32(priv, CSR_OTP_GP_REG) | |
3147 | + |
3148 | + iwl_set_bit(priv, CSR_OTP_GP_REG, |
3149 | CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK | |
3150 | CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); |
3151 | - |
3152 | - for (addr = 0; addr < sz; addr += sizeof(u16)) { |
3153 | - u32 r; |
3154 | - |
3155 | - _iwl_write32(priv, CSR_EEPROM_REG, |
3156 | - CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); |
3157 | - |
3158 | - ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG, |
3159 | - CSR_EEPROM_REG_READ_VALID_MSK, |
3160 | - IWL_EEPROM_ACCESS_TIMEOUT); |
3161 | - if (ret < 0) { |
3162 | - IWL_ERR(priv, "Time out reading OTP[%d]\n", addr); |
3163 | + /* traversing the linked list if no shadow ram supported */ |
3164 | + if (!priv->cfg->shadow_ram_support) { |
3165 | + if (iwl_find_otp_image(priv, &validblockaddr)) { |
3166 | + ret = -ENOENT; |
3167 | goto done; |
3168 | } |
3169 | - r = _iwl_read_direct32(priv, CSR_EEPROM_REG); |
3170 | - /* check for ECC errors: */ |
3171 | - otpgp = iwl_read32(priv, CSR_OTP_GP_REG); |
3172 | - if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { |
3173 | - /* stop in this case */ |
3174 | - IWL_ERR(priv, "Uncorrectable OTP ECC error, Abort OTP read\n"); |
3175 | + } |
3176 | + for (addr = validblockaddr; addr < validblockaddr + sz; |
3177 | + addr += sizeof(u16)) { |
3178 | + u16 eeprom_data; |
3179 | + |
3180 | + ret = iwl_read_otp_word(priv, addr, &eeprom_data); |
3181 | + if (ret) |
3182 | goto done; |
3183 | - } |
3184 | - if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { |
3185 | - /* continue in this case */ |
3186 | - _iwl_write32(priv, CSR_OTP_GP_REG, |
3187 | - iwl_read32(priv, CSR_OTP_GP_REG) | |
3188 | - CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); |
3189 | - IWL_ERR(priv, "Correctable OTP ECC error, continue read\n"); |
3190 | - } |
3191 | - e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16)); |
3192 | + e[cache_addr / 2] = eeprom_data; |
3193 | + cache_addr += sizeof(u16); |
3194 | } |
3195 | } else { |
3196 | /* eeprom is an array of 16bit values */ |
3197 | diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h |
3198 | index 195b4ef..7899885 100644 |
3199 | --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h |
3200 | +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h |
3201 | @@ -180,8 +180,14 @@ struct iwl_eeprom_channel { |
3202 | #define EEPROM_5050_EEPROM_VERSION (0x21E) |
3203 | |
3204 | /* OTP */ |
3205 | -#define OTP_LOWER_BLOCKS_TOTAL (3) |
3206 | -#define OTP_BLOCK_SIZE (0x400) |
3207 | +/* lower blocks contain EEPROM image and calibration data */ |
3208 | +#define OTP_LOW_IMAGE_SIZE (2 * 512 * sizeof(u16)) /* 2 KB */ |
3209 | +/* high blocks contain PAPD data */ |
3210 | +#define OTP_HIGH_IMAGE_SIZE_6x00 (6 * 512 * sizeof(u16)) /* 6 KB */ |
3211 | +#define OTP_HIGH_IMAGE_SIZE_1000 (0x200 * sizeof(u16)) /* 1024 bytes */ |
3212 | +#define OTP_MAX_LL_ITEMS_1000 (3) /* OTP blocks for 1000 */ |
3213 | +#define OTP_MAX_LL_ITEMS_6x00 (4) /* OTP blocks for 6x00 */ |
3214 | +#define OTP_MAX_LL_ITEMS_6x50 (7) /* OTP blocks for 6x50 */ |
3215 | |
3216 | /* 2.4 GHz */ |
3217 | extern const u8 iwl_eeprom_band_1[14]; |
3218 | diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h |
3219 | index 3b9cac3..d393e8f 100644 |
3220 | --- a/drivers/net/wireless/iwlwifi/iwl-prph.h |
3221 | +++ b/drivers/net/wireless/iwlwifi/iwl-prph.h |
3222 | @@ -80,6 +80,8 @@ |
3223 | #define APMG_RFKILL_REG (APMG_BASE + 0x0014) |
3224 | #define APMG_RTC_INT_STT_REG (APMG_BASE + 0x001c) |
3225 | #define APMG_RTC_INT_MSK_REG (APMG_BASE + 0x0020) |
3226 | +#define APMG_DIGITAL_SVR_REG (APMG_BASE + 0x0058) |
3227 | +#define APMG_ANALOG_SVR_REG (APMG_BASE + 0x006C) |
3228 | |
3229 | #define APMG_CLK_VAL_DMA_CLK_RQT (0x00000200) |
3230 | #define APMG_CLK_VAL_BSM_CLK_RQT (0x00000800) |
3231 | @@ -91,7 +93,8 @@ |
3232 | #define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000) |
3233 | #define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ |
3234 | #define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000) |
3235 | - |
3236 | +#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ |
3237 | +#define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060) |
3238 | |
3239 | #define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) |
3240 | |
3241 | diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c |
3242 | index e26875d..474fd49 100644 |
3243 | --- a/drivers/net/wireless/iwlwifi/iwl-scan.c |
3244 | +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c |
3245 | @@ -799,7 +799,8 @@ void iwl_bg_abort_scan(struct work_struct *work) |
3246 | { |
3247 | struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); |
3248 | |
3249 | - if (!iwl_is_ready(priv)) |
3250 | + if (!test_bit(STATUS_READY, &priv->status) || |
3251 | + !test_bit(STATUS_GEO_CONFIGURED, &priv->status)) |
3252 | return; |
3253 | |
3254 | mutex_lock(&priv->mutex); |
3255 | diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c |
3256 | index 5238433..054d6c7 100644 |
3257 | --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c |
3258 | +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c |
3259 | @@ -2111,7 +2111,7 @@ static void iwl3945_nic_start(struct iwl_priv *priv) |
3260 | */ |
3261 | static int iwl3945_read_ucode(struct iwl_priv *priv) |
3262 | { |
3263 | - struct iwl_ucode *ucode; |
3264 | + const struct iwl_ucode_header *ucode; |
3265 | int ret = -EINVAL, index; |
3266 | const struct firmware *ucode_raw; |
3267 | /* firmware file name contains uCode/driver compatibility version */ |
3268 | @@ -2152,22 +2152,24 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) |
3269 | goto error; |
3270 | |
3271 | /* Make sure that we got at least our header! */ |
3272 | - if (ucode_raw->size < sizeof(*ucode)) { |
3273 | + if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) { |
3274 | IWL_ERR(priv, "File size way too small!\n"); |
3275 | ret = -EINVAL; |
3276 | goto err_release; |
3277 | } |
3278 | |
3279 | /* Data from ucode file: header followed by uCode images */ |
3280 | - ucode = (void *)ucode_raw->data; |
3281 | + ucode = (struct iwl_ucode_header *)ucode_raw->data; |
3282 | |
3283 | priv->ucode_ver = le32_to_cpu(ucode->ver); |
3284 | api_ver = IWL_UCODE_API(priv->ucode_ver); |
3285 | - inst_size = le32_to_cpu(ucode->inst_size); |
3286 | - data_size = le32_to_cpu(ucode->data_size); |
3287 | - init_size = le32_to_cpu(ucode->init_size); |
3288 | - init_data_size = le32_to_cpu(ucode->init_data_size); |
3289 | - boot_size = le32_to_cpu(ucode->boot_size); |
3290 | + inst_size = priv->cfg->ops->ucode->get_inst_size(ucode, api_ver); |
3291 | + data_size = priv->cfg->ops->ucode->get_data_size(ucode, api_ver); |
3292 | + init_size = priv->cfg->ops->ucode->get_init_size(ucode, api_ver); |
3293 | + init_data_size = |
3294 | + priv->cfg->ops->ucode->get_init_data_size(ucode, api_ver); |
3295 | + boot_size = priv->cfg->ops->ucode->get_boot_size(ucode, api_ver); |
3296 | + src = priv->cfg->ops->ucode->get_data(ucode, api_ver); |
3297 | |
3298 | /* api_ver should match the api version forming part of the |
3299 | * firmware filename ... but we don't check for that and only rely |
3300 | @@ -2208,12 +2210,13 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) |
3301 | |
3302 | |
3303 | /* Verify size of file vs. image size info in file's header */ |
3304 | - if (ucode_raw->size < sizeof(*ucode) + |
3305 | + if (ucode_raw->size != priv->cfg->ops->ucode->get_header_size(api_ver) + |
3306 | inst_size + data_size + init_size + |
3307 | init_data_size + boot_size) { |
3308 | |
3309 | - IWL_DEBUG_INFO(priv, "uCode file size %zd too small\n", |
3310 | - ucode_raw->size); |
3311 | + IWL_DEBUG_INFO(priv, |
3312 | + "uCode file size %zd does not match expected size\n", |
3313 | + ucode_raw->size); |
3314 | ret = -EINVAL; |
3315 | goto err_release; |
3316 | } |
3317 | @@ -2296,44 +2299,44 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) |
3318 | /* Copy images into buffers for card's bus-master reads ... */ |
3319 | |
3320 | /* Runtime instructions (first block of data in file) */ |
3321 | - src = &ucode->data[0]; |
3322 | - len = priv->ucode_code.len; |
3323 | + len = inst_size; |
3324 | IWL_DEBUG_INFO(priv, |
3325 | "Copying (but not loading) uCode instr len %zd\n", len); |
3326 | memcpy(priv->ucode_code.v_addr, src, len); |
3327 | + src += len; |
3328 | + |
3329 | IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", |
3330 | priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); |
3331 | |
3332 | /* Runtime data (2nd block) |
3333 | * NOTE: Copy into backup buffer will be done in iwl3945_up() */ |
3334 | - src = &ucode->data[inst_size]; |
3335 | - len = priv->ucode_data.len; |
3336 | + len = data_size; |
3337 | IWL_DEBUG_INFO(priv, |
3338 | "Copying (but not loading) uCode data len %zd\n", len); |
3339 | memcpy(priv->ucode_data.v_addr, src, len); |
3340 | memcpy(priv->ucode_data_backup.v_addr, src, len); |
3341 | + src += len; |
3342 | |
3343 | /* Initialization instructions (3rd block) */ |
3344 | if (init_size) { |
3345 | - src = &ucode->data[inst_size + data_size]; |
3346 | - len = priv->ucode_init.len; |
3347 | + len = init_size; |
3348 | IWL_DEBUG_INFO(priv, |
3349 | "Copying (but not loading) init instr len %zd\n", len); |
3350 | memcpy(priv->ucode_init.v_addr, src, len); |
3351 | + src += len; |
3352 | } |
3353 | |
3354 | /* Initialization data (4th block) */ |
3355 | if (init_data_size) { |
3356 | - src = &ucode->data[inst_size + data_size + init_size]; |
3357 | - len = priv->ucode_init_data.len; |
3358 | + len = init_data_size; |
3359 | IWL_DEBUG_INFO(priv, |
3360 | "Copying (but not loading) init data len %zd\n", len); |
3361 | memcpy(priv->ucode_init_data.v_addr, src, len); |
3362 | + src += len; |
3363 | } |
3364 | |
3365 | /* Bootstrap instructions (5th block) */ |
3366 | - src = &ucode->data[inst_size + data_size + init_size + init_data_size]; |
3367 | - len = priv->ucode_boot.len; |
3368 | + len = boot_size; |
3369 | IWL_DEBUG_INFO(priv, |
3370 | "Copying (but not loading) boot instr len %zd\n", len); |
3371 | memcpy(priv->ucode_boot.v_addr, src, len); |
3372 | diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c |
3373 | index 0e877a1..6e1b889 100644 |
3374 | --- a/drivers/net/wireless/p54/p54usb.c |
3375 | +++ b/drivers/net/wireless/p54/p54usb.c |
3376 | @@ -66,6 +66,7 @@ static struct usb_device_id p54u_table[] __devinitdata = { |
3377 | {USB_DEVICE(0x0bf8, 0x1009)}, /* FUJITSU E-5400 USB D1700*/ |
3378 | {USB_DEVICE(0x0cde, 0x0006)}, /* Medion MD40900 */ |
3379 | {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */ |
3380 | + {USB_DEVICE(0x0cde, 0x0015)}, /* Zcomax XG-705A */ |
3381 | {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */ |
3382 | {USB_DEVICE(0x124a, 0x4025)}, /* IOGear GWU513 (GW3887IK chip) */ |
3383 | {USB_DEVICE(0x1260, 0xee22)}, /* SMC 2862W-G version 2 */ |
3384 | diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c |
3385 | index 9e1140f..e1dcced 100644 |
3386 | --- a/drivers/pcmcia/at91_cf.c |
3387 | +++ b/drivers/pcmcia/at91_cf.c |
3388 | @@ -363,7 +363,7 @@ static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg) |
3389 | struct at91_cf_socket *cf = platform_get_drvdata(pdev); |
3390 | struct at91_cf_data *board = cf->board; |
3391 | |
3392 | - pcmcia_socket_dev_suspend(&pdev->dev, mesg); |
3393 | + pcmcia_socket_dev_suspend(&pdev->dev); |
3394 | if (device_may_wakeup(&pdev->dev)) { |
3395 | enable_irq_wake(board->det_pin); |
3396 | if (board->irq_pin) |
3397 | diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c |
3398 | index 9001334..0208870 100644 |
3399 | --- a/drivers/pcmcia/au1000_generic.c |
3400 | +++ b/drivers/pcmcia/au1000_generic.c |
3401 | @@ -515,7 +515,7 @@ static int au1x00_drv_pcmcia_probe(struct platform_device *dev) |
3402 | static int au1x00_drv_pcmcia_suspend(struct platform_device *dev, |
3403 | pm_message_t state) |
3404 | { |
3405 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3406 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3407 | } |
3408 | |
3409 | static int au1x00_drv_pcmcia_resume(struct platform_device *dev) |
3410 | diff --git a/drivers/pcmcia/bfin_cf_pcmcia.c b/drivers/pcmcia/bfin_cf_pcmcia.c |
3411 | index b59d411..300b368 100644 |
3412 | --- a/drivers/pcmcia/bfin_cf_pcmcia.c |
3413 | +++ b/drivers/pcmcia/bfin_cf_pcmcia.c |
3414 | @@ -302,7 +302,7 @@ static int __devexit bfin_cf_remove(struct platform_device *pdev) |
3415 | |
3416 | static int bfin_cf_suspend(struct platform_device *pdev, pm_message_t mesg) |
3417 | { |
3418 | - return pcmcia_socket_dev_suspend(&pdev->dev, mesg); |
3419 | + return pcmcia_socket_dev_suspend(&pdev->dev); |
3420 | } |
3421 | |
3422 | static int bfin_cf_resume(struct platform_device *pdev) |
3423 | diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c |
3424 | index 0660ad1..934d4be 100644 |
3425 | --- a/drivers/pcmcia/cs.c |
3426 | +++ b/drivers/pcmcia/cs.c |
3427 | @@ -101,7 +101,7 @@ EXPORT_SYMBOL(pcmcia_socket_list_rwsem); |
3428 | static int socket_resume(struct pcmcia_socket *skt); |
3429 | static int socket_suspend(struct pcmcia_socket *skt); |
3430 | |
3431 | -int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state) |
3432 | +int pcmcia_socket_dev_suspend(struct device *dev) |
3433 | { |
3434 | struct pcmcia_socket *socket; |
3435 | |
3436 | diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c |
3437 | index 46561fa..a04f21c 100644 |
3438 | --- a/drivers/pcmcia/i82092.c |
3439 | +++ b/drivers/pcmcia/i82092.c |
3440 | @@ -42,7 +42,7 @@ MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids); |
3441 | #ifdef CONFIG_PM |
3442 | static int i82092aa_socket_suspend (struct pci_dev *dev, pm_message_t state) |
3443 | { |
3444 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3445 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3446 | } |
3447 | |
3448 | static int i82092aa_socket_resume (struct pci_dev *dev) |
3449 | diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c |
3450 | index 40d4953..b906abe 100644 |
3451 | --- a/drivers/pcmcia/i82365.c |
3452 | +++ b/drivers/pcmcia/i82365.c |
3453 | @@ -1241,7 +1241,7 @@ static int pcic_init(struct pcmcia_socket *s) |
3454 | static int i82365_drv_pcmcia_suspend(struct platform_device *dev, |
3455 | pm_message_t state) |
3456 | { |
3457 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3458 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3459 | } |
3460 | |
3461 | static int i82365_drv_pcmcia_resume(struct platform_device *dev) |
3462 | diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c |
3463 | index 62b4ecc..d1d89c4 100644 |
3464 | --- a/drivers/pcmcia/m32r_cfc.c |
3465 | +++ b/drivers/pcmcia/m32r_cfc.c |
3466 | @@ -699,7 +699,7 @@ static struct pccard_operations pcc_operations = { |
3467 | static int cfc_drv_pcmcia_suspend(struct platform_device *dev, |
3468 | pm_message_t state) |
3469 | { |
3470 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3471 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3472 | } |
3473 | |
3474 | static int cfc_drv_pcmcia_resume(struct platform_device *dev) |
3475 | diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c |
3476 | index 12034b4..a065583 100644 |
3477 | --- a/drivers/pcmcia/m32r_pcc.c |
3478 | +++ b/drivers/pcmcia/m32r_pcc.c |
3479 | @@ -675,7 +675,7 @@ static struct pccard_operations pcc_operations = { |
3480 | static int pcc_drv_pcmcia_suspend(struct platform_device *dev, |
3481 | pm_message_t state) |
3482 | { |
3483 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3484 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3485 | } |
3486 | |
3487 | static int pcc_drv_pcmcia_resume(struct platform_device *dev) |
3488 | diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c |
3489 | index d1ad096..c69f2c4 100644 |
3490 | --- a/drivers/pcmcia/m8xx_pcmcia.c |
3491 | +++ b/drivers/pcmcia/m8xx_pcmcia.c |
3492 | @@ -1296,7 +1296,7 @@ static int m8xx_remove(struct of_device *ofdev) |
3493 | #ifdef CONFIG_PM |
3494 | static int m8xx_suspend(struct platform_device *pdev, pm_message_t state) |
3495 | { |
3496 | - return pcmcia_socket_dev_suspend(&pdev->dev, state); |
3497 | + return pcmcia_socket_dev_suspend(&pdev->dev); |
3498 | } |
3499 | |
3500 | static int m8xx_resume(struct platform_device *pdev) |
3501 | diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c |
3502 | index f373639..68570bc 100644 |
3503 | --- a/drivers/pcmcia/omap_cf.c |
3504 | +++ b/drivers/pcmcia/omap_cf.c |
3505 | @@ -334,7 +334,7 @@ static int __exit omap_cf_remove(struct platform_device *pdev) |
3506 | |
3507 | static int omap_cf_suspend(struct platform_device *pdev, pm_message_t mesg) |
3508 | { |
3509 | - return pcmcia_socket_dev_suspend(&pdev->dev, mesg); |
3510 | + return pcmcia_socket_dev_suspend(&pdev->dev); |
3511 | } |
3512 | |
3513 | static int omap_cf_resume(struct platform_device *pdev) |
3514 | diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c |
3515 | index 8bed1da..1c39d34 100644 |
3516 | --- a/drivers/pcmcia/pd6729.c |
3517 | +++ b/drivers/pcmcia/pd6729.c |
3518 | @@ -758,7 +758,7 @@ static void __devexit pd6729_pci_remove(struct pci_dev *dev) |
3519 | #ifdef CONFIG_PM |
3520 | static int pd6729_socket_suspend(struct pci_dev *dev, pm_message_t state) |
3521 | { |
3522 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3523 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3524 | } |
3525 | |
3526 | static int pd6729_socket_resume(struct pci_dev *dev) |
3527 | diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c |
3528 | index c49a726..86ad876 100644 |
3529 | --- a/drivers/pcmcia/pxa2xx_base.c |
3530 | +++ b/drivers/pcmcia/pxa2xx_base.c |
3531 | @@ -302,7 +302,7 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev) |
3532 | |
3533 | static int pxa2xx_drv_pcmcia_suspend(struct platform_device *dev, pm_message_t state) |
3534 | { |
3535 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3536 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3537 | } |
3538 | |
3539 | static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev) |
3540 | diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c |
3541 | index d8da5ac..2d0e997 100644 |
3542 | --- a/drivers/pcmcia/sa1100_generic.c |
3543 | +++ b/drivers/pcmcia/sa1100_generic.c |
3544 | @@ -89,7 +89,7 @@ static int sa11x0_drv_pcmcia_remove(struct platform_device *dev) |
3545 | static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev, |
3546 | pm_message_t state) |
3547 | { |
3548 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3549 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3550 | } |
3551 | |
3552 | static int sa11x0_drv_pcmcia_resume(struct platform_device *dev) |
3553 | diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c |
3554 | index 401052a..4be4e17 100644 |
3555 | --- a/drivers/pcmcia/sa1111_generic.c |
3556 | +++ b/drivers/pcmcia/sa1111_generic.c |
3557 | @@ -159,7 +159,7 @@ static int __devexit pcmcia_remove(struct sa1111_dev *dev) |
3558 | |
3559 | static int pcmcia_suspend(struct sa1111_dev *dev, pm_message_t state) |
3560 | { |
3561 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3562 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3563 | } |
3564 | |
3565 | static int pcmcia_resume(struct sa1111_dev *dev) |
3566 | diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c |
3567 | index 8eb0423..582413f 100644 |
3568 | --- a/drivers/pcmcia/tcic.c |
3569 | +++ b/drivers/pcmcia/tcic.c |
3570 | @@ -366,7 +366,7 @@ static int __init get_tcic_id(void) |
3571 | static int tcic_drv_pcmcia_suspend(struct platform_device *dev, |
3572 | pm_message_t state) |
3573 | { |
3574 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3575 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3576 | } |
3577 | |
3578 | static int tcic_drv_pcmcia_resume(struct platform_device *dev) |
3579 | diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c |
3580 | index d4ad50d..c9fcbdc 100644 |
3581 | --- a/drivers/pcmcia/vrc4171_card.c |
3582 | +++ b/drivers/pcmcia/vrc4171_card.c |
3583 | @@ -707,7 +707,7 @@ __setup("vrc4171_card=", vrc4171_card_setup); |
3584 | static int vrc4171_card_suspend(struct platform_device *dev, |
3585 | pm_message_t state) |
3586 | { |
3587 | - return pcmcia_socket_dev_suspend(&dev->dev, state); |
3588 | + return pcmcia_socket_dev_suspend(&dev->dev); |
3589 | } |
3590 | |
3591 | static int vrc4171_card_resume(struct platform_device *dev) |
3592 | diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c |
3593 | index 3ecd7c9..f728a45 100644 |
3594 | --- a/drivers/pcmcia/yenta_socket.c |
3595 | +++ b/drivers/pcmcia/yenta_socket.c |
3596 | @@ -1225,60 +1225,71 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i |
3597 | } |
3598 | |
3599 | #ifdef CONFIG_PM |
3600 | -static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state) |
3601 | +static int yenta_dev_suspend_noirq(struct device *dev) |
3602 | { |
3603 | - struct yenta_socket *socket = pci_get_drvdata(dev); |
3604 | + struct pci_dev *pdev = to_pci_dev(dev); |
3605 | + struct yenta_socket *socket = pci_get_drvdata(pdev); |
3606 | int ret; |
3607 | |
3608 | - ret = pcmcia_socket_dev_suspend(&dev->dev, state); |
3609 | + ret = pcmcia_socket_dev_suspend(dev); |
3610 | |
3611 | - if (socket) { |
3612 | - if (socket->type && socket->type->save_state) |
3613 | - socket->type->save_state(socket); |
3614 | + if (!socket) |
3615 | + return ret; |
3616 | |
3617 | - /* FIXME: pci_save_state needs to have a better interface */ |
3618 | - pci_save_state(dev); |
3619 | - pci_read_config_dword(dev, 16*4, &socket->saved_state[0]); |
3620 | - pci_read_config_dword(dev, 17*4, &socket->saved_state[1]); |
3621 | - pci_disable_device(dev); |
3622 | + if (socket->type && socket->type->save_state) |
3623 | + socket->type->save_state(socket); |
3624 | |
3625 | - /* |
3626 | - * Some laptops (IBM T22) do not like us putting the Cardbus |
3627 | - * bridge into D3. At a guess, some other laptop will |
3628 | - * probably require this, so leave it commented out for now. |
3629 | - */ |
3630 | - /* pci_set_power_state(dev, 3); */ |
3631 | - } |
3632 | + pci_save_state(pdev); |
3633 | + pci_read_config_dword(pdev, 16*4, &socket->saved_state[0]); |
3634 | + pci_read_config_dword(pdev, 17*4, &socket->saved_state[1]); |
3635 | + pci_disable_device(pdev); |
3636 | + |
3637 | + /* |
3638 | + * Some laptops (IBM T22) do not like us putting the Cardbus |
3639 | + * bridge into D3. At a guess, some other laptop will |
3640 | + * probably require this, so leave it commented out for now. |
3641 | + */ |
3642 | + /* pci_set_power_state(dev, 3); */ |
3643 | |
3644 | return ret; |
3645 | } |
3646 | |
3647 | - |
3648 | -static int yenta_dev_resume (struct pci_dev *dev) |
3649 | +static int yenta_dev_resume_noirq(struct device *dev) |
3650 | { |
3651 | - struct yenta_socket *socket = pci_get_drvdata(dev); |
3652 | + struct pci_dev *pdev = to_pci_dev(dev); |
3653 | + struct yenta_socket *socket = pci_get_drvdata(pdev); |
3654 | + int ret; |
3655 | |
3656 | - if (socket) { |
3657 | - int rc; |
3658 | + if (!socket) |
3659 | + return 0; |
3660 | |
3661 | - pci_set_power_state(dev, 0); |
3662 | - /* FIXME: pci_restore_state needs to have a better interface */ |
3663 | - pci_restore_state(dev); |
3664 | - pci_write_config_dword(dev, 16*4, socket->saved_state[0]); |
3665 | - pci_write_config_dword(dev, 17*4, socket->saved_state[1]); |
3666 | + pci_write_config_dword(pdev, 16*4, socket->saved_state[0]); |
3667 | + pci_write_config_dword(pdev, 17*4, socket->saved_state[1]); |
3668 | |
3669 | - rc = pci_enable_device(dev); |
3670 | - if (rc) |
3671 | - return rc; |
3672 | + ret = pci_enable_device(pdev); |
3673 | + if (ret) |
3674 | + return ret; |
3675 | |
3676 | - pci_set_master(dev); |
3677 | + pci_set_master(pdev); |
3678 | |
3679 | - if (socket->type && socket->type->restore_state) |
3680 | - socket->type->restore_state(socket); |
3681 | - } |
3682 | + if (socket->type && socket->type->restore_state) |
3683 | + socket->type->restore_state(socket); |
3684 | |
3685 | - return pcmcia_socket_dev_resume(&dev->dev); |
3686 | + return pcmcia_socket_dev_resume(dev); |
3687 | } |
3688 | + |
3689 | +static struct dev_pm_ops yenta_pm_ops = { |
3690 | + .suspend_noirq = yenta_dev_suspend_noirq, |
3691 | + .resume_noirq = yenta_dev_resume_noirq, |
3692 | + .freeze_noirq = yenta_dev_suspend_noirq, |
3693 | + .thaw_noirq = yenta_dev_resume_noirq, |
3694 | + .poweroff_noirq = yenta_dev_suspend_noirq, |
3695 | + .restore_noirq = yenta_dev_resume_noirq, |
3696 | +}; |
3697 | + |
3698 | +#define YENTA_PM_OPS (¥ta_pm_ops) |
3699 | +#else |
3700 | +#define YENTA_PM_OPS NULL |
3701 | #endif |
3702 | |
3703 | #define CB_ID(vend,dev,type) \ |
3704 | @@ -1376,10 +1387,7 @@ static struct pci_driver yenta_cardbus_driver = { |
3705 | .id_table = yenta_table, |
3706 | .probe = yenta_probe, |
3707 | .remove = __devexit_p(yenta_close), |
3708 | -#ifdef CONFIG_PM |
3709 | - .suspend = yenta_dev_suspend, |
3710 | - .resume = yenta_dev_resume, |
3711 | -#endif |
3712 | + .driver.pm = YENTA_PM_OPS, |
3713 | }; |
3714 | |
3715 | |
3716 | diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c |
3717 | index dafaa4a..a234a9d 100644 |
3718 | --- a/drivers/platform/x86/sony-laptop.c |
3719 | +++ b/drivers/platform/x86/sony-laptop.c |
3720 | @@ -1081,6 +1081,8 @@ static int sony_nc_setup_rfkill(struct acpi_device *device, |
3721 | struct rfkill *rfk; |
3722 | enum rfkill_type type; |
3723 | const char *name; |
3724 | + int result; |
3725 | + bool hwblock; |
3726 | |
3727 | switch (nc_type) { |
3728 | case SONY_WIFI: |
3729 | @@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device, |
3730 | if (!rfk) |
3731 | return -ENOMEM; |
3732 | |
3733 | + sony_call_snc_handle(0x124, 0x200, &result); |
3734 | + hwblock = !(result & 0x1); |
3735 | + rfkill_set_hw_state(rfk, hwblock); |
3736 | + |
3737 | err = rfkill_register(rfk); |
3738 | if (err) { |
3739 | rfkill_destroy(rfk); |
3740 | diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c |
3741 | index e856008..d287283 100644 |
3742 | --- a/drivers/platform/x86/thinkpad_acpi.c |
3743 | +++ b/drivers/platform/x86/thinkpad_acpi.c |
3744 | @@ -5655,16 +5655,16 @@ static const struct tpacpi_quirk brightness_quirk_table[] __initconst = { |
3745 | /* Models with ATI GPUs known to require ECNVRAM mode */ |
3746 | TPACPI_Q_IBM('1', 'Y', TPACPI_BRGHT_Q_EC), /* T43/p ATI */ |
3747 | |
3748 | - /* Models with ATI GPUs (waiting confirmation) */ |
3749 | - TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), |
3750 | + /* Models with ATI GPUs that can use ECNVRAM */ |
3751 | + TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), |
3752 | TPACPI_Q_IBM('1', 'Q', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), |
3753 | TPACPI_Q_IBM('7', '6', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), |
3754 | TPACPI_Q_IBM('7', '8', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), |
3755 | |
3756 | - /* Models with Intel Extreme Graphics 2 (waiting confirmation) */ |
3757 | + /* Models with Intel Extreme Graphics 2 */ |
3758 | + TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_NOEC), |
3759 | TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC), |
3760 | TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC), |
3761 | - TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC), |
3762 | |
3763 | /* Models with Intel GMA900 */ |
3764 | TPACPI_Q_IBM('7', '0', TPACPI_BRGHT_Q_NOEC), /* T43, R52 */ |
3765 | diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c |
3766 | index b4a7650..4fff4e5 100644 |
3767 | --- a/drivers/serial/bfin_5xx.c |
3768 | +++ b/drivers/serial/bfin_5xx.c |
3769 | @@ -42,6 +42,10 @@ |
3770 | # undef CONFIG_EARLY_PRINTK |
3771 | #endif |
3772 | |
3773 | +#ifdef CONFIG_SERIAL_BFIN_MODULE |
3774 | +# undef CONFIG_EARLY_PRINTK |
3775 | +#endif |
3776 | + |
3777 | /* UART name and device definitions */ |
3778 | #define BFIN_SERIAL_NAME "ttyBF" |
3779 | #define BFIN_SERIAL_MAJOR 204 |
3780 | diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c |
3781 | index 79c9c5f..6ecb51b 100644 |
3782 | --- a/drivers/serial/serial_cs.c |
3783 | +++ b/drivers/serial/serial_cs.c |
3784 | @@ -884,6 +884,7 @@ static struct pcmcia_device_id serial_ids[] = { |
3785 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- pre update */ |
3786 | PCMCIA_DEVICE_CIS_MANF_CARD(0x013f, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- post update */ |
3787 | PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"), |
3788 | + PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-2", 0x96913a85, 0x27ab5437, "COMpad2.cis"), |
3789 | PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), |
3790 | PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), |
3791 | PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"), |
3792 | diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c |
3793 | index 2bfc41e..e3861b2 100644 |
3794 | --- a/drivers/usb/class/cdc-acm.c |
3795 | +++ b/drivers/usb/class/cdc-acm.c |
3796 | @@ -59,6 +59,7 @@ |
3797 | #include <linux/init.h> |
3798 | #include <linux/slab.h> |
3799 | #include <linux/tty.h> |
3800 | +#include <linux/serial.h> |
3801 | #include <linux/tty_driver.h> |
3802 | #include <linux/tty_flip.h> |
3803 | #include <linux/module.h> |
3804 | @@ -609,6 +610,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) |
3805 | acm->throttle = 0; |
3806 | |
3807 | tasklet_schedule(&acm->urb_task); |
3808 | + set_bit(ASYNCB_INITIALIZED, &acm->port.flags); |
3809 | rv = tty_port_block_til_ready(&acm->port, tty, filp); |
3810 | done: |
3811 | mutex_unlock(&acm->mutex); |
3812 | @@ -858,10 +860,7 @@ static void acm_tty_set_termios(struct tty_struct *tty, |
3813 | if (!ACM_READY(acm)) |
3814 | return; |
3815 | |
3816 | - /* FIXME: Needs to support the tty_baud interface */ |
3817 | - /* FIXME: Broken on sparc */ |
3818 | - newline.dwDTERate = cpu_to_le32p(acm_tty_speed + |
3819 | - (termios->c_cflag & CBAUD & ~CBAUDEX) + (termios->c_cflag & CBAUDEX ? 15 : 0)); |
3820 | + newline.dwDTERate = cpu_to_le32(tty_get_baud_rate(tty)); |
3821 | newline.bCharFormat = termios->c_cflag & CSTOPB ? 2 : 0; |
3822 | newline.bParityType = termios->c_cflag & PARENB ? |
3823 | (termios->c_cflag & PARODD ? 1 : 2) + |
3824 | diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c |
3825 | index ba589d4..a9c3399 100644 |
3826 | --- a/drivers/usb/class/cdc-wdm.c |
3827 | +++ b/drivers/usb/class/cdc-wdm.c |
3828 | @@ -313,8 +313,13 @@ static ssize_t wdm_write |
3829 | r = usb_autopm_get_interface(desc->intf); |
3830 | if (r < 0) |
3831 | goto outnp; |
3832 | - r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE, |
3833 | - &desc->flags)); |
3834 | + |
3835 | + if (!file->f_flags && O_NONBLOCK) |
3836 | + r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE, |
3837 | + &desc->flags)); |
3838 | + else |
3839 | + if (test_bit(WDM_IN_USE, &desc->flags)) |
3840 | + r = -EAGAIN; |
3841 | if (r < 0) |
3842 | goto out; |
3843 | |
3844 | @@ -377,7 +382,7 @@ outnl: |
3845 | static ssize_t wdm_read |
3846 | (struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
3847 | { |
3848 | - int rv, cntr; |
3849 | + int rv, cntr = 0; |
3850 | int i = 0; |
3851 | struct wdm_device *desc = file->private_data; |
3852 | |
3853 | @@ -389,10 +394,23 @@ static ssize_t wdm_read |
3854 | if (desc->length == 0) { |
3855 | desc->read = 0; |
3856 | retry: |
3857 | + if (test_bit(WDM_DISCONNECTING, &desc->flags)) { |
3858 | + rv = -ENODEV; |
3859 | + goto err; |
3860 | + } |
3861 | i++; |
3862 | - rv = wait_event_interruptible(desc->wait, |
3863 | - test_bit(WDM_READ, &desc->flags)); |
3864 | + if (file->f_flags & O_NONBLOCK) { |
3865 | + if (!test_bit(WDM_READ, &desc->flags)) { |
3866 | + rv = cntr ? cntr : -EAGAIN; |
3867 | + goto err; |
3868 | + } |
3869 | + rv = 0; |
3870 | + } else { |
3871 | + rv = wait_event_interruptible(desc->wait, |
3872 | + test_bit(WDM_READ, &desc->flags)); |
3873 | + } |
3874 | |
3875 | + /* may have happened while we slept */ |
3876 | if (test_bit(WDM_DISCONNECTING, &desc->flags)) { |
3877 | rv = -ENODEV; |
3878 | goto err; |
3879 | @@ -448,7 +466,7 @@ retry: |
3880 | |
3881 | err: |
3882 | mutex_unlock(&desc->rlock); |
3883 | - if (rv < 0) |
3884 | + if (rv < 0 && rv != -EAGAIN) |
3885 | dev_err(&desc->intf->dev, "wdm_read: exit error\n"); |
3886 | return rv; |
3887 | } |
3888 | diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c |
3889 | index b09a527..21b3719 100644 |
3890 | --- a/drivers/usb/class/usbtmc.c |
3891 | +++ b/drivers/usb/class/usbtmc.c |
3892 | @@ -367,13 +367,13 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf, |
3893 | { |
3894 | struct usbtmc_device_data *data; |
3895 | struct device *dev; |
3896 | - unsigned long int n_characters; |
3897 | + u32 n_characters; |
3898 | u8 *buffer; |
3899 | int actual; |
3900 | - int done; |
3901 | - int remaining; |
3902 | + size_t done; |
3903 | + size_t remaining; |
3904 | int retval; |
3905 | - int this_part; |
3906 | + size_t this_part; |
3907 | |
3908 | /* Get pointer to private data structure */ |
3909 | data = filp->private_data; |
3910 | @@ -455,6 +455,18 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf, |
3911 | (buffer[6] << 16) + |
3912 | (buffer[7] << 24); |
3913 | |
3914 | + /* Ensure the instrument doesn't lie about it */ |
3915 | + if(n_characters > actual - 12) { |
3916 | + dev_err(dev, "Device lies about message size: %zu > %zu\n", n_characters, actual - 12); |
3917 | + n_characters = actual - 12; |
3918 | + } |
3919 | + |
3920 | + /* Ensure the instrument doesn't send more back than requested */ |
3921 | + if(n_characters > this_part) { |
3922 | + dev_err(dev, "Device returns more than requested: %zu > %zu\n", done + n_characters, done + this_part); |
3923 | + n_characters = this_part; |
3924 | + } |
3925 | + |
3926 | /* Copy buffer to user space */ |
3927 | if (copy_to_user(buf + done, &buffer[12], n_characters)) { |
3928 | /* There must have been an addressing problem */ |
3929 | @@ -465,6 +477,8 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf, |
3930 | done += n_characters; |
3931 | if (n_characters < USBTMC_SIZE_IOBUFFER) |
3932 | remaining = 0; |
3933 | + else |
3934 | + remaining -= n_characters; |
3935 | } |
3936 | |
3937 | /* Update file position value */ |
3938 | diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c |
3939 | index a16c538..0d3af6a 100644 |
3940 | --- a/drivers/usb/core/config.c |
3941 | +++ b/drivers/usb/core/config.c |
3942 | @@ -105,7 +105,7 @@ static int usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno, |
3943 | ep->ss_ep_comp->extralen = i; |
3944 | buffer += i; |
3945 | size -= i; |
3946 | - retval = buffer - buffer_start + i; |
3947 | + retval = buffer - buffer_start; |
3948 | if (num_skipped > 0) |
3949 | dev_dbg(ddev, "skipped %d descriptor%s after %s\n", |
3950 | num_skipped, plural(num_skipped), |
3951 | diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c |
3952 | index a949259..5b22a4d 100644 |
3953 | --- a/drivers/usb/host/sl811-hcd.c |
3954 | +++ b/drivers/usb/host/sl811-hcd.c |
3955 | @@ -719,8 +719,12 @@ retry: |
3956 | /* port status seems weird until after reset, so |
3957 | * force the reset and make khubd clean up later. |
3958 | */ |
3959 | - sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION) |
3960 | - | (1 << USB_PORT_FEAT_CONNECTION); |
3961 | + if (sl811->stat_insrmv & 1) |
3962 | + sl811->port1 |= 1 << USB_PORT_FEAT_CONNECTION; |
3963 | + else |
3964 | + sl811->port1 &= ~(1 << USB_PORT_FEAT_CONNECTION); |
3965 | + |
3966 | + sl811->port1 |= 1 << USB_PORT_FEAT_C_CONNECTION; |
3967 | |
3968 | } else if (irqstat & SL11H_INTMASK_RD) { |
3969 | if (sl811->port1 & (1 << USB_PORT_FEAT_SUSPEND)) { |
3970 | diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c |
3971 | index 705e343..33128d5 100644 |
3972 | --- a/drivers/usb/host/xhci-dbg.c |
3973 | +++ b/drivers/usb/host/xhci-dbg.c |
3974 | @@ -413,7 +413,8 @@ void xhci_dbg_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx) |
3975 | int i; |
3976 | |
3977 | struct xhci_slot_ctx *slot_ctx = xhci_get_slot_ctx(xhci, ctx); |
3978 | - dma_addr_t dma = ctx->dma + ((unsigned long)slot_ctx - (unsigned long)ctx); |
3979 | + dma_addr_t dma = ctx->dma + |
3980 | + ((unsigned long)slot_ctx - (unsigned long)ctx->bytes); |
3981 | int csz = HCC_64BYTE_CONTEXT(xhci->hcc_params); |
3982 | |
3983 | xhci_dbg(xhci, "Slot Context:\n"); |
3984 | @@ -459,7 +460,7 @@ void xhci_dbg_ep_ctx(struct xhci_hcd *xhci, |
3985 | for (i = 0; i < last_ep_ctx; ++i) { |
3986 | struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, ctx, i); |
3987 | dma_addr_t dma = ctx->dma + |
3988 | - ((unsigned long)ep_ctx - (unsigned long)ctx); |
3989 | + ((unsigned long)ep_ctx - (unsigned long)ctx->bytes); |
3990 | |
3991 | xhci_dbg(xhci, "Endpoint %02d Context:\n", i); |
3992 | xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - ep_info\n", |
3993 | diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c |
3994 | index 816c39c..e478a63 100644 |
3995 | --- a/drivers/usb/host/xhci-hcd.c |
3996 | +++ b/drivers/usb/host/xhci-hcd.c |
3997 | @@ -22,12 +22,18 @@ |
3998 | |
3999 | #include <linux/irq.h> |
4000 | #include <linux/module.h> |
4001 | +#include <linux/moduleparam.h> |
4002 | |
4003 | #include "xhci.h" |
4004 | |
4005 | #define DRIVER_AUTHOR "Sarah Sharp" |
4006 | #define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver" |
4007 | |
4008 | +/* Some 0.95 hardware can't handle the chain bit on a Link TRB being cleared */ |
4009 | +static int link_quirk; |
4010 | +module_param(link_quirk, int, S_IRUGO | S_IWUSR); |
4011 | +MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB"); |
4012 | + |
4013 | /* TODO: copied from ehci-hcd.c - can this be refactored? */ |
4014 | /* |
4015 | * handshake - spin reading hc until handshake completes or fails |
4016 | @@ -214,6 +220,12 @@ int xhci_init(struct usb_hcd *hcd) |
4017 | |
4018 | xhci_dbg(xhci, "xhci_init\n"); |
4019 | spin_lock_init(&xhci->lock); |
4020 | + if (link_quirk) { |
4021 | + xhci_dbg(xhci, "QUIRK: Not clearing Link TRB chain bits.\n"); |
4022 | + xhci->quirks |= XHCI_LINK_TRB_QUIRK; |
4023 | + } else { |
4024 | + xhci_dbg(xhci, "xHCI doesn't need link TRB QUIRK\n"); |
4025 | + } |
4026 | retval = xhci_mem_init(xhci, GFP_KERNEL); |
4027 | xhci_dbg(xhci, "Finished xhci_init\n"); |
4028 | |
4029 | @@ -555,13 +567,22 @@ unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc) |
4030 | return 1 << (xhci_get_endpoint_index(desc) + 1); |
4031 | } |
4032 | |
4033 | +/* Find the flag for this endpoint (for use in the control context). Use the |
4034 | + * endpoint index to create a bitmask. The slot context is bit 0, endpoint 0 is |
4035 | + * bit 1, etc. |
4036 | + */ |
4037 | +unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index) |
4038 | +{ |
4039 | + return 1 << (ep_index + 1); |
4040 | +} |
4041 | + |
4042 | /* Compute the last valid endpoint context index. Basically, this is the |
4043 | * endpoint index plus one. For slot contexts with more than valid endpoint, |
4044 | * we find the most significant bit set in the added contexts flags. |
4045 | * e.g. ep 1 IN (with epnum 0x81) => added_ctxs = 0b1000 |
4046 | * fls(0b1000) = 4, but the endpoint context index is 3, so subtract one. |
4047 | */ |
4048 | -static inline unsigned int xhci_last_valid_endpoint(u32 added_ctxs) |
4049 | +unsigned int xhci_last_valid_endpoint(u32 added_ctxs) |
4050 | { |
4051 | return fls(added_ctxs) - 1; |
4052 | } |
4053 | @@ -589,6 +610,70 @@ int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev, |
4054 | return 1; |
4055 | } |
4056 | |
4057 | +static int xhci_configure_endpoint(struct xhci_hcd *xhci, |
4058 | + struct usb_device *udev, struct xhci_virt_device *virt_dev, |
4059 | + bool ctx_change); |
4060 | + |
4061 | +/* |
4062 | + * Full speed devices may have a max packet size greater than 8 bytes, but the |
4063 | + * USB core doesn't know that until it reads the first 8 bytes of the |
4064 | + * descriptor. If the usb_device's max packet size changes after that point, |
4065 | + * we need to issue an evaluate context command and wait on it. |
4066 | + */ |
4067 | +static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, |
4068 | + unsigned int ep_index, struct urb *urb) |
4069 | +{ |
4070 | + struct xhci_container_ctx *in_ctx; |
4071 | + struct xhci_container_ctx *out_ctx; |
4072 | + struct xhci_input_control_ctx *ctrl_ctx; |
4073 | + struct xhci_ep_ctx *ep_ctx; |
4074 | + int max_packet_size; |
4075 | + int hw_max_packet_size; |
4076 | + int ret = 0; |
4077 | + |
4078 | + out_ctx = xhci->devs[slot_id]->out_ctx; |
4079 | + ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); |
4080 | + hw_max_packet_size = MAX_PACKET_DECODED(ep_ctx->ep_info2); |
4081 | + max_packet_size = urb->dev->ep0.desc.wMaxPacketSize; |
4082 | + if (hw_max_packet_size != max_packet_size) { |
4083 | + xhci_dbg(xhci, "Max Packet Size for ep 0 changed.\n"); |
4084 | + xhci_dbg(xhci, "Max packet size in usb_device = %d\n", |
4085 | + max_packet_size); |
4086 | + xhci_dbg(xhci, "Max packet size in xHCI HW = %d\n", |
4087 | + hw_max_packet_size); |
4088 | + xhci_dbg(xhci, "Issuing evaluate context command.\n"); |
4089 | + |
4090 | + /* Set up the modified control endpoint 0 */ |
4091 | + xhci_endpoint_copy(xhci, xhci->devs[slot_id], ep_index); |
4092 | + in_ctx = xhci->devs[slot_id]->in_ctx; |
4093 | + ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index); |
4094 | + ep_ctx->ep_info2 &= ~MAX_PACKET_MASK; |
4095 | + ep_ctx->ep_info2 |= MAX_PACKET(max_packet_size); |
4096 | + |
4097 | + /* Set up the input context flags for the command */ |
4098 | + /* FIXME: This won't work if a non-default control endpoint |
4099 | + * changes max packet sizes. |
4100 | + */ |
4101 | + ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); |
4102 | + ctrl_ctx->add_flags = EP0_FLAG; |
4103 | + ctrl_ctx->drop_flags = 0; |
4104 | + |
4105 | + xhci_dbg(xhci, "Slot %d input context\n", slot_id); |
4106 | + xhci_dbg_ctx(xhci, in_ctx, ep_index); |
4107 | + xhci_dbg(xhci, "Slot %d output context\n", slot_id); |
4108 | + xhci_dbg_ctx(xhci, out_ctx, ep_index); |
4109 | + |
4110 | + ret = xhci_configure_endpoint(xhci, urb->dev, |
4111 | + xhci->devs[slot_id], true); |
4112 | + |
4113 | + /* Clean up the input context for later use by bandwidth |
4114 | + * functions. |
4115 | + */ |
4116 | + ctrl_ctx->add_flags = SLOT_FLAG; |
4117 | + } |
4118 | + return ret; |
4119 | +} |
4120 | + |
4121 | /* |
4122 | * non-error returns are a promise to giveback() the urb later |
4123 | * we drop ownership so next owner (or urb unlink) can get it |
4124 | @@ -600,13 +685,13 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) |
4125 | int ret = 0; |
4126 | unsigned int slot_id, ep_index; |
4127 | |
4128 | + |
4129 | if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, __func__) <= 0) |
4130 | return -EINVAL; |
4131 | |
4132 | slot_id = urb->dev->slot_id; |
4133 | ep_index = xhci_get_endpoint_index(&urb->ep->desc); |
4134 | |
4135 | - spin_lock_irqsave(&xhci->lock, flags); |
4136 | if (!xhci->devs || !xhci->devs[slot_id]) { |
4137 | if (!in_interrupt()) |
4138 | dev_warn(&urb->dev->dev, "WARN: urb submitted for dev with no Slot ID\n"); |
4139 | @@ -619,19 +704,38 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) |
4140 | ret = -ESHUTDOWN; |
4141 | goto exit; |
4142 | } |
4143 | - if (usb_endpoint_xfer_control(&urb->ep->desc)) |
4144 | + if (usb_endpoint_xfer_control(&urb->ep->desc)) { |
4145 | + /* Check to see if the max packet size for the default control |
4146 | + * endpoint changed during FS device enumeration |
4147 | + */ |
4148 | + if (urb->dev->speed == USB_SPEED_FULL) { |
4149 | + ret = xhci_check_maxpacket(xhci, slot_id, |
4150 | + ep_index, urb); |
4151 | + if (ret < 0) |
4152 | + return ret; |
4153 | + } |
4154 | + |
4155 | /* We have a spinlock and interrupts disabled, so we must pass |
4156 | * atomic context to this function, which may allocate memory. |
4157 | */ |
4158 | + spin_lock_irqsave(&xhci->lock, flags); |
4159 | ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb, |
4160 | slot_id, ep_index); |
4161 | - else if (usb_endpoint_xfer_bulk(&urb->ep->desc)) |
4162 | + spin_unlock_irqrestore(&xhci->lock, flags); |
4163 | + } else if (usb_endpoint_xfer_bulk(&urb->ep->desc)) { |
4164 | + spin_lock_irqsave(&xhci->lock, flags); |
4165 | ret = xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb, |
4166 | slot_id, ep_index); |
4167 | - else |
4168 | + spin_unlock_irqrestore(&xhci->lock, flags); |
4169 | + } else if (usb_endpoint_xfer_int(&urb->ep->desc)) { |
4170 | + spin_lock_irqsave(&xhci->lock, flags); |
4171 | + ret = xhci_queue_intr_tx(xhci, GFP_ATOMIC, urb, |
4172 | + slot_id, ep_index); |
4173 | + spin_unlock_irqrestore(&xhci->lock, flags); |
4174 | + } else { |
4175 | ret = -EINVAL; |
4176 | + } |
4177 | exit: |
4178 | - spin_unlock_irqrestore(&xhci->lock, flags); |
4179 | return ret; |
4180 | } |
4181 | |
4182 | @@ -930,6 +1034,122 @@ static void xhci_zero_in_ctx(struct xhci_hcd *xhci, struct xhci_virt_device *vir |
4183 | } |
4184 | } |
4185 | |
4186 | +static int xhci_configure_endpoint_result(struct xhci_hcd *xhci, |
4187 | + struct usb_device *udev, struct xhci_virt_device *virt_dev) |
4188 | +{ |
4189 | + int ret; |
4190 | + |
4191 | + switch (virt_dev->cmd_status) { |
4192 | + case COMP_ENOMEM: |
4193 | + dev_warn(&udev->dev, "Not enough host controller resources " |
4194 | + "for new device state.\n"); |
4195 | + ret = -ENOMEM; |
4196 | + /* FIXME: can we allocate more resources for the HC? */ |
4197 | + break; |
4198 | + case COMP_BW_ERR: |
4199 | + dev_warn(&udev->dev, "Not enough bandwidth " |
4200 | + "for new device state.\n"); |
4201 | + ret = -ENOSPC; |
4202 | + /* FIXME: can we go back to the old state? */ |
4203 | + break; |
4204 | + case COMP_TRB_ERR: |
4205 | + /* the HCD set up something wrong */ |
4206 | + dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, " |
4207 | + "add flag = 1, " |
4208 | + "and endpoint is not disabled.\n"); |
4209 | + ret = -EINVAL; |
4210 | + break; |
4211 | + case COMP_SUCCESS: |
4212 | + dev_dbg(&udev->dev, "Successful Endpoint Configure command\n"); |
4213 | + ret = 0; |
4214 | + break; |
4215 | + default: |
4216 | + xhci_err(xhci, "ERROR: unexpected command completion " |
4217 | + "code 0x%x.\n", virt_dev->cmd_status); |
4218 | + ret = -EINVAL; |
4219 | + break; |
4220 | + } |
4221 | + return ret; |
4222 | +} |
4223 | + |
4224 | +static int xhci_evaluate_context_result(struct xhci_hcd *xhci, |
4225 | + struct usb_device *udev, struct xhci_virt_device *virt_dev) |
4226 | +{ |
4227 | + int ret; |
4228 | + |
4229 | + switch (virt_dev->cmd_status) { |
4230 | + case COMP_EINVAL: |
4231 | + dev_warn(&udev->dev, "WARN: xHCI driver setup invalid evaluate " |
4232 | + "context command.\n"); |
4233 | + ret = -EINVAL; |
4234 | + break; |
4235 | + case COMP_EBADSLT: |
4236 | + dev_warn(&udev->dev, "WARN: slot not enabled for" |
4237 | + "evaluate context command.\n"); |
4238 | + case COMP_CTX_STATE: |
4239 | + dev_warn(&udev->dev, "WARN: invalid context state for " |
4240 | + "evaluate context command.\n"); |
4241 | + xhci_dbg_ctx(xhci, virt_dev->out_ctx, 1); |
4242 | + ret = -EINVAL; |
4243 | + break; |
4244 | + case COMP_SUCCESS: |
4245 | + dev_dbg(&udev->dev, "Successful evaluate context command\n"); |
4246 | + ret = 0; |
4247 | + break; |
4248 | + default: |
4249 | + xhci_err(xhci, "ERROR: unexpected command completion " |
4250 | + "code 0x%x.\n", virt_dev->cmd_status); |
4251 | + ret = -EINVAL; |
4252 | + break; |
4253 | + } |
4254 | + return ret; |
4255 | +} |
4256 | + |
4257 | +/* Issue a configure endpoint command or evaluate context command |
4258 | + * and wait for it to finish. |
4259 | + */ |
4260 | +static int xhci_configure_endpoint(struct xhci_hcd *xhci, |
4261 | + struct usb_device *udev, struct xhci_virt_device *virt_dev, |
4262 | + bool ctx_change) |
4263 | +{ |
4264 | + int ret; |
4265 | + int timeleft; |
4266 | + unsigned long flags; |
4267 | + |
4268 | + spin_lock_irqsave(&xhci->lock, flags); |
4269 | + if (!ctx_change) |
4270 | + ret = xhci_queue_configure_endpoint(xhci, virt_dev->in_ctx->dma, |
4271 | + udev->slot_id); |
4272 | + else |
4273 | + ret = xhci_queue_evaluate_context(xhci, virt_dev->in_ctx->dma, |
4274 | + udev->slot_id); |
4275 | + if (ret < 0) { |
4276 | + spin_unlock_irqrestore(&xhci->lock, flags); |
4277 | + xhci_dbg(xhci, "FIXME allocate a new ring segment\n"); |
4278 | + return -ENOMEM; |
4279 | + } |
4280 | + xhci_ring_cmd_db(xhci); |
4281 | + spin_unlock_irqrestore(&xhci->lock, flags); |
4282 | + |
4283 | + /* Wait for the configure endpoint command to complete */ |
4284 | + timeleft = wait_for_completion_interruptible_timeout( |
4285 | + &virt_dev->cmd_completion, |
4286 | + USB_CTRL_SET_TIMEOUT); |
4287 | + if (timeleft <= 0) { |
4288 | + xhci_warn(xhci, "%s while waiting for %s command\n", |
4289 | + timeleft == 0 ? "Timeout" : "Signal", |
4290 | + ctx_change == 0 ? |
4291 | + "configure endpoint" : |
4292 | + "evaluate context"); |
4293 | + /* FIXME cancel the configure endpoint command */ |
4294 | + return -ETIME; |
4295 | + } |
4296 | + |
4297 | + if (!ctx_change) |
4298 | + return xhci_configure_endpoint_result(xhci, udev, virt_dev); |
4299 | + return xhci_evaluate_context_result(xhci, udev, virt_dev); |
4300 | +} |
4301 | + |
4302 | /* Called after one or more calls to xhci_add_endpoint() or |
4303 | * xhci_drop_endpoint(). If this call fails, the USB core is expected |
4304 | * to call xhci_reset_bandwidth(). |
4305 | @@ -944,8 +1164,6 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) |
4306 | { |
4307 | int i; |
4308 | int ret = 0; |
4309 | - int timeleft; |
4310 | - unsigned long flags; |
4311 | struct xhci_hcd *xhci; |
4312 | struct xhci_virt_device *virt_dev; |
4313 | struct xhci_input_control_ctx *ctrl_ctx; |
4314 | @@ -975,56 +1193,7 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) |
4315 | xhci_dbg_ctx(xhci, virt_dev->in_ctx, |
4316 | LAST_CTX_TO_EP_NUM(slot_ctx->dev_info)); |
4317 | |
4318 | - spin_lock_irqsave(&xhci->lock, flags); |
4319 | - ret = xhci_queue_configure_endpoint(xhci, virt_dev->in_ctx->dma, |
4320 | - udev->slot_id); |
4321 | - if (ret < 0) { |
4322 | - spin_unlock_irqrestore(&xhci->lock, flags); |
4323 | - xhci_dbg(xhci, "FIXME allocate a new ring segment\n"); |
4324 | - return -ENOMEM; |
4325 | - } |
4326 | - xhci_ring_cmd_db(xhci); |
4327 | - spin_unlock_irqrestore(&xhci->lock, flags); |
4328 | - |
4329 | - /* Wait for the configure endpoint command to complete */ |
4330 | - timeleft = wait_for_completion_interruptible_timeout( |
4331 | - &virt_dev->cmd_completion, |
4332 | - USB_CTRL_SET_TIMEOUT); |
4333 | - if (timeleft <= 0) { |
4334 | - xhci_warn(xhci, "%s while waiting for configure endpoint command\n", |
4335 | - timeleft == 0 ? "Timeout" : "Signal"); |
4336 | - /* FIXME cancel the configure endpoint command */ |
4337 | - return -ETIME; |
4338 | - } |
4339 | - |
4340 | - switch (virt_dev->cmd_status) { |
4341 | - case COMP_ENOMEM: |
4342 | - dev_warn(&udev->dev, "Not enough host controller resources " |
4343 | - "for new device state.\n"); |
4344 | - ret = -ENOMEM; |
4345 | - /* FIXME: can we allocate more resources for the HC? */ |
4346 | - break; |
4347 | - case COMP_BW_ERR: |
4348 | - dev_warn(&udev->dev, "Not enough bandwidth " |
4349 | - "for new device state.\n"); |
4350 | - ret = -ENOSPC; |
4351 | - /* FIXME: can we go back to the old state? */ |
4352 | - break; |
4353 | - case COMP_TRB_ERR: |
4354 | - /* the HCD set up something wrong */ |
4355 | - dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, add flag = 1, " |
4356 | - "and endpoint is not disabled.\n"); |
4357 | - ret = -EINVAL; |
4358 | - break; |
4359 | - case COMP_SUCCESS: |
4360 | - dev_dbg(&udev->dev, "Successful Endpoint Configure command\n"); |
4361 | - break; |
4362 | - default: |
4363 | - xhci_err(xhci, "ERROR: unexpected command completion " |
4364 | - "code 0x%x.\n", virt_dev->cmd_status); |
4365 | - ret = -EINVAL; |
4366 | - break; |
4367 | - } |
4368 | + ret = xhci_configure_endpoint(xhci, udev, virt_dev, false); |
4369 | if (ret) { |
4370 | /* Callee should call reset_bandwidth() */ |
4371 | return ret; |
4372 | @@ -1075,6 +1244,75 @@ void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) |
4373 | xhci_zero_in_ctx(xhci, virt_dev); |
4374 | } |
4375 | |
4376 | +void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci, |
4377 | + unsigned int slot_id, unsigned int ep_index, |
4378 | + struct xhci_dequeue_state *deq_state) |
4379 | +{ |
4380 | + struct xhci_container_ctx *in_ctx; |
4381 | + struct xhci_input_control_ctx *ctrl_ctx; |
4382 | + struct xhci_ep_ctx *ep_ctx; |
4383 | + u32 added_ctxs; |
4384 | + dma_addr_t addr; |
4385 | + |
4386 | + xhci_endpoint_copy(xhci, xhci->devs[slot_id], ep_index); |
4387 | + in_ctx = xhci->devs[slot_id]->in_ctx; |
4388 | + ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index); |
4389 | + addr = xhci_trb_virt_to_dma(deq_state->new_deq_seg, |
4390 | + deq_state->new_deq_ptr); |
4391 | + if (addr == 0) { |
4392 | + xhci_warn(xhci, "WARN Cannot submit config ep after " |
4393 | + "reset ep command\n"); |
4394 | + xhci_warn(xhci, "WARN deq seg = %p, deq ptr = %p\n", |
4395 | + deq_state->new_deq_seg, |
4396 | + deq_state->new_deq_ptr); |
4397 | + return; |
4398 | + } |
4399 | + ep_ctx->deq = addr | deq_state->new_cycle_state; |
4400 | + |
4401 | + xhci_slot_copy(xhci, xhci->devs[slot_id]); |
4402 | + |
4403 | + ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); |
4404 | + added_ctxs = xhci_get_endpoint_flag_from_index(ep_index); |
4405 | + ctrl_ctx->add_flags = added_ctxs | SLOT_FLAG; |
4406 | + ctrl_ctx->drop_flags = added_ctxs; |
4407 | + |
4408 | + xhci_dbg(xhci, "Slot ID %d Input Context:\n", slot_id); |
4409 | + xhci_dbg_ctx(xhci, in_ctx, ep_index); |
4410 | +} |
4411 | + |
4412 | +void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, |
4413 | + struct usb_device *udev, |
4414 | + unsigned int ep_index, struct xhci_ring *ep_ring) |
4415 | +{ |
4416 | + struct xhci_dequeue_state deq_state; |
4417 | + |
4418 | + xhci_dbg(xhci, "Cleaning up stalled endpoint ring\n"); |
4419 | + /* We need to move the HW's dequeue pointer past this TD, |
4420 | + * or it will attempt to resend it on the next doorbell ring. |
4421 | + */ |
4422 | + xhci_find_new_dequeue_state(xhci, udev->slot_id, |
4423 | + ep_index, ep_ring->stopped_td, |
4424 | + &deq_state); |
4425 | + |
4426 | + /* HW with the reset endpoint quirk will use the saved dequeue state to |
4427 | + * issue a configure endpoint command later. |
4428 | + */ |
4429 | + if (!(xhci->quirks & XHCI_RESET_EP_QUIRK)) { |
4430 | + xhci_dbg(xhci, "Queueing new dequeue state\n"); |
4431 | + xhci_queue_new_dequeue_state(xhci, ep_ring, |
4432 | + udev->slot_id, |
4433 | + ep_index, &deq_state); |
4434 | + } else { |
4435 | + /* Better hope no one uses the input context between now and the |
4436 | + * reset endpoint completion! |
4437 | + */ |
4438 | + xhci_dbg(xhci, "Setting up input context for " |
4439 | + "configure endpoint command\n"); |
4440 | + xhci_setup_input_ctx_for_quirk(xhci, udev->slot_id, |
4441 | + ep_index, &deq_state); |
4442 | + } |
4443 | +} |
4444 | + |
4445 | /* Deal with stalled endpoints. The core should have sent the control message |
4446 | * to clear the halt condition. However, we need to make the xHCI hardware |
4447 | * reset its sequence number, since a device will expect a sequence number of |
4448 | @@ -1089,7 +1327,6 @@ void xhci_endpoint_reset(struct usb_hcd *hcd, |
4449 | unsigned int ep_index; |
4450 | unsigned long flags; |
4451 | int ret; |
4452 | - struct xhci_dequeue_state deq_state; |
4453 | struct xhci_ring *ep_ring; |
4454 | |
4455 | xhci = hcd_to_xhci(hcd); |
4456 | @@ -1106,6 +1343,10 @@ void xhci_endpoint_reset(struct usb_hcd *hcd, |
4457 | ep->desc.bEndpointAddress); |
4458 | return; |
4459 | } |
4460 | + if (usb_endpoint_xfer_control(&ep->desc)) { |
4461 | + xhci_dbg(xhci, "Control endpoint stall already handled.\n"); |
4462 | + return; |
4463 | + } |
4464 | |
4465 | xhci_dbg(xhci, "Queueing reset endpoint command\n"); |
4466 | spin_lock_irqsave(&xhci->lock, flags); |
4467 | @@ -1116,16 +1357,7 @@ void xhci_endpoint_reset(struct usb_hcd *hcd, |
4468 | * command. Better hope that last command worked! |
4469 | */ |
4470 | if (!ret) { |
4471 | - xhci_dbg(xhci, "Cleaning up stalled endpoint ring\n"); |
4472 | - /* We need to move the HW's dequeue pointer past this TD, |
4473 | - * or it will attempt to resend it on the next doorbell ring. |
4474 | - */ |
4475 | - xhci_find_new_dequeue_state(xhci, udev->slot_id, |
4476 | - ep_index, ep_ring->stopped_td, &deq_state); |
4477 | - xhci_dbg(xhci, "Queueing new dequeue state\n"); |
4478 | - xhci_queue_new_dequeue_state(xhci, ep_ring, |
4479 | - udev->slot_id, |
4480 | - ep_index, &deq_state); |
4481 | + xhci_cleanup_stalled_ring(xhci, udev, ep_index, ep_ring); |
4482 | kfree(ep_ring->stopped_td); |
4483 | xhci_ring_cmd_db(xhci); |
4484 | } |
4485 | diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c |
4486 | index e6b9a1c..55920b3 100644 |
4487 | --- a/drivers/usb/host/xhci-mem.c |
4488 | +++ b/drivers/usb/host/xhci-mem.c |
4489 | @@ -94,6 +94,9 @@ static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, |
4490 | val = prev->trbs[TRBS_PER_SEGMENT-1].link.control; |
4491 | val &= ~TRB_TYPE_BITMASK; |
4492 | val |= TRB_TYPE(TRB_LINK); |
4493 | + /* Always set the chain bit with 0.95 hardware */ |
4494 | + if (xhci_link_trb_quirk(xhci)) |
4495 | + val |= TRB_CHAIN; |
4496 | prev->trbs[TRBS_PER_SEGMENT-1].link.control = val; |
4497 | } |
4498 | xhci_dbg(xhci, "Linking segment 0x%llx to segment 0x%llx (DMA)\n", |
4499 | @@ -398,15 +401,28 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud |
4500 | /* Step 5 */ |
4501 | ep0_ctx->ep_info2 = EP_TYPE(CTRL_EP); |
4502 | /* |
4503 | - * See section 4.3 bullet 6: |
4504 | - * The default Max Packet size for ep0 is "8 bytes for a USB2 |
4505 | - * LS/FS/HS device or 512 bytes for a USB3 SS device" |
4506 | * XXX: Not sure about wireless USB devices. |
4507 | */ |
4508 | - if (udev->speed == USB_SPEED_SUPER) |
4509 | + switch (udev->speed) { |
4510 | + case USB_SPEED_SUPER: |
4511 | ep0_ctx->ep_info2 |= MAX_PACKET(512); |
4512 | - else |
4513 | + break; |
4514 | + case USB_SPEED_HIGH: |
4515 | + /* USB core guesses at a 64-byte max packet first for FS devices */ |
4516 | + case USB_SPEED_FULL: |
4517 | + ep0_ctx->ep_info2 |= MAX_PACKET(64); |
4518 | + break; |
4519 | + case USB_SPEED_LOW: |
4520 | ep0_ctx->ep_info2 |= MAX_PACKET(8); |
4521 | + break; |
4522 | + case USB_SPEED_VARIABLE: |
4523 | + xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); |
4524 | + return -EINVAL; |
4525 | + break; |
4526 | + default: |
4527 | + /* New speed? */ |
4528 | + BUG(); |
4529 | + } |
4530 | /* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */ |
4531 | ep0_ctx->ep_info2 |= MAX_BURST(0); |
4532 | ep0_ctx->ep_info2 |= ERROR_COUNT(3); |
4533 | @@ -598,6 +614,44 @@ void xhci_endpoint_zero(struct xhci_hcd *xhci, |
4534 | */ |
4535 | } |
4536 | |
4537 | +/* Copy output xhci_ep_ctx to the input xhci_ep_ctx copy. |
4538 | + * Useful when you want to change one particular aspect of the endpoint and then |
4539 | + * issue a configure endpoint command. |
4540 | + */ |
4541 | +void xhci_endpoint_copy(struct xhci_hcd *xhci, |
4542 | + struct xhci_virt_device *vdev, unsigned int ep_index) |
4543 | +{ |
4544 | + struct xhci_ep_ctx *out_ep_ctx; |
4545 | + struct xhci_ep_ctx *in_ep_ctx; |
4546 | + |
4547 | + out_ep_ctx = xhci_get_ep_ctx(xhci, vdev->out_ctx, ep_index); |
4548 | + in_ep_ctx = xhci_get_ep_ctx(xhci, vdev->in_ctx, ep_index); |
4549 | + |
4550 | + in_ep_ctx->ep_info = out_ep_ctx->ep_info; |
4551 | + in_ep_ctx->ep_info2 = out_ep_ctx->ep_info2; |
4552 | + in_ep_ctx->deq = out_ep_ctx->deq; |
4553 | + in_ep_ctx->tx_info = out_ep_ctx->tx_info; |
4554 | +} |
4555 | + |
4556 | +/* Copy output xhci_slot_ctx to the input xhci_slot_ctx. |
4557 | + * Useful when you want to change one particular aspect of the endpoint and then |
4558 | + * issue a configure endpoint command. Only the context entries field matters, |
4559 | + * but we'll copy the whole thing anyway. |
4560 | + */ |
4561 | +void xhci_slot_copy(struct xhci_hcd *xhci, struct xhci_virt_device *vdev) |
4562 | +{ |
4563 | + struct xhci_slot_ctx *in_slot_ctx; |
4564 | + struct xhci_slot_ctx *out_slot_ctx; |
4565 | + |
4566 | + in_slot_ctx = xhci_get_slot_ctx(xhci, vdev->in_ctx); |
4567 | + out_slot_ctx = xhci_get_slot_ctx(xhci, vdev->out_ctx); |
4568 | + |
4569 | + in_slot_ctx->dev_info = out_slot_ctx->dev_info; |
4570 | + in_slot_ctx->dev_info2 = out_slot_ctx->dev_info2; |
4571 | + in_slot_ctx->tt_info = out_slot_ctx->tt_info; |
4572 | + in_slot_ctx->dev_state = out_slot_ctx->dev_state; |
4573 | +} |
4574 | + |
4575 | /* Set up the scratchpad buffer array and scratchpad buffers, if needed. */ |
4576 | static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) |
4577 | { |
4578 | diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c |
4579 | index 592fe7e..8fb308d 100644 |
4580 | --- a/drivers/usb/host/xhci-pci.c |
4581 | +++ b/drivers/usb/host/xhci-pci.c |
4582 | @@ -24,6 +24,10 @@ |
4583 | |
4584 | #include "xhci.h" |
4585 | |
4586 | +/* Device for a quirk */ |
4587 | +#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 |
4588 | +#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 |
4589 | + |
4590 | static const char hcd_name[] = "xhci_hcd"; |
4591 | |
4592 | /* called after powerup, by probe or system-pm "wakeup" */ |
4593 | @@ -62,6 +66,15 @@ static int xhci_pci_setup(struct usb_hcd *hcd) |
4594 | xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hcc_params); |
4595 | xhci_print_registers(xhci); |
4596 | |
4597 | + /* Look for vendor-specific quirks */ |
4598 | + if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && |
4599 | + pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK && |
4600 | + pdev->revision == 0x0) { |
4601 | + xhci->quirks |= XHCI_RESET_EP_QUIRK; |
4602 | + xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure" |
4603 | + " endpoint cmd after reset endpoint\n"); |
4604 | + } |
4605 | + |
4606 | /* Make sure the HC is halted. */ |
4607 | retval = xhci_halt(xhci); |
4608 | if (retval) |
4609 | diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c |
4610 | index aa88a06..ff5e6bc 100644 |
4611 | --- a/drivers/usb/host/xhci-ring.c |
4612 | +++ b/drivers/usb/host/xhci-ring.c |
4613 | @@ -172,8 +172,9 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer |
4614 | * have their chain bit cleared (so that each Link TRB is a separate TD). |
4615 | * |
4616 | * Section 6.4.4.1 of the 0.95 spec says link TRBs cannot have the chain bit |
4617 | - * set, but other sections talk about dealing with the chain bit set. |
4618 | - * Assume section 6.4.4.1 is wrong, and the chain bit can be set in a Link TRB. |
4619 | + * set, but other sections talk about dealing with the chain bit set. This was |
4620 | + * fixed in the 0.96 specification errata, but we have to assume that all 0.95 |
4621 | + * xHCI hardware can't handle the chain bit being cleared on a link TRB. |
4622 | */ |
4623 | static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer) |
4624 | { |
4625 | @@ -191,8 +192,14 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer |
4626 | while (last_trb(xhci, ring, ring->enq_seg, next)) { |
4627 | if (!consumer) { |
4628 | if (ring != xhci->event_ring) { |
4629 | - next->link.control &= ~TRB_CHAIN; |
4630 | - next->link.control |= chain; |
4631 | + /* If we're not dealing with 0.95 hardware, |
4632 | + * carry over the chain bit of the previous TRB |
4633 | + * (which may mean the chain bit is cleared). |
4634 | + */ |
4635 | + if (!xhci_link_trb_quirk(xhci)) { |
4636 | + next->link.control &= ~TRB_CHAIN; |
4637 | + next->link.control |= chain; |
4638 | + } |
4639 | /* Give this link TRB to the hardware */ |
4640 | wmb(); |
4641 | if (next->link.control & TRB_CYCLE) |
4642 | @@ -462,7 +469,6 @@ void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci, |
4643 | * ring running. |
4644 | */ |
4645 | ep_ring->state |= SET_DEQ_PENDING; |
4646 | - xhci_ring_cmd_db(xhci); |
4647 | } |
4648 | |
4649 | /* |
4650 | @@ -531,6 +537,7 @@ static void handle_stopped_endpoint(struct xhci_hcd *xhci, |
4651 | if (deq_state.new_deq_ptr && deq_state.new_deq_seg) { |
4652 | xhci_queue_new_dequeue_state(xhci, ep_ring, |
4653 | slot_id, ep_index, &deq_state); |
4654 | + xhci_ring_cmd_db(xhci); |
4655 | } else { |
4656 | /* Otherwise just ring the doorbell to restart the ring */ |
4657 | ring_ep_doorbell(xhci, slot_id, ep_index); |
4658 | @@ -644,18 +651,31 @@ static void handle_reset_ep_completion(struct xhci_hcd *xhci, |
4659 | { |
4660 | int slot_id; |
4661 | unsigned int ep_index; |
4662 | + struct xhci_ring *ep_ring; |
4663 | |
4664 | slot_id = TRB_TO_SLOT_ID(trb->generic.field[3]); |
4665 | ep_index = TRB_TO_EP_INDEX(trb->generic.field[3]); |
4666 | + ep_ring = xhci->devs[slot_id]->ep_rings[ep_index]; |
4667 | /* This command will only fail if the endpoint wasn't halted, |
4668 | * but we don't care. |
4669 | */ |
4670 | xhci_dbg(xhci, "Ignoring reset ep completion code of %u\n", |
4671 | (unsigned int) GET_COMP_CODE(event->status)); |
4672 | |
4673 | - /* Clear our internal halted state and restart the ring */ |
4674 | - xhci->devs[slot_id]->ep_rings[ep_index]->state &= ~EP_HALTED; |
4675 | - ring_ep_doorbell(xhci, slot_id, ep_index); |
4676 | + /* HW with the reset endpoint quirk needs to have a configure endpoint |
4677 | + * command complete before the endpoint can be used. Queue that here |
4678 | + * because the HW can't handle two commands being queued in a row. |
4679 | + */ |
4680 | + if (xhci->quirks & XHCI_RESET_EP_QUIRK) { |
4681 | + xhci_dbg(xhci, "Queueing configure endpoint command\n"); |
4682 | + xhci_queue_configure_endpoint(xhci, |
4683 | + xhci->devs[slot_id]->in_ctx->dma, slot_id); |
4684 | + xhci_ring_cmd_db(xhci); |
4685 | + } else { |
4686 | + /* Clear our internal halted state and restart the ring */ |
4687 | + ep_ring->state &= ~EP_HALTED; |
4688 | + ring_ep_doorbell(xhci, slot_id, ep_index); |
4689 | + } |
4690 | } |
4691 | |
4692 | static void handle_cmd_completion(struct xhci_hcd *xhci, |
4693 | @@ -664,6 +684,10 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, |
4694 | int slot_id = TRB_TO_SLOT_ID(event->flags); |
4695 | u64 cmd_dma; |
4696 | dma_addr_t cmd_dequeue_dma; |
4697 | + struct xhci_input_control_ctx *ctrl_ctx; |
4698 | + unsigned int ep_index; |
4699 | + struct xhci_ring *ep_ring; |
4700 | + unsigned int ep_state; |
4701 | |
4702 | cmd_dma = event->cmd_trb; |
4703 | cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg, |
4704 | @@ -691,6 +715,41 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, |
4705 | xhci_free_virt_device(xhci, slot_id); |
4706 | break; |
4707 | case TRB_TYPE(TRB_CONFIG_EP): |
4708 | + /* |
4709 | + * Configure endpoint commands can come from the USB core |
4710 | + * configuration or alt setting changes, or because the HW |
4711 | + * needed an extra configure endpoint command after a reset |
4712 | + * endpoint command. In the latter case, the xHCI driver is |
4713 | + * not waiting on the configure endpoint command. |
4714 | + */ |
4715 | + ctrl_ctx = xhci_get_input_control_ctx(xhci, |
4716 | + xhci->devs[slot_id]->in_ctx); |
4717 | + /* Input ctx add_flags are the endpoint index plus one */ |
4718 | + ep_index = xhci_last_valid_endpoint(ctrl_ctx->add_flags) - 1; |
4719 | + ep_ring = xhci->devs[slot_id]->ep_rings[ep_index]; |
4720 | + if (!ep_ring) { |
4721 | + /* This must have been an initial configure endpoint */ |
4722 | + xhci->devs[slot_id]->cmd_status = |
4723 | + GET_COMP_CODE(event->status); |
4724 | + complete(&xhci->devs[slot_id]->cmd_completion); |
4725 | + break; |
4726 | + } |
4727 | + ep_state = ep_ring->state; |
4728 | + xhci_dbg(xhci, "Completed config ep cmd - last ep index = %d, " |
4729 | + "state = %d\n", ep_index, ep_state); |
4730 | + if (xhci->quirks & XHCI_RESET_EP_QUIRK && |
4731 | + ep_state & EP_HALTED) { |
4732 | + /* Clear our internal halted state and restart ring */ |
4733 | + xhci->devs[slot_id]->ep_rings[ep_index]->state &= |
4734 | + ~EP_HALTED; |
4735 | + ring_ep_doorbell(xhci, slot_id, ep_index); |
4736 | + } else { |
4737 | + xhci->devs[slot_id]->cmd_status = |
4738 | + GET_COMP_CODE(event->status); |
4739 | + complete(&xhci->devs[slot_id]->cmd_completion); |
4740 | + } |
4741 | + break; |
4742 | + case TRB_TYPE(TRB_EVAL_CONTEXT): |
4743 | xhci->devs[slot_id]->cmd_status = GET_COMP_CODE(event->status); |
4744 | complete(&xhci->devs[slot_id]->cmd_completion); |
4745 | break; |
4746 | @@ -806,6 +865,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4747 | { |
4748 | struct xhci_virt_device *xdev; |
4749 | struct xhci_ring *ep_ring; |
4750 | + unsigned int slot_id; |
4751 | int ep_index; |
4752 | struct xhci_td *td = 0; |
4753 | dma_addr_t event_dma; |
4754 | @@ -814,9 +874,11 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4755 | struct urb *urb = 0; |
4756 | int status = -EINPROGRESS; |
4757 | struct xhci_ep_ctx *ep_ctx; |
4758 | + u32 trb_comp_code; |
4759 | |
4760 | xhci_dbg(xhci, "In %s\n", __func__); |
4761 | - xdev = xhci->devs[TRB_TO_SLOT_ID(event->flags)]; |
4762 | + slot_id = TRB_TO_SLOT_ID(event->flags); |
4763 | + xdev = xhci->devs[slot_id]; |
4764 | if (!xdev) { |
4765 | xhci_err(xhci, "ERROR Transfer event pointed to bad slot\n"); |
4766 | return -ENODEV; |
4767 | @@ -870,7 +932,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4768 | (unsigned int) event->flags); |
4769 | |
4770 | /* Look for common error cases */ |
4771 | - switch (GET_COMP_CODE(event->transfer_len)) { |
4772 | + trb_comp_code = GET_COMP_CODE(event->transfer_len); |
4773 | + switch (trb_comp_code) { |
4774 | /* Skip codes that require special handling depending on |
4775 | * transfer type |
4776 | */ |
4777 | @@ -913,7 +976,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4778 | /* Was this a control transfer? */ |
4779 | if (usb_endpoint_xfer_control(&td->urb->ep->desc)) { |
4780 | xhci_debug_trb(xhci, xhci->event_ring->dequeue); |
4781 | - switch (GET_COMP_CODE(event->transfer_len)) { |
4782 | + switch (trb_comp_code) { |
4783 | case COMP_SUCCESS: |
4784 | if (event_trb == ep_ring->dequeue) { |
4785 | xhci_warn(xhci, "WARN: Success on ctrl setup TRB without IOC set??\n"); |
4786 | @@ -928,8 +991,39 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4787 | break; |
4788 | case COMP_SHORT_TX: |
4789 | xhci_warn(xhci, "WARN: short transfer on control ep\n"); |
4790 | - status = -EREMOTEIO; |
4791 | + if (td->urb->transfer_flags & URB_SHORT_NOT_OK) |
4792 | + status = -EREMOTEIO; |
4793 | + else |
4794 | + status = 0; |
4795 | break; |
4796 | + case COMP_BABBLE: |
4797 | + /* The 0.96 spec says a babbling control endpoint |
4798 | + * is not halted. The 0.96 spec says it is. Some HW |
4799 | + * claims to be 0.95 compliant, but it halts the control |
4800 | + * endpoint anyway. Check if a babble halted the |
4801 | + * endpoint. |
4802 | + */ |
4803 | + if (ep_ctx->ep_info != EP_STATE_HALTED) |
4804 | + break; |
4805 | + /* else fall through */ |
4806 | + case COMP_STALL: |
4807 | + /* Did we transfer part of the data (middle) phase? */ |
4808 | + if (event_trb != ep_ring->dequeue && |
4809 | + event_trb != td->last_trb) |
4810 | + td->urb->actual_length = |
4811 | + td->urb->transfer_buffer_length |
4812 | + - TRB_LEN(event->transfer_len); |
4813 | + else |
4814 | + td->urb->actual_length = 0; |
4815 | + |
4816 | + ep_ring->stopped_td = td; |
4817 | + ep_ring->stopped_trb = event_trb; |
4818 | + xhci_queue_reset_ep(xhci, slot_id, ep_index); |
4819 | + xhci_cleanup_stalled_ring(xhci, |
4820 | + td->urb->dev, |
4821 | + ep_index, ep_ring); |
4822 | + xhci_ring_cmd_db(xhci); |
4823 | + goto td_cleanup; |
4824 | default: |
4825 | /* Others already handled above */ |
4826 | break; |
4827 | @@ -943,7 +1037,10 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4828 | if (event_trb == td->last_trb) { |
4829 | if (td->urb->actual_length != 0) { |
4830 | /* Don't overwrite a previously set error code */ |
4831 | - if (status == -EINPROGRESS || status == 0) |
4832 | + if ((status == -EINPROGRESS || |
4833 | + status == 0) && |
4834 | + (td->urb->transfer_flags |
4835 | + & URB_SHORT_NOT_OK)) |
4836 | /* Did we already see a short data stage? */ |
4837 | status = -EREMOTEIO; |
4838 | } else { |
4839 | @@ -952,7 +1049,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4840 | } |
4841 | } else { |
4842 | /* Maybe the event was for the data stage? */ |
4843 | - if (GET_COMP_CODE(event->transfer_len) != COMP_STOP_INVAL) { |
4844 | + if (trb_comp_code != COMP_STOP_INVAL) { |
4845 | /* We didn't stop on a link TRB in the middle */ |
4846 | td->urb->actual_length = |
4847 | td->urb->transfer_buffer_length - |
4848 | @@ -964,7 +1061,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4849 | } |
4850 | } |
4851 | } else { |
4852 | - switch (GET_COMP_CODE(event->transfer_len)) { |
4853 | + switch (trb_comp_code) { |
4854 | case COMP_SUCCESS: |
4855 | /* Double check that the HW transferred everything. */ |
4856 | if (event_trb != td->last_trb) { |
4857 | @@ -975,7 +1072,12 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4858 | else |
4859 | status = 0; |
4860 | } else { |
4861 | - xhci_dbg(xhci, "Successful bulk transfer!\n"); |
4862 | + if (usb_endpoint_xfer_bulk(&td->urb->ep->desc)) |
4863 | + xhci_dbg(xhci, "Successful bulk " |
4864 | + "transfer!\n"); |
4865 | + else |
4866 | + xhci_dbg(xhci, "Successful interrupt " |
4867 | + "transfer!\n"); |
4868 | status = 0; |
4869 | } |
4870 | break; |
4871 | @@ -1001,11 +1103,17 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4872 | td->urb->actual_length = |
4873 | td->urb->transfer_buffer_length - |
4874 | TRB_LEN(event->transfer_len); |
4875 | - if (td->urb->actual_length < 0) { |
4876 | + if (td->urb->transfer_buffer_length < |
4877 | + td->urb->actual_length) { |
4878 | xhci_warn(xhci, "HC gave bad length " |
4879 | "of %d bytes left\n", |
4880 | TRB_LEN(event->transfer_len)); |
4881 | td->urb->actual_length = 0; |
4882 | + if (td->urb->transfer_flags & |
4883 | + URB_SHORT_NOT_OK) |
4884 | + status = -EREMOTEIO; |
4885 | + else |
4886 | + status = 0; |
4887 | } |
4888 | /* Don't overwrite a previously set error code */ |
4889 | if (status == -EINPROGRESS) { |
4890 | @@ -1041,14 +1149,14 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4891 | /* If the ring didn't stop on a Link or No-op TRB, add |
4892 | * in the actual bytes transferred from the Normal TRB |
4893 | */ |
4894 | - if (GET_COMP_CODE(event->transfer_len) != COMP_STOP_INVAL) |
4895 | + if (trb_comp_code != COMP_STOP_INVAL) |
4896 | td->urb->actual_length += |
4897 | TRB_LEN(cur_trb->generic.field[2]) - |
4898 | TRB_LEN(event->transfer_len); |
4899 | } |
4900 | } |
4901 | - if (GET_COMP_CODE(event->transfer_len) == COMP_STOP_INVAL || |
4902 | - GET_COMP_CODE(event->transfer_len) == COMP_STOP) { |
4903 | + if (trb_comp_code == COMP_STOP_INVAL || |
4904 | + trb_comp_code == COMP_STOP) { |
4905 | /* The Endpoint Stop Command completion will take care of any |
4906 | * stopped TDs. A stopped TD may be restarted, so don't update |
4907 | * the ring dequeue pointer or take this TD off any lists yet. |
4908 | @@ -1056,7 +1164,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4909 | ep_ring->stopped_td = td; |
4910 | ep_ring->stopped_trb = event_trb; |
4911 | } else { |
4912 | - if (GET_COMP_CODE(event->transfer_len) == COMP_STALL) { |
4913 | + if (trb_comp_code == COMP_STALL || |
4914 | + trb_comp_code == COMP_BABBLE) { |
4915 | /* The transfer is completed from the driver's |
4916 | * perspective, but we need to issue a set dequeue |
4917 | * command for this stalled endpoint to move the dequeue |
4918 | @@ -1072,16 +1181,41 @@ static int handle_tx_event(struct xhci_hcd *xhci, |
4919 | inc_deq(xhci, ep_ring, false); |
4920 | } |
4921 | |
4922 | +td_cleanup: |
4923 | /* Clean up the endpoint's TD list */ |
4924 | urb = td->urb; |
4925 | + /* Do one last check of the actual transfer length. |
4926 | + * If the host controller said we transferred more data than |
4927 | + * the buffer length, urb->actual_length will be a very big |
4928 | + * number (since it's unsigned). Play it safe and say we didn't |
4929 | + * transfer anything. |
4930 | + */ |
4931 | + if (urb->actual_length > urb->transfer_buffer_length) { |
4932 | + xhci_warn(xhci, "URB transfer length is wrong, " |
4933 | + "xHC issue? req. len = %u, " |
4934 | + "act. len = %u\n", |
4935 | + urb->transfer_buffer_length, |
4936 | + urb->actual_length); |
4937 | + urb->actual_length = 0; |
4938 | + if (td->urb->transfer_flags & URB_SHORT_NOT_OK) |
4939 | + status = -EREMOTEIO; |
4940 | + else |
4941 | + status = 0; |
4942 | + } |
4943 | list_del(&td->td_list); |
4944 | /* Was this TD slated to be cancelled but completed anyway? */ |
4945 | if (!list_empty(&td->cancelled_td_list)) { |
4946 | list_del(&td->cancelled_td_list); |
4947 | ep_ring->cancels_pending--; |
4948 | } |
4949 | - /* Leave the TD around for the reset endpoint function to use */ |
4950 | - if (GET_COMP_CODE(event->transfer_len) != COMP_STALL) { |
4951 | + /* Leave the TD around for the reset endpoint function to use |
4952 | + * (but only if it's not a control endpoint, since we already |
4953 | + * queued the Set TR dequeue pointer command for stalled |
4954 | + * control endpoints). |
4955 | + */ |
4956 | + if (usb_endpoint_xfer_control(&urb->ep->desc) || |
4957 | + (trb_comp_code != COMP_STALL && |
4958 | + trb_comp_code != COMP_BABBLE)) { |
4959 | kfree(td); |
4960 | } |
4961 | urb->hcpriv = NULL; |
4962 | @@ -1094,7 +1228,7 @@ cleanup: |
4963 | if (urb) { |
4964 | usb_hcd_unlink_urb_from_ep(xhci_to_hcd(xhci), urb); |
4965 | xhci_dbg(xhci, "Giveback URB %p, len = %d, status = %d\n", |
4966 | - urb, td->urb->actual_length, status); |
4967 | + urb, urb->actual_length, status); |
4968 | spin_unlock(&xhci->lock); |
4969 | usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, status); |
4970 | spin_lock(&xhci->lock); |
4971 | @@ -1335,6 +1469,47 @@ static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id, |
4972 | ring_ep_doorbell(xhci, slot_id, ep_index); |
4973 | } |
4974 | |
4975 | +/* |
4976 | + * xHCI uses normal TRBs for both bulk and interrupt. When the interrupt |
4977 | + * endpoint is to be serviced, the xHC will consume (at most) one TD. A TD |
4978 | + * (comprised of sg list entries) can take several service intervals to |
4979 | + * transmit. |
4980 | + */ |
4981 | +int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, |
4982 | + struct urb *urb, int slot_id, unsigned int ep_index) |
4983 | +{ |
4984 | + struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, |
4985 | + xhci->devs[slot_id]->out_ctx, ep_index); |
4986 | + int xhci_interval; |
4987 | + int ep_interval; |
4988 | + |
4989 | + xhci_interval = EP_INTERVAL_TO_UFRAMES(ep_ctx->ep_info); |
4990 | + ep_interval = urb->interval; |
4991 | + /* Convert to microframes */ |
4992 | + if (urb->dev->speed == USB_SPEED_LOW || |
4993 | + urb->dev->speed == USB_SPEED_FULL) |
4994 | + ep_interval *= 8; |
4995 | + /* FIXME change this to a warning and a suggestion to use the new API |
4996 | + * to set the polling interval (once the API is added). |
4997 | + */ |
4998 | + if (xhci_interval != ep_interval) { |
4999 | + if (!printk_ratelimit()) |
5000 | + dev_dbg(&urb->dev->dev, "Driver uses different interval" |
5001 | + " (%d microframe%s) than xHCI " |
5002 | + "(%d microframe%s)\n", |
5003 | + ep_interval, |
5004 | + ep_interval == 1 ? "" : "s", |
5005 | + xhci_interval, |
5006 | + xhci_interval == 1 ? "" : "s"); |
5007 | + urb->interval = xhci_interval; |
5008 | + /* Convert back to frames for LS/FS devices */ |
5009 | + if (urb->dev->speed == USB_SPEED_LOW || |
5010 | + urb->dev->speed == USB_SPEED_FULL) |
5011 | + urb->interval /= 8; |
5012 | + } |
5013 | + return xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); |
5014 | +} |
5015 | + |
5016 | static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, |
5017 | struct urb *urb, int slot_id, unsigned int ep_index) |
5018 | { |
5019 | @@ -1733,6 +1908,15 @@ int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, |
5020 | TRB_TYPE(TRB_CONFIG_EP) | SLOT_ID_FOR_TRB(slot_id)); |
5021 | } |
5022 | |
5023 | +/* Queue an evaluate context command TRB */ |
5024 | +int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, |
5025 | + u32 slot_id) |
5026 | +{ |
5027 | + return queue_command(xhci, lower_32_bits(in_ctx_ptr), |
5028 | + upper_32_bits(in_ctx_ptr), 0, |
5029 | + TRB_TYPE(TRB_EVAL_CONTEXT) | SLOT_ID_FOR_TRB(slot_id)); |
5030 | +} |
5031 | + |
5032 | int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id, |
5033 | unsigned int ep_index) |
5034 | { |
5035 | diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h |
5036 | index d31d322..8085841 100644 |
5037 | --- a/drivers/usb/host/xhci.h |
5038 | +++ b/drivers/usb/host/xhci.h |
5039 | @@ -581,6 +581,7 @@ struct xhci_ep_ctx { |
5040 | /* bit 15 is Linear Stream Array */ |
5041 | /* Interval - period between requests to an endpoint - 125u increments. */ |
5042 | #define EP_INTERVAL(p) ((p & 0xff) << 16) |
5043 | +#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) |
5044 | |
5045 | /* ep_info2 bitmasks */ |
5046 | /* |
5047 | @@ -589,6 +590,7 @@ struct xhci_ep_ctx { |
5048 | */ |
5049 | #define FORCE_EVENT (0x1) |
5050 | #define ERROR_COUNT(p) (((p) & 0x3) << 1) |
5051 | +#define CTX_TO_EP_TYPE(p) (((p) >> 3) & 0x7) |
5052 | #define EP_TYPE(p) ((p) << 3) |
5053 | #define ISOC_OUT_EP 1 |
5054 | #define BULK_OUT_EP 2 |
5055 | @@ -601,6 +603,8 @@ struct xhci_ep_ctx { |
5056 | /* bit 7 is Host Initiate Disable - for disabling stream selection */ |
5057 | #define MAX_BURST(p) (((p)&0xff) << 8) |
5058 | #define MAX_PACKET(p) (((p)&0xffff) << 16) |
5059 | +#define MAX_PACKET_MASK (0xffff << 16) |
5060 | +#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) |
5061 | |
5062 | |
5063 | /** |
5064 | @@ -926,6 +930,12 @@ struct xhci_td { |
5065 | union xhci_trb *last_trb; |
5066 | }; |
5067 | |
5068 | +struct xhci_dequeue_state { |
5069 | + struct xhci_segment *new_deq_seg; |
5070 | + union xhci_trb *new_deq_ptr; |
5071 | + int new_cycle_state; |
5072 | +}; |
5073 | + |
5074 | struct xhci_ring { |
5075 | struct xhci_segment *first_seg; |
5076 | union xhci_trb *enqueue; |
5077 | @@ -952,12 +962,6 @@ struct xhci_ring { |
5078 | u32 cycle_state; |
5079 | }; |
5080 | |
5081 | -struct xhci_dequeue_state { |
5082 | - struct xhci_segment *new_deq_seg; |
5083 | - union xhci_trb *new_deq_ptr; |
5084 | - int new_cycle_state; |
5085 | -}; |
5086 | - |
5087 | struct xhci_erst_entry { |
5088 | /* 64-bit event ring segment address */ |
5089 | u64 seg_addr; |
5090 | @@ -1058,6 +1062,9 @@ struct xhci_hcd { |
5091 | int noops_submitted; |
5092 | int noops_handled; |
5093 | int error_bitmask; |
5094 | + unsigned int quirks; |
5095 | +#define XHCI_LINK_TRB_QUIRK (1 << 0) |
5096 | +#define XHCI_RESET_EP_QUIRK (1 << 1) |
5097 | }; |
5098 | |
5099 | /* For testing purposes */ |
5100 | @@ -1136,6 +1143,13 @@ static inline void xhci_write_64(struct xhci_hcd *xhci, |
5101 | writel(val_hi, ptr + 1); |
5102 | } |
5103 | |
5104 | +static inline int xhci_link_trb_quirk(struct xhci_hcd *xhci) |
5105 | +{ |
5106 | + u32 temp = xhci_readl(xhci, &xhci->cap_regs->hc_capbase); |
5107 | + return ((HC_VERSION(temp) == 0x95) && |
5108 | + (xhci->quirks & XHCI_LINK_TRB_QUIRK)); |
5109 | +} |
5110 | + |
5111 | /* xHCI debugging */ |
5112 | void xhci_print_ir_set(struct xhci_hcd *xhci, struct xhci_intr_reg *ir_set, int set_num); |
5113 | void xhci_print_registers(struct xhci_hcd *xhci); |
5114 | @@ -1158,7 +1172,12 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device |
5115 | int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev); |
5116 | unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc); |
5117 | unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc); |
5118 | +unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index); |
5119 | +unsigned int xhci_last_valid_endpoint(u32 added_ctxs); |
5120 | void xhci_endpoint_zero(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_host_endpoint *ep); |
5121 | +void xhci_endpoint_copy(struct xhci_hcd *xhci, |
5122 | + struct xhci_virt_device *vdev, unsigned int ep_index); |
5123 | +void xhci_slot_copy(struct xhci_hcd *xhci, struct xhci_virt_device *vdev); |
5124 | int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, |
5125 | struct usb_device *udev, struct usb_host_endpoint *ep, |
5126 | gfp_t mem_flags); |
5127 | @@ -1205,8 +1224,12 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, |
5128 | int slot_id, unsigned int ep_index); |
5129 | int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, |
5130 | int slot_id, unsigned int ep_index); |
5131 | +int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, |
5132 | + int slot_id, unsigned int ep_index); |
5133 | int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, |
5134 | u32 slot_id); |
5135 | +int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, |
5136 | + u32 slot_id); |
5137 | int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id, |
5138 | unsigned int ep_index); |
5139 | void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, |
5140 | @@ -1215,6 +1238,12 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, |
5141 | void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci, |
5142 | struct xhci_ring *ep_ring, unsigned int slot_id, |
5143 | unsigned int ep_index, struct xhci_dequeue_state *deq_state); |
5144 | +void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, |
5145 | + struct usb_device *udev, |
5146 | + unsigned int ep_index, struct xhci_ring *ep_ring); |
5147 | +void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci, |
5148 | + unsigned int slot_id, unsigned int ep_index, |
5149 | + struct xhci_dequeue_state *deq_state); |
5150 | |
5151 | /* xHCI roothub code */ |
5152 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, |
5153 | diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c |
5154 | index aec6188..1a50beb 100644 |
5155 | --- a/drivers/usb/serial/ark3116.c |
5156 | +++ b/drivers/usb/serial/ark3116.c |
5157 | @@ -35,11 +35,6 @@ static struct usb_device_id id_table [] = { |
5158 | }; |
5159 | MODULE_DEVICE_TABLE(usb, id_table); |
5160 | |
5161 | -struct ark3116_private { |
5162 | - spinlock_t lock; |
5163 | - u8 termios_initialized; |
5164 | -}; |
5165 | - |
5166 | static inline void ARK3116_SND(struct usb_serial *serial, int seq, |
5167 | __u8 request, __u8 requesttype, |
5168 | __u16 value, __u16 index) |
5169 | @@ -82,22 +77,11 @@ static inline void ARK3116_RCV_QUIET(struct usb_serial *serial, |
5170 | static int ark3116_attach(struct usb_serial *serial) |
5171 | { |
5172 | char *buf; |
5173 | - struct ark3116_private *priv; |
5174 | - int i; |
5175 | - |
5176 | - for (i = 0; i < serial->num_ports; ++i) { |
5177 | - priv = kzalloc(sizeof(struct ark3116_private), GFP_KERNEL); |
5178 | - if (!priv) |
5179 | - goto cleanup; |
5180 | - spin_lock_init(&priv->lock); |
5181 | - |
5182 | - usb_set_serial_port_data(serial->port[i], priv); |
5183 | - } |
5184 | |
5185 | buf = kmalloc(1, GFP_KERNEL); |
5186 | if (!buf) { |
5187 | dbg("error kmalloc -> out of mem?"); |
5188 | - goto cleanup; |
5189 | + return -ENOMEM; |
5190 | } |
5191 | |
5192 | /* 3 */ |
5193 | @@ -149,13 +133,16 @@ static int ark3116_attach(struct usb_serial *serial) |
5194 | |
5195 | kfree(buf); |
5196 | return 0; |
5197 | +} |
5198 | |
5199 | -cleanup: |
5200 | - for (--i; i >= 0; --i) { |
5201 | - kfree(usb_get_serial_port_data(serial->port[i])); |
5202 | - usb_set_serial_port_data(serial->port[i], NULL); |
5203 | - } |
5204 | - return -ENOMEM; |
5205 | +static void ark3116_init_termios(struct tty_struct *tty) |
5206 | +{ |
5207 | + struct ktermios *termios = tty->termios; |
5208 | + *termios = tty_std_termios; |
5209 | + termios->c_cflag = B9600 | CS8 |
5210 | + | CREAD | HUPCL | CLOCAL; |
5211 | + termios->c_ispeed = 9600; |
5212 | + termios->c_ospeed = 9600; |
5213 | } |
5214 | |
5215 | static void ark3116_set_termios(struct tty_struct *tty, |
5216 | @@ -163,10 +150,8 @@ static void ark3116_set_termios(struct tty_struct *tty, |
5217 | struct ktermios *old_termios) |
5218 | { |
5219 | struct usb_serial *serial = port->serial; |
5220 | - struct ark3116_private *priv = usb_get_serial_port_data(port); |
5221 | struct ktermios *termios = tty->termios; |
5222 | unsigned int cflag = termios->c_cflag; |
5223 | - unsigned long flags; |
5224 | int baud; |
5225 | int ark3116_baud; |
5226 | char *buf; |
5227 | @@ -176,16 +161,6 @@ static void ark3116_set_termios(struct tty_struct *tty, |
5228 | |
5229 | dbg("%s - port %d", __func__, port->number); |
5230 | |
5231 | - spin_lock_irqsave(&priv->lock, flags); |
5232 | - if (!priv->termios_initialized) { |
5233 | - *termios = tty_std_termios; |
5234 | - termios->c_cflag = B9600 | CS8 |
5235 | - | CREAD | HUPCL | CLOCAL; |
5236 | - termios->c_ispeed = 9600; |
5237 | - termios->c_ospeed = 9600; |
5238 | - priv->termios_initialized = 1; |
5239 | - } |
5240 | - spin_unlock_irqrestore(&priv->lock, flags); |
5241 | |
5242 | cflag = termios->c_cflag; |
5243 | termios->c_cflag &= ~(CMSPAR|CRTSCTS); |
5244 | @@ -455,6 +430,7 @@ static struct usb_serial_driver ark3116_device = { |
5245 | .num_ports = 1, |
5246 | .attach = ark3116_attach, |
5247 | .set_termios = ark3116_set_termios, |
5248 | + .init_termios = ark3116_init_termios, |
5249 | .ioctl = ark3116_ioctl, |
5250 | .tiocmget = ark3116_tiocmget, |
5251 | .open = ark3116_open, |
5252 | diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c |
5253 | index 0e4f2e4..3e49b2e 100644 |
5254 | --- a/drivers/usb/serial/console.c |
5255 | +++ b/drivers/usb/serial/console.c |
5256 | @@ -16,6 +16,7 @@ |
5257 | #include <linux/slab.h> |
5258 | #include <linux/tty.h> |
5259 | #include <linux/console.h> |
5260 | +#include <linux/serial.h> |
5261 | #include <linux/usb.h> |
5262 | #include <linux/usb/serial.h> |
5263 | |
5264 | @@ -63,7 +64,7 @@ static int usb_console_setup(struct console *co, char *options) |
5265 | char *s; |
5266 | struct usb_serial *serial; |
5267 | struct usb_serial_port *port; |
5268 | - int retval = 0; |
5269 | + int retval; |
5270 | struct tty_struct *tty = NULL; |
5271 | struct ktermios *termios = NULL, dummy; |
5272 | |
5273 | @@ -116,13 +117,17 @@ static int usb_console_setup(struct console *co, char *options) |
5274 | return -ENODEV; |
5275 | } |
5276 | |
5277 | - port = serial->port[0]; |
5278 | + retval = usb_autopm_get_interface(serial->interface); |
5279 | + if (retval) |
5280 | + goto error_get_interface; |
5281 | + |
5282 | + port = serial->port[co->index - serial->minor]; |
5283 | tty_port_tty_set(&port->port, NULL); |
5284 | |
5285 | info->port = port; |
5286 | |
5287 | ++port->port.count; |
5288 | - if (port->port.count == 1) { |
5289 | + if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) { |
5290 | if (serial->type->set_termios) { |
5291 | /* |
5292 | * allocate a fake tty so the driver can initialize |
5293 | @@ -168,6 +173,7 @@ static int usb_console_setup(struct console *co, char *options) |
5294 | kfree(termios); |
5295 | kfree(tty); |
5296 | } |
5297 | + set_bit(ASYNCB_INITIALIZED, &port->port.flags); |
5298 | } |
5299 | /* Now that any required fake tty operations are completed restore |
5300 | * the tty port count */ |
5301 | @@ -175,18 +181,22 @@ static int usb_console_setup(struct console *co, char *options) |
5302 | /* The console is special in terms of closing the device so |
5303 | * indicate this port is now acting as a system console. */ |
5304 | port->console = 1; |
5305 | - retval = 0; |
5306 | |
5307 | -out: |
5308 | + mutex_unlock(&serial->disc_mutex); |
5309 | return retval; |
5310 | -free_termios: |
5311 | + |
5312 | + free_termios: |
5313 | kfree(termios); |
5314 | tty_port_tty_set(&port->port, NULL); |
5315 | -free_tty: |
5316 | + free_tty: |
5317 | kfree(tty); |
5318 | -reset_open_count: |
5319 | + reset_open_count: |
5320 | port->port.count = 0; |
5321 | - goto out; |
5322 | + usb_autopm_put_interface(serial->interface); |
5323 | + error_get_interface: |
5324 | + usb_serial_put(serial); |
5325 | + mutex_unlock(&serial->disc_mutex); |
5326 | + return retval; |
5327 | } |
5328 | |
5329 | static void usb_console_write(struct console *co, |
5330 | diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c |
5331 | index 985cbcf..b5275c4 100644 |
5332 | --- a/drivers/usb/serial/cp210x.c |
5333 | +++ b/drivers/usb/serial/cp210x.c |
5334 | @@ -399,12 +399,6 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port, |
5335 | |
5336 | /* Configure the termios structure */ |
5337 | cp210x_get_termios(tty, port); |
5338 | - |
5339 | - /* Set the DTR and RTS pins low */ |
5340 | - cp210x_tiocmset_port(tty ? (struct usb_serial_port *) tty->driver_data |
5341 | - : port, |
5342 | - NULL, TIOCM_DTR | TIOCM_RTS, 0); |
5343 | - |
5344 | return 0; |
5345 | } |
5346 | |
5347 | diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c |
5348 | index 59adfe1..27b5a27 100644 |
5349 | --- a/drivers/usb/serial/cypress_m8.c |
5350 | +++ b/drivers/usb/serial/cypress_m8.c |
5351 | @@ -659,15 +659,7 @@ static int cypress_open(struct tty_struct *tty, |
5352 | spin_unlock_irqrestore(&priv->lock, flags); |
5353 | |
5354 | /* Set termios */ |
5355 | - result = cypress_write(tty, port, NULL, 0); |
5356 | - |
5357 | - if (result) { |
5358 | - dev_err(&port->dev, |
5359 | - "%s - failed setting the control lines - error %d\n", |
5360 | - __func__, result); |
5361 | - return result; |
5362 | - } else |
5363 | - dbg("%s - success setting the control lines", __func__); |
5364 | + cypress_send(port); |
5365 | |
5366 | if (tty) |
5367 | cypress_set_termios(tty, port, &priv->tmp_termios); |
5368 | @@ -1005,6 +997,8 @@ static void cypress_set_termios(struct tty_struct *tty, |
5369 | dbg("%s - port %d", __func__, port->number); |
5370 | |
5371 | spin_lock_irqsave(&priv->lock, flags); |
5372 | + /* We can't clean this one up as we don't know the device type |
5373 | + early enough */ |
5374 | if (!priv->termios_initialized) { |
5375 | if (priv->chiptype == CT_EARTHMATE) { |
5376 | *(tty->termios) = tty_std_termios; |
5377 | diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c |
5378 | index 80cb347..3433f9d 100644 |
5379 | --- a/drivers/usb/serial/empeg.c |
5380 | +++ b/drivers/usb/serial/empeg.c |
5381 | @@ -90,8 +90,7 @@ static int empeg_chars_in_buffer(struct tty_struct *tty); |
5382 | static void empeg_throttle(struct tty_struct *tty); |
5383 | static void empeg_unthrottle(struct tty_struct *tty); |
5384 | static int empeg_startup(struct usb_serial *serial); |
5385 | -static void empeg_set_termios(struct tty_struct *tty, |
5386 | - struct usb_serial_port *port, struct ktermios *old_termios); |
5387 | +static void empeg_init_termios(struct tty_struct *tty); |
5388 | static void empeg_write_bulk_callback(struct urb *urb); |
5389 | static void empeg_read_bulk_callback(struct urb *urb); |
5390 | |
5391 | @@ -123,7 +122,7 @@ static struct usb_serial_driver empeg_device = { |
5392 | .throttle = empeg_throttle, |
5393 | .unthrottle = empeg_unthrottle, |
5394 | .attach = empeg_startup, |
5395 | - .set_termios = empeg_set_termios, |
5396 | + .init_termios = empeg_init_termios, |
5397 | .write = empeg_write, |
5398 | .write_room = empeg_write_room, |
5399 | .chars_in_buffer = empeg_chars_in_buffer, |
5400 | @@ -150,9 +149,6 @@ static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, |
5401 | |
5402 | dbg("%s - port %d", __func__, port->number); |
5403 | |
5404 | - /* Force default termio settings */ |
5405 | - empeg_set_termios(tty, port, NULL) ; |
5406 | - |
5407 | bytes_in = 0; |
5408 | bytes_out = 0; |
5409 | |
5410 | @@ -425,11 +421,9 @@ static int empeg_startup(struct usb_serial *serial) |
5411 | } |
5412 | |
5413 | |
5414 | -static void empeg_set_termios(struct tty_struct *tty, |
5415 | - struct usb_serial_port *port, struct ktermios *old_termios) |
5416 | +static void empeg_init_termios(struct tty_struct *tty) |
5417 | { |
5418 | struct ktermios *termios = tty->termios; |
5419 | - dbg("%s - port %d", __func__, port->number); |
5420 | |
5421 | /* |
5422 | * The empeg-car player wants these particular tty settings. |
5423 | diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c |
5424 | index 8fec5d4..0cc78f9 100644 |
5425 | --- a/drivers/usb/serial/ftdi_sio.c |
5426 | +++ b/drivers/usb/serial/ftdi_sio.c |
5427 | @@ -176,6 +176,9 @@ static struct usb_device_id id_table_combined [] = { |
5428 | { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, |
5429 | { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, |
5430 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, |
5431 | + { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_SNIFFER_PID) }, |
5432 | + { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) }, |
5433 | + { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) }, |
5434 | { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, |
5435 | { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, |
5436 | { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) }, |
5437 | @@ -694,6 +697,8 @@ static struct usb_device_id id_table_combined [] = { |
5438 | { USB_DEVICE(DE_VID, WHT_PID) }, |
5439 | { USB_DEVICE(ADI_VID, ADI_GNICE_PID), |
5440 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
5441 | + { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), |
5442 | + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
5443 | { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, |
5444 | { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), |
5445 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
5446 | @@ -702,6 +707,8 @@ static struct usb_device_id id_table_combined [] = { |
5447 | { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) }, |
5448 | { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID), |
5449 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
5450 | + { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, |
5451 | + { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) }, |
5452 | { }, /* Optional parameter entry */ |
5453 | { } /* Terminating entry */ |
5454 | }; |
5455 | diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h |
5456 | index 8c92b88..6f31e0d 100644 |
5457 | --- a/drivers/usb/serial/ftdi_sio.h |
5458 | +++ b/drivers/usb/serial/ftdi_sio.h |
5459 | @@ -81,6 +81,9 @@ |
5460 | |
5461 | /* OpenDCC (www.opendcc.de) product id */ |
5462 | #define FTDI_OPENDCC_PID 0xBFD8 |
5463 | +#define FTDI_OPENDCC_SNIFFER_PID 0xBFD9 |
5464 | +#define FTDI_OPENDCC_THROTTLE_PID 0xBFDA |
5465 | +#define FTDI_OPENDCC_GATEWAY_PID 0xBFDB |
5466 | |
5467 | /* Sprog II (Andrew Crosland's SprogII DCC interface) */ |
5468 | #define FTDI_SPROG_II 0xF0C8 |
5469 | @@ -930,6 +933,7 @@ |
5470 | */ |
5471 | #define ADI_VID 0x0456 |
5472 | #define ADI_GNICE_PID 0xF000 |
5473 | +#define ADI_GNICEPLUS_PID 0xF001 |
5474 | |
5475 | /* |
5476 | * JETI SPECTROMETER SPECBOS 1201 |
5477 | @@ -968,6 +972,12 @@ |
5478 | #define MARVELL_OPENRD_PID 0x9e90 |
5479 | |
5480 | /* |
5481 | + * Hameg HO820 and HO870 interface (using VID 0x0403) |
5482 | + */ |
5483 | +#define HAMEG_HO820_PID 0xed74 |
5484 | +#define HAMEG_HO870_PID 0xed71 |
5485 | + |
5486 | +/* |
5487 | * BmRequestType: 1100 0000b |
5488 | * bRequest: FTDI_E2_READ |
5489 | * wValue: 0 |
5490 | diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c |
5491 | index 96873a7..af6df6c 100644 |
5492 | --- a/drivers/usb/serial/iuu_phoenix.c |
5493 | +++ b/drivers/usb/serial/iuu_phoenix.c |
5494 | @@ -71,7 +71,6 @@ struct iuu_private { |
5495 | spinlock_t lock; /* store irq state */ |
5496 | wait_queue_head_t delta_msr_wait; |
5497 | u8 line_status; |
5498 | - u8 termios_initialized; |
5499 | int tiostatus; /* store IUART SIGNAL for tiocmget call */ |
5500 | u8 reset; /* if 1 reset is needed */ |
5501 | int poll; /* number of poll */ |
5502 | @@ -1018,6 +1017,18 @@ static void iuu_close(struct usb_serial_port *port) |
5503 | } |
5504 | } |
5505 | |
5506 | +static void iuu_init_termios(struct tty_struct *tty) |
5507 | +{ |
5508 | + *(tty->termios) = tty_std_termios; |
5509 | + tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 |
5510 | + | TIOCM_CTS | CSTOPB | PARENB; |
5511 | + tty->termios->c_ispeed = 9600; |
5512 | + tty->termios->c_ospeed = 9600; |
5513 | + tty->termios->c_lflag = 0; |
5514 | + tty->termios->c_oflag = 0; |
5515 | + tty->termios->c_iflag = 0; |
5516 | +} |
5517 | + |
5518 | static int iuu_open(struct tty_struct *tty, |
5519 | struct usb_serial_port *port, struct file *filp) |
5520 | { |
5521 | @@ -1025,7 +1036,6 @@ static int iuu_open(struct tty_struct *tty, |
5522 | u8 *buf; |
5523 | int result; |
5524 | u32 actual; |
5525 | - unsigned long flags; |
5526 | struct iuu_private *priv = usb_get_serial_port_data(port); |
5527 | |
5528 | dbg("%s - port %d", __func__, port->number); |
5529 | @@ -1064,21 +1074,7 @@ static int iuu_open(struct tty_struct *tty, |
5530 | port->bulk_in_buffer, 512, |
5531 | NULL, NULL); |
5532 | |
5533 | - /* set the termios structure */ |
5534 | - spin_lock_irqsave(&priv->lock, flags); |
5535 | - if (tty && !priv->termios_initialized) { |
5536 | - *(tty->termios) = tty_std_termios; |
5537 | - tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 |
5538 | - | TIOCM_CTS | CSTOPB | PARENB; |
5539 | - tty->termios->c_ispeed = 9600; |
5540 | - tty->termios->c_ospeed = 9600; |
5541 | - tty->termios->c_lflag = 0; |
5542 | - tty->termios->c_oflag = 0; |
5543 | - tty->termios->c_iflag = 0; |
5544 | - priv->termios_initialized = 1; |
5545 | - priv->poll = 0; |
5546 | - } |
5547 | - spin_unlock_irqrestore(&priv->lock, flags); |
5548 | + priv->poll = 0; |
5549 | |
5550 | /* initialize writebuf */ |
5551 | #define FISH(a, b, c, d) do { \ |
5552 | @@ -1201,6 +1197,7 @@ static struct usb_serial_driver iuu_device = { |
5553 | .tiocmget = iuu_tiocmget, |
5554 | .tiocmset = iuu_tiocmset, |
5555 | .set_termios = iuu_set_termios, |
5556 | + .init_termios = iuu_init_termios, |
5557 | .attach = iuu_startup, |
5558 | .release = iuu_release, |
5559 | }; |
5560 | diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c |
5561 | index 6db0e56..46d47d1 100644 |
5562 | --- a/drivers/usb/serial/kobil_sct.c |
5563 | +++ b/drivers/usb/serial/kobil_sct.c |
5564 | @@ -85,7 +85,7 @@ static void kobil_read_int_callback(struct urb *urb); |
5565 | static void kobil_write_callback(struct urb *purb); |
5566 | static void kobil_set_termios(struct tty_struct *tty, |
5567 | struct usb_serial_port *port, struct ktermios *old); |
5568 | - |
5569 | +static void kobil_init_termios(struct tty_struct *tty); |
5570 | |
5571 | static struct usb_device_id id_table [] = { |
5572 | { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) }, |
5573 | @@ -120,6 +120,7 @@ static struct usb_serial_driver kobil_device = { |
5574 | .release = kobil_release, |
5575 | .ioctl = kobil_ioctl, |
5576 | .set_termios = kobil_set_termios, |
5577 | + .init_termios = kobil_init_termios, |
5578 | .tiocmget = kobil_tiocmget, |
5579 | .tiocmset = kobil_tiocmset, |
5580 | .open = kobil_open, |
5581 | @@ -210,6 +211,15 @@ static void kobil_release(struct usb_serial *serial) |
5582 | kfree(usb_get_serial_port_data(serial->port[i])); |
5583 | } |
5584 | |
5585 | +static void kobil_init_termios(struct tty_struct *tty) |
5586 | +{ |
5587 | + /* Default to echo off and other sane device settings */ |
5588 | + tty->termios->c_lflag = 0; |
5589 | + tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE); |
5590 | + tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; |
5591 | + /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */ |
5592 | + tty->termios->c_oflag &= ~ONLCR; |
5593 | +} |
5594 | |
5595 | static int kobil_open(struct tty_struct *tty, |
5596 | struct usb_serial_port *port, struct file *filp) |
5597 | @@ -226,16 +236,6 @@ static int kobil_open(struct tty_struct *tty, |
5598 | /* someone sets the dev to 0 if the close method has been called */ |
5599 | port->interrupt_in_urb->dev = port->serial->dev; |
5600 | |
5601 | - if (tty) { |
5602 | - |
5603 | - /* Default to echo off and other sane device settings */ |
5604 | - tty->termios->c_lflag = 0; |
5605 | - tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | |
5606 | - XCASE); |
5607 | - tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; |
5608 | - /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */ |
5609 | - tty->termios->c_oflag &= ~ONLCR; |
5610 | - } |
5611 | /* allocate memory for transfer buffer */ |
5612 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); |
5613 | if (!transfer_buffer) |
5614 | diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c |
5615 | index c784ddb..0101548 100644 |
5616 | --- a/drivers/usb/serial/option.c |
5617 | +++ b/drivers/usb/serial/option.c |
5618 | @@ -292,6 +292,7 @@ static int option_resume(struct usb_serial *serial); |
5619 | |
5620 | #define TELIT_VENDOR_ID 0x1bc7 |
5621 | #define TELIT_PRODUCT_UC864E 0x1003 |
5622 | +#define TELIT_PRODUCT_UC864G 0x1004 |
5623 | |
5624 | /* ZTE PRODUCTS */ |
5625 | #define ZTE_VENDOR_ID 0x19d2 |
5626 | @@ -300,6 +301,7 @@ static int option_resume(struct usb_serial *serial); |
5627 | #define ZTE_PRODUCT_MF626 0x0031 |
5628 | #define ZTE_PRODUCT_CDMA_TECH 0xfffe |
5629 | #define ZTE_PRODUCT_AC8710 0xfff1 |
5630 | +#define ZTE_PRODUCT_AC2726 0xfff5 |
5631 | |
5632 | #define BENQ_VENDOR_ID 0x04a5 |
5633 | #define BENQ_PRODUCT_H10 0x4068 |
5634 | @@ -503,6 +505,7 @@ static struct usb_device_id option_ids[] = { |
5635 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ |
5636 | { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ |
5637 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, |
5638 | + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) }, |
5639 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ |
5640 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff) }, |
5641 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0003, 0xff, 0xff, 0xff) }, |
5642 | @@ -572,6 +575,7 @@ static struct usb_device_id option_ids[] = { |
5643 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, |
5644 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, |
5645 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, |
5646 | + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, |
5647 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, |
5648 | { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, |
5649 | { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, |
5650 | diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c |
5651 | index 3cece27..ef34cff 100644 |
5652 | --- a/drivers/usb/serial/oti6858.c |
5653 | +++ b/drivers/usb/serial/oti6858.c |
5654 | @@ -146,6 +146,7 @@ static int oti6858_open(struct tty_struct *tty, |
5655 | static void oti6858_close(struct usb_serial_port *port); |
5656 | static void oti6858_set_termios(struct tty_struct *tty, |
5657 | struct usb_serial_port *port, struct ktermios *old); |
5658 | +static void oti6858_init_termios(struct tty_struct *tty); |
5659 | static int oti6858_ioctl(struct tty_struct *tty, struct file *file, |
5660 | unsigned int cmd, unsigned long arg); |
5661 | static void oti6858_read_int_callback(struct urb *urb); |
5662 | @@ -186,6 +187,7 @@ static struct usb_serial_driver oti6858_device = { |
5663 | .write = oti6858_write, |
5664 | .ioctl = oti6858_ioctl, |
5665 | .set_termios = oti6858_set_termios, |
5666 | + .init_termios = oti6858_init_termios, |
5667 | .tiocmget = oti6858_tiocmget, |
5668 | .tiocmset = oti6858_tiocmset, |
5669 | .read_bulk_callback = oti6858_read_bulk_callback, |
5670 | @@ -206,7 +208,6 @@ struct oti6858_private { |
5671 | struct { |
5672 | u8 read_urb_in_use; |
5673 | u8 write_urb_in_use; |
5674 | - u8 termios_initialized; |
5675 | } flags; |
5676 | struct delayed_work delayed_write_work; |
5677 | |
5678 | @@ -447,6 +448,14 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty) |
5679 | return chars; |
5680 | } |
5681 | |
5682 | +static void oti6858_init_termios(struct tty_struct *tty) |
5683 | +{ |
5684 | + *(tty->termios) = tty_std_termios; |
5685 | + tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; |
5686 | + tty->termios->c_ispeed = 38400; |
5687 | + tty->termios->c_ospeed = 38400; |
5688 | +} |
5689 | + |
5690 | static void oti6858_set_termios(struct tty_struct *tty, |
5691 | struct usb_serial_port *port, struct ktermios *old_termios) |
5692 | { |
5693 | @@ -464,16 +473,6 @@ static void oti6858_set_termios(struct tty_struct *tty, |
5694 | return; |
5695 | } |
5696 | |
5697 | - spin_lock_irqsave(&priv->lock, flags); |
5698 | - if (!priv->flags.termios_initialized) { |
5699 | - *(tty->termios) = tty_std_termios; |
5700 | - tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; |
5701 | - tty->termios->c_ispeed = 38400; |
5702 | - tty->termios->c_ospeed = 38400; |
5703 | - priv->flags.termios_initialized = 1; |
5704 | - } |
5705 | - spin_unlock_irqrestore(&priv->lock, flags); |
5706 | - |
5707 | cflag = tty->termios->c_cflag; |
5708 | |
5709 | spin_lock_irqsave(&priv->lock, flags); |
5710 | diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c |
5711 | index 3e86815..124d5ae 100644 |
5712 | --- a/drivers/usb/serial/pl2303.c |
5713 | +++ b/drivers/usb/serial/pl2303.c |
5714 | @@ -96,6 +96,7 @@ static struct usb_device_id id_table [] = { |
5715 | { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) }, |
5716 | { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) }, |
5717 | { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, |
5718 | + { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, |
5719 | { } /* Terminating entry */ |
5720 | }; |
5721 | |
5722 | diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h |
5723 | index ee9505e..d640dc9 100644 |
5724 | --- a/drivers/usb/serial/pl2303.h |
5725 | +++ b/drivers/usb/serial/pl2303.h |
5726 | @@ -130,3 +130,7 @@ |
5727 | /* Sony, USB data cable for CMD-Jxx mobile phones */ |
5728 | #define SONY_VENDOR_ID 0x054c |
5729 | #define SONY_QN3USB_PRODUCT_ID 0x0437 |
5730 | + |
5731 | +/* Sanwa KB-USB2 multimeter cable (ID: 11ad:0001) */ |
5732 | +#define SANWA_VENDOR_ID 0x11ad |
5733 | +#define SANWA_PRODUCT_ID 0x0001 |
5734 | diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c |
5735 | index 3c249d8..993a6d5 100644 |
5736 | --- a/drivers/usb/serial/spcp8x5.c |
5737 | +++ b/drivers/usb/serial/spcp8x5.c |
5738 | @@ -299,7 +299,6 @@ struct spcp8x5_private { |
5739 | wait_queue_head_t delta_msr_wait; |
5740 | u8 line_control; |
5741 | u8 line_status; |
5742 | - u8 termios_initialized; |
5743 | }; |
5744 | |
5745 | /* desc : when device plug in,this function would be called. |
5746 | @@ -498,6 +497,15 @@ static void spcp8x5_close(struct usb_serial_port *port) |
5747 | dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result); |
5748 | } |
5749 | |
5750 | +static void spcp8x5_init_termios(struct tty_struct *tty) |
5751 | +{ |
5752 | + /* for the 1st time call this function */ |
5753 | + *(tty->termios) = tty_std_termios; |
5754 | + tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL; |
5755 | + tty->termios->c_ispeed = 115200; |
5756 | + tty->termios->c_ospeed = 115200; |
5757 | +} |
5758 | + |
5759 | /* set the serial param for transfer. we should check if we really need to |
5760 | * transfer. if we set flow control we should do this too. */ |
5761 | static void spcp8x5_set_termios(struct tty_struct *tty, |
5762 | @@ -514,16 +522,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty, |
5763 | int i; |
5764 | u8 control; |
5765 | |
5766 | - /* for the 1st time call this function */ |
5767 | - spin_lock_irqsave(&priv->lock, flags); |
5768 | - if (!priv->termios_initialized) { |
5769 | - *(tty->termios) = tty_std_termios; |
5770 | - tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL; |
5771 | - tty->termios->c_ispeed = 115200; |
5772 | - tty->termios->c_ospeed = 115200; |
5773 | - priv->termios_initialized = 1; |
5774 | - } |
5775 | - spin_unlock_irqrestore(&priv->lock, flags); |
5776 | |
5777 | /* check that they really want us to change something */ |
5778 | if (!tty_termios_hw_change(tty->termios, old_termios)) |
5779 | @@ -1011,6 +1009,7 @@ static struct usb_serial_driver spcp8x5_device = { |
5780 | .carrier_raised = spcp8x5_carrier_raised, |
5781 | .write = spcp8x5_write, |
5782 | .set_termios = spcp8x5_set_termios, |
5783 | + .init_termios = spcp8x5_init_termios, |
5784 | .ioctl = spcp8x5_ioctl, |
5785 | .tiocmget = spcp8x5_tiocmget, |
5786 | .tiocmset = spcp8x5_tiocmset, |
5787 | diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c |
5788 | index 99188c9..a0702db 100644 |
5789 | --- a/drivers/usb/serial/usb-serial.c |
5790 | +++ b/drivers/usb/serial/usb-serial.c |
5791 | @@ -43,8 +43,6 @@ |
5792 | #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/" |
5793 | #define DRIVER_DESC "USB Serial Driver core" |
5794 | |
5795 | -static void port_free(struct usb_serial_port *port); |
5796 | - |
5797 | /* Driver structure we register with the USB core */ |
5798 | static struct usb_driver usb_serial_driver = { |
5799 | .name = "usbserial", |
5800 | @@ -68,6 +66,11 @@ static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; |
5801 | static DEFINE_MUTEX(table_lock); |
5802 | static LIST_HEAD(usb_serial_driver_list); |
5803 | |
5804 | +/* |
5805 | + * Look up the serial structure. If it is found and it hasn't been |
5806 | + * disconnected, return with its disc_mutex held and its refcount |
5807 | + * incremented. Otherwise return NULL. |
5808 | + */ |
5809 | struct usb_serial *usb_serial_get_by_index(unsigned index) |
5810 | { |
5811 | struct usb_serial *serial; |
5812 | @@ -75,8 +78,15 @@ struct usb_serial *usb_serial_get_by_index(unsigned index) |
5813 | mutex_lock(&table_lock); |
5814 | serial = serial_table[index]; |
5815 | |
5816 | - if (serial) |
5817 | - kref_get(&serial->kref); |
5818 | + if (serial) { |
5819 | + mutex_lock(&serial->disc_mutex); |
5820 | + if (serial->disconnected) { |
5821 | + mutex_unlock(&serial->disc_mutex); |
5822 | + serial = NULL; |
5823 | + } else { |
5824 | + kref_get(&serial->kref); |
5825 | + } |
5826 | + } |
5827 | mutex_unlock(&table_lock); |
5828 | return serial; |
5829 | } |
5830 | @@ -125,8 +135,10 @@ static void return_serial(struct usb_serial *serial) |
5831 | |
5832 | dbg("%s", __func__); |
5833 | |
5834 | + mutex_lock(&table_lock); |
5835 | for (i = 0; i < serial->num_ports; ++i) |
5836 | serial_table[serial->minor + i] = NULL; |
5837 | + mutex_unlock(&table_lock); |
5838 | } |
5839 | |
5840 | static void destroy_serial(struct kref *kref) |
5841 | @@ -145,161 +157,157 @@ static void destroy_serial(struct kref *kref) |
5842 | |
5843 | serial->type->release(serial); |
5844 | |
5845 | - for (i = 0; i < serial->num_ports; ++i) { |
5846 | + /* Now that nothing is using the ports, they can be freed */ |
5847 | + for (i = 0; i < serial->num_port_pointers; ++i) { |
5848 | port = serial->port[i]; |
5849 | - if (port) |
5850 | + if (port) { |
5851 | + port->serial = NULL; |
5852 | put_device(&port->dev); |
5853 | - } |
5854 | - |
5855 | - /* If this is a "fake" port, we have to clean it up here, as it will |
5856 | - * not get cleaned up in port_release() as it was never registered with |
5857 | - * the driver core */ |
5858 | - if (serial->num_ports < serial->num_port_pointers) { |
5859 | - for (i = serial->num_ports; |
5860 | - i < serial->num_port_pointers; ++i) { |
5861 | - port = serial->port[i]; |
5862 | - if (port) |
5863 | - port_free(port); |
5864 | } |
5865 | } |
5866 | |
5867 | usb_put_dev(serial->dev); |
5868 | - |
5869 | - /* free up any memory that we allocated */ |
5870 | kfree(serial); |
5871 | } |
5872 | |
5873 | void usb_serial_put(struct usb_serial *serial) |
5874 | { |
5875 | - mutex_lock(&table_lock); |
5876 | kref_put(&serial->kref, destroy_serial); |
5877 | - mutex_unlock(&table_lock); |
5878 | } |
5879 | |
5880 | /***************************************************************************** |
5881 | * Driver tty interface functions |
5882 | *****************************************************************************/ |
5883 | -static int serial_open (struct tty_struct *tty, struct file *filp) |
5884 | + |
5885 | +/** |
5886 | + * serial_install - install tty |
5887 | + * @driver: the driver (USB in our case) |
5888 | + * @tty: the tty being created |
5889 | + * |
5890 | + * Create the termios objects for this tty. We use the default |
5891 | + * USB serial settings but permit them to be overridden by |
5892 | + * serial->type->init_termios. |
5893 | + * |
5894 | + * This is the first place a new tty gets used. Hence this is where we |
5895 | + * acquire references to the usb_serial structure and the driver module, |
5896 | + * where we store a pointer to the port, and where we do an autoresume. |
5897 | + * All these actions are reversed in serial_release(). |
5898 | + */ |
5899 | +static int serial_install(struct tty_driver *driver, struct tty_struct *tty) |
5900 | { |
5901 | + int idx = tty->index; |
5902 | struct usb_serial *serial; |
5903 | struct usb_serial_port *port; |
5904 | - unsigned int portNumber; |
5905 | - int retval = 0; |
5906 | - int first = 0; |
5907 | + int retval = -ENODEV; |
5908 | |
5909 | dbg("%s", __func__); |
5910 | |
5911 | - /* get the serial object associated with this tty pointer */ |
5912 | - serial = usb_serial_get_by_index(tty->index); |
5913 | - if (!serial) { |
5914 | - tty->driver_data = NULL; |
5915 | - return -ENODEV; |
5916 | - } |
5917 | + serial = usb_serial_get_by_index(idx); |
5918 | + if (!serial) |
5919 | + return retval; |
5920 | |
5921 | - mutex_lock(&serial->disc_mutex); |
5922 | - portNumber = tty->index - serial->minor; |
5923 | - port = serial->port[portNumber]; |
5924 | - if (!port || serial->disconnected) |
5925 | - retval = -ENODEV; |
5926 | - else |
5927 | - get_device(&port->dev); |
5928 | - /* |
5929 | - * Note: Our locking order requirement does not allow port->mutex |
5930 | - * to be acquired while serial->disc_mutex is held. |
5931 | - */ |
5932 | - mutex_unlock(&serial->disc_mutex); |
5933 | + port = serial->port[idx - serial->minor]; |
5934 | + if (!port) |
5935 | + goto error_no_port; |
5936 | + if (!try_module_get(serial->type->driver.owner)) |
5937 | + goto error_module_get; |
5938 | + |
5939 | + /* perform the standard setup */ |
5940 | + retval = tty_init_termios(tty); |
5941 | if (retval) |
5942 | - goto bailout_serial_put; |
5943 | + goto error_init_termios; |
5944 | |
5945 | - if (mutex_lock_interruptible(&port->mutex)) { |
5946 | - retval = -ERESTARTSYS; |
5947 | - goto bailout_port_put; |
5948 | - } |
5949 | + retval = usb_autopm_get_interface(serial->interface); |
5950 | + if (retval) |
5951 | + goto error_get_interface; |
5952 | + |
5953 | + mutex_unlock(&serial->disc_mutex); |
5954 | |
5955 | - ++port->port.count; |
5956 | + /* allow the driver to update the settings */ |
5957 | + if (serial->type->init_termios) |
5958 | + serial->type->init_termios(tty); |
5959 | |
5960 | - /* set up our port structure making the tty driver |
5961 | - * remember our port object, and us it */ |
5962 | tty->driver_data = port; |
5963 | - tty_port_tty_set(&port->port, tty); |
5964 | |
5965 | - /* If the console is attached, the device is already open */ |
5966 | - if (port->port.count == 1 && !port->console) { |
5967 | - first = 1; |
5968 | - /* lock this module before we call it |
5969 | - * this may fail, which means we must bail out, |
5970 | - * safe because we are called with BKL held */ |
5971 | - if (!try_module_get(serial->type->driver.owner)) { |
5972 | - retval = -ENODEV; |
5973 | - goto bailout_mutex_unlock; |
5974 | - } |
5975 | + /* Final install (we use the default method) */ |
5976 | + tty_driver_kref_get(driver); |
5977 | + tty->count++; |
5978 | + driver->ttys[idx] = tty; |
5979 | + return retval; |
5980 | |
5981 | + error_get_interface: |
5982 | + error_init_termios: |
5983 | + module_put(serial->type->driver.owner); |
5984 | + error_module_get: |
5985 | + error_no_port: |
5986 | + usb_serial_put(serial); |
5987 | + mutex_unlock(&serial->disc_mutex); |
5988 | + return retval; |
5989 | +} |
5990 | + |
5991 | +static int serial_open(struct tty_struct *tty, struct file *filp) |
5992 | +{ |
5993 | + struct usb_serial_port *port = tty->driver_data; |
5994 | + struct usb_serial *serial = port->serial; |
5995 | + int retval; |
5996 | + |
5997 | + dbg("%s - port %d", __func__, port->number); |
5998 | + |
5999 | + spin_lock_irq(&port->port.lock); |
6000 | + if (!tty_hung_up_p(filp)) |
6001 | + ++port->port.count; |
6002 | + spin_unlock_irq(&port->port.lock); |
6003 | + tty_port_tty_set(&port->port, tty); |
6004 | + |
6005 | + /* Do the device-specific open only if the hardware isn't |
6006 | + * already initialized. |
6007 | + */ |
6008 | + if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) { |
6009 | + if (mutex_lock_interruptible(&port->mutex)) |
6010 | + return -ERESTARTSYS; |
6011 | mutex_lock(&serial->disc_mutex); |
6012 | if (serial->disconnected) |
6013 | retval = -ENODEV; |
6014 | else |
6015 | - retval = usb_autopm_get_interface(serial->interface); |
6016 | - if (retval) |
6017 | - goto bailout_module_put; |
6018 | - |
6019 | - /* only call the device specific open if this |
6020 | - * is the first time the port is opened */ |
6021 | - retval = serial->type->open(tty, port, filp); |
6022 | - if (retval) |
6023 | - goto bailout_interface_put; |
6024 | + retval = port->serial->type->open(tty, port, filp); |
6025 | mutex_unlock(&serial->disc_mutex); |
6026 | + mutex_unlock(&port->mutex); |
6027 | + if (retval) |
6028 | + return retval; |
6029 | set_bit(ASYNCB_INITIALIZED, &port->port.flags); |
6030 | } |
6031 | - mutex_unlock(&port->mutex); |
6032 | + |
6033 | /* Now do the correct tty layer semantics */ |
6034 | retval = tty_port_block_til_ready(&port->port, tty, filp); |
6035 | - if (retval == 0) { |
6036 | - if (!first) |
6037 | - usb_serial_put(serial); |
6038 | - return 0; |
6039 | - } |
6040 | - mutex_lock(&port->mutex); |
6041 | - if (first == 0) |
6042 | - goto bailout_mutex_unlock; |
6043 | - /* Undo the initial port actions */ |
6044 | - mutex_lock(&serial->disc_mutex); |
6045 | -bailout_interface_put: |
6046 | - usb_autopm_put_interface(serial->interface); |
6047 | -bailout_module_put: |
6048 | - mutex_unlock(&serial->disc_mutex); |
6049 | - module_put(serial->type->driver.owner); |
6050 | -bailout_mutex_unlock: |
6051 | - port->port.count = 0; |
6052 | - tty->driver_data = NULL; |
6053 | - tty_port_tty_set(&port->port, NULL); |
6054 | - mutex_unlock(&port->mutex); |
6055 | -bailout_port_put: |
6056 | - put_device(&port->dev); |
6057 | -bailout_serial_put: |
6058 | - usb_serial_put(serial); |
6059 | return retval; |
6060 | } |
6061 | |
6062 | /** |
6063 | - * serial_do_down - shut down hardware |
6064 | - * @port: port to shut down |
6065 | - * |
6066 | - * Shut down a USB port unless it is the console. We never shut down the |
6067 | - * console hardware as it will always be in use. |
6068 | + * serial_down - shut down hardware |
6069 | + * @port: port to shut down |
6070 | * |
6071 | - * Don't free any resources at this point |
6072 | + * Shut down a USB serial port unless it is the console. We never |
6073 | + * shut down the console hardware as it will always be in use. |
6074 | */ |
6075 | -static void serial_do_down(struct usb_serial_port *port) |
6076 | +static void serial_down(struct usb_serial_port *port) |
6077 | { |
6078 | struct usb_serial_driver *drv = port->serial->type; |
6079 | struct usb_serial *serial; |
6080 | struct module *owner; |
6081 | |
6082 | - /* The console is magical, do not hang up the console hardware |
6083 | - or there will be tears */ |
6084 | + /* |
6085 | + * The console is magical. Do not hang up the console hardware |
6086 | + * or there will be tears. |
6087 | + */ |
6088 | if (port->console) |
6089 | return; |
6090 | |
6091 | + /* Don't call the close method if the hardware hasn't been |
6092 | + * initialized. |
6093 | + */ |
6094 | + if (!test_and_clear_bit(ASYNCB_INITIALIZED, &port->port.flags)) |
6095 | + return; |
6096 | + |
6097 | mutex_lock(&port->mutex); |
6098 | serial = port->serial; |
6099 | owner = serial->type->driver.owner; |
6100 | @@ -310,79 +318,69 @@ static void serial_do_down(struct usb_serial_port *port) |
6101 | mutex_unlock(&port->mutex); |
6102 | } |
6103 | |
6104 | -/** |
6105 | - * serial_do_free - free resources post close/hangup |
6106 | - * @port: port to free up |
6107 | - * |
6108 | - * Do the resource freeing and refcount dropping for the port. We must |
6109 | - * be careful about ordering and we must avoid freeing up the console. |
6110 | - */ |
6111 | - |
6112 | -static void serial_do_free(struct usb_serial_port *port) |
6113 | +static void serial_hangup(struct tty_struct *tty) |
6114 | { |
6115 | - struct usb_serial *serial; |
6116 | - struct module *owner; |
6117 | + struct usb_serial_port *port = tty->driver_data; |
6118 | |
6119 | - /* The console is magical, do not hang up the console hardware |
6120 | - or there will be tears */ |
6121 | - if (port->console) |
6122 | - return; |
6123 | + dbg("%s - port %d", __func__, port->number); |
6124 | |
6125 | - serial = port->serial; |
6126 | - owner = serial->type->driver.owner; |
6127 | - put_device(&port->dev); |
6128 | - /* Mustn't dereference port any more */ |
6129 | - mutex_lock(&serial->disc_mutex); |
6130 | - if (!serial->disconnected) |
6131 | - usb_autopm_put_interface(serial->interface); |
6132 | - mutex_unlock(&serial->disc_mutex); |
6133 | - usb_serial_put(serial); |
6134 | - /* Mustn't dereference serial any more */ |
6135 | - module_put(owner); |
6136 | + serial_down(port); |
6137 | + tty_port_hangup(&port->port); |
6138 | } |
6139 | |
6140 | static void serial_close(struct tty_struct *tty, struct file *filp) |
6141 | { |
6142 | struct usb_serial_port *port = tty->driver_data; |
6143 | |
6144 | - if (!port) |
6145 | - return; |
6146 | - |
6147 | dbg("%s - port %d", __func__, port->number); |
6148 | |
6149 | - /* FIXME: |
6150 | - This leaves a very narrow race. Really we should do the |
6151 | - serial_do_free() on tty->shutdown(), but tty->shutdown can |
6152 | - be called from IRQ context and serial_do_free can sleep. |
6153 | - |
6154 | - The right fix is probably to make the tty free (which is rare) |
6155 | - and thus tty->shutdown() occur via a work queue and simplify all |
6156 | - the drivers that use it. |
6157 | - */ |
6158 | - if (tty_hung_up_p(filp)) { |
6159 | - /* serial_hangup already called serial_down at this point. |
6160 | - Another user may have already reopened the port but |
6161 | - serial_do_free is refcounted */ |
6162 | - serial_do_free(port); |
6163 | + if (tty_hung_up_p(filp)) |
6164 | return; |
6165 | - } |
6166 | - |
6167 | if (tty_port_close_start(&port->port, tty, filp) == 0) |
6168 | return; |
6169 | - |
6170 | - serial_do_down(port); |
6171 | + serial_down(port); |
6172 | tty_port_close_end(&port->port, tty); |
6173 | tty_port_tty_set(&port->port, NULL); |
6174 | - serial_do_free(port); |
6175 | } |
6176 | |
6177 | -static void serial_hangup(struct tty_struct *tty) |
6178 | +/** |
6179 | + * serial_release - free resources post close/hangup |
6180 | + * @port: port to free up |
6181 | + * |
6182 | + * Do the resource freeing and refcount dropping for the port. |
6183 | + * Avoid freeing the console. |
6184 | + * |
6185 | + * Called when the last tty kref is dropped. |
6186 | + */ |
6187 | +static void serial_release(struct tty_struct *tty) |
6188 | { |
6189 | struct usb_serial_port *port = tty->driver_data; |
6190 | - serial_do_down(port); |
6191 | - tty_port_hangup(&port->port); |
6192 | - /* We must not free port yet - the USB serial layer depends on it's |
6193 | - continued existence */ |
6194 | + struct usb_serial *serial; |
6195 | + struct module *owner; |
6196 | + |
6197 | + /* The console is magical. Do not hang up the console hardware |
6198 | + * or there will be tears. |
6199 | + */ |
6200 | + if (port->console) |
6201 | + return; |
6202 | + |
6203 | + dbg("%s - port %d", __func__, port->number); |
6204 | + |
6205 | + /* Standard shutdown processing */ |
6206 | + tty_shutdown(tty); |
6207 | + |
6208 | + tty->driver_data = NULL; |
6209 | + |
6210 | + serial = port->serial; |
6211 | + owner = serial->type->driver.owner; |
6212 | + |
6213 | + mutex_lock(&serial->disc_mutex); |
6214 | + if (!serial->disconnected) |
6215 | + usb_autopm_put_interface(serial->interface); |
6216 | + mutex_unlock(&serial->disc_mutex); |
6217 | + |
6218 | + usb_serial_put(serial); |
6219 | + module_put(owner); |
6220 | } |
6221 | |
6222 | static int serial_write(struct tty_struct *tty, const unsigned char *buf, |
6223 | @@ -527,6 +525,7 @@ static int serial_proc_show(struct seq_file *m, void *v) |
6224 | |
6225 | seq_putc(m, '\n'); |
6226 | usb_serial_put(serial); |
6227 | + mutex_unlock(&serial->disc_mutex); |
6228 | } |
6229 | return 0; |
6230 | } |
6231 | @@ -596,14 +595,6 @@ static void usb_serial_port_work(struct work_struct *work) |
6232 | tty_kref_put(tty); |
6233 | } |
6234 | |
6235 | -static void port_release(struct device *dev) |
6236 | -{ |
6237 | - struct usb_serial_port *port = to_usb_serial_port(dev); |
6238 | - |
6239 | - dbg ("%s - %s", __func__, dev_name(dev)); |
6240 | - port_free(port); |
6241 | -} |
6242 | - |
6243 | static void kill_traffic(struct usb_serial_port *port) |
6244 | { |
6245 | usb_kill_urb(port->read_urb); |
6246 | @@ -623,8 +614,12 @@ static void kill_traffic(struct usb_serial_port *port) |
6247 | usb_kill_urb(port->interrupt_out_urb); |
6248 | } |
6249 | |
6250 | -static void port_free(struct usb_serial_port *port) |
6251 | +static void port_release(struct device *dev) |
6252 | { |
6253 | + struct usb_serial_port *port = to_usb_serial_port(dev); |
6254 | + |
6255 | + dbg ("%s - %s", __func__, dev_name(dev)); |
6256 | + |
6257 | /* |
6258 | * Stop all the traffic before cancelling the work, so that |
6259 | * nobody will restart it by calling usb_serial_port_softint. |
6260 | @@ -935,6 +930,11 @@ int usb_serial_probe(struct usb_interface *interface, |
6261 | mutex_init(&port->mutex); |
6262 | INIT_WORK(&port->work, usb_serial_port_work); |
6263 | serial->port[i] = port; |
6264 | + port->dev.parent = &interface->dev; |
6265 | + port->dev.driver = NULL; |
6266 | + port->dev.bus = &usb_serial_bus_type; |
6267 | + port->dev.release = &port_release; |
6268 | + device_initialize(&port->dev); |
6269 | } |
6270 | |
6271 | /* set up the endpoint information */ |
6272 | @@ -1077,15 +1077,10 @@ int usb_serial_probe(struct usb_interface *interface, |
6273 | /* register all of the individual ports with the driver core */ |
6274 | for (i = 0; i < num_ports; ++i) { |
6275 | port = serial->port[i]; |
6276 | - port->dev.parent = &interface->dev; |
6277 | - port->dev.driver = NULL; |
6278 | - port->dev.bus = &usb_serial_bus_type; |
6279 | - port->dev.release = &port_release; |
6280 | - |
6281 | dev_set_name(&port->dev, "ttyUSB%d", port->number); |
6282 | dbg ("%s - registering %s", __func__, dev_name(&port->dev)); |
6283 | port->dev_state = PORT_REGISTERING; |
6284 | - retval = device_register(&port->dev); |
6285 | + retval = device_add(&port->dev); |
6286 | if (retval) { |
6287 | dev_err(&port->dev, "Error registering port device, " |
6288 | "continuing\n"); |
6289 | @@ -1103,39 +1098,7 @@ exit: |
6290 | return 0; |
6291 | |
6292 | probe_error: |
6293 | - for (i = 0; i < num_bulk_in; ++i) { |
6294 | - port = serial->port[i]; |
6295 | - if (!port) |
6296 | - continue; |
6297 | - usb_free_urb(port->read_urb); |
6298 | - kfree(port->bulk_in_buffer); |
6299 | - } |
6300 | - for (i = 0; i < num_bulk_out; ++i) { |
6301 | - port = serial->port[i]; |
6302 | - if (!port) |
6303 | - continue; |
6304 | - usb_free_urb(port->write_urb); |
6305 | - kfree(port->bulk_out_buffer); |
6306 | - } |
6307 | - for (i = 0; i < num_interrupt_in; ++i) { |
6308 | - port = serial->port[i]; |
6309 | - if (!port) |
6310 | - continue; |
6311 | - usb_free_urb(port->interrupt_in_urb); |
6312 | - kfree(port->interrupt_in_buffer); |
6313 | - } |
6314 | - for (i = 0; i < num_interrupt_out; ++i) { |
6315 | - port = serial->port[i]; |
6316 | - if (!port) |
6317 | - continue; |
6318 | - usb_free_urb(port->interrupt_out_urb); |
6319 | - kfree(port->interrupt_out_buffer); |
6320 | - } |
6321 | - |
6322 | - /* free up any memory that we allocated */ |
6323 | - for (i = 0; i < serial->num_port_pointers; ++i) |
6324 | - kfree(serial->port[i]); |
6325 | - kfree(serial); |
6326 | + usb_serial_put(serial); |
6327 | return -EIO; |
6328 | } |
6329 | EXPORT_SYMBOL_GPL(usb_serial_probe); |
6330 | @@ -1161,10 +1124,7 @@ void usb_serial_disconnect(struct usb_interface *interface) |
6331 | if (port) { |
6332 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
6333 | if (tty) { |
6334 | - /* The hangup will occur asynchronously but |
6335 | - the object refcounts will sort out all the |
6336 | - cleanup */ |
6337 | - tty_hangup(tty); |
6338 | + tty_vhangup(tty); |
6339 | tty_kref_put(tty); |
6340 | } |
6341 | kill_traffic(port); |
6342 | @@ -1189,8 +1149,7 @@ void usb_serial_disconnect(struct usb_interface *interface) |
6343 | } |
6344 | serial->type->disconnect(serial); |
6345 | |
6346 | - /* let the last holder of this object |
6347 | - * cause it to be cleaned up */ |
6348 | + /* let the last holder of this object cause it to be cleaned up */ |
6349 | usb_serial_put(serial); |
6350 | dev_info(dev, "device disconnected\n"); |
6351 | } |
6352 | @@ -1246,6 +1205,8 @@ static const struct tty_operations serial_ops = { |
6353 | .chars_in_buffer = serial_chars_in_buffer, |
6354 | .tiocmget = serial_tiocmget, |
6355 | .tiocmset = serial_tiocmset, |
6356 | + .shutdown = serial_release, |
6357 | + .install = serial_install, |
6358 | .proc_fops = &serial_proc_fops, |
6359 | }; |
6360 | |
6361 | diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c |
6362 | index 8d126dd..f7232b1 100644 |
6363 | --- a/drivers/usb/serial/whiteheat.c |
6364 | +++ b/drivers/usb/serial/whiteheat.c |
6365 | @@ -259,7 +259,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, |
6366 | __u8 *data, __u8 datasize); |
6367 | static int firm_open(struct usb_serial_port *port); |
6368 | static int firm_close(struct usb_serial_port *port); |
6369 | -static int firm_setup_port(struct tty_struct *tty); |
6370 | +static void firm_setup_port(struct tty_struct *tty); |
6371 | static int firm_set_rts(struct usb_serial_port *port, __u8 onoff); |
6372 | static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff); |
6373 | static int firm_set_break(struct usb_serial_port *port, __u8 onoff); |
6374 | @@ -1211,7 +1211,7 @@ static int firm_close(struct usb_serial_port *port) |
6375 | } |
6376 | |
6377 | |
6378 | -static int firm_setup_port(struct tty_struct *tty) |
6379 | +static void firm_setup_port(struct tty_struct *tty) |
6380 | { |
6381 | struct usb_serial_port *port = tty->driver_data; |
6382 | struct whiteheat_port_settings port_settings; |
6383 | @@ -1286,7 +1286,7 @@ static int firm_setup_port(struct tty_struct *tty) |
6384 | port_settings.lloop = 0; |
6385 | |
6386 | /* now send the message to the device */ |
6387 | - return firm_send_command(port, WHITEHEAT_SETUP_PORT, |
6388 | + firm_send_command(port, WHITEHEAT_SETUP_PORT, |
6389 | (__u8 *)&port_settings, sizeof(port_settings)); |
6390 | } |
6391 | |
6392 | diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c |
6393 | index ec17c96..105d900 100644 |
6394 | --- a/drivers/usb/storage/initializers.c |
6395 | +++ b/drivers/usb/storage/initializers.c |
6396 | @@ -102,5 +102,5 @@ int usb_stor_huawei_e220_init(struct us_data *us) |
6397 | USB_TYPE_STANDARD | USB_RECIP_DEVICE, |
6398 | 0x01, 0x0, NULL, 0x0, 1000); |
6399 | US_DEBUGP("Huawei mode set result is %d\n", result); |
6400 | - return (result ? 0 : -ENODEV); |
6401 | + return 0; |
6402 | } |
6403 | diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c |
6404 | index 380233b..80e65f2 100644 |
6405 | --- a/drivers/usb/storage/onetouch.c |
6406 | +++ b/drivers/usb/storage/onetouch.c |
6407 | @@ -163,7 +163,7 @@ static void usb_onetouch_pm_hook(struct us_data *us, int action) |
6408 | usb_kill_urb(onetouch->irq); |
6409 | break; |
6410 | case US_RESUME: |
6411 | - if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0) |
6412 | + if (usb_submit_urb(onetouch->irq, GFP_NOIO) != 0) |
6413 | dev_err(&onetouch->irq->dev->dev, |
6414 | "usb_submit_urb failed\n"); |
6415 | break; |
6416 | diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c |
6417 | index 3a44695..29ff5ea 100644 |
6418 | --- a/drivers/video/console/fbcon.c |
6419 | +++ b/drivers/video/console/fbcon.c |
6420 | @@ -114,6 +114,7 @@ static int last_fb_vc = MAX_NR_CONSOLES - 1; |
6421 | static int fbcon_is_default = 1; |
6422 | static int fbcon_has_exited; |
6423 | static int primary_device = -1; |
6424 | +static int fbcon_has_console_bind; |
6425 | |
6426 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY |
6427 | static int map_override; |
6428 | @@ -544,6 +545,8 @@ static int fbcon_takeover(int show_logo) |
6429 | con2fb_map[i] = -1; |
6430 | } |
6431 | info_idx = -1; |
6432 | + } else { |
6433 | + fbcon_has_console_bind = 1; |
6434 | } |
6435 | |
6436 | return err; |
6437 | @@ -2923,6 +2926,10 @@ static int fbcon_unbind(void) |
6438 | |
6439 | ret = unbind_con_driver(&fb_con, first_fb_vc, last_fb_vc, |
6440 | fbcon_is_default); |
6441 | + |
6442 | + if (!ret) |
6443 | + fbcon_has_console_bind = 0; |
6444 | + |
6445 | return ret; |
6446 | } |
6447 | #else |
6448 | @@ -2936,6 +2943,9 @@ static int fbcon_fb_unbind(int idx) |
6449 | { |
6450 | int i, new_idx = -1, ret = 0; |
6451 | |
6452 | + if (!fbcon_has_console_bind) |
6453 | + return 0; |
6454 | + |
6455 | for (i = first_fb_vc; i <= last_fb_vc; i++) { |
6456 | if (con2fb_map[i] != idx && |
6457 | con2fb_map[i] != -1) { |
6458 | diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c |
6459 | index 5a72083..adf9632 100644 |
6460 | --- a/drivers/video/s3c-fb.c |
6461 | +++ b/drivers/video/s3c-fb.c |
6462 | @@ -1036,7 +1036,7 @@ static int s3c_fb_resume(struct platform_device *pdev) |
6463 | |
6464 | static struct platform_driver s3c_fb_driver = { |
6465 | .probe = s3c_fb_probe, |
6466 | - .remove = s3c_fb_remove, |
6467 | + .remove = __devexit_p(s3c_fb_remove), |
6468 | .suspend = s3c_fb_suspend, |
6469 | .resume = s3c_fb_resume, |
6470 | .driver = { |
6471 | diff --git a/drivers/video/sis/vstruct.h b/drivers/video/sis/vstruct.h |
6472 | index 705c853..bef4aae 100644 |
6473 | --- a/drivers/video/sis/vstruct.h |
6474 | +++ b/drivers/video/sis/vstruct.h |
6475 | @@ -342,7 +342,7 @@ struct SiS_Private |
6476 | unsigned short SiS_RY4COE; |
6477 | unsigned short SiS_LCDHDES; |
6478 | unsigned short SiS_LCDVDES; |
6479 | - unsigned short SiS_DDC_Port; |
6480 | + SISIOADDRESS SiS_DDC_Port; |
6481 | unsigned short SiS_DDC_Index; |
6482 | unsigned short SiS_DDC_Data; |
6483 | unsigned short SiS_DDC_NData; |
6484 | diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile |
6485 | index ec2a39b..7c28434 100644 |
6486 | --- a/drivers/xen/Makefile |
6487 | +++ b/drivers/xen/Makefile |
6488 | @@ -1,6 +1,9 @@ |
6489 | obj-y += grant-table.o features.o events.o manage.o |
6490 | obj-y += xenbus/ |
6491 | |
6492 | +nostackp := $(call cc-option, -fno-stack-protector) |
6493 | +CFLAGS_features.o := $(nostackp) |
6494 | + |
6495 | obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o |
6496 | obj-$(CONFIG_XEN_XENCOMM) += xencomm.o |
6497 | obj-$(CONFIG_XEN_BALLOON) += balloon.o |
6498 | diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h |
6499 | index 6084d63..3cfec69 100644 |
6500 | --- a/fs/cifs/cifsglob.h |
6501 | +++ b/fs/cifs/cifsglob.h |
6502 | @@ -572,9 +572,9 @@ require use of the stronger protocol */ |
6503 | #define CIFSSEC_MUST_LANMAN 0x10010 |
6504 | #define CIFSSEC_MUST_PLNTXT 0x20020 |
6505 | #ifdef CONFIG_CIFS_UPCALL |
6506 | -#define CIFSSEC_MASK 0xAF0AF /* allows weak security but also krb5 */ |
6507 | +#define CIFSSEC_MASK 0xBF0BF /* allows weak security but also krb5 */ |
6508 | #else |
6509 | -#define CIFSSEC_MASK 0xA70A7 /* current flags supported if weak */ |
6510 | +#define CIFSSEC_MASK 0xB70B7 /* current flags supported if weak */ |
6511 | #endif /* UPCALL */ |
6512 | #else /* do not allow weak pw hash */ |
6513 | #ifdef CONFIG_CIFS_UPCALL |
6514 | diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c |
6515 | index b91851f..f0b53df 100644 |
6516 | --- a/fs/ecryptfs/crypto.c |
6517 | +++ b/fs/ecryptfs/crypto.c |
6518 | @@ -797,6 +797,7 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat) |
6519 | kfree(full_alg_name); |
6520 | if (IS_ERR(crypt_stat->tfm)) { |
6521 | rc = PTR_ERR(crypt_stat->tfm); |
6522 | + crypt_stat->tfm = NULL; |
6523 | ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): " |
6524 | "Error initializing cipher [%s]\n", |
6525 | crypt_stat->cipher); |
6526 | @@ -1702,7 +1703,7 @@ ecryptfs_encrypt_filename(struct ecryptfs_filename *filename, |
6527 | } else { |
6528 | printk(KERN_ERR "%s: No support for requested filename " |
6529 | "encryption method in this release\n", __func__); |
6530 | - rc = -ENOTSUPP; |
6531 | + rc = -EOPNOTSUPP; |
6532 | goto out; |
6533 | } |
6534 | out: |
6535 | @@ -2166,7 +2167,7 @@ int ecryptfs_encrypt_and_encode_filename( |
6536 | (*encoded_name)[(*encoded_name_size)] = '\0'; |
6537 | (*encoded_name_size)++; |
6538 | } else { |
6539 | - rc = -ENOTSUPP; |
6540 | + rc = -EOPNOTSUPP; |
6541 | } |
6542 | if (rc) { |
6543 | printk(KERN_ERR "%s: Error attempting to encode " |
6544 | diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c |
6545 | index 2f0945d..056fed6 100644 |
6546 | --- a/fs/ecryptfs/inode.c |
6547 | +++ b/fs/ecryptfs/inode.c |
6548 | @@ -476,6 +476,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry) |
6549 | struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir); |
6550 | struct dentry *lower_dir_dentry; |
6551 | |
6552 | + dget(lower_dentry); |
6553 | lower_dir_dentry = lock_parent(lower_dentry); |
6554 | rc = vfs_unlink(lower_dir_inode, lower_dentry); |
6555 | if (rc) { |
6556 | @@ -489,6 +490,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry) |
6557 | d_drop(dentry); |
6558 | out_unlock: |
6559 | unlock_dir(lower_dir_dentry); |
6560 | + dput(lower_dentry); |
6561 | return rc; |
6562 | } |
6563 | |
6564 | diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c |
6565 | index 259525c..c77438f 100644 |
6566 | --- a/fs/ecryptfs/keystore.c |
6567 | +++ b/fs/ecryptfs/keystore.c |
6568 | @@ -416,7 +416,9 @@ ecryptfs_find_global_auth_tok_for_sig( |
6569 | &mount_crypt_stat->global_auth_tok_list, |
6570 | mount_crypt_stat_list) { |
6571 | if (memcmp(walker->sig, sig, ECRYPTFS_SIG_SIZE_HEX) == 0) { |
6572 | - (*global_auth_tok) = walker; |
6573 | + rc = key_validate(walker->global_auth_tok_key); |
6574 | + if (!rc) |
6575 | + (*global_auth_tok) = walker; |
6576 | goto out; |
6577 | } |
6578 | } |
6579 | @@ -612,7 +614,12 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes, |
6580 | } |
6581 | /* TODO: Support other key modules than passphrase for |
6582 | * filename encryption */ |
6583 | - BUG_ON(s->auth_tok->token_type != ECRYPTFS_PASSWORD); |
6584 | + if (s->auth_tok->token_type != ECRYPTFS_PASSWORD) { |
6585 | + rc = -EOPNOTSUPP; |
6586 | + printk(KERN_INFO "%s: Filename encryption only supports " |
6587 | + "password tokens\n", __func__); |
6588 | + goto out_free_unlock; |
6589 | + } |
6590 | sg_init_one( |
6591 | &s->hash_sg, |
6592 | (u8 *)s->auth_tok->token.password.session_key_encryption_key, |
6593 | @@ -910,7 +917,12 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size, |
6594 | } |
6595 | /* TODO: Support other key modules than passphrase for |
6596 | * filename encryption */ |
6597 | - BUG_ON(s->auth_tok->token_type != ECRYPTFS_PASSWORD); |
6598 | + if (s->auth_tok->token_type != ECRYPTFS_PASSWORD) { |
6599 | + rc = -EOPNOTSUPP; |
6600 | + printk(KERN_INFO "%s: Filename encryption only supports " |
6601 | + "password tokens\n", __func__); |
6602 | + goto out_free_unlock; |
6603 | + } |
6604 | rc = crypto_blkcipher_setkey( |
6605 | s->desc.tfm, |
6606 | s->auth_tok->token.password.session_key_encryption_key, |
6607 | @@ -1316,8 +1328,10 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat, |
6608 | rc = -EINVAL; |
6609 | goto out_free; |
6610 | } |
6611 | - ecryptfs_cipher_code_to_string(crypt_stat->cipher, |
6612 | - (u16)data[(*packet_size)]); |
6613 | + rc = ecryptfs_cipher_code_to_string(crypt_stat->cipher, |
6614 | + (u16)data[(*packet_size)]); |
6615 | + if (rc) |
6616 | + goto out_free; |
6617 | /* A little extra work to differentiate among the AES key |
6618 | * sizes; see RFC2440 */ |
6619 | switch(data[(*packet_size)++]) { |
6620 | @@ -1328,7 +1342,9 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat, |
6621 | crypt_stat->key_size = |
6622 | (*new_auth_tok)->session_key.encrypted_key_size; |
6623 | } |
6624 | - ecryptfs_init_crypt_ctx(crypt_stat); |
6625 | + rc = ecryptfs_init_crypt_ctx(crypt_stat); |
6626 | + if (rc) |
6627 | + goto out_free; |
6628 | if (unlikely(data[(*packet_size)++] != 0x03)) { |
6629 | printk(KERN_WARNING "Only S2K ID 3 is currently supported\n"); |
6630 | rc = -ENOSYS; |
6631 | diff --git a/fs/ecryptfs/kthread.c b/fs/ecryptfs/kthread.c |
6632 | index c6d7a4d..e14cf7e 100644 |
6633 | --- a/fs/ecryptfs/kthread.c |
6634 | +++ b/fs/ecryptfs/kthread.c |
6635 | @@ -136,6 +136,7 @@ int ecryptfs_privileged_open(struct file **lower_file, |
6636 | const struct cred *cred) |
6637 | { |
6638 | struct ecryptfs_open_req *req; |
6639 | + int flags = O_LARGEFILE; |
6640 | int rc = 0; |
6641 | |
6642 | /* Corresponding dput() and mntput() are done when the |
6643 | @@ -143,10 +144,14 @@ int ecryptfs_privileged_open(struct file **lower_file, |
6644 | * destroyed. */ |
6645 | dget(lower_dentry); |
6646 | mntget(lower_mnt); |
6647 | - (*lower_file) = dentry_open(lower_dentry, lower_mnt, |
6648 | - (O_RDWR | O_LARGEFILE), cred); |
6649 | + flags |= IS_RDONLY(lower_dentry->d_inode) ? O_RDONLY : O_RDWR; |
6650 | + (*lower_file) = dentry_open(lower_dentry, lower_mnt, flags, cred); |
6651 | if (!IS_ERR(*lower_file)) |
6652 | goto out; |
6653 | + if (flags & O_RDONLY) { |
6654 | + rc = PTR_ERR((*lower_file)); |
6655 | + goto out; |
6656 | + } |
6657 | req = kmem_cache_alloc(ecryptfs_open_req_cache, GFP_KERNEL); |
6658 | if (!req) { |
6659 | rc = -ENOMEM; |
6660 | @@ -180,21 +185,8 @@ int ecryptfs_privileged_open(struct file **lower_file, |
6661 | __func__); |
6662 | goto out_unlock; |
6663 | } |
6664 | - if (IS_ERR(*req->lower_file)) { |
6665 | + if (IS_ERR(*req->lower_file)) |
6666 | rc = PTR_ERR(*req->lower_file); |
6667 | - dget(lower_dentry); |
6668 | - mntget(lower_mnt); |
6669 | - (*lower_file) = dentry_open(lower_dentry, lower_mnt, |
6670 | - (O_RDONLY | O_LARGEFILE), cred); |
6671 | - if (IS_ERR(*lower_file)) { |
6672 | - rc = PTR_ERR(*req->lower_file); |
6673 | - (*lower_file) = NULL; |
6674 | - printk(KERN_WARNING "%s: Error attempting privileged " |
6675 | - "open of lower file with either RW or RO " |
6676 | - "perms; rc = [%d]. Giving up.\n", |
6677 | - __func__, rc); |
6678 | - } |
6679 | - } |
6680 | out_unlock: |
6681 | mutex_unlock(&req->mux); |
6682 | out_free: |
6683 | diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c |
6684 | index 9f0aa98..101fe4c 100644 |
6685 | --- a/fs/ecryptfs/main.c |
6686 | +++ b/fs/ecryptfs/main.c |
6687 | @@ -129,11 +129,10 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) |
6688 | lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); |
6689 | rc = ecryptfs_privileged_open(&inode_info->lower_file, |
6690 | lower_dentry, lower_mnt, cred); |
6691 | - if (rc || IS_ERR(inode_info->lower_file)) { |
6692 | + if (rc) { |
6693 | printk(KERN_ERR "Error opening lower persistent file " |
6694 | "for lower_dentry [0x%p] and lower_mnt [0x%p]; " |
6695 | "rc = [%d]\n", lower_dentry, lower_mnt, rc); |
6696 | - rc = PTR_ERR(inode_info->lower_file); |
6697 | inode_info->lower_file = NULL; |
6698 | } |
6699 | } |
6700 | diff --git a/fs/inode.c b/fs/inode.c |
6701 | index ae7b67e..1a959c0 100644 |
6702 | --- a/fs/inode.c |
6703 | +++ b/fs/inode.c |
6704 | @@ -697,13 +697,15 @@ void unlock_new_inode(struct inode *inode) |
6705 | } |
6706 | #endif |
6707 | /* |
6708 | - * This is special! We do not need the spinlock |
6709 | - * when clearing I_LOCK, because we're guaranteed |
6710 | - * that nobody else tries to do anything about the |
6711 | - * state of the inode when it is locked, as we |
6712 | - * just created it (so there can be no old holders |
6713 | - * that haven't tested I_LOCK). |
6714 | + * This is special! We do not need the spinlock when clearing I_LOCK, |
6715 | + * because we're guaranteed that nobody else tries to do anything about |
6716 | + * the state of the inode when it is locked, as we just created it (so |
6717 | + * there can be no old holders that haven't tested I_LOCK). |
6718 | + * However we must emit the memory barrier so that other CPUs reliably |
6719 | + * see the clearing of I_LOCK after the other inode initialisation has |
6720 | + * completed. |
6721 | */ |
6722 | + smp_mb(); |
6723 | WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW)); |
6724 | inode->i_state &= ~(I_LOCK|I_NEW); |
6725 | wake_up_inode(inode); |
6726 | diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c |
6727 | index 3fd23f7..bf9b470 100644 |
6728 | --- a/fs/nfsd/nfs4callback.c |
6729 | +++ b/fs/nfsd/nfs4callback.c |
6730 | @@ -444,6 +444,7 @@ static struct rpc_cred *lookup_cb_cred(struct nfs4_cb_conn *cb) |
6731 | struct auth_cred acred = { |
6732 | .machine_cred = 1 |
6733 | }; |
6734 | + struct rpc_auth *auth = cb->cb_client->cl_auth; |
6735 | |
6736 | /* |
6737 | * Note in the gss case this doesn't actually have to wait for a |
6738 | @@ -451,8 +452,7 @@ static struct rpc_cred *lookup_cb_cred(struct nfs4_cb_conn *cb) |
6739 | * non-uptodate cred which the rpc state machine will fill in with |
6740 | * a refresh_upcall later. |
6741 | */ |
6742 | - return rpcauth_lookup_credcache(cb->cb_client->cl_auth, &acred, |
6743 | - RPCAUTH_LOOKUP_NEW); |
6744 | + return auth->au_ops->lookup_cred(auth, &acred, RPCAUTH_LOOKUP_NEW); |
6745 | } |
6746 | |
6747 | void do_probe_callback(struct nfs4_client *clp) |
6748 | diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c |
6749 | index c668bca..5be2c8b 100644 |
6750 | --- a/fs/nilfs2/btnode.c |
6751 | +++ b/fs/nilfs2/btnode.c |
6752 | @@ -36,6 +36,7 @@ |
6753 | |
6754 | void nilfs_btnode_cache_init_once(struct address_space *btnc) |
6755 | { |
6756 | + memset(btnc, 0, sizeof(*btnc)); |
6757 | INIT_RADIX_TREE(&btnc->page_tree, GFP_ATOMIC); |
6758 | spin_lock_init(&btnc->tree_lock); |
6759 | INIT_LIST_HEAD(&btnc->private_list); |
6760 | diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c |
6761 | index 59b43a0..5fd7d2b 100644 |
6762 | --- a/fs/proc/kcore.c |
6763 | +++ b/fs/proc/kcore.c |
6764 | @@ -361,7 +361,13 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) |
6765 | /* don't dump ioremap'd stuff! (TA) */ |
6766 | if (m->flags & VM_IOREMAP) |
6767 | continue; |
6768 | - memcpy(elf_buf + (vmstart - start), |
6769 | + /* |
6770 | + * we may access memory holes, then use |
6771 | + * ex_table. checking return value just for |
6772 | + * avoid warnings. |
6773 | + */ |
6774 | + vmsize = __copy_from_user_inatomic( |
6775 | + elf_buf + (vmstart - start), |
6776 | (char *)vmstart, vmsize); |
6777 | } |
6778 | read_unlock(&vmlist_lock); |
6779 | diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c |
6780 | index 0c10a0b..766b1d4 100644 |
6781 | --- a/fs/proc/uptime.c |
6782 | +++ b/fs/proc/uptime.c |
6783 | @@ -4,13 +4,18 @@ |
6784 | #include <linux/sched.h> |
6785 | #include <linux/seq_file.h> |
6786 | #include <linux/time.h> |
6787 | +#include <linux/kernel_stat.h> |
6788 | #include <asm/cputime.h> |
6789 | |
6790 | static int uptime_proc_show(struct seq_file *m, void *v) |
6791 | { |
6792 | struct timespec uptime; |
6793 | struct timespec idle; |
6794 | - cputime_t idletime = cputime_add(init_task.utime, init_task.stime); |
6795 | + int i; |
6796 | + cputime_t idletime = cputime_zero; |
6797 | + |
6798 | + for_each_possible_cpu(i) |
6799 | + idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle); |
6800 | |
6801 | do_posix_clock_monotonic_gettime(&uptime); |
6802 | monotonic_to_bootbased(&uptime); |
6803 | diff --git a/include/linux/tty.h b/include/linux/tty.h |
6804 | index e8c6c91..b982a17 100644 |
6805 | --- a/include/linux/tty.h |
6806 | +++ b/include/linux/tty.h |
6807 | @@ -185,7 +185,12 @@ struct tty_port; |
6808 | struct tty_port_operations { |
6809 | /* Return 1 if the carrier is raised */ |
6810 | int (*carrier_raised)(struct tty_port *port); |
6811 | + /* Control the DTR line */ |
6812 | void (*dtr_rts)(struct tty_port *port, int raise); |
6813 | + /* Called when the last close completes or a hangup finishes |
6814 | + IFF the port was initialized. Do not use to free resources */ |
6815 | + void (*shutdown)(struct tty_port *port); |
6816 | + void (*drop)(struct tty_port *port); |
6817 | }; |
6818 | |
6819 | struct tty_port { |
6820 | @@ -457,7 +462,8 @@ extern int tty_port_block_til_ready(struct tty_port *port, |
6821 | extern int tty_port_close_start(struct tty_port *port, |
6822 | struct tty_struct *tty, struct file *filp); |
6823 | extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); |
6824 | - |
6825 | +extern void tty_port_close(struct tty_port *port, |
6826 | + struct tty_struct *tty, struct file *filp); |
6827 | extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc); |
6828 | extern int tty_unregister_ldisc(int disc); |
6829 | extern int tty_set_ldisc(struct tty_struct *tty, int ldisc); |
6830 | diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h |
6831 | index 0ec50ba..73f121e 100644 |
6832 | --- a/include/linux/usb/serial.h |
6833 | +++ b/include/linux/usb/serial.h |
6834 | @@ -261,6 +261,9 @@ struct usb_serial_driver { |
6835 | be an attached tty at this point */ |
6836 | void (*dtr_rts)(struct usb_serial_port *port, int on); |
6837 | int (*carrier_raised)(struct usb_serial_port *port); |
6838 | + /* Called by the usb serial hooks to allow the user to rework the |
6839 | + termios state */ |
6840 | + void (*init_termios)(struct tty_struct *tty); |
6841 | /* USB events */ |
6842 | void (*read_int_callback)(struct urb *urb); |
6843 | void (*write_int_callback)(struct urb *urb); |
6844 | diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h |
6845 | index 9b4ac93..56677eb 100644 |
6846 | --- a/include/pcmcia/ss.h |
6847 | +++ b/include/pcmcia/ss.h |
6848 | @@ -279,7 +279,7 @@ extern struct pccard_resource_ops pccard_iodyn_ops; |
6849 | extern struct pccard_resource_ops pccard_nonstatic_ops; |
6850 | |
6851 | /* socket drivers are expected to use these callbacks in their .drv struct */ |
6852 | -extern int pcmcia_socket_dev_suspend(struct device *dev, pm_message_t state); |
6853 | +extern int pcmcia_socket_dev_suspend(struct device *dev); |
6854 | extern int pcmcia_socket_dev_resume(struct device *dev); |
6855 | |
6856 | /* socket drivers use this callback in their IRQ handler */ |
6857 | diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c |
6858 | index 3f49f53..b1dc468 100644 |
6859 | --- a/kernel/perf_counter.c |
6860 | +++ b/kernel/perf_counter.c |
6861 | @@ -4143,8 +4143,8 @@ done: |
6862 | static int perf_copy_attr(struct perf_counter_attr __user *uattr, |
6863 | struct perf_counter_attr *attr) |
6864 | { |
6865 | - int ret; |
6866 | u32 size; |
6867 | + int ret; |
6868 | |
6869 | if (!access_ok(VERIFY_WRITE, uattr, PERF_ATTR_SIZE_VER0)) |
6870 | return -EFAULT; |
6871 | @@ -4169,19 +4169,19 @@ static int perf_copy_attr(struct perf_counter_attr __user *uattr, |
6872 | |
6873 | /* |
6874 | * If we're handed a bigger struct than we know of, |
6875 | - * ensure all the unknown bits are 0. |
6876 | + * ensure all the unknown bits are 0 - i.e. new |
6877 | + * user-space does not rely on any kernel feature |
6878 | + * extensions we dont know about yet. |
6879 | */ |
6880 | if (size > sizeof(*attr)) { |
6881 | - unsigned long val; |
6882 | - unsigned long __user *addr; |
6883 | - unsigned long __user *end; |
6884 | + unsigned char __user *addr; |
6885 | + unsigned char __user *end; |
6886 | + unsigned char val; |
6887 | |
6888 | - addr = PTR_ALIGN((void __user *)uattr + sizeof(*attr), |
6889 | - sizeof(unsigned long)); |
6890 | - end = PTR_ALIGN((void __user *)uattr + size, |
6891 | - sizeof(unsigned long)); |
6892 | + addr = (void __user *)uattr + sizeof(*attr); |
6893 | + end = (void __user *)uattr + size; |
6894 | |
6895 | - for (; addr < end; addr += sizeof(unsigned long)) { |
6896 | + for (; addr < end; addr++) { |
6897 | ret = get_user(val, addr); |
6898 | if (ret) |
6899 | return ret; |
6900 | diff --git a/mm/hugetlb.c b/mm/hugetlb.c |
6901 | index cafdcee..cae0337 100644 |
6902 | --- a/mm/hugetlb.c |
6903 | +++ b/mm/hugetlb.c |
6904 | @@ -1010,6 +1010,7 @@ int __weak alloc_bootmem_huge_page(struct hstate *h) |
6905 | NODE_DATA(h->hugetlb_next_nid), |
6906 | huge_page_size(h), huge_page_size(h), 0); |
6907 | |
6908 | + hstate_next_node(h); |
6909 | if (addr) { |
6910 | /* |
6911 | * Use the beginning of the huge page to store the |
6912 | @@ -1019,7 +1020,6 @@ int __weak alloc_bootmem_huge_page(struct hstate *h) |
6913 | m = addr; |
6914 | goto found; |
6915 | } |
6916 | - hstate_next_node(h); |
6917 | nr_nodes--; |
6918 | } |
6919 | return 0; |
6920 | diff --git a/mm/memory.c b/mm/memory.c |
6921 | index aede2ce..753b2e6 100644 |
6922 | --- a/mm/memory.c |
6923 | +++ b/mm/memory.c |
6924 | @@ -2638,7 +2638,8 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, |
6925 | goto oom_free_page; |
6926 | |
6927 | entry = mk_pte(page, vma->vm_page_prot); |
6928 | - entry = maybe_mkwrite(pte_mkdirty(entry), vma); |
6929 | + if (vma->vm_flags & VM_WRITE) |
6930 | + entry = pte_mkwrite(pte_mkdirty(entry)); |
6931 | |
6932 | page_table = pte_offset_map_lock(mm, pmd, address, &ptl); |
6933 | if (!pte_none(*page_table)) |
6934 | diff --git a/mm/mlock.c b/mm/mlock.c |
6935 | index 45eb650..e13918d 100644 |
6936 | --- a/mm/mlock.c |
6937 | +++ b/mm/mlock.c |
6938 | @@ -139,49 +139,36 @@ static void munlock_vma_page(struct page *page) |
6939 | } |
6940 | |
6941 | /** |
6942 | - * __mlock_vma_pages_range() - mlock/munlock a range of pages in the vma. |
6943 | + * __mlock_vma_pages_range() - mlock a range of pages in the vma. |
6944 | * @vma: target vma |
6945 | * @start: start address |
6946 | * @end: end address |
6947 | - * @mlock: 0 indicate munlock, otherwise mlock. |
6948 | * |
6949 | - * If @mlock == 0, unlock an mlocked range; |
6950 | - * else mlock the range of pages. This takes care of making the pages present , |
6951 | - * too. |
6952 | + * This takes care of making the pages present too. |
6953 | * |
6954 | * return 0 on success, negative error code on error. |
6955 | * |
6956 | * vma->vm_mm->mmap_sem must be held for at least read. |
6957 | */ |
6958 | static long __mlock_vma_pages_range(struct vm_area_struct *vma, |
6959 | - unsigned long start, unsigned long end, |
6960 | - int mlock) |
6961 | + unsigned long start, unsigned long end) |
6962 | { |
6963 | struct mm_struct *mm = vma->vm_mm; |
6964 | unsigned long addr = start; |
6965 | struct page *pages[16]; /* 16 gives a reasonable batch */ |
6966 | int nr_pages = (end - start) / PAGE_SIZE; |
6967 | int ret = 0; |
6968 | - int gup_flags = 0; |
6969 | + int gup_flags; |
6970 | |
6971 | VM_BUG_ON(start & ~PAGE_MASK); |
6972 | VM_BUG_ON(end & ~PAGE_MASK); |
6973 | VM_BUG_ON(start < vma->vm_start); |
6974 | VM_BUG_ON(end > vma->vm_end); |
6975 | - VM_BUG_ON((!rwsem_is_locked(&mm->mmap_sem)) && |
6976 | - (atomic_read(&mm->mm_users) != 0)); |
6977 | - |
6978 | - /* |
6979 | - * mlock: don't page populate if vma has PROT_NONE permission. |
6980 | - * munlock: always do munlock although the vma has PROT_NONE |
6981 | - * permission, or SIGKILL is pending. |
6982 | - */ |
6983 | - if (!mlock) |
6984 | - gup_flags |= GUP_FLAGS_IGNORE_VMA_PERMISSIONS | |
6985 | - GUP_FLAGS_IGNORE_SIGKILL; |
6986 | + VM_BUG_ON(!rwsem_is_locked(&mm->mmap_sem)); |
6987 | |
6988 | + gup_flags = 0; |
6989 | if (vma->vm_flags & VM_WRITE) |
6990 | - gup_flags |= GUP_FLAGS_WRITE; |
6991 | + gup_flags = GUP_FLAGS_WRITE; |
6992 | |
6993 | while (nr_pages > 0) { |
6994 | int i; |
6995 | @@ -201,19 +188,10 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma, |
6996 | * This can happen for, e.g., VM_NONLINEAR regions before |
6997 | * a page has been allocated and mapped at a given offset, |
6998 | * or for addresses that map beyond end of a file. |
6999 | - * We'll mlock the the pages if/when they get faulted in. |
7000 | + * We'll mlock the pages if/when they get faulted in. |
7001 | */ |
7002 | if (ret < 0) |
7003 | break; |
7004 | - if (ret == 0) { |
7005 | - /* |
7006 | - * We know the vma is there, so the only time |
7007 | - * we cannot get a single page should be an |
7008 | - * error (ret < 0) case. |
7009 | - */ |
7010 | - WARN_ON(1); |
7011 | - break; |
7012 | - } |
7013 | |
7014 | lru_add_drain(); /* push cached pages to LRU */ |
7015 | |
7016 | @@ -224,28 +202,22 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma, |
7017 | /* |
7018 | * Because we lock page here and migration is blocked |
7019 | * by the elevated reference, we need only check for |
7020 | - * page truncation (file-cache only). |
7021 | + * file-cache page truncation. This page->mapping |
7022 | + * check also neatly skips over the ZERO_PAGE(), |
7023 | + * though if that's common we'd prefer not to lock it. |
7024 | */ |
7025 | - if (page->mapping) { |
7026 | - if (mlock) |
7027 | - mlock_vma_page(page); |
7028 | - else |
7029 | - munlock_vma_page(page); |
7030 | - } |
7031 | + if (page->mapping) |
7032 | + mlock_vma_page(page); |
7033 | unlock_page(page); |
7034 | - put_page(page); /* ref from get_user_pages() */ |
7035 | - |
7036 | - /* |
7037 | - * here we assume that get_user_pages() has given us |
7038 | - * a list of virtually contiguous pages. |
7039 | - */ |
7040 | - addr += PAGE_SIZE; /* for next get_user_pages() */ |
7041 | - nr_pages--; |
7042 | + put_page(page); /* ref from get_user_pages() */ |
7043 | } |
7044 | + |
7045 | + addr += ret * PAGE_SIZE; |
7046 | + nr_pages -= ret; |
7047 | ret = 0; |
7048 | } |
7049 | |
7050 | - return ret; /* count entire vma as locked_vm */ |
7051 | + return ret; /* 0 or negative error code */ |
7052 | } |
7053 | |
7054 | /* |
7055 | @@ -289,7 +261,7 @@ long mlock_vma_pages_range(struct vm_area_struct *vma, |
7056 | is_vm_hugetlb_page(vma) || |
7057 | vma == get_gate_vma(current))) { |
7058 | |
7059 | - __mlock_vma_pages_range(vma, start, end, 1); |
7060 | + __mlock_vma_pages_range(vma, start, end); |
7061 | |
7062 | /* Hide errors from mmap() and other callers */ |
7063 | return 0; |
7064 | @@ -310,7 +282,6 @@ no_mlock: |
7065 | return nr_pages; /* error or pages NOT mlocked */ |
7066 | } |
7067 | |
7068 | - |
7069 | /* |
7070 | * munlock_vma_pages_range() - munlock all pages in the vma range.' |
7071 | * @vma - vma containing range to be munlock()ed. |
7072 | @@ -330,10 +301,24 @@ no_mlock: |
7073 | * free them. This will result in freeing mlocked pages. |
7074 | */ |
7075 | void munlock_vma_pages_range(struct vm_area_struct *vma, |
7076 | - unsigned long start, unsigned long end) |
7077 | + unsigned long start, unsigned long end) |
7078 | { |
7079 | + unsigned long addr; |
7080 | + |
7081 | + lru_add_drain(); |
7082 | vma->vm_flags &= ~VM_LOCKED; |
7083 | - __mlock_vma_pages_range(vma, start, end, 0); |
7084 | + |
7085 | + for (addr = start; addr < end; addr += PAGE_SIZE) { |
7086 | + struct page *page = follow_page(vma, addr, FOLL_GET); |
7087 | + if (page) { |
7088 | + lock_page(page); |
7089 | + if (page->mapping) |
7090 | + munlock_vma_page(page); |
7091 | + unlock_page(page); |
7092 | + put_page(page); |
7093 | + } |
7094 | + cond_resched(); |
7095 | + } |
7096 | } |
7097 | |
7098 | /* |
7099 | @@ -400,18 +385,14 @@ success: |
7100 | * It's okay if try_to_unmap_one unmaps a page just after we |
7101 | * set VM_LOCKED, __mlock_vma_pages_range will bring it back. |
7102 | */ |
7103 | - vma->vm_flags = newflags; |
7104 | |
7105 | if (lock) { |
7106 | - ret = __mlock_vma_pages_range(vma, start, end, 1); |
7107 | - |
7108 | - if (ret > 0) { |
7109 | - mm->locked_vm -= ret; |
7110 | - ret = 0; |
7111 | - } else |
7112 | - ret = __mlock_posix_error_return(ret); /* translate if needed */ |
7113 | + vma->vm_flags = newflags; |
7114 | + ret = __mlock_vma_pages_range(vma, start, end); |
7115 | + if (ret < 0) |
7116 | + ret = __mlock_posix_error_return(ret); |
7117 | } else { |
7118 | - __mlock_vma_pages_range(vma, start, end, 0); |
7119 | + munlock_vma_pages_range(vma, start, end); |
7120 | } |
7121 | |
7122 | out: |
7123 | diff --git a/mm/mmap.c b/mm/mmap.c |
7124 | index 8101de4..cbb7cb3 100644 |
7125 | --- a/mm/mmap.c |
7126 | +++ b/mm/mmap.c |
7127 | @@ -570,9 +570,9 @@ again: remove_next = 1 + (end > next->vm_end); |
7128 | |
7129 | /* |
7130 | * When changing only vma->vm_end, we don't really need |
7131 | - * anon_vma lock: but is that case worth optimizing out? |
7132 | + * anon_vma lock. |
7133 | */ |
7134 | - if (vma->anon_vma) |
7135 | + if (vma->anon_vma && (insert || importer || start != vma->vm_start)) |
7136 | anon_vma = vma->anon_vma; |
7137 | if (anon_vma) { |
7138 | spin_lock(&anon_vma->lock); |
7139 | diff --git a/mm/nommu.c b/mm/nommu.c |
7140 | index 66e81e7..82fedca 100644 |
7141 | --- a/mm/nommu.c |
7142 | +++ b/mm/nommu.c |
7143 | @@ -1056,7 +1056,7 @@ static int do_mmap_shared_file(struct vm_area_struct *vma) |
7144 | ret = vma->vm_file->f_op->mmap(vma->vm_file, vma); |
7145 | if (ret == 0) { |
7146 | vma->vm_region->vm_top = vma->vm_region->vm_end; |
7147 | - return ret; |
7148 | + return 0; |
7149 | } |
7150 | if (ret != -ENOSYS) |
7151 | return ret; |
7152 | @@ -1073,7 +1073,8 @@ static int do_mmap_shared_file(struct vm_area_struct *vma) |
7153 | */ |
7154 | static int do_mmap_private(struct vm_area_struct *vma, |
7155 | struct vm_region *region, |
7156 | - unsigned long len) |
7157 | + unsigned long len, |
7158 | + unsigned long capabilities) |
7159 | { |
7160 | struct page *pages; |
7161 | unsigned long total, point, n, rlen; |
7162 | @@ -1084,13 +1085,13 @@ static int do_mmap_private(struct vm_area_struct *vma, |
7163 | * shared mappings on devices or memory |
7164 | * - VM_MAYSHARE will be set if it may attempt to share |
7165 | */ |
7166 | - if (vma->vm_file) { |
7167 | + if (capabilities & BDI_CAP_MAP_DIRECT) { |
7168 | ret = vma->vm_file->f_op->mmap(vma->vm_file, vma); |
7169 | if (ret == 0) { |
7170 | /* shouldn't return success if we're not sharing */ |
7171 | BUG_ON(!(vma->vm_flags & VM_MAYSHARE)); |
7172 | vma->vm_region->vm_top = vma->vm_region->vm_end; |
7173 | - return ret; |
7174 | + return 0; |
7175 | } |
7176 | if (ret != -ENOSYS) |
7177 | return ret; |
7178 | @@ -1328,7 +1329,7 @@ unsigned long do_mmap_pgoff(struct file *file, |
7179 | * - this is the hook for quasi-memory character devices to |
7180 | * tell us the location of a shared mapping |
7181 | */ |
7182 | - if (file && file->f_op->get_unmapped_area) { |
7183 | + if (capabilities & BDI_CAP_MAP_DIRECT) { |
7184 | addr = file->f_op->get_unmapped_area(file, addr, len, |
7185 | pgoff, flags); |
7186 | if (IS_ERR((void *) addr)) { |
7187 | @@ -1352,15 +1353,17 @@ unsigned long do_mmap_pgoff(struct file *file, |
7188 | } |
7189 | |
7190 | vma->vm_region = region; |
7191 | - add_nommu_region(region); |
7192 | |
7193 | - /* set up the mapping */ |
7194 | + /* set up the mapping |
7195 | + * - the region is filled in if BDI_CAP_MAP_DIRECT is still set |
7196 | + */ |
7197 | if (file && vma->vm_flags & VM_SHARED) |
7198 | ret = do_mmap_shared_file(vma); |
7199 | else |
7200 | - ret = do_mmap_private(vma, region, len); |
7201 | + ret = do_mmap_private(vma, region, len, capabilities); |
7202 | if (ret < 0) |
7203 | - goto error_put_region; |
7204 | + goto error_just_free; |
7205 | + add_nommu_region(region); |
7206 | |
7207 | /* okay... we have a mapping; now we have to register it */ |
7208 | result = vma->vm_start; |
7209 | @@ -1378,19 +1381,6 @@ share: |
7210 | kleave(" = %lx", result); |
7211 | return result; |
7212 | |
7213 | -error_put_region: |
7214 | - __put_nommu_region(region); |
7215 | - if (vma) { |
7216 | - if (vma->vm_file) { |
7217 | - fput(vma->vm_file); |
7218 | - if (vma->vm_flags & VM_EXECUTABLE) |
7219 | - removed_exe_file_vma(vma->vm_mm); |
7220 | - } |
7221 | - kmem_cache_free(vm_area_cachep, vma); |
7222 | - } |
7223 | - kleave(" = %d [pr]", ret); |
7224 | - return ret; |
7225 | - |
7226 | error_just_free: |
7227 | up_write(&nommu_region_sem); |
7228 | error: |
7229 | diff --git a/mm/page_alloc.c b/mm/page_alloc.c |
7230 | index a0de15f..0b3c6cb 100644 |
7231 | --- a/mm/page_alloc.c |
7232 | +++ b/mm/page_alloc.c |
7233 | @@ -2783,7 +2783,8 @@ static void setup_zone_migrate_reserve(struct zone *zone) |
7234 | { |
7235 | unsigned long start_pfn, pfn, end_pfn; |
7236 | struct page *page; |
7237 | - unsigned long reserve, block_migratetype; |
7238 | + unsigned long block_migratetype; |
7239 | + int reserve; |
7240 | |
7241 | /* Get the start pfn, end pfn and the number of blocks to reserve */ |
7242 | start_pfn = zone->zone_start_pfn; |
7243 | @@ -2791,6 +2792,15 @@ static void setup_zone_migrate_reserve(struct zone *zone) |
7244 | reserve = roundup(min_wmark_pages(zone), pageblock_nr_pages) >> |
7245 | pageblock_order; |
7246 | |
7247 | + /* |
7248 | + * Reserve blocks are generally in place to help high-order atomic |
7249 | + * allocations that are short-lived. A min_free_kbytes value that |
7250 | + * would result in more than 2 reserve blocks for atomic allocations |
7251 | + * is assumed to be in place to help anti-fragmentation for the |
7252 | + * future allocation of hugepages at runtime. |
7253 | + */ |
7254 | + reserve = min(2, reserve); |
7255 | + |
7256 | for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) { |
7257 | if (!pfn_valid(pfn)) |
7258 | continue; |
7259 | diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c |
7260 | index da0f64f..f03529c 100644 |
7261 | --- a/net/ax25/af_ax25.c |
7262 | +++ b/net/ax25/af_ax25.c |
7263 | @@ -538,7 +538,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, |
7264 | if (level != SOL_AX25) |
7265 | return -ENOPROTOOPT; |
7266 | |
7267 | - if (optlen < sizeof(int)) |
7268 | + if (optlen < (int)sizeof(int)) |
7269 | return -EINVAL; |
7270 | |
7271 | if (get_user(opt, (int __user *)optval)) |
7272 | diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c |
7273 | index d22f611..991fe40 100644 |
7274 | --- a/net/bridge/br_netfilter.c |
7275 | +++ b/net/bridge/br_netfilter.c |
7276 | @@ -359,7 +359,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb) |
7277 | }, |
7278 | .proto = 0, |
7279 | }; |
7280 | - struct in_device *in_dev = in_dev_get(dev); |
7281 | + struct in_device *in_dev = __in_dev_get_rcu(dev); |
7282 | |
7283 | /* If err equals -EHOSTUNREACH the error is due to a |
7284 | * martian destination or due to the fact that |
7285 | diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c |
7286 | index 133eeae..ce50688 100644 |
7287 | --- a/net/bridge/netfilter/ebt_ulog.c |
7288 | +++ b/net/bridge/netfilter/ebt_ulog.c |
7289 | @@ -266,7 +266,7 @@ static bool ebt_ulog_tg_check(const struct xt_tgchk_param *par) |
7290 | if (uloginfo->qthreshold > EBT_ULOG_MAX_QLEN) |
7291 | uloginfo->qthreshold = EBT_ULOG_MAX_QLEN; |
7292 | |
7293 | - return 0; |
7294 | + return true; |
7295 | } |
7296 | |
7297 | static struct xt_target ebt_ulog_tg_reg __read_mostly = { |
7298 | diff --git a/net/can/af_can.c b/net/can/af_can.c |
7299 | index e733725..264c968 100644 |
7300 | --- a/net/can/af_can.c |
7301 | +++ b/net/can/af_can.c |
7302 | @@ -199,6 +199,8 @@ static int can_create(struct net *net, struct socket *sock, int protocol) |
7303 | * @skb: pointer to socket buffer with CAN frame in data section |
7304 | * @loop: loopback for listeners on local CAN sockets (recommended default!) |
7305 | * |
7306 | + * Due to the loopback this routine must not be called from hardirq context. |
7307 | + * |
7308 | * Return: |
7309 | * 0 on success |
7310 | * -ENETDOWN when the selected interface is down |
7311 | @@ -278,7 +280,7 @@ int can_send(struct sk_buff *skb, int loop) |
7312 | } |
7313 | |
7314 | if (newskb) |
7315 | - netif_rx(newskb); |
7316 | + netif_rx_ni(newskb); |
7317 | |
7318 | /* update statistics */ |
7319 | can_stats.tx_frames++; |
7320 | diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c |
7321 | index 3229e0a..b6ddd56 100644 |
7322 | --- a/net/ipv4/netfilter/nf_nat_core.c |
7323 | +++ b/net/ipv4/netfilter/nf_nat_core.c |
7324 | @@ -212,7 +212,7 @@ find_best_ips_proto(struct nf_conntrack_tuple *tuple, |
7325 | maxip = ntohl(range->max_ip); |
7326 | j = jhash_2words((__force u32)tuple->src.u3.ip, |
7327 | range->flags & IP_NAT_RANGE_PERSISTENT ? |
7328 | - (__force u32)tuple->dst.u3.ip : 0, 0); |
7329 | + 0 : (__force u32)tuple->dst.u3.ip, 0); |
7330 | j = ((u64)j * (maxip - minip + 1)) >> 32; |
7331 | *var_ipp = htonl(minip + j); |
7332 | } |
7333 | diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c |
7334 | index b5869b9..b8614c6 100644 |
7335 | --- a/net/netfilter/nf_conntrack_core.c |
7336 | +++ b/net/netfilter/nf_conntrack_core.c |
7337 | @@ -1089,14 +1089,14 @@ void nf_conntrack_flush_report(struct net *net, u32 pid, int report) |
7338 | } |
7339 | EXPORT_SYMBOL_GPL(nf_conntrack_flush_report); |
7340 | |
7341 | -static void nf_ct_release_dying_list(void) |
7342 | +static void nf_ct_release_dying_list(struct net *net) |
7343 | { |
7344 | struct nf_conntrack_tuple_hash *h; |
7345 | struct nf_conn *ct; |
7346 | struct hlist_nulls_node *n; |
7347 | |
7348 | spin_lock_bh(&nf_conntrack_lock); |
7349 | - hlist_nulls_for_each_entry(h, n, &init_net.ct.dying, hnnode) { |
7350 | + hlist_nulls_for_each_entry(h, n, &net->ct.dying, hnnode) { |
7351 | ct = nf_ct_tuplehash_to_ctrack(h); |
7352 | /* never fails to remove them, no listeners at this point */ |
7353 | nf_ct_kill(ct); |
7354 | @@ -1115,7 +1115,7 @@ static void nf_conntrack_cleanup_net(struct net *net) |
7355 | { |
7356 | i_see_dead_people: |
7357 | nf_ct_iterate_cleanup(net, kill_all, NULL); |
7358 | - nf_ct_release_dying_list(); |
7359 | + nf_ct_release_dying_list(net); |
7360 | if (atomic_read(&net->ct.count) != 0) { |
7361 | schedule(); |
7362 | goto i_see_dead_people; |
7363 | diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c |
7364 | index ebe5718..f9f7177 100644 |
7365 | --- a/net/packet/af_packet.c |
7366 | +++ b/net/packet/af_packet.c |
7367 | @@ -1836,7 +1836,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv |
7368 | static int packet_getsockopt(struct socket *sock, int level, int optname, |
7369 | char __user *optval, int __user *optlen) |
7370 | { |
7371 | - int len; |
7372 | + unsigned int len; |
7373 | int val; |
7374 | struct sock *sk = sock->sk; |
7375 | struct packet_sock *po = pkt_sk(sk); |
7376 | @@ -1849,7 +1849,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, |
7377 | if (get_user(len, optlen)) |
7378 | return -EFAULT; |
7379 | |
7380 | - if (len < 0) |
7381 | + if ((int)len < 0) |
7382 | return -EINVAL; |
7383 | |
7384 | switch (optname) { |
7385 | diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include |
7386 | index c29be8f..43300b3 100644 |
7387 | --- a/scripts/Kbuild.include |
7388 | +++ b/scripts/Kbuild.include |
7389 | @@ -105,12 +105,12 @@ as-instr = $(call try-run,\ |
7390 | # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) |
7391 | |
7392 | cc-option = $(call try-run,\ |
7393 | - $(CC) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2)) |
7394 | + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2)) |
7395 | |
7396 | # cc-option-yn |
7397 | # Usage: flag := $(call cc-option-yn,-march=winchip-c6) |
7398 | cc-option-yn = $(call try-run,\ |
7399 | - $(CC) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n) |
7400 | + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n) |
7401 | |
7402 | # cc-option-align |
7403 | # Prefix align with either -falign or -malign |
7404 | diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c |
7405 | index 64343cc..86c3896 100644 |
7406 | --- a/scripts/kallsyms.c |
7407 | +++ b/scripts/kallsyms.c |
7408 | @@ -585,7 +585,7 @@ static int prefix_underscores_count(const char *str) |
7409 | { |
7410 | const char *tail = str; |
7411 | |
7412 | - while (*tail != '_') |
7413 | + while (*tail == '_') |
7414 | tail++; |
7415 | |
7416 | return tail - str; |
7417 | diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c |
7418 | index 5e17de9..5010952 100644 |
7419 | --- a/tools/perf/builtin-annotate.c |
7420 | +++ b/tools/perf/builtin-annotate.c |
7421 | @@ -1335,8 +1335,8 @@ static int __cmd_annotate(void) |
7422 | exit(-1); |
7423 | } |
7424 | |
7425 | - if (!force && (stat.st_uid != geteuid())) { |
7426 | - fprintf(stderr, "file: %s not owned by current user\n", input_name); |
7427 | + if (!force && stat.st_uid && (stat.st_uid != geteuid())) { |
7428 | + fprintf(stderr, "file: %s not owned by current user or root\n", input_name); |
7429 | exit(-1); |
7430 | } |
7431 | |
7432 | diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c |
7433 | index 8b2ec88..b8a75f6 100644 |
7434 | --- a/tools/perf/builtin-report.c |
7435 | +++ b/tools/perf/builtin-report.c |
7436 | @@ -1857,8 +1857,8 @@ static int __cmd_report(void) |
7437 | exit(-1); |
7438 | } |
7439 | |
7440 | - if (!force && (stat.st_uid != geteuid())) { |
7441 | - fprintf(stderr, "file: %s not owned by current user\n", input_name); |
7442 | + if (!force && stat.st_uid && (stat.st_uid != geteuid())) { |
7443 | + fprintf(stderr, "file: %s not owned by current user or root\n", input_name); |
7444 | exit(-1); |
7445 | } |
7446 | |
7447 | diff --git a/tools/perf/util/module.c b/tools/perf/util/module.c |
7448 | index ddabe92..702083d 100644 |
7449 | --- a/tools/perf/util/module.c |
7450 | +++ b/tools/perf/util/module.c |
7451 | @@ -422,7 +422,7 @@ static int mod_dso__load_module_paths(struct mod_dso *self) |
7452 | len += strlen(uts.release); |
7453 | len += strlen("/modules.dep"); |
7454 | |
7455 | - path = calloc(1, len); |
7456 | + path = calloc(1, len + 1); |
7457 | if (path == NULL) |
7458 | goto out_failure; |
7459 |