Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

authored by

Thomas Gleixner and committed by
Thomas Gleixner
f0827613 7d27c814

+1664 -2261
+1 -2
Documentation/cpusets.txt
··· 252 252 There is an exception to the above. If hotplug funtionality is used 253 253 to remove all the CPUs that are currently assigned to a cpuset, 254 254 then the kernel will automatically update the cpus_allowed of all 255 - tasks attached to CPUs in that cpuset with the online CPUs of the 256 - nearest parent cpuset that still has some CPUs online. When memory 255 + tasks attached to CPUs in that cpuset to allow all CPUs. When memory 257 256 hotplug functionality for removing Memory Nodes is available, a 258 257 similar exception is expected to apply there as well. In general, 259 258 the kernel prefers to violate cpuset placement, over starving a task
+3
Documentation/x86_64/boot-options.txt
··· 25 25 26 26 noapictimer Don't set up the APIC timer 27 27 28 + no_timer_check Don't check the IO-APIC timer. This can work around 29 + problems with incorrect timer initialization on some boards. 30 + 28 31 Early Console 29 32 30 33 syntax: earlyprintk=vga
+6 -3
arch/i386/kernel/cpu/amd.c
··· 195 195 c->x86_num_cores = 1; 196 196 } 197 197 198 - #ifdef CONFIG_X86_SMP 198 + #ifdef CONFIG_X86_HT 199 199 /* 200 200 * On a AMD dual core setup the lower bits of the APIC id 201 201 * distingush the cores. Assumes number of cores is a power ··· 203 203 */ 204 204 if (c->x86_num_cores > 1) { 205 205 int cpu = smp_processor_id(); 206 - /* Fix up the APIC ID following AMD specifications. */ 207 - cpu_core_id[cpu] >>= hweight32(c->x86_num_cores - 1); 206 + unsigned bits = 0; 207 + while ((1 << bits) < c->x86_num_cores) 208 + bits++; 209 + cpu_core_id[cpu] = phys_proc_id[cpu] & ((1<<bits)-1); 210 + phys_proc_id[cpu] >>= bits; 208 211 printk(KERN_INFO "CPU %d(%d) -> Core %d\n", 209 212 cpu, c->x86_num_cores, cpu_core_id[cpu]); 210 213 }
+1 -4
arch/i386/kernel/cpu/common.c
··· 244 244 245 245 early_intel_workaround(c); 246 246 247 - #ifdef CONFIG_SMP 248 247 #ifdef CONFIG_X86_HT 249 - phys_proc_id[smp_processor_id()] = 250 - #endif 251 - cpu_core_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff; 248 + phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff; 252 249 #endif 253 250 } 254 251
+1
arch/i386/kernel/smpboot.c
··· 888 888 889 889 cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned; 890 890 cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned; 891 + EXPORT_SYMBOL(cpu_core_map); 891 892 892 893 static void __init smp_boot_cpus(unsigned int max_cpus) 893 894 {
+6 -4
arch/i386/mm/ioremap.c
··· 238 238 addr < phys_to_virt(ISA_END_ADDRESS)) 239 239 return; 240 240 241 - p = remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr)); 241 + write_lock(&vmlist_lock); 242 + p = __remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr)); 242 243 if (!p) { 243 - printk("__iounmap: bad address %p\n", addr); 244 - return; 244 + printk("iounmap: bad address %p\n", addr); 245 + goto out_unlock; 245 246 } 246 247 247 248 if ((p->flags >> 20) && p->phys_addr < virt_to_phys(high_memory) - 1) { 248 - /* p->size includes the guard page, but cpa doesn't like that */ 249 249 change_page_attr(virt_to_page(__va(p->phys_addr)), 250 250 p->size >> PAGE_SHIFT, 251 251 PAGE_KERNEL); 252 252 global_flush_tlb(); 253 253 } 254 + out_unlock: 255 + write_unlock(&vmlist_lock); 254 256 kfree(p); 255 257 } 256 258
+9 -6
arch/ppc/kernel/head_44x.S
··· 330 330 /* If we are faulting a kernel address, we have to use the 331 331 * kernel page tables. 332 332 */ 333 - andis. r11, r10, 0x8000 334 - beq 3f 333 + lis r11, TASK_SIZE@h 334 + cmplw r10, r11 335 + blt+ 3f 335 336 lis r11, swapper_pg_dir@h 336 337 ori r11, r11, swapper_pg_dir@l 337 338 ··· 465 464 /* If we are faulting a kernel address, we have to use the 466 465 * kernel page tables. 467 466 */ 468 - andis. r11, r10, 0x8000 469 - beq 3f 467 + lis r11, TASK_SIZE@h 468 + cmplw r10, r11 469 + blt+ 3f 470 470 lis r11, swapper_pg_dir@h 471 471 ori r11, r11, swapper_pg_dir@l 472 472 ··· 535 533 /* If we are faulting a kernel address, we have to use the 536 534 * kernel page tables. 537 535 */ 538 - andis. r11, r10, 0x8000 539 - beq 3f 536 + lis r11, TASK_SIZE@h 537 + cmplw r10, r11 538 + blt+ 3f 540 539 lis r11, swapper_pg_dir@h 541 540 ori r11, r11, swapper_pg_dir@l 542 541
+1 -1
arch/ppc/kernel/setup.c
··· 499 499 { 500 500 struct device_node *prom_stdout; 501 501 char *name; 502 - int offset; 502 + int offset = 0; 503 503 504 504 if (of_stdout_device == NULL) 505 505 return -ENODEV;
+5 -2
arch/ppc/lib/string.S
··· 446 446 #ifdef CONFIG_8xx 447 447 /* Don't use prefetch on 8xx */ 448 448 mtctr r0 449 + li r0,0 449 450 53: COPY_16_BYTES_WITHEX(0) 450 451 bdnz 53b 451 452 ··· 565 564 /* or write fault in cacheline loop */ 566 565 105: li r9,1 567 566 92: li r3,LG_CACHELINE_BYTES 568 - b 99f 567 + mfctr r8 568 + add r0,r0,r8 569 + b 106f 569 570 /* read fault in final word loop */ 570 571 108: li r9,0 571 572 b 93f ··· 588 585 * r5 + (ctr << r3), and r9 is 0 for read or 1 for write. 589 586 */ 590 587 99: mfctr r0 591 - slw r3,r0,r3 588 + 106: slw r3,r0,r3 592 589 add. r3,r3,r5 593 590 beq 120f /* shouldn't happen */ 594 591 cmpwi 0,r9,0
+1
arch/ppc/mm/init.c
··· 179 179 if (!have_of) 180 180 FREESEC(openfirmware); 181 181 printk("\n"); 182 + ppc_md.progress = NULL; 182 183 #undef FREESEC 183 184 } 184 185
+1
arch/ppc/syslib/mpc83xx_devices.c
··· 61 61 .iotype = UPIO_MEM, 62 62 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, 63 63 }, 64 + { }, 64 65 }; 65 66 66 67 struct platform_device ppc_sys_platform_devices[] = {
+1
arch/ppc/syslib/mpc85xx_devices.c
··· 61 61 .iotype = UPIO_MEM, 62 62 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ, 63 63 }, 64 + { }, 64 65 }; 65 66 66 67 struct platform_device ppc_sys_platform_devices[] = {
-2
arch/ppc/syslib/open_pic.c
··· 557 557 */ 558 558 void openpic_cause_IPI(u_int ipi, cpumask_t cpumask) 559 559 { 560 - cpumask_t phys; 561 560 DECL_THIS_CPU; 562 561 563 562 CHECK_THIS_CPU; 564 563 check_arg_ipi(ipi); 565 - phys = physmask(cpumask); 566 564 openpic_write(&OpenPIC->THIS_CPU.IPI_Dispatch(ipi), 567 565 cpus_addr(physmask(cpumask))[0]); 568 566 }
+43 -1
arch/ppc64/kernel/prom_init.c
··· 1750 1750 prom_printf("Device tree struct 0x%x -> 0x%x\n", 1751 1751 RELOC(dt_struct_start), RELOC(dt_struct_end)); 1752 1752 1753 - } 1753 + } 1754 + 1755 + 1756 + static void __init fixup_device_tree(void) 1757 + { 1758 + unsigned long offset = reloc_offset(); 1759 + phandle u3, i2c, mpic; 1760 + u32 u3_rev; 1761 + u32 interrupts[2]; 1762 + u32 parent; 1763 + 1764 + /* Some G5s have a missing interrupt definition, fix it up here */ 1765 + u3 = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000")); 1766 + if ((long)u3 <= 0) 1767 + return; 1768 + i2c = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/i2c@f8001000")); 1769 + if ((long)i2c <= 0) 1770 + return; 1771 + mpic = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/mpic@f8040000")); 1772 + if ((long)mpic <= 0) 1773 + return; 1774 + 1775 + /* check if proper rev of u3 */ 1776 + if (prom_getprop(u3, "device-rev", &u3_rev, sizeof(u3_rev)) <= 0) 1777 + return; 1778 + if (u3_rev != 0x35) 1779 + return; 1780 + /* does it need fixup ? */ 1781 + if (prom_getproplen(i2c, "interrupts") > 0) 1782 + return; 1783 + /* interrupt on this revision of u3 is number 0 and level */ 1784 + interrupts[0] = 0; 1785 + interrupts[1] = 1; 1786 + prom_setprop(i2c, "interrupts", &interrupts, sizeof(interrupts)); 1787 + parent = (u32)mpic; 1788 + prom_setprop(i2c, "interrupt-parent", &parent, sizeof(parent)); 1789 + } 1790 + 1754 1791 1755 1792 static void __init prom_find_boot_cpu(void) 1756 1793 { ··· 1955 1918 prom_setprop(_prom->chosen, "linux,tce-alloc-end", 1956 1919 PTRRELOC(&prom_tce_alloc_end), sizeof(RELOC(prom_tce_alloc_end))); 1957 1920 } 1921 + 1922 + /* 1923 + * Fixup any known bugs in the device-tree 1924 + */ 1925 + fixup_device_tree(); 1958 1926 1959 1927 /* 1960 1928 * Now finally create the flattened device-tree
+67 -100
arch/sparc64/kernel/pci_iommu.c
··· 8 8 #include <linux/kernel.h> 9 9 #include <linux/sched.h> 10 10 #include <linux/mm.h> 11 + #include <linux/delay.h> 11 12 12 13 #include <asm/pbm.h> 13 14 ··· 380 379 return PCI_DMA_ERROR_CODE; 381 380 } 382 381 382 + static void pci_strbuf_flush(struct pci_strbuf *strbuf, struct pci_iommu *iommu, u32 vaddr, unsigned long ctx, unsigned long npages) 383 + { 384 + int limit; 385 + 386 + PCI_STC_FLUSHFLAG_INIT(strbuf); 387 + if (strbuf->strbuf_ctxflush && 388 + iommu->iommu_ctxflush) { 389 + unsigned long matchreg, flushreg; 390 + 391 + flushreg = strbuf->strbuf_ctxflush; 392 + matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); 393 + 394 + limit = 100000; 395 + pci_iommu_write(flushreg, ctx); 396 + for(;;) { 397 + if (((long)pci_iommu_read(matchreg)) >= 0L) 398 + break; 399 + limit--; 400 + if (!limit) 401 + break; 402 + udelay(1); 403 + } 404 + if (!limit) 405 + printk(KERN_WARNING "pci_strbuf_flush: ctx flush " 406 + "timeout vaddr[%08x] ctx[%lx]\n", 407 + vaddr, ctx); 408 + } else { 409 + unsigned long i; 410 + 411 + for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE) 412 + pci_iommu_write(strbuf->strbuf_pflush, vaddr); 413 + } 414 + 415 + pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); 416 + (void) pci_iommu_read(iommu->write_complete_reg); 417 + 418 + limit = 100000; 419 + while (!PCI_STC_FLUSHFLAG_SET(strbuf)) { 420 + limit--; 421 + if (!limit) 422 + break; 423 + udelay(1); 424 + membar("#LoadLoad"); 425 + } 426 + if (!limit) 427 + printk(KERN_WARNING "pci_strbuf_flush: flushflag timeout " 428 + "vaddr[%08x] ctx[%lx] npages[%ld]\n", 429 + vaddr, ctx, npages); 430 + } 431 + 383 432 /* Unmap a single streaming mode DMA translation. */ 384 433 void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) 385 434 { ··· 437 386 struct pci_iommu *iommu; 438 387 struct pci_strbuf *strbuf; 439 388 iopte_t *base; 440 - unsigned long flags, npages, i, ctx; 389 + unsigned long flags, npages, ctx; 441 390 442 391 if (direction == PCI_DMA_NONE) 443 392 BUG(); ··· 465 414 ctx = (iopte_val(*base) & IOPTE_CONTEXT) >> 47UL; 466 415 467 416 /* Step 1: Kick data out of streaming buffers if necessary. */ 468 - if (strbuf->strbuf_enabled) { 469 - u32 vaddr = bus_addr; 470 - 471 - PCI_STC_FLUSHFLAG_INIT(strbuf); 472 - if (strbuf->strbuf_ctxflush && 473 - iommu->iommu_ctxflush) { 474 - unsigned long matchreg, flushreg; 475 - 476 - flushreg = strbuf->strbuf_ctxflush; 477 - matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); 478 - do { 479 - pci_iommu_write(flushreg, ctx); 480 - } while(((long)pci_iommu_read(matchreg)) < 0L); 481 - } else { 482 - for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE) 483 - pci_iommu_write(strbuf->strbuf_pflush, vaddr); 484 - } 485 - 486 - pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); 487 - (void) pci_iommu_read(iommu->write_complete_reg); 488 - while (!PCI_STC_FLUSHFLAG_SET(strbuf)) 489 - membar("#LoadLoad"); 490 - } 417 + if (strbuf->strbuf_enabled) 418 + pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); 491 419 492 420 /* Step 2: Clear out first TSB entry. */ 493 421 iopte_make_dummy(iommu, base); ··· 677 647 ctx = (iopte_val(*base) & IOPTE_CONTEXT) >> 47UL; 678 648 679 649 /* Step 1: Kick data out of streaming buffers if necessary. */ 680 - if (strbuf->strbuf_enabled) { 681 - u32 vaddr = (u32) bus_addr; 682 - 683 - PCI_STC_FLUSHFLAG_INIT(strbuf); 684 - if (strbuf->strbuf_ctxflush && 685 - iommu->iommu_ctxflush) { 686 - unsigned long matchreg, flushreg; 687 - 688 - flushreg = strbuf->strbuf_ctxflush; 689 - matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); 690 - do { 691 - pci_iommu_write(flushreg, ctx); 692 - } while(((long)pci_iommu_read(matchreg)) < 0L); 693 - } else { 694 - for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE) 695 - pci_iommu_write(strbuf->strbuf_pflush, vaddr); 696 - } 697 - 698 - pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); 699 - (void) pci_iommu_read(iommu->write_complete_reg); 700 - while (!PCI_STC_FLUSHFLAG_SET(strbuf)) 701 - membar("#LoadLoad"); 702 - } 650 + if (strbuf->strbuf_enabled) 651 + pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); 703 652 704 653 /* Step 2: Clear out first TSB entry. */ 705 654 iopte_make_dummy(iommu, base); ··· 724 715 } 725 716 726 717 /* Step 2: Kick data out of streaming buffers. */ 727 - PCI_STC_FLUSHFLAG_INIT(strbuf); 728 - if (iommu->iommu_ctxflush && 729 - strbuf->strbuf_ctxflush) { 730 - unsigned long matchreg, flushreg; 731 - 732 - flushreg = strbuf->strbuf_ctxflush; 733 - matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); 734 - do { 735 - pci_iommu_write(flushreg, ctx); 736 - } while(((long)pci_iommu_read(matchreg)) < 0L); 737 - } else { 738 - unsigned long i; 739 - 740 - for (i = 0; i < npages; i++, bus_addr += IO_PAGE_SIZE) 741 - pci_iommu_write(strbuf->strbuf_pflush, bus_addr); 742 - } 743 - 744 - /* Step 3: Perform flush synchronization sequence. */ 745 - pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); 746 - (void) pci_iommu_read(iommu->write_complete_reg); 747 - while (!PCI_STC_FLUSHFLAG_SET(strbuf)) 748 - membar("#LoadLoad"); 718 + pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); 749 719 750 720 spin_unlock_irqrestore(&iommu->lock, flags); 751 721 } ··· 737 749 struct pcidev_cookie *pcp; 738 750 struct pci_iommu *iommu; 739 751 struct pci_strbuf *strbuf; 740 - unsigned long flags, ctx; 752 + unsigned long flags, ctx, npages, i; 753 + u32 bus_addr; 741 754 742 755 pcp = pdev->sysdata; 743 756 iommu = pcp->pbm->iommu; ··· 761 772 } 762 773 763 774 /* Step 2: Kick data out of streaming buffers. */ 764 - PCI_STC_FLUSHFLAG_INIT(strbuf); 765 - if (iommu->iommu_ctxflush && 766 - strbuf->strbuf_ctxflush) { 767 - unsigned long matchreg, flushreg; 768 - 769 - flushreg = strbuf->strbuf_ctxflush; 770 - matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); 771 - do { 772 - pci_iommu_write(flushreg, ctx); 773 - } while (((long)pci_iommu_read(matchreg)) < 0L); 774 - } else { 775 - unsigned long i, npages; 776 - u32 bus_addr; 777 - 778 - bus_addr = sglist[0].dma_address & IO_PAGE_MASK; 779 - 780 - for(i = 1; i < nelems; i++) 781 - if (!sglist[i].dma_length) 782 - break; 783 - i--; 784 - npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) - bus_addr) >> IO_PAGE_SHIFT; 785 - for (i = 0; i < npages; i++, bus_addr += IO_PAGE_SIZE) 786 - pci_iommu_write(strbuf->strbuf_pflush, bus_addr); 787 - } 788 - 789 - /* Step 3: Perform flush synchronization sequence. */ 790 - pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); 791 - (void) pci_iommu_read(iommu->write_complete_reg); 792 - while (!PCI_STC_FLUSHFLAG_SET(strbuf)) 793 - membar("#LoadLoad"); 775 + bus_addr = sglist[0].dma_address & IO_PAGE_MASK; 776 + for(i = 1; i < nelems; i++) 777 + if (!sglist[i].dma_length) 778 + break; 779 + i--; 780 + npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) 781 + - bus_addr) >> IO_PAGE_SHIFT; 782 + pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); 794 783 795 784 spin_unlock_irqrestore(&iommu->lock, flags); 796 785 }
+23 -8
arch/sparc64/kernel/sbus.c
··· 117 117 118 118 #define STRBUF_TAG_VALID 0x02UL 119 119 120 - static void strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages) 120 + static void sbus_strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages) 121 121 { 122 + unsigned long n; 123 + int limit; 124 + 122 125 iommu->strbuf_flushflag = 0UL; 123 - while (npages--) 124 - upa_writeq(base + (npages << IO_PAGE_SHIFT), 126 + n = npages; 127 + while (n--) 128 + upa_writeq(base + (n << IO_PAGE_SHIFT), 125 129 iommu->strbuf_regs + STRBUF_PFLUSH); 126 130 127 131 /* Whoopee cushion! */ 128 132 upa_writeq(__pa(&iommu->strbuf_flushflag), 129 133 iommu->strbuf_regs + STRBUF_FSYNC); 130 134 upa_readq(iommu->sbus_control_reg); 131 - while (iommu->strbuf_flushflag == 0UL) 135 + 136 + limit = 100000; 137 + while (iommu->strbuf_flushflag == 0UL) { 138 + limit--; 139 + if (!limit) 140 + break; 141 + udelay(1); 132 142 membar("#LoadLoad"); 143 + } 144 + if (!limit) 145 + printk(KERN_WARNING "sbus_strbuf_flush: flushflag timeout " 146 + "vaddr[%08x] npages[%ld]\n", 147 + base, npages); 133 148 } 134 149 135 150 static iopte_t *alloc_streaming_cluster(struct sbus_iommu *iommu, unsigned long npages) ··· 421 406 422 407 spin_lock_irqsave(&iommu->lock, flags); 423 408 free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT); 424 - strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT); 409 + sbus_strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT); 425 410 spin_unlock_irqrestore(&iommu->lock, flags); 426 411 } 427 412 ··· 584 569 iommu = sdev->bus->iommu; 585 570 spin_lock_irqsave(&iommu->lock, flags); 586 571 free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT); 587 - strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT); 572 + sbus_strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT); 588 573 spin_unlock_irqrestore(&iommu->lock, flags); 589 574 } 590 575 ··· 596 581 size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK)); 597 582 598 583 spin_lock_irqsave(&iommu->lock, flags); 599 - strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT); 584 + sbus_strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT); 600 585 spin_unlock_irqrestore(&iommu->lock, flags); 601 586 } 602 587 ··· 620 605 size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - base; 621 606 622 607 spin_lock_irqsave(&iommu->lock, flags); 623 - strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT); 608 + sbus_strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT); 624 609 spin_unlock_irqrestore(&iommu->lock, flags); 625 610 } 626 611
+4
arch/um/Kconfig_x86_64
··· 6 6 bool 7 7 default y 8 8 9 + config TOP_ADDR 10 + hex 11 + default 0x80000000 12 + 9 13 config 3_LEVEL_PGTABLES 10 14 bool 11 15 default y
+15 -7
arch/um/drivers/chan_kern.c
··· 20 20 #include "os.h" 21 21 22 22 #ifdef CONFIG_NOCONFIG_CHAN 23 + 24 + /* The printk's here are wrong because we are complaining that there is no 25 + * output device, but printk is printing to that output device. The user will 26 + * never see the error. printf would be better, except it can't run on a 27 + * kernel stack because it will overflow it. 28 + * Use printk for now since that will avoid crashing. 29 + */ 30 + 23 31 static void *not_configged_init(char *str, int device, struct chan_opts *opts) 24 32 { 25 - printf(KERN_ERR "Using a channel type which is configured out of " 33 + printk(KERN_ERR "Using a channel type which is configured out of " 26 34 "UML\n"); 27 35 return(NULL); 28 36 } ··· 38 30 static int not_configged_open(int input, int output, int primary, void *data, 39 31 char **dev_out) 40 32 { 41 - printf(KERN_ERR "Using a channel type which is configured out of " 33 + printk(KERN_ERR "Using a channel type which is configured out of " 42 34 "UML\n"); 43 35 return(-ENODEV); 44 36 } 45 37 46 38 static void not_configged_close(int fd, void *data) 47 39 { 48 - printf(KERN_ERR "Using a channel type which is configured out of " 40 + printk(KERN_ERR "Using a channel type which is configured out of " 49 41 "UML\n"); 50 42 } 51 43 52 44 static int not_configged_read(int fd, char *c_out, void *data) 53 45 { 54 - printf(KERN_ERR "Using a channel type which is configured out of " 46 + printk(KERN_ERR "Using a channel type which is configured out of " 55 47 "UML\n"); 56 48 return(-EIO); 57 49 } 58 50 59 51 static int not_configged_write(int fd, const char *buf, int len, void *data) 60 52 { 61 - printf(KERN_ERR "Using a channel type which is configured out of " 53 + printk(KERN_ERR "Using a channel type which is configured out of " 62 54 "UML\n"); 63 55 return(-EIO); 64 56 } ··· 66 58 static int not_configged_console_write(int fd, const char *buf, int len, 67 59 void *data) 68 60 { 69 - printf(KERN_ERR "Using a channel type which is configured out of " 61 + printk(KERN_ERR "Using a channel type which is configured out of " 70 62 "UML\n"); 71 63 return(-EIO); 72 64 } ··· 74 66 static int not_configged_window_size(int fd, void *data, unsigned short *rows, 75 67 unsigned short *cols) 76 68 { 77 - printf(KERN_ERR "Using a channel type which is configured out of " 69 + printk(KERN_ERR "Using a channel type which is configured out of " 78 70 "UML\n"); 79 71 return(-ENODEV); 80 72 }
+1 -3
arch/um/drivers/mcast_kern.c
··· 73 73 struct mcast_init *init = data; 74 74 char *port_str = NULL, *ttl_str = NULL, *remain; 75 75 char *last; 76 - int n; 77 76 78 77 *init = ((struct mcast_init) 79 78 { .addr = "239.192.168.1", ··· 88 89 } 89 90 90 91 if(port_str != NULL){ 91 - n = simple_strtoul(port_str, &last, 10); 92 + init->port = simple_strtoul(port_str, &last, 10); 92 93 if((*last != '\0') || (last == port_str)){ 93 94 printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", 94 95 port_str); 95 96 return(0); 96 97 } 97 - init->port = htons(n); 98 98 } 99 99 100 100 if(ttl_str != NULL){
+15 -32
arch/um/drivers/mcast_user.c
··· 38 38 } 39 39 sin->sin_family = AF_INET; 40 40 sin->sin_addr.s_addr = in_aton(addr); 41 - sin->sin_port = port; 41 + sin->sin_port = htons(port); 42 42 return(sin); 43 43 } 44 44 ··· 55 55 struct mcast_data *pri = data; 56 56 struct sockaddr_in *sin = pri->mcast_addr; 57 57 struct ip_mreq mreq; 58 - int fd, yes = 1; 58 + int fd = -EINVAL, yes = 1, err = -EINVAL;; 59 59 60 60 61 - if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) { 62 - fd = -EINVAL; 61 + if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) 63 62 goto out; 64 - } 65 63 66 64 fd = socket(AF_INET, SOCK_DGRAM, 0); 65 + 67 66 if (fd < 0){ 68 67 printk("mcast_open : data socket failed, errno = %d\n", 69 68 errno); 70 - fd = -ENOMEM; 69 + fd = -errno; 71 70 goto out; 72 71 } 73 72 74 73 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { 75 74 printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", 76 75 errno); 77 - os_close_file(fd); 78 - fd = -EINVAL; 79 - goto out; 76 + goto out_close; 80 77 } 81 78 82 79 /* set ttl according to config */ ··· 81 84 sizeof(pri->ttl)) < 0) { 82 85 printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", 83 86 errno); 84 - os_close_file(fd); 85 - fd = -EINVAL; 86 - goto out; 87 + goto out_close; 87 88 } 88 89 89 90 /* set LOOP, so data does get fed back to local sockets */ 90 91 if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { 91 92 printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", 92 93 errno); 93 - os_close_file(fd); 94 - fd = -EINVAL; 95 - goto out; 94 + goto out_close; 96 95 } 97 96 98 97 /* bind socket to mcast address */ 99 98 if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { 100 99 printk("mcast_open : data bind failed, errno = %d\n", errno); 101 - os_close_file(fd); 102 - fd = -EINVAL; 103 - goto out; 100 + goto out_close; 104 101 } 105 102 106 103 /* subscribe to the multicast group */ ··· 108 117 "interface on the host.\n"); 109 118 printk("eth0 should be configured in order to use the " 110 119 "multicast transport.\n"); 111 - os_close_file(fd); 112 - fd = -EINVAL; 120 + goto out_close; 113 121 } 114 122 115 123 out: 116 - return(fd); 124 + return fd; 125 + 126 + out_close: 127 + os_close_file(fd); 128 + return err; 117 129 } 118 130 119 131 static void mcast_close(int fd, void *data) ··· 158 164 .delete_address = NULL, 159 165 .max_packet = MAX_PACKET - ETH_HEADER_OTHER 160 166 }; 161 - 162 - /* 163 - * Overrides for Emacs so that we follow Linus's tabbing style. 164 - * Emacs will notice this stuff at the end of the file and automatically 165 - * adjust the settings for this buffer only. This must remain at the end 166 - * of the file. 167 - * --------------------------------------------------------------------------- 168 - * Local variables: 169 - * c-file-style: "linux" 170 - * End: 171 - */
+3 -293
arch/um/drivers/ubd_kern.c
··· 55 55 #include "mem_kern.h" 56 56 #include "cow.h" 57 57 58 - enum ubd_req { UBD_READ, UBD_WRITE, UBD_MMAP }; 58 + enum ubd_req { UBD_READ, UBD_WRITE }; 59 59 60 60 struct io_thread_req { 61 61 enum ubd_req op; ··· 68 68 unsigned long sector_mask; 69 69 unsigned long long cow_offset; 70 70 unsigned long bitmap_words[2]; 71 - int map_fd; 72 - unsigned long long map_offset; 73 71 int error; 74 72 }; 75 73 ··· 120 122 121 123 #define MAX_DEV (8) 122 124 123 - /* Changed in early boot */ 124 - static int ubd_do_mmap = 0; 125 - #define UBD_MMAP_BLOCK_SIZE PAGE_SIZE 126 - 127 125 static struct block_device_operations ubd_blops = { 128 126 .owner = THIS_MODULE, 129 127 .open = ubd_open, ··· 169 175 int no_cow; 170 176 struct cow cow; 171 177 struct platform_device pdev; 172 - 173 - int map_writes; 174 - int map_reads; 175 - int nomap_writes; 176 - int nomap_reads; 177 - int write_maps; 178 178 }; 179 179 180 180 #define DEFAULT_COW { \ ··· 188 200 .openflags = OPEN_FLAGS, \ 189 201 .no_cow = 0, \ 190 202 .cow = DEFAULT_COW, \ 191 - .map_writes = 0, \ 192 - .map_reads = 0, \ 193 - .nomap_writes = 0, \ 194 - .nomap_reads = 0, \ 195 - .write_maps = 0, \ 196 203 } 197 204 198 205 struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD }; ··· 297 314 int major; 298 315 299 316 str++; 300 - if(!strcmp(str, "mmap")){ 301 - CHOOSE_MODE(printk("mmap not supported by the ubd " 302 - "driver in tt mode\n"), 303 - ubd_do_mmap = 1); 304 - return(0); 305 - } 306 - 307 317 if(!strcmp(str, "sync")){ 308 318 global_openflags = of_sync(global_openflags); 309 319 return(0); ··· 500 524 { 501 525 struct io_thread_req req; 502 526 struct request *rq = elv_next_request(ubd_queue); 503 - int n, err; 527 + int n; 504 528 505 529 do_ubd = NULL; 506 530 intr_count++; ··· 514 538 return; 515 539 } 516 540 517 - if((req.op != UBD_MMAP) && 518 - ((req.offset != ((__u64) (rq->sector)) << 9) || 519 - (req.length != (rq->current_nr_sectors) << 9))) 520 - panic("I/O op mismatch"); 521 - 522 - if(req.map_fd != -1){ 523 - err = physmem_subst_mapping(req.buffer, req.map_fd, 524 - req.map_offset, 1); 525 - if(err) 526 - printk("ubd_handler - physmem_subst_mapping failed, " 527 - "err = %d\n", -err); 528 - } 529 - 530 541 ubd_finish(rq, req.error); 531 542 reactivate_fd(thread_fd, UBD_IRQ); 532 543 do_ubd_request(ubd_queue); ··· 546 583 547 584 static void ubd_close(struct ubd *dev) 548 585 { 549 - if(ubd_do_mmap) 550 - physmem_forget_descriptor(dev->fd); 551 586 os_close_file(dev->fd); 552 587 if(dev->cow.file == NULL) 553 588 return; 554 589 555 - if(ubd_do_mmap) 556 - physmem_forget_descriptor(dev->cow.fd); 557 590 os_close_file(dev->cow.fd); 558 591 vfree(dev->cow.bitmap); 559 592 dev->cow.bitmap = NULL; ··· 969 1010 req->bitmap_words, bitmap_len); 970 1011 } 971 1012 972 - static int mmap_fd(struct request *req, struct ubd *dev, __u64 offset) 973 - { 974 - __u64 sector; 975 - unsigned char *bitmap; 976 - int bit, i; 977 - 978 - /* mmap must have been requested on the command line */ 979 - if(!ubd_do_mmap) 980 - return(-1); 981 - 982 - /* The buffer must be page aligned */ 983 - if(((unsigned long) req->buffer % UBD_MMAP_BLOCK_SIZE) != 0) 984 - return(-1); 985 - 986 - /* The request must be a page long */ 987 - if((req->current_nr_sectors << 9) != PAGE_SIZE) 988 - return(-1); 989 - 990 - if(dev->cow.file == NULL) 991 - return(dev->fd); 992 - 993 - sector = offset >> 9; 994 - bitmap = (unsigned char *) dev->cow.bitmap; 995 - bit = ubd_test_bit(sector, bitmap); 996 - 997 - for(i = 1; i < req->current_nr_sectors; i++){ 998 - if(ubd_test_bit(sector + i, bitmap) != bit) 999 - return(-1); 1000 - } 1001 - 1002 - if(bit || (rq_data_dir(req) == WRITE)) 1003 - offset += dev->cow.data_offset; 1004 - 1005 - /* The data on disk must be page aligned */ 1006 - if((offset % UBD_MMAP_BLOCK_SIZE) != 0) 1007 - return(-1); 1008 - 1009 - return(bit ? dev->fd : dev->cow.fd); 1010 - } 1011 - 1012 - static int prepare_mmap_request(struct ubd *dev, int fd, __u64 offset, 1013 - struct request *req, 1014 - struct io_thread_req *io_req) 1015 - { 1016 - int err; 1017 - 1018 - if(rq_data_dir(req) == WRITE){ 1019 - /* Writes are almost no-ops since the new data is already in the 1020 - * host page cache 1021 - */ 1022 - dev->map_writes++; 1023 - if(dev->cow.file != NULL) 1024 - cowify_bitmap(io_req->offset, io_req->length, 1025 - &io_req->sector_mask, &io_req->cow_offset, 1026 - dev->cow.bitmap, dev->cow.bitmap_offset, 1027 - io_req->bitmap_words, 1028 - dev->cow.bitmap_len); 1029 - } 1030 - else { 1031 - int w; 1032 - 1033 - if((dev->cow.file != NULL) && (fd == dev->cow.fd)) 1034 - w = 0; 1035 - else w = dev->openflags.w; 1036 - 1037 - if((dev->cow.file != NULL) && (fd == dev->fd)) 1038 - offset += dev->cow.data_offset; 1039 - 1040 - err = physmem_subst_mapping(req->buffer, fd, offset, w); 1041 - if(err){ 1042 - printk("physmem_subst_mapping failed, err = %d\n", 1043 - -err); 1044 - return(1); 1045 - } 1046 - dev->map_reads++; 1047 - } 1048 - io_req->op = UBD_MMAP; 1049 - io_req->buffer = req->buffer; 1050 - return(0); 1051 - } 1052 - 1053 1013 /* Called with ubd_io_lock held */ 1054 1014 static int prepare_request(struct request *req, struct io_thread_req *io_req) 1055 1015 { 1056 1016 struct gendisk *disk = req->rq_disk; 1057 1017 struct ubd *dev = disk->private_data; 1058 1018 __u64 offset; 1059 - int len, fd; 1019 + int len; 1060 1020 1061 1021 if(req->rq_status == RQ_INACTIVE) return(1); 1062 1022 ··· 992 1114 993 1115 io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; 994 1116 io_req->fds[1] = dev->fd; 995 - io_req->map_fd = -1; 996 1117 io_req->cow_offset = -1; 997 1118 io_req->offset = offset; 998 1119 io_req->length = len; 999 1120 io_req->error = 0; 1000 1121 io_req->sector_mask = 0; 1001 - 1002 - fd = mmap_fd(req, dev, io_req->offset); 1003 - if(fd > 0){ 1004 - /* If mmapping is otherwise OK, but the first access to the 1005 - * page is a write, then it's not mapped in yet. So we have 1006 - * to write the data to disk first, then we can map the disk 1007 - * page in and continue normally from there. 1008 - */ 1009 - if((rq_data_dir(req) == WRITE) && !is_remapped(req->buffer)){ 1010 - io_req->map_fd = dev->fd; 1011 - io_req->map_offset = io_req->offset + 1012 - dev->cow.data_offset; 1013 - dev->write_maps++; 1014 - } 1015 - else return(prepare_mmap_request(dev, fd, io_req->offset, req, 1016 - io_req)); 1017 - } 1018 - 1019 - if(rq_data_dir(req) == READ) 1020 - dev->nomap_reads++; 1021 - else dev->nomap_writes++; 1022 1122 1023 1123 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE; 1024 1124 io_req->offsets[0] = 0; ··· 1084 1228 } 1085 1229 return(-EINVAL); 1086 1230 } 1087 - 1088 - static int ubd_check_remapped(int fd, unsigned long address, int is_write, 1089 - __u64 offset) 1090 - { 1091 - __u64 bitmap_offset; 1092 - unsigned long new_bitmap[2]; 1093 - int i, err, n; 1094 - 1095 - /* If it's not a write access, we can't do anything about it */ 1096 - if(!is_write) 1097 - return(0); 1098 - 1099 - /* We have a write */ 1100 - for(i = 0; i < sizeof(ubd_dev) / sizeof(ubd_dev[0]); i++){ 1101 - struct ubd *dev = &ubd_dev[i]; 1102 - 1103 - if((dev->fd != fd) && (dev->cow.fd != fd)) 1104 - continue; 1105 - 1106 - /* It's a write to a ubd device */ 1107 - 1108 - /* This should be impossible now */ 1109 - if(!dev->openflags.w){ 1110 - /* It's a write access on a read-only device - probably 1111 - * shouldn't happen. If the kernel is trying to change 1112 - * something with no intention of writing it back out, 1113 - * then this message will clue us in that this needs 1114 - * fixing 1115 - */ 1116 - printk("Write access to mapped page from readonly ubd " 1117 - "device %d\n", i); 1118 - return(0); 1119 - } 1120 - 1121 - /* It's a write to a writeable ubd device - it must be COWed 1122 - * because, otherwise, the page would have been mapped in 1123 - * writeable 1124 - */ 1125 - 1126 - if(!dev->cow.file) 1127 - panic("Write fault on writeable non-COW ubd device %d", 1128 - i); 1129 - 1130 - /* It should also be an access to the backing file since the 1131 - * COW pages should be mapped in read-write 1132 - */ 1133 - 1134 - if(fd == dev->fd) 1135 - panic("Write fault on a backing page of ubd " 1136 - "device %d\n", i); 1137 - 1138 - /* So, we do the write, copying the backing data to the COW 1139 - * file... 1140 - */ 1141 - 1142 - err = os_seek_file(dev->fd, offset + dev->cow.data_offset); 1143 - if(err < 0) 1144 - panic("Couldn't seek to %lld in COW file of ubd " 1145 - "device %d, err = %d", 1146 - offset + dev->cow.data_offset, i, -err); 1147 - 1148 - n = os_write_file(dev->fd, (void *) address, PAGE_SIZE); 1149 - if(n != PAGE_SIZE) 1150 - panic("Couldn't copy data to COW file of ubd " 1151 - "device %d, err = %d", i, -n); 1152 - 1153 - /* ... updating the COW bitmap... */ 1154 - 1155 - cowify_bitmap(offset, PAGE_SIZE, NULL, &bitmap_offset, 1156 - dev->cow.bitmap, dev->cow.bitmap_offset, 1157 - new_bitmap, dev->cow.bitmap_len); 1158 - 1159 - err = os_seek_file(dev->fd, bitmap_offset); 1160 - if(err < 0) 1161 - panic("Couldn't seek to %lld in COW file of ubd " 1162 - "device %d, err = %d", bitmap_offset, i, -err); 1163 - 1164 - n = os_write_file(dev->fd, new_bitmap, sizeof(new_bitmap)); 1165 - if(n != sizeof(new_bitmap)) 1166 - panic("Couldn't update bitmap of ubd device %d, " 1167 - "err = %d", i, -n); 1168 - 1169 - /* Maybe we can map the COW page in, and maybe we can't. If 1170 - * it is a pre-V3 COW file, we can't, since the alignment will 1171 - * be wrong. If it is a V3 or later COW file which has been 1172 - * moved to a system with a larger page size, then maybe we 1173 - * can't, depending on the exact location of the page. 1174 - */ 1175 - 1176 - offset += dev->cow.data_offset; 1177 - 1178 - /* Remove the remapping, putting the original anonymous page 1179 - * back. If the COW file can be mapped in, that is done. 1180 - * Otherwise, the COW page is read in. 1181 - */ 1182 - 1183 - if(!physmem_remove_mapping((void *) address)) 1184 - panic("Address 0x%lx not remapped by ubd device %d", 1185 - address, i); 1186 - if((offset % UBD_MMAP_BLOCK_SIZE) == 0) 1187 - physmem_subst_mapping((void *) address, dev->fd, 1188 - offset, 1); 1189 - else { 1190 - err = os_seek_file(dev->fd, offset); 1191 - if(err < 0) 1192 - panic("Couldn't seek to %lld in COW file of " 1193 - "ubd device %d, err = %d", offset, i, 1194 - -err); 1195 - 1196 - n = os_read_file(dev->fd, (void *) address, PAGE_SIZE); 1197 - if(n != PAGE_SIZE) 1198 - panic("Failed to read page from offset %llx of " 1199 - "COW file of ubd device %d, err = %d", 1200 - offset, i, -n); 1201 - } 1202 - 1203 - return(1); 1204 - } 1205 - 1206 - /* It's not a write on a ubd device */ 1207 - return(0); 1208 - } 1209 - 1210 - static struct remapper ubd_remapper = { 1211 - .list = LIST_HEAD_INIT(ubd_remapper.list), 1212 - .proc = ubd_check_remapped, 1213 - }; 1214 - 1215 - static int ubd_remapper_setup(void) 1216 - { 1217 - if(ubd_do_mmap) 1218 - register_remapper(&ubd_remapper); 1219 - 1220 - return(0); 1221 - } 1222 - 1223 - __initcall(ubd_remapper_setup); 1224 1231 1225 1232 static int same_backing_files(char *from_cmdline, char *from_cow, char *cow) 1226 1233 { ··· 1286 1567 int n, nsectors, start, end, bit; 1287 1568 int err; 1288 1569 __u64 off; 1289 - 1290 - if(req->op == UBD_MMAP){ 1291 - /* Touch the page to force the host to do any necessary IO to 1292 - * get it into memory 1293 - */ 1294 - n = *((volatile int *) req->buffer); 1295 - req->error = update_bitmap(req); 1296 - return; 1297 - } 1298 1570 1299 1571 nsectors = req->length / req->sectorsize; 1300 1572 start = 0;
+1 -1
arch/um/include/sysdep-i386/ptrace.h
··· 31 31 #ifdef UML_CONFIG_MODE_SKAS 32 32 33 33 #include "skas_ptregs.h" 34 - #include "sysdep/faultinfo.h" 35 34 36 35 #define REGS_IP(r) ((r)[HOST_IP]) 37 36 #define REGS_SP(r) ((r)[HOST_SP]) ··· 58 59 #define PTRACE_SYSEMU_SINGLESTEP 32 59 60 #endif 60 61 62 + #include "sysdep/faultinfo.h" 61 63 #include "choose-mode.h" 62 64 63 65 union uml_pt_regs {
+10 -16
arch/um/include/sysdep-x86_64/checksum.h
··· 9 9 #include "linux/in6.h" 10 10 #include "asm/uaccess.h" 11 11 12 - extern unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst, int len, 13 - int sum, int *err_ptr); 14 12 extern unsigned csum_partial(const unsigned char *buff, unsigned len, 15 13 unsigned sum); 16 14 ··· 29 31 } 30 32 31 33 static __inline__ 32 - unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, 33 - int len, int sum, int *err_ptr) 34 + unsigned int csum_partial_copy_from_user(const unsigned char *src, 35 + unsigned char *dst, int len, int sum, 36 + int *err_ptr) 34 37 { 35 - return csum_partial_copy_from(src, dst, len, sum, err_ptr); 38 + if(copy_from_user(dst, src, len)){ 39 + *err_ptr = -EFAULT; 40 + return(-1); 41 + } 42 + return csum_partial(dst, len, sum); 36 43 } 37 44 38 45 /** ··· 140 137 return a; 141 138 } 142 139 143 - #endif 140 + extern unsigned short ip_compute_csum(unsigned char * buff, int len); 144 141 145 - /* 146 - * Overrides for Emacs so that we follow Linus's tabbing style. 147 - * Emacs will notice this stuff at the end of the file and automatically 148 - * adjust the settings for this buffer only. This must remain at the end 149 - * of the file. 150 - * --------------------------------------------------------------------------- 151 - * Local variables: 152 - * c-file-style: "linux" 153 - * End: 154 - */ 142 + #endif
+26 -36
arch/um/include/sysdep-x86_64/ptrace.h
··· 135 135 __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs)) 136 136 #define UPT_SC(r) ((r)->tt.sc) 137 137 #define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall) 138 + #define UPT_SYSCALL_RET(r) UPT_RAX(r) 138 139 139 140 extern int user_context(unsigned long sp); 140 141 ··· 197 196 198 197 199 198 #define UPT_SET(regs, reg, val) \ 200 - ({ unsigned long val; \ 199 + ({ unsigned long __upt_val = val; \ 201 200 switch(reg){ \ 202 - case R8: UPT_R8(regs) = val; break; \ 203 - case R9: UPT_R9(regs) = val; break; \ 204 - case R10: UPT_R10(regs) = val; break; \ 205 - case R11: UPT_R11(regs) = val; break; \ 206 - case R12: UPT_R12(regs) = val; break; \ 207 - case R13: UPT_R13(regs) = val; break; \ 208 - case R14: UPT_R14(regs) = val; break; \ 209 - case R15: UPT_R15(regs) = val; break; \ 210 - case RIP: UPT_IP(regs) = val; break; \ 211 - case RSP: UPT_SP(regs) = val; break; \ 212 - case RAX: UPT_RAX(regs) = val; break; \ 213 - case RBX: UPT_RBX(regs) = val; break; \ 214 - case RCX: UPT_RCX(regs) = val; break; \ 215 - case RDX: UPT_RDX(regs) = val; break; \ 216 - case RSI: UPT_RSI(regs) = val; break; \ 217 - case RDI: UPT_RDI(regs) = val; break; \ 218 - case RBP: UPT_RBP(regs) = val; break; \ 219 - case ORIG_RAX: UPT_ORIG_RAX(regs) = val; break; \ 220 - case CS: UPT_CS(regs) = val; break; \ 221 - case DS: UPT_DS(regs) = val; break; \ 222 - case ES: UPT_ES(regs) = val; break; \ 223 - case FS: UPT_FS(regs) = val; break; \ 224 - case GS: UPT_GS(regs) = val; break; \ 225 - case EFLAGS: UPT_EFLAGS(regs) = val; break; \ 201 + case R8: UPT_R8(regs) = __upt_val; break; \ 202 + case R9: UPT_R9(regs) = __upt_val; break; \ 203 + case R10: UPT_R10(regs) = __upt_val; break; \ 204 + case R11: UPT_R11(regs) = __upt_val; break; \ 205 + case R12: UPT_R12(regs) = __upt_val; break; \ 206 + case R13: UPT_R13(regs) = __upt_val; break; \ 207 + case R14: UPT_R14(regs) = __upt_val; break; \ 208 + case R15: UPT_R15(regs) = __upt_val; break; \ 209 + case RIP: UPT_IP(regs) = __upt_val; break; \ 210 + case RSP: UPT_SP(regs) = __upt_val; break; \ 211 + case RAX: UPT_RAX(regs) = __upt_val; break; \ 212 + case RBX: UPT_RBX(regs) = __upt_val; break; \ 213 + case RCX: UPT_RCX(regs) = __upt_val; break; \ 214 + case RDX: UPT_RDX(regs) = __upt_val; break; \ 215 + case RSI: UPT_RSI(regs) = __upt_val; break; \ 216 + case RDI: UPT_RDI(regs) = __upt_val; break; \ 217 + case RBP: UPT_RBP(regs) = __upt_val; break; \ 218 + case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \ 219 + case CS: UPT_CS(regs) = __upt_val; break; \ 220 + case DS: UPT_DS(regs) = __upt_val; break; \ 221 + case ES: UPT_ES(regs) = __upt_val; break; \ 222 + case FS: UPT_FS(regs) = __upt_val; break; \ 223 + case GS: UPT_GS(regs) = __upt_val; break; \ 224 + case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \ 226 225 default : \ 227 226 panic("Bad register in UPT_SET : %d\n", reg); \ 228 227 break; \ ··· 246 245 CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo)) 247 246 248 247 #endif 249 - 250 - /* 251 - * Overrides for Emacs so that we follow Linus's tabbing style. 252 - * Emacs will notice this stuff at the end of the file and automatically 253 - * adjust the settings for this buffer only. This must remain at the end 254 - * of the file. 255 - * --------------------------------------------------------------------------- 256 - * Local variables: 257 - * c-file-style: "linux" 258 - * End: 259 - */
+1 -1
arch/um/kernel/Makefile
··· 14 14 tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o umid.o \ 15 15 user_util.o 16 16 17 - obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o 17 + obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o 18 18 obj-$(CONFIG_GPROF) += gprof_syms.o 19 19 obj-$(CONFIG_GCOV) += gmon_syms.o 20 20 obj-$(CONFIG_TTY_LOG) += tty_log.o
arch/um/kernel/checksum.c
+78
arch/um/kernel/initrd.c
··· 1 + /* 2 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 3 + * Licensed under the GPL 4 + */ 5 + 6 + #include "linux/init.h" 7 + #include "linux/bootmem.h" 8 + #include "linux/initrd.h" 9 + #include "asm/types.h" 10 + #include "user_util.h" 11 + #include "kern_util.h" 12 + #include "initrd.h" 13 + #include "init.h" 14 + #include "os.h" 15 + 16 + /* Changed by uml_initrd_setup, which is a setup */ 17 + static char *initrd __initdata = NULL; 18 + 19 + static int __init read_initrd(void) 20 + { 21 + void *area; 22 + long long size; 23 + int err; 24 + 25 + if(initrd == NULL) return 0; 26 + err = os_file_size(initrd, &size); 27 + if(err) return 0; 28 + area = alloc_bootmem(size); 29 + if(area == NULL) return 0; 30 + if(load_initrd(initrd, area, size) == -1) return 0; 31 + initrd_start = (unsigned long) area; 32 + initrd_end = initrd_start + size; 33 + return 0; 34 + } 35 + 36 + __uml_postsetup(read_initrd); 37 + 38 + static int __init uml_initrd_setup(char *line, int *add) 39 + { 40 + initrd = line; 41 + return 0; 42 + } 43 + 44 + __uml_setup("initrd=", uml_initrd_setup, 45 + "initrd=<initrd image>\n" 46 + " This is used to boot UML from an initrd image. The argument is the\n" 47 + " name of the file containing the image.\n\n" 48 + ); 49 + 50 + int load_initrd(char *filename, void *buf, int size) 51 + { 52 + int fd, n; 53 + 54 + fd = os_open_file(filename, of_read(OPENFLAGS()), 0); 55 + if(fd < 0){ 56 + printk("Opening '%s' failed - err = %d\n", filename, -fd); 57 + return(-1); 58 + } 59 + n = os_read_file(fd, buf, size); 60 + if(n != size){ 61 + printk("Read of %d bytes from '%s' failed, err = %d\n", size, 62 + filename, -n); 63 + return(-1); 64 + } 65 + 66 + os_close_file(fd); 67 + return(0); 68 + } 69 + /* 70 + * Overrides for Emacs so that we follow Linus's tabbing style. 71 + * Emacs will notice this stuff at the end of the file and automatically 72 + * adjust the settings for this buffer only. This must remain at the end 73 + * of the file. 74 + * --------------------------------------------------------------------------- 75 + * Local variables: 76 + * c-file-style: "linux" 77 + * End: 78 + */
+1
arch/um/kernel/ksyms.c
··· 57 57 EXPORT_SYMBOL(strncpy_from_user_skas); 58 58 EXPORT_SYMBOL(copy_to_user_skas); 59 59 EXPORT_SYMBOL(copy_from_user_skas); 60 + EXPORT_SYMBOL(clear_user_skas); 60 61 #endif 61 62 EXPORT_SYMBOL(uml_strdup); 62 63
+31 -9
arch/um/kernel/mem.c
··· 100 100 #endif 101 101 } 102 102 103 + /* 104 + * Create a page table and place a pointer to it in a middle page 105 + * directory entry. 106 + */ 107 + static void __init one_page_table_init(pmd_t *pmd) 108 + { 109 + if (pmd_none(*pmd)) { 110 + pte_t *pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); 111 + set_pmd(pmd, __pmd(_KERNPG_TABLE + 112 + (unsigned long) __pa(pte))); 113 + if (pte != pte_offset_kernel(pmd, 0)) 114 + BUG(); 115 + } 116 + } 117 + 118 + static void __init one_md_table_init(pud_t *pud) 119 + { 120 + #ifdef CONFIG_3_LEVEL_PGTABLES 121 + pmd_t *pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE); 122 + set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table))); 123 + if (pmd_table != pmd_offset(pud, 0)) 124 + BUG(); 125 + #endif 126 + } 127 + 103 128 static void __init fixrange_init(unsigned long start, unsigned long end, 104 129 pgd_t *pgd_base) 105 130 { 106 131 pgd_t *pgd; 132 + pud_t *pud; 107 133 pmd_t *pmd; 108 - pte_t *pte; 109 134 int i, j; 110 135 unsigned long vaddr; 111 136 ··· 140 115 pgd = pgd_base + i; 141 116 142 117 for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) { 143 - pmd = (pmd_t *)pgd; 118 + pud = pud_offset(pgd, vaddr); 119 + if (pud_none(*pud)) 120 + one_md_table_init(pud); 121 + pmd = pmd_offset(pud, vaddr); 144 122 for (; (j < PTRS_PER_PMD) && (vaddr != end); pmd++, j++) { 145 - if (pmd_none(*pmd)) { 146 - pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); 147 - set_pmd(pmd, __pmd(_KERNPG_TABLE + 148 - (unsigned long) __pa(pte))); 149 - if (pte != pte_offset_kernel(pmd, 0)) 150 - BUG(); 151 - } 123 + one_page_table_init(pmd); 152 124 vaddr += PMD_SIZE; 153 125 } 154 126 j = 0;
+3 -3
arch/um/kernel/ptrace.c
··· 28 28 child->thread.singlestep_syscall = 0; 29 29 30 30 #ifdef SUBARCH_SET_SINGLESTEPPING 31 - SUBARCH_SET_SINGLESTEPPING(child, on) 31 + SUBARCH_SET_SINGLESTEPPING(child, on); 32 32 #endif 33 - } 33 + } 34 34 35 35 /* 36 36 * Called by kernel/ptrace.c when detaching.. ··· 83 83 } 84 84 85 85 #ifdef SUBACH_PTRACE_SPECIAL 86 - SUBARCH_PTRACE_SPECIAL(child,request,addr,data) 86 + SUBARCH_PTRACE_SPECIAL(child,request,addr,data); 87 87 #endif 88 88 89 89 ret = ptrace_check_attach(child, request == PTRACE_KILL);
+4 -32
arch/um/kernel/trap_kern.c
··· 57 57 *code_out = SEGV_ACCERR; 58 58 if(is_write && !(vma->vm_flags & VM_WRITE)) 59 59 goto out; 60 + 61 + if(!(vma->vm_flags & (VM_READ | VM_EXEC))) 62 + goto out; 63 + 60 64 page = address & PAGE_MASK; 61 - pgd = pgd_offset(mm, page); 62 - pud = pud_offset(pgd, page); 63 - pmd = pmd_offset(pud, page); 64 65 do { 65 66 survive: 66 67 switch (handle_mm_fault(mm, vma, address, is_write)){ ··· 107 106 goto out; 108 107 } 109 108 110 - LIST_HEAD(physmem_remappers); 111 - 112 - void register_remapper(struct remapper *info) 113 - { 114 - list_add(&info->list, &physmem_remappers); 115 - } 116 - 117 - static int check_remapped_addr(unsigned long address, int is_write) 118 - { 119 - struct remapper *remapper; 120 - struct list_head *ele; 121 - __u64 offset; 122 - int fd; 123 - 124 - fd = phys_mapping(__pa(address), &offset); 125 - if(fd == -1) 126 - return(0); 127 - 128 - list_for_each(ele, &physmem_remappers){ 129 - remapper = list_entry(ele, struct remapper, list); 130 - if((*remapper->proc)(fd, address, is_write, offset)) 131 - return(1); 132 - } 133 - 134 - return(0); 135 - } 136 - 137 109 /* 138 110 * We give a *copy* of the faultinfo in the regs to segv. 139 111 * This must be done, since nesting SEGVs could overwrite ··· 125 151 flush_tlb_kernel_vm(); 126 152 return(0); 127 153 } 128 - else if(check_remapped_addr(address & PAGE_MASK, is_write)) 129 - return(0); 130 154 else if(current->mm == NULL) 131 155 panic("Segfault with no mm"); 132 156 err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
+1
arch/um/kernel/tt/ksyms.c
··· 12 12 EXPORT_SYMBOL(__do_strncpy_from_user); 13 13 EXPORT_SYMBOL(__do_strnlen_user); 14 14 EXPORT_SYMBOL(__do_clear_user); 15 + EXPORT_SYMBOL(clear_user_tt); 15 16 16 17 EXPORT_SYMBOL(tracing_pid); 17 18 EXPORT_SYMBOL(honeypot);
+2
arch/um/kernel/uml.lds.S
··· 73 73 74 74 .got : { *(.got.plt) *(.got) } 75 75 .dynamic : { *(.dynamic) } 76 + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } 77 + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 76 78 /* We want the small data sections together, so single-instruction offsets 77 79 can access them all, and initialized data all before uninitialized, so 78 80 we can shorten the on-disk segment size. */
+2 -2
arch/um/sys-i386/Makefile
··· 9 9 10 10 SYMLINKS = bitops.c semaphore.c highmem.c module.c 11 11 12 + include arch/um/scripts/Makefile.rules 13 + 12 14 bitops.c-dir = lib 13 15 semaphore.c-dir = kernel 14 16 highmem.c-dir = mm 15 17 module.c-dir = kernel 16 18 17 19 subdir- := util 18 - 19 - include arch/um/scripts/Makefile.rules
+12 -4
arch/um/sys-i386/delay.c
··· 1 - #include "linux/delay.h" 2 - #include "asm/param.h" 1 + #include <linux/module.h> 2 + #include <linux/kernel.h> 3 + #include <linux/delay.h> 4 + #include <asm/param.h> 3 5 4 6 void __delay(unsigned long time) 5 7 { ··· 22 20 int i, n; 23 21 24 22 n = (loops_per_jiffy * HZ * usecs) / MILLION; 25 - for(i=0;i<n;i++) ; 23 + for(i=0;i<n;i++) 24 + cpu_relax(); 26 25 } 26 + 27 + EXPORT_SYMBOL(__udelay); 27 28 28 29 void __const_udelay(unsigned long usecs) 29 30 { 30 31 int i, n; 31 32 32 33 n = (loops_per_jiffy * HZ * usecs) / MILLION; 33 - for(i=0;i<n;i++) ; 34 + for(i=0;i<n;i++) 35 + cpu_relax(); 34 36 } 37 + 38 + EXPORT_SYMBOL(__const_udelay);
+2 -4
arch/um/sys-x86_64/Makefile
··· 14 14 15 15 USER_OBJS := ptrace_user.o sigcontext.o 16 16 17 - include arch/um/scripts/Makefile.rules 18 - 19 17 SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c memcpy.S \ 20 18 semaphore.c thunk.S module.c 19 + 20 + include arch/um/scripts/Makefile.rules 21 21 22 22 bitops.c-dir = lib 23 23 csum-copy.S-dir = lib ··· 27 27 semaphore.c-dir = kernel 28 28 thunk.S-dir = lib 29 29 module.c-dir = kernel 30 - 31 - CFLAGS_csum-partial.o := -Dcsum_partial=arch_csum_partial 32 30 33 31 subdir- := util
+15 -18
arch/um/sys-x86_64/delay.c
··· 5 5 * Licensed under the GPL 6 6 */ 7 7 8 - #include "linux/delay.h" 9 - #include "asm/processor.h" 10 - #include "asm/param.h" 8 + #include <linux/module.h> 9 + #include <linux/delay.h> 10 + #include <asm/processor.h> 11 + #include <asm/param.h> 11 12 12 13 void __delay(unsigned long loops) 13 14 { 14 15 unsigned long i; 15 16 16 - for(i = 0; i < loops; i++) ; 17 + for(i = 0; i < loops; i++) 18 + cpu_relax(); 17 19 } 18 20 19 21 void __udelay(unsigned long usecs) 20 22 { 21 - int i, n; 23 + unsigned long i, n; 22 24 23 25 n = (loops_per_jiffy * HZ * usecs) / MILLION; 24 - for(i=0;i<n;i++) ; 26 + for(i=0;i<n;i++) 27 + cpu_relax(); 25 28 } 29 + 30 + EXPORT_SYMBOL(__udelay); 26 31 27 32 void __const_udelay(unsigned long usecs) 28 33 { 29 - int i, n; 34 + unsigned long i, n; 30 35 31 36 n = (loops_per_jiffy * HZ * usecs) / MILLION; 32 - for(i=0;i<n;i++) ; 37 + for(i=0;i<n;i++) 38 + cpu_relax(); 33 39 } 34 40 35 - /* 36 - * Overrides for Emacs so that we follow Linus's tabbing style. 37 - * Emacs will notice this stuff at the end of the file and automatically 38 - * adjust the settings for this buffer only. This must remain at the end 39 - * of the file. 40 - * --------------------------------------------------------------------------- 41 - * Local variables: 42 - * c-file-style: "linux" 43 - * End: 44 - */ 41 + EXPORT_SYMBOL(__const_udelay);
+1 -2
arch/um/sys-x86_64/ksyms.c
··· 16 16 EXPORT_SYMBOL(__memcpy); 17 17 18 18 /* Networking helper routines. */ 19 - /*EXPORT_SYMBOL(csum_partial_copy_from); 20 - EXPORT_SYMBOL(csum_partial_copy_to);*/ 19 + EXPORT_SYMBOL(ip_compute_csum);
+5 -4
arch/um/sys-x86_64/ptrace.c
··· 5 5 */ 6 6 7 7 #define __FRAME_OFFSETS 8 - #include "asm/ptrace.h" 9 - #include "linux/sched.h" 10 - #include "linux/errno.h" 11 - #include "asm/elf.h" 8 + #include <asm/ptrace.h> 9 + #include <linux/sched.h> 10 + #include <linux/errno.h> 11 + #include <asm/uaccess.h> 12 + #include <asm/elf.h> 12 13 13 14 /* XXX x86_64 */ 14 15 unsigned long not_ss;
+1
arch/um/sys-x86_64/syscalls.c
··· 15 15 #include "asm/unistd.h" 16 16 #include "asm/prctl.h" /* XXX This should get the constants from libc */ 17 17 #include "choose-mode.h" 18 + #include "kern.h" 18 19 19 20 asmlinkage long sys_uname64(struct new_utsname __user * name) 20 21 {
+8
arch/um/sys-x86_64/user-offsets.c
··· 3 3 #include <signal.h> 4 4 #define __FRAME_OFFSETS 5 5 #include <asm/ptrace.h> 6 + #include <asm/types.h> 7 + /* For some reason, x86_64 defines u64 and u32 only in <pci/types.h>, which I 8 + * refuse to include here, even though they're used throughout the headers. 9 + * These are used in asm/user.h, and that include can't be avoided because of 10 + * the sizeof(struct user_regs_struct) below. 11 + */ 12 + typedef __u64 u64; 13 + typedef __u32 u32; 6 14 #include <asm/user.h> 7 15 8 16 #define DEFINE(sym, val) \
+10 -1
arch/x86_64/kernel/io_apic.c
··· 42 42 43 43 int sis_apic_bug; /* not actually supported, dummy for compile */ 44 44 45 + static int no_timer_check; 46 + 45 47 static DEFINE_SPINLOCK(ioapic_lock); 46 48 47 49 /* ··· 1603 1601 * Ok, does IRQ0 through the IOAPIC work? 1604 1602 */ 1605 1603 unmask_IO_APIC_irq(0); 1606 - if (timer_irq_works()) { 1604 + if (!no_timer_check && timer_irq_works()) { 1607 1605 nmi_watchdog_default(); 1608 1606 if (nmi_watchdog == NMI_IO_APIC) { 1609 1607 disable_8259A_irq(0); ··· 1672 1670 apic_printk(APIC_VERBOSE," failed :(.\n"); 1673 1671 panic("IO-APIC + timer doesn't work! Try using the 'noapic' kernel parameter\n"); 1674 1672 } 1673 + 1674 + static int __init notimercheck(char *s) 1675 + { 1676 + no_timer_check = 1; 1677 + return 1; 1678 + } 1679 + __setup("no_timer_check", notimercheck); 1675 1680 1676 1681 /* 1677 1682 *
+2 -2
arch/x86_64/kernel/ptrace.c
··· 380 380 break; 381 381 382 382 switch (addr) { 383 - case 0 ... sizeof(struct user_regs_struct): 383 + case 0 ... sizeof(struct user_regs_struct) - sizeof(long): 384 384 tmp = getreg(child, addr); 385 385 break; 386 386 case offsetof(struct user, u_debugreg[0]): ··· 425 425 break; 426 426 427 427 switch (addr) { 428 - case 0 ... sizeof(struct user_regs_struct): 428 + case 0 ... sizeof(struct user_regs_struct) - sizeof(long): 429 429 ret = putreg(child, addr, data); 430 430 break; 431 431 /* Disallows to set a breakpoint into the vsyscall */
+12 -13
arch/x86_64/kernel/setup.c
··· 719 719 } 720 720 } 721 721 722 - #ifdef CONFIG_SMP 723 722 /* 724 723 * On a AMD dual core setup the lower bits of the APIC id distingush the cores. 725 724 * Assumes number of cores is a power of two. ··· 728 729 #ifdef CONFIG_SMP 729 730 int cpu = smp_processor_id(); 730 731 int node = 0; 732 + unsigned bits; 731 733 if (c->x86_num_cores == 1) 732 734 return; 733 - /* Fix up the APIC ID following the AMD specification. */ 734 - cpu_core_id[cpu] >>= hweight32(c->x86_num_cores - 1); 735 + 736 + bits = 0; 737 + while ((1 << bits) < c->x86_num_cores) 738 + bits++; 739 + 740 + /* Low order bits define the core id (index of core in socket) */ 741 + cpu_core_id[cpu] = phys_proc_id[cpu] & ((1 << bits)-1); 742 + /* Convert the APIC ID into the socket ID */ 743 + phys_proc_id[cpu] >>= bits; 735 744 736 745 #ifdef CONFIG_NUMA 737 746 /* When an ACPI SRAT table is available use the mappings from SRAT 738 747 instead. */ 739 748 if (acpi_numa <= 0) { 740 - node = cpu_core_id[cpu]; 749 + node = phys_proc_id[cpu]; 741 750 if (!node_online(node)) 742 751 node = first_node(node_online_map); 743 752 cpu_to_node[cpu] = node; ··· 753 746 node = cpu_to_node[cpu]; 754 747 } 755 748 #endif 756 - /* For now: - better than BAD_APIC_ID at least*/ 757 - phys_proc_id[cpu] = cpu_core_id[cpu]; 758 749 759 750 printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n", 760 751 cpu, c->x86_num_cores, node, cpu_core_id[cpu]); 761 752 #endif 762 753 } 763 - #else 764 - static void __init amd_detect_cmp(struct cpuinfo_x86 *c) 765 - { 766 - } 767 - #endif 768 754 769 755 static int __init init_amd(struct cpuinfo_x86 *c) 770 756 { ··· 963 963 } 964 964 965 965 #ifdef CONFIG_SMP 966 - phys_proc_id[smp_processor_id()] = 967 - cpu_core_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff; 966 + phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff; 968 967 #endif 969 968 } 970 969
+3 -1
arch/x86_64/kernel/signal.c
··· 452 452 regs->rip -= 2; 453 453 } 454 454 if (regs->rax == (unsigned long)-ERESTART_RESTARTBLOCK) { 455 - regs->rax = __NR_restart_syscall; 455 + regs->rax = test_thread_flag(TIF_IA32) ? 456 + __NR_ia32_restart_syscall : 457 + __NR_restart_syscall; 456 458 regs->rip -= 2; 457 459 } 458 460 }
+1
arch/x86_64/kernel/smpboot.c
··· 94 94 95 95 cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned; 96 96 cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned; 97 + EXPORT_SYMBOL(cpu_core_map); 97 98 98 99 /* 99 100 * Trampoline 80x86 program as an array.
+8 -21
arch/x86_64/mm/ioremap.c
··· 133 133 unsigned long flags) 134 134 { 135 135 int err = 0; 136 - if (flags && phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) { 136 + if (phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) { 137 137 unsigned long npages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 138 138 unsigned long vaddr = (unsigned long) __va(phys_addr); 139 139 ··· 214 214 remove_vm_area((void *)(PAGE_MASK & (unsigned long) addr)); 215 215 return NULL; 216 216 } 217 - if (ioremap_change_attr(phys_addr, size, flags) < 0) { 217 + if (flags && ioremap_change_attr(phys_addr, size, flags) < 0) { 218 218 area->flags &= 0xffffff; 219 219 vunmap(addr); 220 220 return NULL; ··· 251 251 252 252 void iounmap(volatile void __iomem *addr) 253 253 { 254 - struct vm_struct *p, **pprev; 254 + struct vm_struct *p; 255 255 256 256 if (addr <= high_memory) 257 257 return; ··· 260 260 return; 261 261 262 262 write_lock(&vmlist_lock); 263 - for (p = vmlist, pprev = &vmlist; p != NULL; pprev = &p->next, p = *pprev) 264 - if (p->addr == (void *)(PAGE_MASK & (unsigned long)addr)) 265 - break; 266 - if (!p) { 267 - printk("__iounmap: bad address %p\n", addr); 268 - goto out_unlock; 269 - } 270 - *pprev = p->next; 271 - unmap_vm_area(p); 272 - if ((p->flags >> 20) && 273 - p->phys_addr + p->size - 1 < virt_to_phys(high_memory)) { 274 - /* p->size includes the guard page, but cpa doesn't like that */ 275 - change_page_attr_addr((unsigned long)__va(p->phys_addr), 276 - p->size >> PAGE_SHIFT, 277 - PAGE_KERNEL); 278 - global_flush_tlb(); 279 - } 280 - out_unlock: 263 + p = __remove_vm_area((void *)((unsigned long)addr & PAGE_MASK)); 264 + if (!p) 265 + printk("iounmap: bad address %p\n", addr); 266 + else if (p->flags >> 20) 267 + ioremap_change_attr(p->phys_addr, p->size, 0); 281 268 write_unlock(&vmlist_lock); 282 269 kfree(p); 283 270 }
+7 -1
drivers/block/pktcdvd.c
··· 2021 2021 BUG_ON(pd->refcnt < 0); 2022 2022 2023 2023 pd->refcnt++; 2024 - if (pd->refcnt == 1) { 2024 + if (pd->refcnt > 1) { 2025 + if ((file->f_mode & FMODE_WRITE) && 2026 + !test_bit(PACKET_WRITABLE, &pd->flags)) { 2027 + ret = -EBUSY; 2028 + goto out_dec; 2029 + } 2030 + } else { 2025 2031 if (pkt_open_dev(pd, file->f_mode & FMODE_WRITE)) { 2026 2032 ret = -EIO; 2027 2033 goto out_dec;
+18 -2
drivers/char/ipmi/ipmi_devintf.c
··· 44 44 #include <linux/ipmi.h> 45 45 #include <asm/semaphore.h> 46 46 #include <linux/init.h> 47 + #include <linux/device.h> 47 48 48 49 #define IPMI_DEVINTF_VERSION "v33" 49 50 ··· 520 519 " interface. Other values will set the major device number" 521 520 " to that value."); 522 521 522 + static struct class *ipmi_class; 523 + 523 524 static void ipmi_new_smi(int if_num) 524 525 { 525 - devfs_mk_cdev(MKDEV(ipmi_major, if_num), 526 - S_IFCHR | S_IRUSR | S_IWUSR, 526 + dev_t dev = MKDEV(ipmi_major, if_num); 527 + 528 + devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, 527 529 "ipmidev/%d", if_num); 530 + 531 + class_simple_device_add(ipmi_class, dev, NULL, "ipmi%d", if_num); 528 532 } 529 533 530 534 static void ipmi_smi_gone(int if_num) 531 535 { 536 + class_simple_device_remove(ipmi_class, MKDEV(ipmi_major, if_num)); 532 537 devfs_remove("ipmidev/%d", if_num); 533 538 } 534 539 ··· 555 548 printk(KERN_INFO "ipmi device interface version " 556 549 IPMI_DEVINTF_VERSION "\n"); 557 550 551 + ipmi_class = class_simple_create(THIS_MODULE, "ipmi"); 552 + if (IS_ERR(ipmi_class)) { 553 + printk(KERN_ERR "ipmi: can't register device class\n"); 554 + return PTR_ERR(ipmi_class); 555 + } 556 + 558 557 rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops); 559 558 if (rv < 0) { 559 + class_simple_destroy(ipmi_class); 560 560 printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major); 561 561 return rv; 562 562 } ··· 577 563 rv = ipmi_smi_watcher_register(&smi_watcher); 578 564 if (rv) { 579 565 unregister_chrdev(ipmi_major, DEVICE_NAME); 566 + class_simple_destroy(ipmi_class); 580 567 printk(KERN_WARNING "ipmi: can't register smi watcher\n"); 581 568 return rv; 582 569 } ··· 588 573 589 574 static __exit void cleanup_ipmi(void) 590 575 { 576 + class_simple_destroy(ipmi_class); 591 577 ipmi_smi_watcher_unregister(&smi_watcher); 592 578 devfs_remove(DEVICE_NAME); 593 579 unregister_chrdev(ipmi_major, DEVICE_NAME);
+5
drivers/i2c/busses/i2c-keywest.c
··· 516 516 u32 *psteps, *prate; 517 517 int rc; 518 518 519 + if (np->n_intrs < 1 || np->n_addrs < 1) { 520 + printk(KERN_ERR "%s: Missing interrupt or address !\n", 521 + np->full_name); 522 + return -ENODEV; 523 + } 519 524 if (pmac_low_i2c_lock(np)) 520 525 return -ENODEV; 521 526
+4 -1
drivers/mmc/mmc_block.c
··· 383 383 struct mmc_blk_data *md; 384 384 int err; 385 385 386 - if (card->csd.cmdclass & ~0x1ff) 386 + /* 387 + * Check that the card supports the command class(es) we need. 388 + */ 389 + if (!(card->csd.cmdclass & CCC_BLOCK_READ)) 387 390 return -ENODEV; 388 391 389 392 if (card->csd.read_blkbits < 9) {
+364 -116
drivers/net/tg3.c
··· 420 420 { 421 421 tw32(TG3PCI_MISC_HOST_CTRL, 422 422 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); 423 - tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000); 423 + tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 424 + (tp->last_tag << 24)); 424 425 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 425 426 426 427 tg3_cond_int(tp); ··· 456 455 { 457 456 tw32(TG3PCI_MISC_HOST_CTRL, 458 457 (tp->misc_host_ctrl & ~MISC_HOST_CTRL_MASK_PCI_INT)); 459 - tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000); 458 + tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 459 + tp->last_tag << 24); 460 460 mmiowb(); 461 461 462 - if (tg3_has_work(tp)) 462 + /* When doing tagged status, this work check is unnecessary. 463 + * The last_tag we write above tells the chip which piece of 464 + * work we've completed. 465 + */ 466 + if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) && 467 + tg3_has_work(tp)) 463 468 tw32(HOSTCC_MODE, tp->coalesce_mode | 464 469 (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW)); 465 470 } ··· 2507 2500 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 2508 2501 if (netif_carrier_ok(tp->dev)) { 2509 2502 tw32(HOSTCC_STAT_COAL_TICKS, 2510 - DEFAULT_STAT_COAL_TICKS); 2503 + tp->coal.stats_block_coalesce_usecs); 2511 2504 } else { 2512 2505 tw32(HOSTCC_STAT_COAL_TICKS, 0); 2513 2506 } ··· 2893 2886 * All RX "locking" is done by ensuring outside 2894 2887 * code synchronizes with dev->poll() 2895 2888 */ 2896 - done = 1; 2897 2889 if (sblk->idx[0].rx_producer != tp->rx_rcb_ptr) { 2898 2890 int orig_budget = *budget; 2899 2891 int work_done; ··· 2904 2898 2905 2899 *budget -= work_done; 2906 2900 netdev->quota -= work_done; 2907 - 2908 - if (work_done >= orig_budget) 2909 - done = 0; 2910 2901 } 2911 2902 2903 + if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) 2904 + tp->last_tag = sblk->status_tag; 2905 + rmb(); 2906 + 2912 2907 /* if no more work, tell net stack and NIC we're done */ 2908 + done = !tg3_has_work(tp); 2913 2909 if (done) { 2914 2910 spin_lock_irqsave(&tp->lock, flags); 2915 2911 __netif_rx_complete(netdev); ··· 2936 2928 spin_lock_irqsave(&tp->lock, flags); 2937 2929 2938 2930 /* 2939 - * writing any value to intr-mbox-0 clears PCI INTA# and 2931 + * Writing any value to intr-mbox-0 clears PCI INTA# and 2940 2932 * chip-internal interrupt pending events. 2941 - * writing non-zero to intr-mbox-0 additional tells the 2933 + * Writing non-zero to intr-mbox-0 additional tells the 2942 2934 * NIC to stop sending us irqs, engaging "in-intr-handler" 2943 2935 * event coalescing. 2944 2936 */ 2945 2937 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001); 2938 + tp->last_tag = sblk->status_tag; 2946 2939 sblk->status &= ~SD_STATUS_UPDATED; 2947 - 2948 2940 if (likely(tg3_has_work(tp))) 2949 2941 netif_rx_schedule(dev); /* schedule NAPI poll */ 2950 2942 else { 2951 - /* no work, re-enable interrupts 2952 - */ 2943 + /* No work, re-enable interrupts. */ 2953 2944 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 2954 - 0x00000000); 2945 + tp->last_tag << 24); 2955 2946 } 2956 2947 2957 2948 spin_unlock_irqrestore(&tp->lock, flags); ··· 2976 2969 if ((sblk->status & SD_STATUS_UPDATED) || 2977 2970 !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) { 2978 2971 /* 2972 + * Writing any value to intr-mbox-0 clears PCI INTA# and 2973 + * chip-internal interrupt pending events. 2974 + * Writing non-zero to intr-mbox-0 additional tells the 2975 + * NIC to stop sending us irqs, engaging "in-intr-handler" 2976 + * event coalescing. 2977 + */ 2978 + tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 2979 + 0x00000001); 2980 + sblk->status &= ~SD_STATUS_UPDATED; 2981 + if (likely(tg3_has_work(tp))) 2982 + netif_rx_schedule(dev); /* schedule NAPI poll */ 2983 + else { 2984 + /* No work, shared interrupt perhaps? re-enable 2985 + * interrupts, and flush that PCI write 2986 + */ 2987 + tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 2988 + 0x00000000); 2989 + tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 2990 + } 2991 + } else { /* shared interrupt */ 2992 + handled = 0; 2993 + } 2994 + 2995 + spin_unlock_irqrestore(&tp->lock, flags); 2996 + 2997 + return IRQ_RETVAL(handled); 2998 + } 2999 + 3000 + static irqreturn_t tg3_interrupt_tagged(int irq, void *dev_id, struct pt_regs *regs) 3001 + { 3002 + struct net_device *dev = dev_id; 3003 + struct tg3 *tp = netdev_priv(dev); 3004 + struct tg3_hw_status *sblk = tp->hw_status; 3005 + unsigned long flags; 3006 + unsigned int handled = 1; 3007 + 3008 + spin_lock_irqsave(&tp->lock, flags); 3009 + 3010 + /* In INTx mode, it is possible for the interrupt to arrive at 3011 + * the CPU before the status block posted prior to the interrupt. 3012 + * Reading the PCI State register will confirm whether the 3013 + * interrupt is ours and will flush the status block. 3014 + */ 3015 + if ((sblk->status & SD_STATUS_UPDATED) || 3016 + !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) { 3017 + /* 2979 3018 * writing any value to intr-mbox-0 clears PCI INTA# and 2980 3019 * chip-internal interrupt pending events. 2981 3020 * writing non-zero to intr-mbox-0 additional tells the ··· 3030 2977 */ 3031 2978 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 3032 2979 0x00000001); 3033 - /* 3034 - * Flush PCI write. This also guarantees that our 3035 - * status block has been flushed to host memory. 3036 - */ 3037 - tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 2980 + tp->last_tag = sblk->status_tag; 3038 2981 sblk->status &= ~SD_STATUS_UPDATED; 3039 - 3040 2982 if (likely(tg3_has_work(tp))) 3041 2983 netif_rx_schedule(dev); /* schedule NAPI poll */ 3042 2984 else { ··· 3039 2991 * interrupts, and flush that PCI write 3040 2992 */ 3041 2993 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 3042 - 0x00000000); 2994 + tp->last_tag << 24); 3043 2995 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 3044 2996 } 3045 2997 } else { /* shared interrupt */ ··· 5092 5044 } 5093 5045 5094 5046 static void __tg3_set_rx_mode(struct net_device *); 5047 + static void tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec) 5048 + { 5049 + tw32(HOSTCC_RXCOL_TICKS, ec->rx_coalesce_usecs); 5050 + tw32(HOSTCC_TXCOL_TICKS, ec->tx_coalesce_usecs); 5051 + tw32(HOSTCC_RXMAX_FRAMES, ec->rx_max_coalesced_frames); 5052 + tw32(HOSTCC_TXMAX_FRAMES, ec->tx_max_coalesced_frames); 5053 + if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 5054 + tw32(HOSTCC_RXCOAL_TICK_INT, ec->rx_coalesce_usecs_irq); 5055 + tw32(HOSTCC_TXCOAL_TICK_INT, ec->tx_coalesce_usecs_irq); 5056 + } 5057 + tw32(HOSTCC_RXCOAL_MAXF_INT, ec->rx_max_coalesced_frames_irq); 5058 + tw32(HOSTCC_TXCOAL_MAXF_INT, ec->tx_max_coalesced_frames_irq); 5059 + if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 5060 + u32 val = ec->stats_block_coalesce_usecs; 5061 + 5062 + if (!netif_carrier_ok(tp->dev)) 5063 + val = 0; 5064 + 5065 + tw32(HOSTCC_STAT_COAL_TICKS, val); 5066 + } 5067 + } 5095 5068 5096 5069 /* tp->lock is held. */ 5097 5070 static int tg3_reset_hw(struct tg3 *tp) ··· 5435 5366 udelay(10); 5436 5367 } 5437 5368 5438 - tw32(HOSTCC_RXCOL_TICKS, 0); 5439 - tw32(HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS); 5440 - tw32(HOSTCC_RXMAX_FRAMES, 1); 5441 - tw32(HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES); 5442 - if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 5443 - tw32(HOSTCC_RXCOAL_TICK_INT, 0); 5444 - tw32(HOSTCC_TXCOAL_TICK_INT, 0); 5445 - } 5446 - tw32(HOSTCC_RXCOAL_MAXF_INT, 1); 5447 - tw32(HOSTCC_TXCOAL_MAXF_INT, 0); 5369 + tg3_set_coalesce(tp, &tp->coal); 5448 5370 5449 5371 /* set status block DMA address */ 5450 5372 tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, ··· 5448 5388 * the tg3_periodic_fetch_stats call there, and 5449 5389 * tg3_get_stats to see how this works for 5705/5750 chips. 5450 5390 */ 5451 - tw32(HOSTCC_STAT_COAL_TICKS, 5452 - DEFAULT_STAT_COAL_TICKS); 5453 5391 tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 5454 5392 ((u64) tp->stats_mapping >> 32)); 5455 5393 tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW, ··· 5503 5445 udelay(100); 5504 5446 5505 5447 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0); 5506 - tr32(MAILBOX_INTERRUPT_0); 5448 + tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 5449 + tp->last_tag = 0; 5507 5450 5508 5451 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 5509 5452 tw32_f(DMAC_MODE, DMAC_MODE_ENABLE); ··· 5782 5723 spin_lock_irqsave(&tp->lock, flags); 5783 5724 spin_lock(&tp->tx_lock); 5784 5725 5785 - /* All of this garbage is because when using non-tagged 5786 - * IRQ status the mailbox/status_block protocol the chip 5787 - * uses with the cpu is race prone. 5788 - */ 5789 - if (tp->hw_status->status & SD_STATUS_UPDATED) { 5790 - tw32(GRC_LOCAL_CTRL, 5791 - tp->grc_local_ctrl | GRC_LCLCTRL_SETINT); 5792 - } else { 5793 - tw32(HOSTCC_MODE, tp->coalesce_mode | 5794 - (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW)); 5795 - } 5726 + if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) { 5727 + /* All of this garbage is because when using non-tagged 5728 + * IRQ status the mailbox/status_block protocol the chip 5729 + * uses with the cpu is race prone. 5730 + */ 5731 + if (tp->hw_status->status & SD_STATUS_UPDATED) { 5732 + tw32(GRC_LOCAL_CTRL, 5733 + tp->grc_local_ctrl | GRC_LCLCTRL_SETINT); 5734 + } else { 5735 + tw32(HOSTCC_MODE, tp->coalesce_mode | 5736 + (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW)); 5737 + } 5796 5738 5797 - if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { 5798 - tp->tg3_flags2 |= TG3_FLG2_RESTART_TIMER; 5799 - spin_unlock(&tp->tx_lock); 5800 - spin_unlock_irqrestore(&tp->lock, flags); 5801 - schedule_work(&tp->reset_task); 5802 - return; 5739 + if (!(tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { 5740 + tp->tg3_flags2 |= TG3_FLG2_RESTART_TIMER; 5741 + spin_unlock(&tp->tx_lock); 5742 + spin_unlock_irqrestore(&tp->lock, flags); 5743 + schedule_work(&tp->reset_task); 5744 + return; 5745 + } 5803 5746 } 5804 - 5805 - if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) 5806 - tg3_periodic_fetch_stats(tp); 5807 5747 5808 5748 /* This part only runs once per second. */ 5809 5749 if (!--tp->timer_counter) { 5750 + if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) 5751 + tg3_periodic_fetch_stats(tp); 5752 + 5810 5753 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) { 5811 5754 u32 mac_stat; 5812 5755 int phy_event; ··· 5907 5846 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) 5908 5847 err = request_irq(tp->pdev->irq, tg3_msi, 5909 5848 SA_SAMPLE_RANDOM, dev->name, dev); 5910 - else 5911 - err = request_irq(tp->pdev->irq, tg3_interrupt, 5849 + else { 5850 + irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt; 5851 + if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) 5852 + fn = tg3_interrupt_tagged; 5853 + err = request_irq(tp->pdev->irq, fn, 5912 5854 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 5855 + } 5913 5856 5914 5857 if (err) 5915 5858 return err; ··· 5965 5900 5966 5901 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; 5967 5902 5968 - err = request_irq(tp->pdev->irq, tg3_interrupt, 5969 - SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 5903 + { 5904 + irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt; 5905 + if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) 5906 + fn = tg3_interrupt_tagged; 5970 5907 5908 + err = request_irq(tp->pdev->irq, fn, 5909 + SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 5910 + } 5971 5911 if (err) 5972 5912 return err; 5973 5913 ··· 6018 5948 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 6019 5949 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) && 6020 5950 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) { 6021 - if (pci_enable_msi(tp->pdev) == 0) { 5951 + /* All MSI supporting chips should support tagged 5952 + * status. Assert that this is the case. 5953 + */ 5954 + if (!(tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)) { 5955 + printk(KERN_WARNING PFX "%s: MSI without TAGGED? " 5956 + "Not using MSI.\n", tp->dev->name); 5957 + } else if (pci_enable_msi(tp->pdev) == 0) { 6022 5958 u32 msi_mode; 6023 5959 6024 5960 msi_mode = tr32(MSGINT_MODE); ··· 6035 5959 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) 6036 5960 err = request_irq(tp->pdev->irq, tg3_msi, 6037 5961 SA_SAMPLE_RANDOM, dev->name, dev); 6038 - else 6039 - err = request_irq(tp->pdev->irq, tg3_interrupt, 5962 + else { 5963 + irqreturn_t (*fn)(int, void *, struct pt_regs *)=tg3_interrupt; 5964 + if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) 5965 + fn = tg3_interrupt_tagged; 5966 + 5967 + err = request_irq(tp->pdev->irq, fn, 6040 5968 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 5969 + } 6041 5970 6042 5971 if (err) { 6043 5972 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { ··· 6061 5980 tg3_halt(tp, 1); 6062 5981 tg3_free_rings(tp); 6063 5982 } else { 6064 - tp->timer_offset = HZ / 10; 6065 - tp->timer_counter = tp->timer_multiplier = 10; 6066 - tp->asf_counter = tp->asf_multiplier = (10 * 120); 5983 + if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) 5984 + tp->timer_offset = HZ; 5985 + else 5986 + tp->timer_offset = HZ / 10; 5987 + 5988 + BUG_ON(tp->timer_offset > HZ); 5989 + tp->timer_counter = tp->timer_multiplier = 5990 + (HZ / tp->timer_offset); 5991 + tp->asf_counter = tp->asf_multiplier = 5992 + ((HZ / tp->timer_offset) * 120); 6067 5993 6068 5994 init_timer(&tp->timer); 6069 5995 tp->timer.expires = jiffies + tp->timer_offset; ··· 6093 6005 6094 6006 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) { 6095 6007 err = tg3_test_msi(tp); 6008 + 6096 6009 if (err) { 6097 6010 spin_lock_irq(&tp->lock); 6098 6011 spin_lock(&tp->tx_lock); ··· 7292 7203 } 7293 7204 #endif 7294 7205 7206 + static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) 7207 + { 7208 + struct tg3 *tp = netdev_priv(dev); 7209 + 7210 + memcpy(ec, &tp->coal, sizeof(*ec)); 7211 + return 0; 7212 + } 7213 + 7295 7214 static struct ethtool_ops tg3_ethtool_ops = { 7296 7215 .get_settings = tg3_get_settings, 7297 7216 .set_settings = tg3_set_settings, ··· 7332 7235 .get_strings = tg3_get_strings, 7333 7236 .get_stats_count = tg3_get_stats_count, 7334 7237 .get_ethtool_stats = tg3_get_ethtool_stats, 7238 + .get_coalesce = tg3_get_coalesce, 7335 7239 }; 7336 7240 7337 7241 static void __devinit tg3_get_eeprom_size(struct tg3 *tp) ··· 8520 8422 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) 8521 8423 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; 8522 8424 8523 - /* Only 5701 and later support tagged irq status mode. 8524 - * Also, 5788 chips cannot use tagged irq status. 8525 - * 8526 - * However, since we are using NAPI avoid tagged irq status 8527 - * because the interrupt condition is more difficult to 8528 - * fully clear in that mode. 8529 - */ 8530 8425 tp->coalesce_mode = 0; 8531 - 8532 8426 if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX && 8533 8427 GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_BX) 8534 8428 tp->coalesce_mode |= HOSTCC_MODE_32BYTE; ··· 8583 8493 (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 || 8584 8494 grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M)) 8585 8495 tp->tg3_flags2 |= TG3_FLG2_IS_5788; 8496 + 8497 + if (!(tp->tg3_flags2 & TG3_FLG2_IS_5788) && 8498 + (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700)) 8499 + tp->tg3_flags |= TG3_FLAG_TAGGED_STATUS; 8500 + if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) { 8501 + tp->coalesce_mode |= (HOSTCC_MODE_CLRTICK_RXBD | 8502 + HOSTCC_MODE_CLRTICK_TXBD); 8503 + 8504 + tp->misc_host_ctrl |= MISC_HOST_CTRL_TAGGED_STATUS; 8505 + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, 8506 + tp->misc_host_ctrl); 8507 + } 8586 8508 8587 8509 /* these are limited to 10/100 only */ 8588 8510 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 && ··· 8773 8671 return 0; 8774 8672 } 8775 8673 8674 + #define BOUNDARY_SINGLE_CACHELINE 1 8675 + #define BOUNDARY_MULTI_CACHELINE 2 8676 + 8677 + static u32 __devinit tg3_calc_dma_bndry(struct tg3 *tp, u32 val) 8678 + { 8679 + int cacheline_size; 8680 + u8 byte; 8681 + int goal; 8682 + 8683 + pci_read_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, &byte); 8684 + if (byte == 0) 8685 + cacheline_size = 1024; 8686 + else 8687 + cacheline_size = (int) byte * 4; 8688 + 8689 + /* On 5703 and later chips, the boundary bits have no 8690 + * effect. 8691 + */ 8692 + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 && 8693 + GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701 && 8694 + !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) 8695 + goto out; 8696 + 8697 + #if defined(CONFIG_PPC64) || defined(CONFIG_IA64) || defined(CONFIG_PARISC) 8698 + goal = BOUNDARY_MULTI_CACHELINE; 8699 + #else 8700 + #if defined(CONFIG_SPARC64) || defined(CONFIG_ALPHA) 8701 + goal = BOUNDARY_SINGLE_CACHELINE; 8702 + #else 8703 + goal = 0; 8704 + #endif 8705 + #endif 8706 + 8707 + if (!goal) 8708 + goto out; 8709 + 8710 + /* PCI controllers on most RISC systems tend to disconnect 8711 + * when a device tries to burst across a cache-line boundary. 8712 + * Therefore, letting tg3 do so just wastes PCI bandwidth. 8713 + * 8714 + * Unfortunately, for PCI-E there are only limited 8715 + * write-side controls for this, and thus for reads 8716 + * we will still get the disconnects. We'll also waste 8717 + * these PCI cycles for both read and write for chips 8718 + * other than 5700 and 5701 which do not implement the 8719 + * boundary bits. 8720 + */ 8721 + if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) && 8722 + !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) { 8723 + switch (cacheline_size) { 8724 + case 16: 8725 + case 32: 8726 + case 64: 8727 + case 128: 8728 + if (goal == BOUNDARY_SINGLE_CACHELINE) { 8729 + val |= (DMA_RWCTRL_READ_BNDRY_128_PCIX | 8730 + DMA_RWCTRL_WRITE_BNDRY_128_PCIX); 8731 + } else { 8732 + val |= (DMA_RWCTRL_READ_BNDRY_384_PCIX | 8733 + DMA_RWCTRL_WRITE_BNDRY_384_PCIX); 8734 + } 8735 + break; 8736 + 8737 + case 256: 8738 + val |= (DMA_RWCTRL_READ_BNDRY_256_PCIX | 8739 + DMA_RWCTRL_WRITE_BNDRY_256_PCIX); 8740 + break; 8741 + 8742 + default: 8743 + val |= (DMA_RWCTRL_READ_BNDRY_384_PCIX | 8744 + DMA_RWCTRL_WRITE_BNDRY_384_PCIX); 8745 + break; 8746 + }; 8747 + } else if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) { 8748 + switch (cacheline_size) { 8749 + case 16: 8750 + case 32: 8751 + case 64: 8752 + if (goal == BOUNDARY_SINGLE_CACHELINE) { 8753 + val &= ~DMA_RWCTRL_WRITE_BNDRY_DISAB_PCIE; 8754 + val |= DMA_RWCTRL_WRITE_BNDRY_64_PCIE; 8755 + break; 8756 + } 8757 + /* fallthrough */ 8758 + case 128: 8759 + default: 8760 + val &= ~DMA_RWCTRL_WRITE_BNDRY_DISAB_PCIE; 8761 + val |= DMA_RWCTRL_WRITE_BNDRY_128_PCIE; 8762 + break; 8763 + }; 8764 + } else { 8765 + switch (cacheline_size) { 8766 + case 16: 8767 + if (goal == BOUNDARY_SINGLE_CACHELINE) { 8768 + val |= (DMA_RWCTRL_READ_BNDRY_16 | 8769 + DMA_RWCTRL_WRITE_BNDRY_16); 8770 + break; 8771 + } 8772 + /* fallthrough */ 8773 + case 32: 8774 + if (goal == BOUNDARY_SINGLE_CACHELINE) { 8775 + val |= (DMA_RWCTRL_READ_BNDRY_32 | 8776 + DMA_RWCTRL_WRITE_BNDRY_32); 8777 + break; 8778 + } 8779 + /* fallthrough */ 8780 + case 64: 8781 + if (goal == BOUNDARY_SINGLE_CACHELINE) { 8782 + val |= (DMA_RWCTRL_READ_BNDRY_64 | 8783 + DMA_RWCTRL_WRITE_BNDRY_64); 8784 + break; 8785 + } 8786 + /* fallthrough */ 8787 + case 128: 8788 + if (goal == BOUNDARY_SINGLE_CACHELINE) { 8789 + val |= (DMA_RWCTRL_READ_BNDRY_128 | 8790 + DMA_RWCTRL_WRITE_BNDRY_128); 8791 + break; 8792 + } 8793 + /* fallthrough */ 8794 + case 256: 8795 + val |= (DMA_RWCTRL_READ_BNDRY_256 | 8796 + DMA_RWCTRL_WRITE_BNDRY_256); 8797 + break; 8798 + case 512: 8799 + val |= (DMA_RWCTRL_READ_BNDRY_512 | 8800 + DMA_RWCTRL_WRITE_BNDRY_512); 8801 + break; 8802 + case 1024: 8803 + default: 8804 + val |= (DMA_RWCTRL_READ_BNDRY_1024 | 8805 + DMA_RWCTRL_WRITE_BNDRY_1024); 8806 + break; 8807 + }; 8808 + } 8809 + 8810 + out: 8811 + return val; 8812 + } 8813 + 8776 8814 static int __devinit tg3_do_test_dma(struct tg3 *tp, u32 *buf, dma_addr_t buf_dma, int size, int to_device) 8777 8815 { 8778 8816 struct tg3_internal_buffer_desc test_desc; ··· 8999 8757 static int __devinit tg3_test_dma(struct tg3 *tp) 9000 8758 { 9001 8759 dma_addr_t buf_dma; 9002 - u32 *buf; 8760 + u32 *buf, saved_dma_rwctrl; 9003 8761 int ret; 9004 8762 9005 8763 buf = pci_alloc_consistent(tp->pdev, TEST_BUFFER_SIZE, &buf_dma); ··· 9011 8769 tp->dma_rwctrl = ((0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) | 9012 8770 (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT)); 9013 8771 9014 - #ifndef CONFIG_X86 9015 - { 9016 - u8 byte; 9017 - int cacheline_size; 9018 - pci_read_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, &byte); 9019 - 9020 - if (byte == 0) 9021 - cacheline_size = 1024; 9022 - else 9023 - cacheline_size = (int) byte * 4; 9024 - 9025 - switch (cacheline_size) { 9026 - case 16: 9027 - case 32: 9028 - case 64: 9029 - case 128: 9030 - if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) && 9031 - !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) { 9032 - tp->dma_rwctrl |= 9033 - DMA_RWCTRL_WRITE_BNDRY_384_PCIX; 9034 - break; 9035 - } else if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) { 9036 - tp->dma_rwctrl &= 9037 - ~(DMA_RWCTRL_PCI_WRITE_CMD); 9038 - tp->dma_rwctrl |= 9039 - DMA_RWCTRL_WRITE_BNDRY_128_PCIE; 9040 - break; 9041 - } 9042 - /* fallthrough */ 9043 - case 256: 9044 - if (!(tp->tg3_flags & TG3_FLAG_PCIX_MODE) && 9045 - !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) 9046 - tp->dma_rwctrl |= 9047 - DMA_RWCTRL_WRITE_BNDRY_256; 9048 - else if (!(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) 9049 - tp->dma_rwctrl |= 9050 - DMA_RWCTRL_WRITE_BNDRY_256_PCIX; 9051 - }; 9052 - } 9053 - #endif 8772 + tp->dma_rwctrl = tg3_calc_dma_bndry(tp, tp->dma_rwctrl); 9054 8773 9055 8774 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) { 9056 8775 /* DMA read watermark not used on PCIE */ ··· 9030 8827 if (ccval == 0x6 || ccval == 0x7) 9031 8828 tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA; 9032 8829 9033 - /* Set bit 23 to renable PCIX hw bug fix */ 8830 + /* Set bit 23 to enable PCIX hw bug fix */ 9034 8831 tp->dma_rwctrl |= 0x009f0000; 9035 8832 } else { 9036 8833 tp->dma_rwctrl |= 0x001b000f; ··· 9071 8868 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) 9072 8869 goto out; 9073 8870 8871 + /* It is best to perform DMA test with maximum write burst size 8872 + * to expose the 5700/5701 write DMA bug. 8873 + */ 8874 + saved_dma_rwctrl = tp->dma_rwctrl; 8875 + tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK; 8876 + tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); 8877 + 9074 8878 while (1) { 9075 8879 u32 *p = buf, i; 9076 8880 ··· 9116 8906 if (p[i] == i) 9117 8907 continue; 9118 8908 9119 - if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) == 9120 - DMA_RWCTRL_WRITE_BNDRY_DISAB) { 8909 + if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) != 8910 + DMA_RWCTRL_WRITE_BNDRY_16) { 8911 + tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK; 9121 8912 tp->dma_rwctrl |= DMA_RWCTRL_WRITE_BNDRY_16; 9122 8913 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); 9123 8914 break; ··· 9134 8923 ret = 0; 9135 8924 break; 9136 8925 } 8926 + } 8927 + if ((tp->dma_rwctrl & DMA_RWCTRL_WRITE_BNDRY_MASK) != 8928 + DMA_RWCTRL_WRITE_BNDRY_16) { 8929 + /* DMA test passed without adjusting DMA boundary, 8930 + * just restore the calculated DMA boundary 8931 + */ 8932 + tp->dma_rwctrl = saved_dma_rwctrl; 8933 + tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); 9137 8934 } 9138 8935 9139 8936 out: ··· 9228 9009 pci_dev_put(peer); 9229 9010 9230 9011 return peer; 9012 + } 9013 + 9014 + static void __devinit tg3_init_coal(struct tg3 *tp) 9015 + { 9016 + struct ethtool_coalesce *ec = &tp->coal; 9017 + 9018 + memset(ec, 0, sizeof(*ec)); 9019 + ec->cmd = ETHTOOL_GCOALESCE; 9020 + ec->rx_coalesce_usecs = LOW_RXCOL_TICKS; 9021 + ec->tx_coalesce_usecs = LOW_TXCOL_TICKS; 9022 + ec->rx_max_coalesced_frames = LOW_RXMAX_FRAMES; 9023 + ec->tx_max_coalesced_frames = LOW_TXMAX_FRAMES; 9024 + ec->rx_coalesce_usecs_irq = DEFAULT_RXCOAL_TICK_INT; 9025 + ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT; 9026 + ec->rx_max_coalesced_frames_irq = DEFAULT_RXCOAL_MAXF_INT; 9027 + ec->tx_max_coalesced_frames_irq = DEFAULT_TXCOAL_MAXF_INT; 9028 + ec->stats_block_coalesce_usecs = DEFAULT_STAT_COAL_TICKS; 9029 + 9030 + if (tp->coalesce_mode & (HOSTCC_MODE_CLRTICK_RXBD | 9031 + HOSTCC_MODE_CLRTICK_TXBD)) { 9032 + ec->rx_coalesce_usecs = LOW_RXCOL_TICKS_CLRTCKS; 9033 + ec->rx_coalesce_usecs_irq = DEFAULT_RXCOAL_TICK_INT_CLRTCKS; 9034 + ec->tx_coalesce_usecs = LOW_TXCOL_TICKS_CLRTCKS; 9035 + ec->tx_coalesce_usecs_irq = DEFAULT_TXCOAL_TICK_INT_CLRTCKS; 9036 + } 9231 9037 } 9232 9038 9233 9039 static int __devinit tg3_init_one(struct pci_dev *pdev, ··· 9500 9256 /* flow control autonegotiation is default behavior */ 9501 9257 tp->tg3_flags |= TG3_FLAG_PAUSE_AUTONEG; 9502 9258 9259 + tg3_init_coal(tp); 9260 + 9503 9261 err = register_netdev(dev); 9504 9262 if (err) { 9505 9263 printk(KERN_ERR PFX "Cannot register net device, " ··· 9544 9298 (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) != 0, 9545 9299 (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED) == 0, 9546 9300 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) != 0); 9301 + printk(KERN_INFO "%s: dma_rwctrl[%08x]\n", 9302 + dev->name, tp->dma_rwctrl); 9547 9303 9548 9304 return 0; 9549 9305
+7 -1
drivers/net/tg3.h
··· 876 876 #define HOSTCC_STATUS_ERROR_ATTN 0x00000004 877 877 #define HOSTCC_RXCOL_TICKS 0x00003c08 878 878 #define LOW_RXCOL_TICKS 0x00000032 879 + #define LOW_RXCOL_TICKS_CLRTCKS 0x00000014 879 880 #define DEFAULT_RXCOL_TICKS 0x00000048 880 881 #define HIGH_RXCOL_TICKS 0x00000096 881 882 #define HOSTCC_TXCOL_TICKS 0x00003c0c 882 883 #define LOW_TXCOL_TICKS 0x00000096 884 + #define LOW_TXCOL_TICKS_CLRTCKS 0x00000048 883 885 #define DEFAULT_TXCOL_TICKS 0x0000012c 884 886 #define HIGH_TXCOL_TICKS 0x00000145 885 887 #define HOSTCC_RXMAX_FRAMES 0x00003c10 ··· 894 892 #define HIGH_TXMAX_FRAMES 0x00000052 895 893 #define HOSTCC_RXCOAL_TICK_INT 0x00003c18 896 894 #define DEFAULT_RXCOAL_TICK_INT 0x00000019 895 + #define DEFAULT_RXCOAL_TICK_INT_CLRTCKS 0x00000014 897 896 #define HOSTCC_TXCOAL_TICK_INT 0x00003c1c 898 897 #define DEFAULT_TXCOAL_TICK_INT 0x00000019 898 + #define DEFAULT_TXCOAL_TICK_INT_CLRTCKS 0x00000014 899 899 #define HOSTCC_RXCOAL_MAXF_INT 0x00003c20 900 900 #define DEFAULT_RXCOAL_MAXF_INT 0x00000005 901 901 #define HOSTCC_TXCOAL_MAXF_INT 0x00003c24 ··· 2027 2023 2028 2024 struct tg3_hw_status *hw_status; 2029 2025 dma_addr_t status_mapping; 2026 + u32 last_tag; 2030 2027 2031 2028 u32 msg_enable; 2032 2029 ··· 2073 2068 2074 2069 u32 rx_offset; 2075 2070 u32 tg3_flags; 2071 + #define TG3_FLAG_TAGGED_STATUS 0x00000001 2076 2072 #define TG3_FLAG_TXD_MBOX_HWBUG 0x00000002 2077 2073 #define TG3_FLAG_RX_CHECKSUMS 0x00000004 2078 2074 #define TG3_FLAG_USE_LINKCHG_REG 0x00000008 ··· 2231 2225 2232 2226 #define SST_25VF0X0_PAGE_SIZE 4098 2233 2227 2234 - 2228 + struct ethtool_coalesce coal; 2235 2229 }; 2236 2230 2237 2231 #endif /* !(_T3_H) */
+2 -6
drivers/sbus/char/aurora.c
··· 81 81 int irqhit=0; 82 82 #endif 83 83 84 - #ifndef MIN 85 - #define MIN(a,b) ((a) < (b) ? (a) : (b)) 86 - #endif 87 - 88 84 static struct tty_driver *aurora_driver; 89 85 static struct Aurora_board aurora_board[AURORA_NBOARD] = { 90 86 {0,}, ··· 590 594 &bp->r[chip]->r[CD180_TDR]); 591 595 port->COR2 &= ~COR2_ETC; 592 596 } 593 - count = MIN(port->break_length, 0xff); 597 + count = min(port->break_length, 0xff); 594 598 sbus_writeb(CD180_C_ESC, 595 599 &bp->r[chip]->r[CD180_TDR]); 596 600 sbus_writeb(CD180_C_DELAY, ··· 1571 1575 save_flags(flags); 1572 1576 while (1) { 1573 1577 cli(); 1574 - c = MIN(count, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, 1578 + c = min(count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1, 1575 1579 SERIAL_XMIT_SIZE - port->xmit_head)); 1576 1580 if (c <= 0) { 1577 1581 restore_flags(flags);
+1 -51
drivers/scsi/aic7xxx/aic7770_osm.c
··· 41 41 42 42 #include "aic7xxx_osm.h" 43 43 44 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 45 44 #include <linux/device.h> 46 45 #include <linux/eisa.h> 47 46 ··· 61 62 }; 62 63 63 64 typedef struct device *aic7770_dev_t; 64 - #else 65 - #define MINSLOT 1 66 - #define NUMSLOTS 16 67 - #define IDOFFSET 0x80 68 - 69 - typedef void *aic7770_dev_t; 70 - #endif 71 65 72 66 static int aic7770_linux_config(struct aic7770_identity *entry, 73 67 aic7770_dev_t dev, u_int eisaBase); ··· 68 76 int 69 77 ahc_linux_eisa_init(void) 70 78 { 71 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 72 79 struct eisa_device_id *eid; 73 80 struct aic7770_identity *id; 74 81 int i; ··· 101 110 eid->sig[0] = 0; 102 111 103 112 return eisa_driver_register(&aic7770_driver); 104 - #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */ 105 - struct aic7770_identity *entry; 106 - u_int slot; 107 - u_int eisaBase; 108 - u_int i; 109 - int ret = -ENODEV; 110 - 111 - if (aic7xxx_probe_eisa_vl == 0) 112 - return ret; 113 - 114 - eisaBase = 0x1000 + AHC_EISA_SLOT_OFFSET; 115 - for (slot = 1; slot < NUMSLOTS; eisaBase+=0x1000, slot++) { 116 - uint32_t eisa_id; 117 - size_t id_size; 118 - 119 - if (request_region(eisaBase, AHC_EISA_IOSIZE, "aic7xxx") == 0) 120 - continue; 121 - 122 - eisa_id = 0; 123 - id_size = sizeof(eisa_id); 124 - for (i = 0; i < 4; i++) { 125 - /* VLcards require priming*/ 126 - outb(0x80 + i, eisaBase + IDOFFSET); 127 - eisa_id |= inb(eisaBase + IDOFFSET + i) 128 - << ((id_size-i-1) * 8); 129 - } 130 - release_region(eisaBase, AHC_EISA_IOSIZE); 131 - if (eisa_id & 0x80000000) 132 - continue; /* no EISA card in slot */ 133 - 134 - entry = aic7770_find_device(eisa_id); 135 - if (entry != NULL) { 136 - aic7770_linux_config(entry, NULL, eisaBase); 137 - ret = 0; 138 - } 139 - } 140 - return ret; 141 - #endif 142 113 } 143 114 144 115 void ··· 140 187 ahc_free(ahc); 141 188 return (error); 142 189 } 143 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 190 + 144 191 dev->driver_data = (void *)ahc; 145 192 if (aic7xxx_detect_complete) 146 193 error = ahc_linux_register_host(ahc, &aic7xxx_driver_template); 147 - #endif 148 194 return (error); 149 195 } 150 196 ··· 177 225 return (-error); 178 226 } 179 227 180 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 181 228 static int 182 229 aic7770_eisa_dev_probe(struct device *dev) 183 230 { ··· 212 261 213 262 return (0); 214 263 } 215 - #endif
+354 -1082
drivers/scsi/aic7xxx/aic7xxx_osm.c
··· 134 134 #include "aiclib.c" 135 135 136 136 #include <linux/init.h> /* __setup */ 137 - 138 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 139 - #include "sd.h" /* For geometry detection */ 140 - #endif 141 - 142 137 #include <linux/mm.h> /* For fetching system memory size */ 143 138 #include <linux/blkdev.h> /* For block_size() */ 144 139 #include <linux/delay.h> /* For ssleep/msleep */ ··· 142 147 * Lock protecting manipulation of the ahc softc list. 143 148 */ 144 149 spinlock_t ahc_list_spinlock; 145 - 146 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 147 - /* For dynamic sglist size calculation. */ 148 - u_int ahc_linux_nseg; 149 - #endif 150 150 151 151 /* 152 152 * Set this to the delay in seconds after SCSI bus reset. ··· 426 436 struct ahc_linux_device *, 427 437 struct scb *); 428 438 static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, 429 - Scsi_Cmnd *cmd); 439 + struct scsi_cmnd *cmd); 430 440 static void ahc_linux_sem_timeout(u_long arg); 431 441 static void ahc_linux_freeze_simq(struct ahc_softc *ahc); 432 442 static void ahc_linux_release_simq(u_long arg); 433 - static void ahc_linux_dev_timed_unfreeze(u_long arg); 434 - static int ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag); 443 + static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag); 435 444 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); 436 - static void ahc_linux_size_nseg(void); 437 - static void ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc); 438 445 static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, 439 446 struct ahc_devinfo *devinfo); 440 447 static void ahc_linux_device_queue_depth(struct ahc_softc *ahc, ··· 445 458 u_int); 446 459 static void ahc_linux_free_device(struct ahc_softc*, 447 460 struct ahc_linux_device*); 448 - static void ahc_linux_run_device_queue(struct ahc_softc*, 449 - struct ahc_linux_device*); 461 + static int ahc_linux_run_command(struct ahc_softc*, 462 + struct ahc_linux_device *, 463 + struct scsi_cmnd *); 450 464 static void ahc_linux_setup_tag_info_global(char *p); 451 465 static aic_option_callback_t ahc_linux_setup_tag_info; 452 466 static int aic7xxx_setup(char *s); 453 467 static int ahc_linux_next_unit(void); 454 - static void ahc_runq_tasklet(unsigned long data); 455 - static struct ahc_cmd *ahc_linux_run_complete_queue(struct ahc_softc *ahc); 456 468 457 469 /********************************* Inlines ************************************/ 458 - static __inline void ahc_schedule_runq(struct ahc_softc *ahc); 459 470 static __inline struct ahc_linux_device* 460 471 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, 461 - u_int target, u_int lun, int alloc); 462 - static __inline void ahc_schedule_completeq(struct ahc_softc *ahc); 463 - static __inline void ahc_linux_check_device_queue(struct ahc_softc *ahc, 464 - struct ahc_linux_device *dev); 465 - static __inline struct ahc_linux_device * 466 - ahc_linux_next_device_to_run(struct ahc_softc *ahc); 467 - static __inline void ahc_linux_run_device_queues(struct ahc_softc *ahc); 472 + u_int target, u_int lun); 468 473 static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); 469 474 470 475 static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, 471 476 struct ahc_dma_seg *sg, 472 477 dma_addr_t addr, bus_size_t len); 473 478 474 - static __inline void 475 - ahc_schedule_completeq(struct ahc_softc *ahc) 476 - { 477 - if ((ahc->platform_data->flags & AHC_RUN_CMPLT_Q_TIMER) == 0) { 478 - ahc->platform_data->flags |= AHC_RUN_CMPLT_Q_TIMER; 479 - ahc->platform_data->completeq_timer.expires = jiffies; 480 - add_timer(&ahc->platform_data->completeq_timer); 481 - } 482 - } 483 - 484 - /* 485 - * Must be called with our lock held. 486 - */ 487 - static __inline void 488 - ahc_schedule_runq(struct ahc_softc *ahc) 489 - { 490 - tasklet_schedule(&ahc->platform_data->runq_tasklet); 491 - } 492 - 493 479 static __inline struct ahc_linux_device* 494 480 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target, 495 - u_int lun, int alloc) 481 + u_int lun) 496 482 { 497 483 struct ahc_linux_target *targ; 498 484 struct ahc_linux_device *dev; ··· 475 515 if (channel != 0) 476 516 target_offset += 8; 477 517 targ = ahc->platform_data->targets[target_offset]; 478 - if (targ == NULL) { 479 - if (alloc != 0) { 480 - targ = ahc_linux_alloc_target(ahc, channel, target); 481 - if (targ == NULL) 482 - return (NULL); 483 - } else 484 - return (NULL); 485 - } 518 + BUG_ON(targ == NULL); 486 519 dev = targ->devices[lun]; 487 - if (dev == NULL && alloc != 0) 488 - dev = ahc_linux_alloc_device(ahc, targ, lun); 489 - return (dev); 490 - } 491 - 492 - #define AHC_LINUX_MAX_RETURNED_ERRORS 4 493 - static struct ahc_cmd * 494 - ahc_linux_run_complete_queue(struct ahc_softc *ahc) 495 - { 496 - struct ahc_cmd *acmd; 497 - u_long done_flags; 498 - int with_errors; 499 - 500 - with_errors = 0; 501 - ahc_done_lock(ahc, &done_flags); 502 - while ((acmd = TAILQ_FIRST(&ahc->platform_data->completeq)) != NULL) { 503 - Scsi_Cmnd *cmd; 504 - 505 - if (with_errors > AHC_LINUX_MAX_RETURNED_ERRORS) { 506 - /* 507 - * Linux uses stack recursion to requeue 508 - * commands that need to be retried. Avoid 509 - * blowing out the stack by "spoon feeding" 510 - * commands that completed with error back 511 - * the operating system in case they are going 512 - * to be retried. "ick" 513 - */ 514 - ahc_schedule_completeq(ahc); 515 - break; 516 - } 517 - TAILQ_REMOVE(&ahc->platform_data->completeq, 518 - acmd, acmd_links.tqe); 519 - cmd = &acmd_scsi_cmd(acmd); 520 - cmd->host_scribble = NULL; 521 - if (ahc_cmd_get_transaction_status(cmd) != DID_OK 522 - || (cmd->result & 0xFF) != SCSI_STATUS_OK) 523 - with_errors++; 524 - 525 - cmd->scsi_done(cmd); 526 - } 527 - ahc_done_unlock(ahc, &done_flags); 528 - return (acmd); 529 - } 530 - 531 - static __inline void 532 - ahc_linux_check_device_queue(struct ahc_softc *ahc, 533 - struct ahc_linux_device *dev) 534 - { 535 - if ((dev->flags & AHC_DEV_FREEZE_TIL_EMPTY) != 0 536 - && dev->active == 0) { 537 - dev->flags &= ~AHC_DEV_FREEZE_TIL_EMPTY; 538 - dev->qfrozen--; 539 - } 540 - 541 - if (TAILQ_FIRST(&dev->busyq) == NULL 542 - || dev->openings == 0 || dev->qfrozen != 0) 543 - return; 544 - 545 - ahc_linux_run_device_queue(ahc, dev); 546 - } 547 - 548 - static __inline struct ahc_linux_device * 549 - ahc_linux_next_device_to_run(struct ahc_softc *ahc) 550 - { 551 - 552 - if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0 553 - || (ahc->platform_data->qfrozen != 0)) 554 - return (NULL); 555 - return (TAILQ_FIRST(&ahc->platform_data->device_runq)); 556 - } 557 - 558 - static __inline void 559 - ahc_linux_run_device_queues(struct ahc_softc *ahc) 560 - { 561 - struct ahc_linux_device *dev; 562 - 563 - while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) { 564 - TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links); 565 - dev->flags &= ~AHC_DEV_ON_RUN_LIST; 566 - ahc_linux_check_device_queue(ahc, dev); 567 - } 520 + return dev; 568 521 } 569 522 570 523 static __inline void 571 524 ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) 572 525 { 573 - Scsi_Cmnd *cmd; 526 + struct scsi_cmnd *cmd; 574 527 575 528 cmd = scb->io_ctx; 576 529 ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE); ··· 523 650 return (consumed); 524 651 } 525 652 526 - /************************ Host template entry points *************************/ 527 - static int ahc_linux_detect(Scsi_Host_Template *); 528 - static int ahc_linux_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *)); 529 - static const char *ahc_linux_info(struct Scsi_Host *); 530 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 531 - static int ahc_linux_slave_alloc(Scsi_Device *); 532 - static int ahc_linux_slave_configure(Scsi_Device *); 533 - static void ahc_linux_slave_destroy(Scsi_Device *); 534 - #if defined(__i386__) 535 - static int ahc_linux_biosparam(struct scsi_device*, 536 - struct block_device*, 537 - sector_t, int[]); 538 - #endif 539 - #else 540 - static int ahc_linux_release(struct Scsi_Host *); 541 - static void ahc_linux_select_queue_depth(struct Scsi_Host *host, 542 - Scsi_Device *scsi_devs); 543 - #if defined(__i386__) 544 - static int ahc_linux_biosparam(Disk *, kdev_t, int[]); 545 - #endif 546 - #endif 547 - static int ahc_linux_bus_reset(Scsi_Cmnd *); 548 - static int ahc_linux_dev_reset(Scsi_Cmnd *); 549 - static int ahc_linux_abort(Scsi_Cmnd *); 550 - 551 - /* 552 - * Calculate a safe value for AHC_NSEG (as expressed through ahc_linux_nseg). 553 - * 554 - * In pre-2.5.X... 555 - * The midlayer allocates an S/G array dynamically when a command is issued 556 - * using SCSI malloc. This array, which is in an OS dependent format that 557 - * must later be copied to our private S/G list, is sized to house just the 558 - * number of segments needed for the current transfer. Since the code that 559 - * sizes the SCSI malloc pool does not take into consideration fragmentation 560 - * of the pool, executing transactions numbering just a fraction of our 561 - * concurrent transaction limit with list lengths aproaching AHC_NSEG will 562 - * quickly depleat the SCSI malloc pool of usable space. Unfortunately, the 563 - * mid-layer does not properly handle this scsi malloc failures for the S/G 564 - * array and the result can be a lockup of the I/O subsystem. We try to size 565 - * our S/G list so that it satisfies our drivers allocation requirements in 566 - * addition to avoiding fragmentation of the SCSI malloc pool. 567 - */ 568 - static void 569 - ahc_linux_size_nseg(void) 570 - { 571 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 572 - u_int cur_size; 573 - u_int best_size; 574 - 575 - /* 576 - * The SCSI allocator rounds to the nearest 512 bytes 577 - * an cannot allocate across a page boundary. Our algorithm 578 - * is to start at 1K of scsi malloc space per-command and 579 - * loop through all factors of the PAGE_SIZE and pick the best. 580 - */ 581 - best_size = 0; 582 - for (cur_size = 1024; cur_size <= PAGE_SIZE; cur_size *= 2) { 583 - u_int nseg; 584 - 585 - nseg = cur_size / sizeof(struct scatterlist); 586 - if (nseg < AHC_LINUX_MIN_NSEG) 587 - continue; 588 - 589 - if (best_size == 0) { 590 - best_size = cur_size; 591 - ahc_linux_nseg = nseg; 592 - } else { 593 - u_int best_rem; 594 - u_int cur_rem; 595 - 596 - /* 597 - * Compare the traits of the current "best_size" 598 - * with the current size to determine if the 599 - * current size is a better size. 600 - */ 601 - best_rem = best_size % sizeof(struct scatterlist); 602 - cur_rem = cur_size % sizeof(struct scatterlist); 603 - if (cur_rem < best_rem) { 604 - best_size = cur_size; 605 - ahc_linux_nseg = nseg; 606 - } 607 - } 608 - } 609 - #endif 610 - } 611 - 612 653 /* 613 654 * Try to detect an Adaptec 7XXX controller. 614 655 */ 615 656 static int 616 - ahc_linux_detect(Scsi_Host_Template *template) 657 + ahc_linux_detect(struct scsi_host_template *template) 617 658 { 618 659 struct ahc_softc *ahc; 619 660 int found = 0; 620 - 621 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 622 - /* 623 - * It is a bug that the upper layer takes 624 - * this lock just prior to calling us. 625 - */ 626 - spin_unlock_irq(&io_request_lock); 627 - #endif 628 661 629 662 /* 630 663 * Sanity checking of Linux SCSI data structures so ··· 543 764 printf("ahc_linux_detect: Unable to attach\n"); 544 765 return (0); 545 766 } 546 - ahc_linux_size_nseg(); 547 767 /* 548 768 * If we've been passed any parameters, process them now. 549 769 */ ··· 571 793 found++; 572 794 } 573 795 574 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 575 - spin_lock_irq(&io_request_lock); 576 - #endif 577 796 aic7xxx_detect_complete++; 578 797 579 798 return (found); 580 799 } 581 - 582 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 583 - /* 584 - * Free the passed in Scsi_Host memory structures prior to unloading the 585 - * module. 586 - */ 587 - int 588 - ahc_linux_release(struct Scsi_Host * host) 589 - { 590 - struct ahc_softc *ahc; 591 - u_long l; 592 - 593 - ahc_list_lock(&l); 594 - if (host != NULL) { 595 - 596 - /* 597 - * We should be able to just perform 598 - * the free directly, but check our 599 - * list for extra sanity. 600 - */ 601 - ahc = ahc_find_softc(*(struct ahc_softc **)host->hostdata); 602 - if (ahc != NULL) { 603 - u_long s; 604 - 605 - ahc_lock(ahc, &s); 606 - ahc_intr_enable(ahc, FALSE); 607 - ahc_unlock(ahc, &s); 608 - ahc_free(ahc); 609 - } 610 - } 611 - ahc_list_unlock(&l); 612 - return (0); 613 - } 614 - #endif 615 800 616 801 /* 617 802 * Return a string describing the driver. ··· 608 867 * Queue an SCB to the controller. 609 868 */ 610 869 static int 611 - ahc_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *)) 870 + ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) 612 871 { 613 872 struct ahc_softc *ahc; 614 873 struct ahc_linux_device *dev; 615 - u_long flags; 616 874 617 875 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 618 876 ··· 620 880 */ 621 881 cmd->scsi_done = scsi_done; 622 882 623 - ahc_midlayer_entrypoint_lock(ahc, &flags); 624 - 625 883 /* 626 884 * Close the race of a command that was in the process of 627 885 * being queued to us just as our simq was frozen. Let 628 886 * DV commands through so long as we are only frozen to 629 887 * perform DV. 630 888 */ 631 - if (ahc->platform_data->qfrozen != 0) { 889 + if (ahc->platform_data->qfrozen != 0) 890 + return SCSI_MLQUEUE_HOST_BUSY; 632 891 633 - ahc_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ); 634 - ahc_linux_queue_cmd_complete(ahc, cmd); 635 - ahc_schedule_completeq(ahc); 636 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 637 - return (0); 638 - } 639 892 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 640 - cmd->device->lun, /*alloc*/TRUE); 641 - if (dev == NULL) { 642 - ahc_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL); 643 - ahc_linux_queue_cmd_complete(ahc, cmd); 644 - ahc_schedule_completeq(ahc); 645 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 646 - printf("%s: aic7xxx_linux_queue - Unable to allocate device!\n", 647 - ahc_name(ahc)); 648 - return (0); 649 - } 893 + cmd->device->lun); 894 + BUG_ON(dev == NULL); 895 + 650 896 cmd->result = CAM_REQ_INPROG << 16; 651 - TAILQ_INSERT_TAIL(&dev->busyq, (struct ahc_cmd *)cmd, acmd_links.tqe); 652 - if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) { 653 - TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links); 654 - dev->flags |= AHC_DEV_ON_RUN_LIST; 655 - ahc_linux_run_device_queues(ahc); 656 - } 657 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 658 - return (0); 897 + 898 + return ahc_linux_run_command(ahc, dev, cmd); 659 899 } 660 900 661 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 662 901 static int 663 - ahc_linux_slave_alloc(Scsi_Device *device) 902 + ahc_linux_slave_alloc(struct scsi_device *device) 664 903 { 665 904 struct ahc_softc *ahc; 905 + struct ahc_linux_target *targ; 906 + struct scsi_target *starget = device->sdev_target; 907 + struct ahc_linux_device *dev; 908 + unsigned int target_offset; 909 + unsigned long flags; 910 + int retval = -ENOMEM; 911 + 912 + target_offset = starget->id; 913 + if (starget->channel != 0) 914 + target_offset += 8; 666 915 667 916 ahc = *((struct ahc_softc **)device->host->hostdata); 668 917 if (bootverbose) 669 918 printf("%s: Slave Alloc %d\n", ahc_name(ahc), device->id); 670 - return (0); 919 + ahc_lock(ahc, &flags); 920 + targ = ahc->platform_data->targets[target_offset]; 921 + if (targ == NULL) { 922 + targ = ahc_linux_alloc_target(ahc, starget->channel, starget->id); 923 + struct seeprom_config *sc = ahc->seep_config; 924 + if (targ == NULL) 925 + goto out; 926 + 927 + if (sc) { 928 + unsigned short scsirate; 929 + struct ahc_devinfo devinfo; 930 + struct ahc_initiator_tinfo *tinfo; 931 + struct ahc_tmode_tstate *tstate; 932 + char channel = starget->channel + 'A'; 933 + unsigned int our_id = ahc->our_id; 934 + 935 + if (starget->channel) 936 + our_id = ahc->our_id_b; 937 + 938 + if ((ahc->features & AHC_ULTRA2) != 0) { 939 + scsirate = sc->device_flags[target_offset] & CFXFER; 940 + } else { 941 + scsirate = (sc->device_flags[target_offset] & CFXFER) << 4; 942 + if (sc->device_flags[target_offset] & CFSYNCH) 943 + scsirate |= SOFS; 944 + } 945 + if (sc->device_flags[target_offset] & CFWIDEB) { 946 + scsirate |= WIDEXFER; 947 + spi_max_width(starget) = 1; 948 + } else 949 + spi_max_width(starget) = 0; 950 + spi_min_period(starget) = 951 + ahc_find_period(ahc, scsirate, AHC_SYNCRATE_DT); 952 + tinfo = ahc_fetch_transinfo(ahc, channel, ahc->our_id, 953 + targ->target, &tstate); 954 + ahc_compile_devinfo(&devinfo, our_id, targ->target, 955 + CAM_LUN_WILDCARD, channel, 956 + ROLE_INITIATOR); 957 + ahc_set_syncrate(ahc, &devinfo, NULL, 0, 0, 0, 958 + AHC_TRANS_GOAL, /*paused*/FALSE); 959 + ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, 960 + AHC_TRANS_GOAL, /*paused*/FALSE); 961 + } 962 + 963 + } 964 + dev = targ->devices[device->lun]; 965 + if (dev == NULL) { 966 + dev = ahc_linux_alloc_device(ahc, targ, device->lun); 967 + if (dev == NULL) 968 + goto out; 969 + } 970 + retval = 0; 971 + 972 + out: 973 + ahc_unlock(ahc, &flags); 974 + return retval; 671 975 } 672 976 673 977 static int 674 - ahc_linux_slave_configure(Scsi_Device *device) 978 + ahc_linux_slave_configure(struct scsi_device *device) 675 979 { 676 980 struct ahc_softc *ahc; 677 981 struct ahc_linux_device *dev; 678 - u_long flags; 679 982 680 983 ahc = *((struct ahc_softc **)device->host->hostdata); 984 + 681 985 if (bootverbose) 682 986 printf("%s: Slave Configure %d\n", ahc_name(ahc), device->id); 683 - ahc_midlayer_entrypoint_lock(ahc, &flags); 684 - /* 685 - * Since Linux has attached to the device, configure 686 - * it so we don't free and allocate the device 687 - * structure on every command. 688 - */ 689 - dev = ahc_linux_get_device(ahc, device->channel, 690 - device->id, device->lun, 691 - /*alloc*/TRUE); 692 - if (dev != NULL) { 693 - dev->flags &= ~AHC_DEV_UNCONFIGURED; 694 - dev->scsi_device = device; 695 - ahc_linux_device_queue_depth(ahc, dev); 696 - } 697 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 987 + 988 + dev = ahc_linux_get_device(ahc, device->channel, device->id, 989 + device->lun); 990 + dev->scsi_device = device; 991 + ahc_linux_device_queue_depth(ahc, dev); 698 992 699 993 /* Initial Domain Validation */ 700 994 if (!spi_initial_dv(device->sdev_target)) 701 995 spi_dv_device(device); 702 996 703 - return (0); 997 + return 0; 704 998 } 705 999 706 1000 static void 707 - ahc_linux_slave_destroy(Scsi_Device *device) 1001 + ahc_linux_slave_destroy(struct scsi_device *device) 708 1002 { 709 1003 struct ahc_softc *ahc; 710 1004 struct ahc_linux_device *dev; 711 - u_long flags; 712 1005 713 1006 ahc = *((struct ahc_softc **)device->host->hostdata); 714 1007 if (bootverbose) 715 1008 printf("%s: Slave Destroy %d\n", ahc_name(ahc), device->id); 716 - ahc_midlayer_entrypoint_lock(ahc, &flags); 717 1009 dev = ahc_linux_get_device(ahc, device->channel, 718 - device->id, device->lun, 719 - /*alloc*/FALSE); 720 - /* 721 - * Filter out "silly" deletions of real devices by only 722 - * deleting devices that have had slave_configure() 723 - * called on them. All other devices that have not 724 - * been configured will automatically be deleted by 725 - * the refcounting process. 726 - */ 727 - if (dev != NULL 728 - && (dev->flags & AHC_DEV_SLAVE_CONFIGURED) != 0) { 729 - dev->flags |= AHC_DEV_UNCONFIGURED; 730 - if (TAILQ_EMPTY(&dev->busyq) 731 - && dev->active == 0 732 - && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0) 733 - ahc_linux_free_device(ahc, dev); 734 - } 735 - ahc_midlayer_entrypoint_unlock(ahc, &flags); 1010 + device->id, device->lun); 1011 + 1012 + BUG_ON(dev->active); 1013 + 1014 + ahc_linux_free_device(ahc, dev); 736 1015 } 737 - #else 738 - /* 739 - * Sets the queue depth for each SCSI device hanging 740 - * off the input host adapter. 741 - */ 742 - static void 743 - ahc_linux_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs) 744 - { 745 - Scsi_Device *device; 746 - Scsi_Device *ldev; 747 - struct ahc_softc *ahc; 748 - u_long flags; 749 - 750 - ahc = *((struct ahc_softc **)host->hostdata); 751 - ahc_lock(ahc, &flags); 752 - for (device = scsi_devs; device != NULL; device = device->next) { 753 - 754 - /* 755 - * Watch out for duplicate devices. This works around 756 - * some quirks in how the SCSI scanning code does its 757 - * device management. 758 - */ 759 - for (ldev = scsi_devs; ldev != device; ldev = ldev->next) { 760 - if (ldev->host == device->host 761 - && ldev->channel == device->channel 762 - && ldev->id == device->id 763 - && ldev->lun == device->lun) 764 - break; 765 - } 766 - /* Skip duplicate. */ 767 - if (ldev != device) 768 - continue; 769 - 770 - if (device->host == host) { 771 - struct ahc_linux_device *dev; 772 - 773 - /* 774 - * Since Linux has attached to the device, configure 775 - * it so we don't free and allocate the device 776 - * structure on every command. 777 - */ 778 - dev = ahc_linux_get_device(ahc, device->channel, 779 - device->id, device->lun, 780 - /*alloc*/TRUE); 781 - if (dev != NULL) { 782 - dev->flags &= ~AHC_DEV_UNCONFIGURED; 783 - dev->scsi_device = device; 784 - ahc_linux_device_queue_depth(ahc, dev); 785 - device->queue_depth = dev->openings 786 - + dev->active; 787 - if ((dev->flags & (AHC_DEV_Q_BASIC 788 - | AHC_DEV_Q_TAGGED)) == 0) { 789 - /* 790 - * We allow the OS to queue 2 untagged 791 - * transactions to us at any time even 792 - * though we can only execute them 793 - * serially on the controller/device. 794 - * This should remove some latency. 795 - */ 796 - device->queue_depth = 2; 797 - } 798 - } 799 - } 800 - } 801 - ahc_unlock(ahc, &flags); 802 - } 803 - #endif 804 1016 805 1017 #if defined(__i386__) 806 1018 /* 807 1019 * Return the disk geometry for the given SCSI device. 808 1020 */ 809 1021 static int 810 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 811 1022 ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, 812 1023 sector_t capacity, int geom[]) 813 1024 { 814 1025 uint8_t *bh; 815 - #else 816 - ahc_linux_biosparam(Disk *disk, kdev_t dev, int geom[]) 817 - { 818 - struct scsi_device *sdev = disk->device; 819 - u_long capacity = disk->capacity; 820 - struct buffer_head *bh; 821 - #endif 822 1026 int heads; 823 1027 int sectors; 824 1028 int cylinders; ··· 774 1090 ahc = *((struct ahc_softc **)sdev->host->hostdata); 775 1091 channel = sdev->channel; 776 1092 777 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 778 1093 bh = scsi_bios_ptable(bdev); 779 - #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17) 780 - bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, block_size(dev)); 781 - #else 782 - bh = bread(MKDEV(MAJOR(dev), MINOR(dev) & ~0xf), 0, 1024); 783 - #endif 784 - 785 1094 if (bh) { 786 1095 ret = scsi_partsize(bh, capacity, 787 1096 &geom[2], &geom[0], &geom[1]); 788 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 789 1097 kfree(bh); 790 - #else 791 - brelse(bh); 792 - #endif 793 1098 if (ret != -1) 794 1099 return (ret); 795 1100 } ··· 808 1135 * Abort the current SCSI command(s). 809 1136 */ 810 1137 static int 811 - ahc_linux_abort(Scsi_Cmnd *cmd) 1138 + ahc_linux_abort(struct scsi_cmnd *cmd) 812 1139 { 813 1140 int error; 814 1141 ··· 822 1149 * Attempt to send a target reset message to the device that timed out. 823 1150 */ 824 1151 static int 825 - ahc_linux_dev_reset(Scsi_Cmnd *cmd) 1152 + ahc_linux_dev_reset(struct scsi_cmnd *cmd) 826 1153 { 827 1154 int error; 828 1155 ··· 836 1163 * Reset the SCSI bus. 837 1164 */ 838 1165 static int 839 - ahc_linux_bus_reset(Scsi_Cmnd *cmd) 1166 + ahc_linux_bus_reset(struct scsi_cmnd *cmd) 840 1167 { 841 1168 struct ahc_softc *ahc; 842 - u_long s; 843 1169 int found; 844 1170 845 1171 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 846 - ahc_midlayer_entrypoint_lock(ahc, &s); 847 1172 found = ahc_reset_channel(ahc, cmd->device->channel + 'A', 848 1173 /*initiate reset*/TRUE); 849 - ahc_linux_run_complete_queue(ahc); 850 - ahc_midlayer_entrypoint_unlock(ahc, &s); 851 1174 852 1175 if (bootverbose) 853 1176 printf("%s: SCSI bus reset delivered. " ··· 852 1183 return SUCCESS; 853 1184 } 854 1185 855 - Scsi_Host_Template aic7xxx_driver_template = { 1186 + struct scsi_host_template aic7xxx_driver_template = { 856 1187 .module = THIS_MODULE, 857 1188 .name = "aic7xxx", 858 1189 .proc_info = ahc_linux_proc_info, ··· 874 1205 }; 875 1206 876 1207 /**************************** Tasklet Handler *********************************/ 877 - 878 - /* 879 - * In 2.4.X and above, this routine is called from a tasklet, 880 - * so we must re-acquire our lock prior to executing this code. 881 - * In all prior kernels, ahc_schedule_runq() calls this routine 882 - * directly and ahc_schedule_runq() is called with our lock held. 883 - */ 884 - static void 885 - ahc_runq_tasklet(unsigned long data) 886 - { 887 - struct ahc_softc* ahc; 888 - struct ahc_linux_device *dev; 889 - u_long flags; 890 - 891 - ahc = (struct ahc_softc *)data; 892 - ahc_lock(ahc, &flags); 893 - while ((dev = ahc_linux_next_device_to_run(ahc)) != NULL) { 894 - 895 - TAILQ_REMOVE(&ahc->platform_data->device_runq, dev, links); 896 - dev->flags &= ~AHC_DEV_ON_RUN_LIST; 897 - ahc_linux_check_device_queue(ahc, dev); 898 - /* Yeild to our interrupt handler */ 899 - ahc_unlock(ahc, &flags); 900 - ahc_lock(ahc, &flags); 901 - } 902 - ahc_unlock(ahc, &flags); 903 - } 904 1208 905 1209 /******************************** Macros **************************************/ 906 1210 #define BUILD_SCSIID(ahc, cmd) \ ··· 920 1278 ahc_dmamem_alloc(struct ahc_softc *ahc, bus_dma_tag_t dmat, void** vaddr, 921 1279 int flags, bus_dmamap_t *mapp) 922 1280 { 923 - bus_dmamap_t map; 924 - 925 - map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT); 926 - if (map == NULL) 927 - return (ENOMEM); 928 - /* 929 - * Although we can dma data above 4GB, our 930 - * "consistent" memory is below 4GB for 931 - * space efficiency reasons (only need a 4byte 932 - * address). For this reason, we have to reset 933 - * our dma mask when doing allocations. 934 - */ 935 - if (ahc->dev_softc != NULL) 936 - if (pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) { 937 - printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 938 - kfree(map); 939 - return (ENODEV); 940 - } 941 1281 *vaddr = pci_alloc_consistent(ahc->dev_softc, 942 - dmat->maxsize, &map->bus_addr); 943 - if (ahc->dev_softc != NULL) 944 - if (pci_set_dma_mask(ahc->dev_softc, 945 - ahc->platform_data->hw_dma_mask)) { 946 - printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 947 - kfree(map); 948 - return (ENODEV); 949 - } 1282 + dmat->maxsize, mapp); 950 1283 if (*vaddr == NULL) 951 - return (ENOMEM); 952 - *mapp = map; 953 - return(0); 1284 + return ENOMEM; 1285 + return 0; 954 1286 } 955 1287 956 1288 void ··· 932 1316 void* vaddr, bus_dmamap_t map) 933 1317 { 934 1318 pci_free_consistent(ahc->dev_softc, dmat->maxsize, 935 - vaddr, map->bus_addr); 1319 + vaddr, map); 936 1320 } 937 1321 938 1322 int ··· 946 1330 */ 947 1331 bus_dma_segment_t stack_sg; 948 1332 949 - stack_sg.ds_addr = map->bus_addr; 1333 + stack_sg.ds_addr = map; 950 1334 stack_sg.ds_len = dmat->maxsize; 951 1335 cb(cb_arg, &stack_sg, /*nseg*/1, /*error*/0); 952 1336 return (0); ··· 955 1339 void 956 1340 ahc_dmamap_destroy(struct ahc_softc *ahc, bus_dma_tag_t dmat, bus_dmamap_t map) 957 1341 { 958 - /* 959 - * The map may is NULL in our < 2.3.X implementation. 960 - * Now it's 2.6.5, but just in case... 961 - */ 962 - BUG_ON(map == NULL); 963 - free(map, M_DEVBUF); 964 1342 } 965 1343 966 1344 int ··· 1160 1550 uint32_t aic7xxx_verbose; 1161 1551 1162 1552 int 1163 - ahc_linux_register_host(struct ahc_softc *ahc, Scsi_Host_Template *template) 1553 + ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template) 1164 1554 { 1165 1555 char buf[80]; 1166 1556 struct Scsi_Host *host; ··· 1174 1564 1175 1565 *((struct ahc_softc **)host->hostdata) = ahc; 1176 1566 ahc_lock(ahc, &s); 1177 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1178 1567 scsi_assign_lock(host, &ahc->platform_data->spin_lock); 1179 - #elif AHC_SCSI_HAS_HOST_LOCK != 0 1180 - host->lock = &ahc->platform_data->spin_lock; 1181 - #endif 1182 1568 ahc->platform_data->host = host; 1183 1569 host->can_queue = AHC_MAX_QUEUE; 1184 1570 host->cmd_per_lun = 2; ··· 1193 1587 ahc_set_name(ahc, new_name); 1194 1588 } 1195 1589 host->unique_id = ahc->unit; 1196 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 1197 - scsi_set_pci_device(host, ahc->dev_softc); 1198 - #endif 1199 1590 ahc_linux_initialize_scsi_bus(ahc); 1200 1591 ahc_intr_enable(ahc, TRUE); 1201 1592 ahc_unlock(ahc, &s); 1202 1593 1203 1594 host->transportt = ahc_linux_transport_template; 1204 1595 1205 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1206 1596 scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */ 1207 1597 scsi_scan_host(host); 1208 - #endif 1209 1598 return (0); 1210 1599 } 1211 1600 ··· 1318 1717 if (ahc->platform_data == NULL) 1319 1718 return (ENOMEM); 1320 1719 memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data)); 1321 - TAILQ_INIT(&ahc->platform_data->completeq); 1322 - TAILQ_INIT(&ahc->platform_data->device_runq); 1323 1720 ahc->platform_data->irq = AHC_LINUX_NOIRQ; 1324 - ahc->platform_data->hw_dma_mask = 0xFFFFFFFF; 1325 1721 ahc_lockinit(ahc); 1326 - ahc_done_lockinit(ahc); 1327 - init_timer(&ahc->platform_data->completeq_timer); 1328 - ahc->platform_data->completeq_timer.data = (u_long)ahc; 1329 - ahc->platform_data->completeq_timer.function = 1330 - (ahc_linux_callback_t *)ahc_linux_thread_run_complete_queue; 1331 1722 init_MUTEX_LOCKED(&ahc->platform_data->eh_sem); 1332 - tasklet_init(&ahc->platform_data->runq_tasklet, ahc_runq_tasklet, 1333 - (unsigned long)ahc); 1334 1723 ahc->seltime = (aic7xxx_seltime & 0x3) << 4; 1335 1724 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4; 1336 1725 if (aic7xxx_pci_parity == 0) ··· 1337 1746 int i, j; 1338 1747 1339 1748 if (ahc->platform_data != NULL) { 1340 - del_timer_sync(&ahc->platform_data->completeq_timer); 1341 - tasklet_kill(&ahc->platform_data->runq_tasklet); 1342 1749 if (ahc->platform_data->host != NULL) { 1343 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1344 1750 scsi_remove_host(ahc->platform_data->host); 1345 - #endif 1346 1751 scsi_host_put(ahc->platform_data->host); 1347 1752 } 1348 1753 ··· 1374 1787 release_mem_region(ahc->platform_data->mem_busaddr, 1375 1788 0x1000); 1376 1789 } 1377 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 1378 - /* 1379 - * In 2.4 we detach from the scsi midlayer before the PCI 1380 - * layer invokes our remove callback. No per-instance 1381 - * detach is provided, so we must reach inside the PCI 1382 - * subsystem's internals and detach our driver manually. 1383 - */ 1384 - if (ahc->dev_softc != NULL) 1385 - ahc->dev_softc->driver = NULL; 1386 - #endif 1790 + 1387 1791 free(ahc->platform_data, M_DEVBUF); 1388 1792 } 1389 1793 } ··· 1398 1820 1399 1821 dev = ahc_linux_get_device(ahc, devinfo->channel - 'A', 1400 1822 devinfo->target, 1401 - devinfo->lun, /*alloc*/FALSE); 1823 + devinfo->lun); 1402 1824 if (dev == NULL) 1403 1825 return; 1404 1826 was_queuing = dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED); ··· 1451 1873 dev->maxtags = 0; 1452 1874 dev->openings = 1 - dev->active; 1453 1875 } 1454 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1455 1876 if (dev->scsi_device != NULL) { 1456 1877 switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) { 1457 1878 case AHC_DEV_Q_BASIC: ··· 1476 1899 break; 1477 1900 } 1478 1901 } 1479 - #endif 1480 1902 } 1481 1903 1482 1904 int 1483 1905 ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, char channel, 1484 1906 int lun, u_int tag, role_t role, uint32_t status) 1485 1907 { 1486 - int chan; 1487 - int maxchan; 1488 - int targ; 1489 - int maxtarg; 1490 - int clun; 1491 - int maxlun; 1492 - int count; 1493 - 1494 - if (tag != SCB_LIST_NULL) 1495 - return (0); 1496 - 1497 - chan = 0; 1498 - if (channel != ALL_CHANNELS) { 1499 - chan = channel - 'A'; 1500 - maxchan = chan + 1; 1501 - } else { 1502 - maxchan = (ahc->features & AHC_TWIN) ? 2 : 1; 1503 - } 1504 - targ = 0; 1505 - if (target != CAM_TARGET_WILDCARD) { 1506 - targ = target; 1507 - maxtarg = targ + 1; 1508 - } else { 1509 - maxtarg = (ahc->features & AHC_WIDE) ? 16 : 8; 1510 - } 1511 - clun = 0; 1512 - if (lun != CAM_LUN_WILDCARD) { 1513 - clun = lun; 1514 - maxlun = clun + 1; 1515 - } else { 1516 - maxlun = AHC_NUM_LUNS; 1517 - } 1518 - 1519 - count = 0; 1520 - for (; chan < maxchan; chan++) { 1521 - 1522 - for (; targ < maxtarg; targ++) { 1523 - 1524 - for (; clun < maxlun; clun++) { 1525 - struct ahc_linux_device *dev; 1526 - struct ahc_busyq *busyq; 1527 - struct ahc_cmd *acmd; 1528 - 1529 - dev = ahc_linux_get_device(ahc, chan, 1530 - targ, clun, 1531 - /*alloc*/FALSE); 1532 - if (dev == NULL) 1533 - continue; 1534 - 1535 - busyq = &dev->busyq; 1536 - while ((acmd = TAILQ_FIRST(busyq)) != NULL) { 1537 - Scsi_Cmnd *cmd; 1538 - 1539 - cmd = &acmd_scsi_cmd(acmd); 1540 - TAILQ_REMOVE(busyq, acmd, 1541 - acmd_links.tqe); 1542 - count++; 1543 - cmd->result = status << 16; 1544 - ahc_linux_queue_cmd_complete(ahc, cmd); 1545 - } 1546 - } 1547 - } 1548 - } 1549 - 1550 - return (count); 1551 - } 1552 - 1553 - static void 1554 - ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc) 1555 - { 1556 - u_long flags; 1557 - 1558 - ahc_lock(ahc, &flags); 1559 - del_timer(&ahc->platform_data->completeq_timer); 1560 - ahc->platform_data->flags &= ~AHC_RUN_CMPLT_Q_TIMER; 1561 - ahc_linux_run_complete_queue(ahc); 1562 - ahc_unlock(ahc, &flags); 1908 + return 0; 1563 1909 } 1564 1910 1565 1911 static u_int ··· 1545 2045 } 1546 2046 } 1547 2047 1548 - static void 1549 - ahc_linux_run_device_queue(struct ahc_softc *ahc, struct ahc_linux_device *dev) 2048 + static int 2049 + ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, 2050 + struct scsi_cmnd *cmd) 1550 2051 { 1551 - struct ahc_cmd *acmd; 1552 - struct scsi_cmnd *cmd; 1553 2052 struct scb *scb; 1554 2053 struct hardware_scb *hscb; 1555 2054 struct ahc_initiator_tinfo *tinfo; 1556 2055 struct ahc_tmode_tstate *tstate; 1557 2056 uint16_t mask; 2057 + struct scb_tailq *untagged_q = NULL; 1558 2058 1559 - if ((dev->flags & AHC_DEV_ON_RUN_LIST) != 0) 1560 - panic("running device on run list"); 2059 + /* 2060 + * Schedule us to run later. The only reason we are not 2061 + * running is because the whole controller Q is frozen. 2062 + */ 2063 + if (ahc->platform_data->qfrozen != 0) 2064 + return SCSI_MLQUEUE_HOST_BUSY; 1561 2065 1562 - while ((acmd = TAILQ_FIRST(&dev->busyq)) != NULL 1563 - && dev->openings > 0 && dev->qfrozen == 0) { 2066 + /* 2067 + * We only allow one untagged transaction 2068 + * per target in the initiator role unless 2069 + * we are storing a full busy target *lun* 2070 + * table in SCB space. 2071 + */ 2072 + if (!blk_rq_tagged(cmd->request) 2073 + && (ahc->features & AHC_SCB_BTT) == 0) { 2074 + int target_offset; 1564 2075 1565 - /* 1566 - * Schedule us to run later. The only reason we are not 1567 - * running is because the whole controller Q is frozen. 1568 - */ 1569 - if (ahc->platform_data->qfrozen != 0) { 1570 - TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, 1571 - dev, links); 1572 - dev->flags |= AHC_DEV_ON_RUN_LIST; 1573 - return; 1574 - } 1575 - /* 1576 - * Get an scb to use. 1577 - */ 1578 - if ((scb = ahc_get_scb(ahc)) == NULL) { 1579 - TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, 1580 - dev, links); 1581 - dev->flags |= AHC_DEV_ON_RUN_LIST; 1582 - ahc->flags |= AHC_RESOURCE_SHORTAGE; 1583 - return; 1584 - } 1585 - TAILQ_REMOVE(&dev->busyq, acmd, acmd_links.tqe); 1586 - cmd = &acmd_scsi_cmd(acmd); 1587 - scb->io_ctx = cmd; 1588 - scb->platform_data->dev = dev; 1589 - hscb = scb->hscb; 1590 - cmd->host_scribble = (char *)scb; 1591 - 1592 - /* 1593 - * Fill out basics of the HSCB. 1594 - */ 1595 - hscb->control = 0; 1596 - hscb->scsiid = BUILD_SCSIID(ahc, cmd); 1597 - hscb->lun = cmd->device->lun; 1598 - mask = SCB_GET_TARGET_MASK(ahc, scb); 1599 - tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb), 1600 - SCB_GET_OUR_ID(scb), 1601 - SCB_GET_TARGET(ahc, scb), &tstate); 1602 - hscb->scsirate = tinfo->scsirate; 1603 - hscb->scsioffset = tinfo->curr.offset; 1604 - if ((tstate->ultraenb & mask) != 0) 1605 - hscb->control |= ULTRAENB; 1606 - 1607 - if ((ahc->user_discenable & mask) != 0) 1608 - hscb->control |= DISCENB; 1609 - 1610 - if ((tstate->auto_negotiate & mask) != 0) { 1611 - scb->flags |= SCB_AUTO_NEGOTIATE; 1612 - scb->hscb->control |= MK_MESSAGE; 1613 - } 1614 - 1615 - if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) { 1616 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1617 - int msg_bytes; 1618 - uint8_t tag_msgs[2]; 1619 - 1620 - msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); 1621 - if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { 1622 - hscb->control |= tag_msgs[0]; 1623 - if (tag_msgs[0] == MSG_ORDERED_TASK) 1624 - dev->commands_since_idle_or_otag = 0; 1625 - } else 1626 - #endif 1627 - if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH 1628 - && (dev->flags & AHC_DEV_Q_TAGGED) != 0) { 1629 - hscb->control |= MSG_ORDERED_TASK; 1630 - dev->commands_since_idle_or_otag = 0; 1631 - } else { 1632 - hscb->control |= MSG_SIMPLE_TASK; 1633 - } 1634 - } 1635 - 1636 - hscb->cdb_len = cmd->cmd_len; 1637 - if (hscb->cdb_len <= 12) { 1638 - memcpy(hscb->shared_data.cdb, cmd->cmnd, hscb->cdb_len); 1639 - } else { 1640 - memcpy(hscb->cdb32, cmd->cmnd, hscb->cdb_len); 1641 - scb->flags |= SCB_CDB32_PTR; 1642 - } 1643 - 1644 - scb->platform_data->xfer_len = 0; 1645 - ahc_set_residual(scb, 0); 1646 - ahc_set_sense_residual(scb, 0); 1647 - scb->sg_count = 0; 1648 - if (cmd->use_sg != 0) { 1649 - struct ahc_dma_seg *sg; 1650 - struct scatterlist *cur_seg; 1651 - struct scatterlist *end_seg; 1652 - int nseg; 1653 - 1654 - cur_seg = (struct scatterlist *)cmd->request_buffer; 1655 - nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg, 1656 - cmd->sc_data_direction); 1657 - end_seg = cur_seg + nseg; 1658 - /* Copy the segments into the SG list. */ 1659 - sg = scb->sg_list; 1660 - /* 1661 - * The sg_count may be larger than nseg if 1662 - * a transfer crosses a 32bit page. 1663 - */ 1664 - while (cur_seg < end_seg) { 1665 - dma_addr_t addr; 1666 - bus_size_t len; 1667 - int consumed; 1668 - 1669 - addr = sg_dma_address(cur_seg); 1670 - len = sg_dma_len(cur_seg); 1671 - consumed = ahc_linux_map_seg(ahc, scb, 1672 - sg, addr, len); 1673 - sg += consumed; 1674 - scb->sg_count += consumed; 1675 - cur_seg++; 1676 - } 1677 - sg--; 1678 - sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); 1679 - 1680 - /* 1681 - * Reset the sg list pointer. 1682 - */ 1683 - scb->hscb->sgptr = 1684 - ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); 1685 - 1686 - /* 1687 - * Copy the first SG into the "current" 1688 - * data pointer area. 1689 - */ 1690 - scb->hscb->dataptr = scb->sg_list->addr; 1691 - scb->hscb->datacnt = scb->sg_list->len; 1692 - } else if (cmd->request_bufflen != 0) { 1693 - struct ahc_dma_seg *sg; 1694 - dma_addr_t addr; 1695 - 1696 - sg = scb->sg_list; 1697 - addr = pci_map_single(ahc->dev_softc, 1698 - cmd->request_buffer, 1699 - cmd->request_bufflen, 1700 - cmd->sc_data_direction); 1701 - scb->platform_data->buf_busaddr = addr; 1702 - scb->sg_count = ahc_linux_map_seg(ahc, scb, 1703 - sg, addr, 1704 - cmd->request_bufflen); 1705 - sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); 1706 - 1707 - /* 1708 - * Reset the sg list pointer. 1709 - */ 1710 - scb->hscb->sgptr = 1711 - ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); 1712 - 1713 - /* 1714 - * Copy the first SG into the "current" 1715 - * data pointer area. 1716 - */ 1717 - scb->hscb->dataptr = sg->addr; 1718 - scb->hscb->datacnt = sg->len; 1719 - } else { 1720 - scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL); 1721 - scb->hscb->dataptr = 0; 1722 - scb->hscb->datacnt = 0; 1723 - scb->sg_count = 0; 1724 - } 1725 - 1726 - ahc_sync_sglist(ahc, scb, BUS_DMASYNC_PREWRITE); 1727 - LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links); 1728 - dev->openings--; 1729 - dev->active++; 1730 - dev->commands_issued++; 1731 - if ((dev->flags & AHC_DEV_PERIODIC_OTAG) != 0) 1732 - dev->commands_since_idle_or_otag++; 1733 - 1734 - /* 1735 - * We only allow one untagged transaction 1736 - * per target in the initiator role unless 1737 - * we are storing a full busy target *lun* 1738 - * table in SCB space. 1739 - */ 1740 - if ((scb->hscb->control & (TARGET_SCB|TAG_ENB)) == 0 1741 - && (ahc->features & AHC_SCB_BTT) == 0) { 1742 - struct scb_tailq *untagged_q; 1743 - int target_offset; 1744 - 1745 - target_offset = SCB_GET_TARGET_OFFSET(ahc, scb); 1746 - untagged_q = &(ahc->untagged_queues[target_offset]); 1747 - TAILQ_INSERT_TAIL(untagged_q, scb, links.tqe); 1748 - scb->flags |= SCB_UNTAGGEDQ; 1749 - if (TAILQ_FIRST(untagged_q) != scb) 1750 - continue; 1751 - } 1752 - scb->flags |= SCB_ACTIVE; 1753 - ahc_queue_scb(ahc, scb); 2076 + target_offset = cmd->device->id + cmd->device->channel * 8; 2077 + untagged_q = &(ahc->untagged_queues[target_offset]); 2078 + if (!TAILQ_EMPTY(untagged_q)) 2079 + /* if we're already executing an untagged command 2080 + * we're busy to another */ 2081 + return SCSI_MLQUEUE_DEVICE_BUSY; 1754 2082 } 2083 + 2084 + /* 2085 + * Get an scb to use. 2086 + */ 2087 + if ((scb = ahc_get_scb(ahc)) == NULL) { 2088 + ahc->flags |= AHC_RESOURCE_SHORTAGE; 2089 + return SCSI_MLQUEUE_HOST_BUSY; 2090 + } 2091 + 2092 + scb->io_ctx = cmd; 2093 + scb->platform_data->dev = dev; 2094 + hscb = scb->hscb; 2095 + cmd->host_scribble = (char *)scb; 2096 + 2097 + /* 2098 + * Fill out basics of the HSCB. 2099 + */ 2100 + hscb->control = 0; 2101 + hscb->scsiid = BUILD_SCSIID(ahc, cmd); 2102 + hscb->lun = cmd->device->lun; 2103 + mask = SCB_GET_TARGET_MASK(ahc, scb); 2104 + tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb), 2105 + SCB_GET_OUR_ID(scb), 2106 + SCB_GET_TARGET(ahc, scb), &tstate); 2107 + hscb->scsirate = tinfo->scsirate; 2108 + hscb->scsioffset = tinfo->curr.offset; 2109 + if ((tstate->ultraenb & mask) != 0) 2110 + hscb->control |= ULTRAENB; 2111 + 2112 + if ((ahc->user_discenable & mask) != 0) 2113 + hscb->control |= DISCENB; 2114 + 2115 + if ((tstate->auto_negotiate & mask) != 0) { 2116 + scb->flags |= SCB_AUTO_NEGOTIATE; 2117 + scb->hscb->control |= MK_MESSAGE; 2118 + } 2119 + 2120 + if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) { 2121 + int msg_bytes; 2122 + uint8_t tag_msgs[2]; 2123 + 2124 + msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs); 2125 + if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) { 2126 + hscb->control |= tag_msgs[0]; 2127 + if (tag_msgs[0] == MSG_ORDERED_TASK) 2128 + dev->commands_since_idle_or_otag = 0; 2129 + } else if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH 2130 + && (dev->flags & AHC_DEV_Q_TAGGED) != 0) { 2131 + hscb->control |= MSG_ORDERED_TASK; 2132 + dev->commands_since_idle_or_otag = 0; 2133 + } else { 2134 + hscb->control |= MSG_SIMPLE_TASK; 2135 + } 2136 + } 2137 + 2138 + hscb->cdb_len = cmd->cmd_len; 2139 + if (hscb->cdb_len <= 12) { 2140 + memcpy(hscb->shared_data.cdb, cmd->cmnd, hscb->cdb_len); 2141 + } else { 2142 + memcpy(hscb->cdb32, cmd->cmnd, hscb->cdb_len); 2143 + scb->flags |= SCB_CDB32_PTR; 2144 + } 2145 + 2146 + scb->platform_data->xfer_len = 0; 2147 + ahc_set_residual(scb, 0); 2148 + ahc_set_sense_residual(scb, 0); 2149 + scb->sg_count = 0; 2150 + if (cmd->use_sg != 0) { 2151 + struct ahc_dma_seg *sg; 2152 + struct scatterlist *cur_seg; 2153 + struct scatterlist *end_seg; 2154 + int nseg; 2155 + 2156 + cur_seg = (struct scatterlist *)cmd->request_buffer; 2157 + nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg, 2158 + cmd->sc_data_direction); 2159 + end_seg = cur_seg + nseg; 2160 + /* Copy the segments into the SG list. */ 2161 + sg = scb->sg_list; 2162 + /* 2163 + * The sg_count may be larger than nseg if 2164 + * a transfer crosses a 32bit page. 2165 + */ 2166 + while (cur_seg < end_seg) { 2167 + dma_addr_t addr; 2168 + bus_size_t len; 2169 + int consumed; 2170 + 2171 + addr = sg_dma_address(cur_seg); 2172 + len = sg_dma_len(cur_seg); 2173 + consumed = ahc_linux_map_seg(ahc, scb, 2174 + sg, addr, len); 2175 + sg += consumed; 2176 + scb->sg_count += consumed; 2177 + cur_seg++; 2178 + } 2179 + sg--; 2180 + sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); 2181 + 2182 + /* 2183 + * Reset the sg list pointer. 2184 + */ 2185 + scb->hscb->sgptr = 2186 + ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); 2187 + 2188 + /* 2189 + * Copy the first SG into the "current" 2190 + * data pointer area. 2191 + */ 2192 + scb->hscb->dataptr = scb->sg_list->addr; 2193 + scb->hscb->datacnt = scb->sg_list->len; 2194 + } else if (cmd->request_bufflen != 0) { 2195 + struct ahc_dma_seg *sg; 2196 + dma_addr_t addr; 2197 + 2198 + sg = scb->sg_list; 2199 + addr = pci_map_single(ahc->dev_softc, 2200 + cmd->request_buffer, 2201 + cmd->request_bufflen, 2202 + cmd->sc_data_direction); 2203 + scb->platform_data->buf_busaddr = addr; 2204 + scb->sg_count = ahc_linux_map_seg(ahc, scb, 2205 + sg, addr, 2206 + cmd->request_bufflen); 2207 + sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); 2208 + 2209 + /* 2210 + * Reset the sg list pointer. 2211 + */ 2212 + scb->hscb->sgptr = 2213 + ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); 2214 + 2215 + /* 2216 + * Copy the first SG into the "current" 2217 + * data pointer area. 2218 + */ 2219 + scb->hscb->dataptr = sg->addr; 2220 + scb->hscb->datacnt = sg->len; 2221 + } else { 2222 + scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL); 2223 + scb->hscb->dataptr = 0; 2224 + scb->hscb->datacnt = 0; 2225 + scb->sg_count = 0; 2226 + } 2227 + 2228 + LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links); 2229 + dev->openings--; 2230 + dev->active++; 2231 + dev->commands_issued++; 2232 + if ((dev->flags & AHC_DEV_PERIODIC_OTAG) != 0) 2233 + dev->commands_since_idle_or_otag++; 2234 + 2235 + scb->flags |= SCB_ACTIVE; 2236 + if (untagged_q) { 2237 + TAILQ_INSERT_TAIL(untagged_q, scb, links.tqe); 2238 + scb->flags |= SCB_UNTAGGEDQ; 2239 + } 2240 + ahc_queue_scb(ahc, scb); 2241 + return 0; 1755 2242 } 1756 2243 1757 2244 /* ··· 1754 2267 ahc = (struct ahc_softc *) dev_id; 1755 2268 ahc_lock(ahc, &flags); 1756 2269 ours = ahc_intr(ahc); 1757 - if (ahc_linux_next_device_to_run(ahc) != NULL) 1758 - ahc_schedule_runq(ahc); 1759 - ahc_linux_run_complete_queue(ahc); 1760 2270 ahc_unlock(ahc, &flags); 1761 2271 return IRQ_RETVAL(ours); 1762 2272 } ··· 1762 2278 ahc_platform_flushwork(struct ahc_softc *ahc) 1763 2279 { 1764 2280 1765 - while (ahc_linux_run_complete_queue(ahc) != NULL) 1766 - ; 1767 2281 } 1768 2282 1769 2283 static struct ahc_linux_target* ··· 1830 2348 if (dev == NULL) 1831 2349 return (NULL); 1832 2350 memset(dev, 0, sizeof(*dev)); 1833 - init_timer(&dev->timer); 1834 - TAILQ_INIT(&dev->busyq); 1835 - dev->flags = AHC_DEV_UNCONFIGURED; 1836 2351 dev->lun = lun; 1837 2352 dev->target = targ; 1838 2353 ··· 1852 2373 } 1853 2374 1854 2375 static void 1855 - __ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev) 2376 + ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev) 1856 2377 { 1857 2378 struct ahc_linux_target *targ; 1858 2379 ··· 1862 2383 targ->refcount--; 1863 2384 if (targ->refcount == 0) 1864 2385 ahc_linux_free_target(ahc, targ); 1865 - } 1866 - 1867 - static void 1868 - ahc_linux_free_device(struct ahc_softc *ahc, struct ahc_linux_device *dev) 1869 - { 1870 - del_timer_sync(&dev->timer); 1871 - __ahc_linux_free_device(ahc, dev); 1872 2386 } 1873 2387 1874 2388 void ··· 1935 2463 } 1936 2464 case AC_SENT_BDR: 1937 2465 { 1938 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 1939 2466 WARN_ON(lun != CAM_LUN_WILDCARD); 1940 2467 scsi_report_device_reset(ahc->platform_data->host, 1941 2468 channel - 'A', target); 1942 - #else 1943 - Scsi_Device *scsi_dev; 1944 - 1945 - /* 1946 - * Find the SCSI device associated with this 1947 - * request and indicate that a UA is expected. 1948 - */ 1949 - for (scsi_dev = ahc->platform_data->host->host_queue; 1950 - scsi_dev != NULL; scsi_dev = scsi_dev->next) { 1951 - if (channel - 'A' == scsi_dev->channel 1952 - && target == scsi_dev->id 1953 - && (lun == CAM_LUN_WILDCARD 1954 - || lun == scsi_dev->lun)) { 1955 - scsi_dev->was_reset = 1; 1956 - scsi_dev->expecting_cc_ua = 1; 1957 - } 1958 - } 1959 - #endif 1960 2469 break; 1961 2470 } 1962 2471 case AC_BUS_RESET: ··· 1957 2504 void 1958 2505 ahc_done(struct ahc_softc *ahc, struct scb *scb) 1959 2506 { 1960 - Scsi_Cmnd *cmd; 2507 + struct scsi_cmnd *cmd; 1961 2508 struct ahc_linux_device *dev; 1962 2509 1963 2510 LIST_REMOVE(scb, pending_links); ··· 1968 2515 target_offset = SCB_GET_TARGET_OFFSET(ahc, scb); 1969 2516 untagged_q = &(ahc->untagged_queues[target_offset]); 1970 2517 TAILQ_REMOVE(untagged_q, scb, links.tqe); 1971 - ahc_run_untagged_queue(ahc, untagged_q); 2518 + BUG_ON(!TAILQ_EMPTY(untagged_q)); 1972 2519 } 1973 2520 1974 2521 if ((scb->flags & SCB_ACTIVE) == 0) { ··· 2036 2583 } 2037 2584 } else if (ahc_get_transaction_status(scb) == CAM_SCSI_STATUS_ERROR) { 2038 2585 ahc_linux_handle_scsi_status(ahc, dev, scb); 2039 - } else if (ahc_get_transaction_status(scb) == CAM_SEL_TIMEOUT) { 2040 - dev->flags |= AHC_DEV_UNCONFIGURED; 2041 2586 } 2042 2587 2043 2588 if (dev->openings == 1 ··· 2056 2605 2057 2606 if (dev->active == 0) 2058 2607 dev->commands_since_idle_or_otag = 0; 2059 - 2060 - if (TAILQ_EMPTY(&dev->busyq)) { 2061 - if ((dev->flags & AHC_DEV_UNCONFIGURED) != 0 2062 - && dev->active == 0 2063 - && (dev->flags & AHC_DEV_TIMER_ACTIVE) == 0) 2064 - ahc_linux_free_device(ahc, dev); 2065 - } else if ((dev->flags & AHC_DEV_ON_RUN_LIST) == 0) { 2066 - TAILQ_INSERT_TAIL(&ahc->platform_data->device_runq, dev, links); 2067 - dev->flags |= AHC_DEV_ON_RUN_LIST; 2068 - } 2069 2608 2070 2609 if ((scb->flags & SCB_RECOVERY_SCB) != 0) { 2071 2610 printf("Recovery SCB completes\n"); ··· 2100 2659 case SCSI_STATUS_CHECK_COND: 2101 2660 case SCSI_STATUS_CMD_TERMINATED: 2102 2661 { 2103 - Scsi_Cmnd *cmd; 2662 + struct scsi_cmnd *cmd; 2104 2663 2105 2664 /* 2106 2665 * Copy sense information to the OS's cmd ··· 2195 2754 ahc_platform_set_tags(ahc, &devinfo, 2196 2755 (dev->flags & AHC_DEV_Q_BASIC) 2197 2756 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 2198 - /* FALLTHROUGH */ 2199 - } 2200 - case SCSI_STATUS_BUSY: 2201 - { 2202 - /* 2203 - * Set a short timer to defer sending commands for 2204 - * a bit since Linux will not delay in this case. 2205 - */ 2206 - if ((dev->flags & AHC_DEV_TIMER_ACTIVE) != 0) { 2207 - printf("%s:%c:%d: Device Timer still active during " 2208 - "busy processing\n", ahc_name(ahc), 2209 - dev->target->channel, dev->target->target); 2210 - break; 2211 - } 2212 - dev->flags |= AHC_DEV_TIMER_ACTIVE; 2213 - dev->qfrozen++; 2214 - init_timer(&dev->timer); 2215 - dev->timer.data = (u_long)dev; 2216 - dev->timer.expires = jiffies + (HZ/2); 2217 - dev->timer.function = ahc_linux_dev_timed_unfreeze; 2218 - add_timer(&dev->timer); 2219 2757 break; 2220 2758 } 2221 2759 } 2222 2760 } 2223 2761 2224 2762 static void 2225 - ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, Scsi_Cmnd *cmd) 2763 + ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd) 2226 2764 { 2227 - /* 2228 - * Typically, the complete queue has very few entries 2229 - * queued to it before the queue is emptied by 2230 - * ahc_linux_run_complete_queue, so sorting the entries 2231 - * by generation number should be inexpensive. 2232 - * We perform the sort so that commands that complete 2233 - * with an error are retuned in the order origionally 2234 - * queued to the controller so that any subsequent retries 2235 - * are performed in order. The underlying ahc routines do 2236 - * not guarantee the order that aborted commands will be 2237 - * returned to us. 2238 - */ 2239 - struct ahc_completeq *completeq; 2240 - struct ahc_cmd *list_cmd; 2241 - struct ahc_cmd *acmd; 2242 - 2243 2765 /* 2244 2766 * Map CAM error codes into Linux Error codes. We 2245 2767 * avoid the conversion so that the DV code has the ··· 2256 2852 new_status = DID_ERROR; 2257 2853 break; 2258 2854 case CAM_REQUEUE_REQ: 2259 - /* 2260 - * If we want the request requeued, make sure there 2261 - * are sufficent retries. In the old scsi error code, 2262 - * we used to be able to specify a result code that 2263 - * bypassed the retry count. Now we must use this 2264 - * hack. We also "fake" a check condition with 2265 - * a sense code of ABORTED COMMAND. This seems to 2266 - * evoke a retry even if this command is being sent 2267 - * via the eh thread. Ick! Ick! Ick! 2268 - */ 2269 - if (cmd->retries > 0) 2270 - cmd->retries--; 2271 - new_status = DID_OK; 2272 - ahc_cmd_set_scsi_status(cmd, SCSI_STATUS_CHECK_COND); 2273 - cmd->result |= (DRIVER_SENSE << 24); 2274 - memset(cmd->sense_buffer, 0, 2275 - sizeof(cmd->sense_buffer)); 2276 - cmd->sense_buffer[0] = SSD_ERRCODE_VALID 2277 - | SSD_CURRENT_ERROR; 2278 - cmd->sense_buffer[2] = SSD_KEY_ABORTED_COMMAND; 2855 + new_status = DID_REQUEUE; 2279 2856 break; 2280 2857 default: 2281 2858 /* We should never get here */ ··· 2267 2882 ahc_cmd_set_transaction_status(cmd, new_status); 2268 2883 } 2269 2884 2270 - completeq = &ahc->platform_data->completeq; 2271 - list_cmd = TAILQ_FIRST(completeq); 2272 - acmd = (struct ahc_cmd *)cmd; 2273 - while (list_cmd != NULL 2274 - && acmd_scsi_cmd(list_cmd).serial_number 2275 - < acmd_scsi_cmd(acmd).serial_number) 2276 - list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe); 2277 - if (list_cmd != NULL) 2278 - TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe); 2279 - else 2280 - TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe); 2885 + cmd->scsi_done(cmd); 2281 2886 } 2282 2887 2283 2888 static void ··· 2315 2940 ahc->platform_data->qfrozen--; 2316 2941 if (ahc->platform_data->qfrozen == 0) 2317 2942 unblock_reqs = 1; 2318 - ahc_schedule_runq(ahc); 2319 2943 ahc_unlock(ahc, &s); 2320 2944 /* 2321 2945 * There is still a race here. The mid-layer ··· 2326 2952 scsi_unblock_requests(ahc->platform_data->host); 2327 2953 } 2328 2954 2329 - static void 2330 - ahc_linux_dev_timed_unfreeze(u_long arg) 2331 - { 2332 - struct ahc_linux_device *dev; 2333 - struct ahc_softc *ahc; 2334 - u_long s; 2335 - 2336 - dev = (struct ahc_linux_device *)arg; 2337 - ahc = dev->target->ahc; 2338 - ahc_lock(ahc, &s); 2339 - dev->flags &= ~AHC_DEV_TIMER_ACTIVE; 2340 - if (dev->qfrozen > 0) 2341 - dev->qfrozen--; 2342 - if (dev->qfrozen == 0 2343 - && (dev->flags & AHC_DEV_ON_RUN_LIST) == 0) 2344 - ahc_linux_run_device_queue(ahc, dev); 2345 - if (TAILQ_EMPTY(&dev->busyq) 2346 - && dev->active == 0) 2347 - __ahc_linux_free_device(ahc, dev); 2348 - ahc_unlock(ahc, &s); 2349 - } 2350 - 2351 2955 static int 2352 - ahc_linux_queue_recovery_cmd(Scsi_Cmnd *cmd, scb_flag flag) 2956 + ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) 2353 2957 { 2354 2958 struct ahc_softc *ahc; 2355 - struct ahc_cmd *acmd; 2356 - struct ahc_cmd *list_acmd; 2357 2959 struct ahc_linux_device *dev; 2358 2960 struct scb *pending_scb; 2359 - u_long s; 2360 2961 u_int saved_scbptr; 2361 2962 u_int active_scb_index; 2362 2963 u_int last_phase; ··· 2347 2998 paused = FALSE; 2348 2999 wait = FALSE; 2349 3000 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 2350 - acmd = (struct ahc_cmd *)cmd; 2351 3001 2352 3002 printf("%s:%d:%d:%d: Attempting to queue a%s message\n", 2353 3003 ahc_name(ahc), cmd->device->channel, ··· 2359 3011 printf("\n"); 2360 3012 2361 3013 /* 2362 - * In all versions of Linux, we have to work around 2363 - * a major flaw in how the mid-layer is locked down 2364 - * if we are to sleep successfully in our error handler 2365 - * while allowing our interrupt handler to run. Since 2366 - * the midlayer acquires either the io_request_lock or 2367 - * our lock prior to calling us, we must use the 2368 - * spin_unlock_irq() method for unlocking our lock. 2369 - * This will force interrupts to be enabled on the 2370 - * current CPU. Since the EH thread should not have 2371 - * been running with CPU interrupts disabled other than 2372 - * by acquiring either the io_request_lock or our own 2373 - * lock, this *should* be safe. 2374 - */ 2375 - ahc_midlayer_entrypoint_lock(ahc, &s); 2376 - 2377 - /* 2378 3014 * First determine if we currently own this command. 2379 3015 * Start by searching the device queue. If not found 2380 3016 * there, check the pending_scb list. If not found ··· 2366 3034 * command, return success. 2367 3035 */ 2368 3036 dev = ahc_linux_get_device(ahc, cmd->device->channel, cmd->device->id, 2369 - cmd->device->lun, /*alloc*/FALSE); 3037 + cmd->device->lun); 2370 3038 2371 3039 if (dev == NULL) { 2372 3040 /* ··· 2378 3046 cmd->device->lun); 2379 3047 retval = SUCCESS; 2380 3048 goto no_cmd; 2381 - } 2382 - 2383 - TAILQ_FOREACH(list_acmd, &dev->busyq, acmd_links.tqe) { 2384 - if (list_acmd == acmd) 2385 - break; 2386 - } 2387 - 2388 - if (list_acmd != NULL) { 2389 - printf("%s:%d:%d:%d: Command found on device queue\n", 2390 - ahc_name(ahc), cmd->device->channel, cmd->device->id, 2391 - cmd->device->lun); 2392 - if (flag == SCB_ABORT) { 2393 - TAILQ_REMOVE(&dev->busyq, list_acmd, acmd_links.tqe); 2394 - cmd->result = DID_ABORT << 16; 2395 - ahc_linux_queue_cmd_complete(ahc, cmd); 2396 - retval = SUCCESS; 2397 - goto done; 2398 - } 2399 3049 } 2400 3050 2401 3051 if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0 ··· 2613 3299 } 2614 3300 spin_lock_irq(&ahc->platform_data->spin_lock); 2615 3301 } 2616 - ahc_schedule_runq(ahc); 2617 - ahc_linux_run_complete_queue(ahc); 2618 - ahc_midlayer_entrypoint_unlock(ahc, &s); 2619 3302 return (retval); 2620 3303 } 2621 3304 2622 3305 void 2623 3306 ahc_platform_dump_card_state(struct ahc_softc *ahc) 2624 3307 { 2625 - struct ahc_linux_device *dev; 2626 - int channel; 2627 - int maxchannel; 2628 - int target; 2629 - int maxtarget; 2630 - int lun; 2631 - int i; 2632 - 2633 - maxchannel = (ahc->features & AHC_TWIN) ? 1 : 0; 2634 - maxtarget = (ahc->features & AHC_WIDE) ? 15 : 7; 2635 - for (channel = 0; channel <= maxchannel; channel++) { 2636 - 2637 - for (target = 0; target <=maxtarget; target++) { 2638 - 2639 - for (lun = 0; lun < AHC_NUM_LUNS; lun++) { 2640 - struct ahc_cmd *acmd; 2641 - 2642 - dev = ahc_linux_get_device(ahc, channel, target, 2643 - lun, /*alloc*/FALSE); 2644 - if (dev == NULL) 2645 - continue; 2646 - 2647 - printf("DevQ(%d:%d:%d): ", 2648 - channel, target, lun); 2649 - i = 0; 2650 - TAILQ_FOREACH(acmd, &dev->busyq, 2651 - acmd_links.tqe) { 2652 - if (i++ > AHC_SCB_MAX) 2653 - break; 2654 - } 2655 - printf("%d waiting\n", i); 2656 - } 2657 - } 2658 - } 2659 3308 } 2660 3309 2661 3310 static void ahc_linux_exit(void); 3311 + 3312 + static void ahc_linux_get_width(struct scsi_target *starget) 3313 + { 3314 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 3315 + struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); 3316 + struct ahc_tmode_tstate *tstate; 3317 + struct ahc_initiator_tinfo *tinfo 3318 + = ahc_fetch_transinfo(ahc, 3319 + starget->channel + 'A', 3320 + shost->this_id, starget->id, &tstate); 3321 + spi_width(starget) = tinfo->curr.width; 3322 + } 3323 + 3324 + static void ahc_linux_set_width(struct scsi_target *starget, int width) 3325 + { 3326 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 3327 + struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); 3328 + struct ahc_devinfo devinfo; 3329 + unsigned long flags; 3330 + 3331 + ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 3332 + starget->channel + 'A', ROLE_INITIATOR); 3333 + ahc_lock(ahc, &flags); 3334 + ahc_set_width(ahc, &devinfo, width, AHC_TRANS_GOAL, FALSE); 3335 + ahc_unlock(ahc, &flags); 3336 + } 2662 3337 2663 3338 static void ahc_linux_get_period(struct scsi_target *starget) 2664 3339 { ··· 2679 3376 if (offset == 0) 2680 3377 offset = MAX_OFFSET; 2681 3378 3379 + if (period < 9) 3380 + period = 9; /* 12.5ns is our minimum */ 3381 + if (period == 9) 3382 + ppr_options |= MSG_EXT_PPR_DT_REQ; 3383 + 2682 3384 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2683 3385 starget->channel + 'A', ROLE_INITIATOR); 3386 + 3387 + /* all PPR requests apart from QAS require wide transfers */ 3388 + if (ppr_options & ~MSG_EXT_PPR_QAS_REQ) { 3389 + ahc_linux_get_width(starget); 3390 + if (spi_width(starget) == 0) 3391 + ppr_options &= MSG_EXT_PPR_QAS_REQ; 3392 + } 3393 + 2684 3394 syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); 2685 3395 ahc_lock(ahc, &flags); 2686 3396 ahc_set_syncrate(ahc, &devinfo, syncrate, period, offset, ··· 2741 3425 ahc_unlock(ahc, &flags); 2742 3426 } 2743 3427 2744 - static void ahc_linux_get_width(struct scsi_target *starget) 2745 - { 2746 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2747 - struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); 2748 - struct ahc_tmode_tstate *tstate; 2749 - struct ahc_initiator_tinfo *tinfo 2750 - = ahc_fetch_transinfo(ahc, 2751 - starget->channel + 'A', 2752 - shost->this_id, starget->id, &tstate); 2753 - spi_width(starget) = tinfo->curr.width; 2754 - } 2755 - 2756 - static void ahc_linux_set_width(struct scsi_target *starget, int width) 2757 - { 2758 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2759 - struct ahc_softc *ahc = *((struct ahc_softc **)shost->hostdata); 2760 - struct ahc_devinfo devinfo; 2761 - unsigned long flags; 2762 - 2763 - ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2764 - starget->channel + 'A', ROLE_INITIATOR); 2765 - ahc_lock(ahc, &flags); 2766 - ahc_set_width(ahc, &devinfo, width, AHC_TRANS_GOAL, FALSE); 2767 - ahc_unlock(ahc, &flags); 2768 - } 2769 - 2770 3428 static void ahc_linux_get_dt(struct scsi_target *starget) 2771 3429 { 2772 3430 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); ··· 2769 3479 unsigned long flags; 2770 3480 struct ahc_syncrate *syncrate; 2771 3481 3482 + if (dt) { 3483 + period = 9; /* 12.5ns is the only period valid for DT */ 3484 + ppr_options |= MSG_EXT_PPR_DT_REQ; 3485 + } else if (period == 9) 3486 + period = 10; /* if resetting DT, period must be >= 25ns */ 3487 + 2772 3488 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2773 3489 starget->channel + 'A', ROLE_INITIATOR); 2774 - syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2775 - dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2); 3490 + syncrate = ahc_find_syncrate(ahc, &period, &ppr_options,AHC_SYNCRATE_DT); 2776 3491 ahc_lock(ahc, &flags); 2777 3492 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2778 3493 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 2809 3514 unsigned int ppr_options = tinfo->curr.ppr_options 2810 3515 & ~MSG_EXT_PPR_QAS_REQ; 2811 3516 unsigned int period = tinfo->curr.period; 2812 - unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; 2813 3517 unsigned long flags; 2814 3518 struct ahc_syncrate *syncrate; 2815 3519 ··· 2817 3523 2818 3524 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2819 3525 starget->channel + 'A', ROLE_INITIATOR); 2820 - syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2821 - dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2); 3526 + syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); 2822 3527 ahc_lock(ahc, &flags); 2823 3528 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2824 3529 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 2849 3556 unsigned int ppr_options = tinfo->curr.ppr_options 2850 3557 & ~MSG_EXT_PPR_IU_REQ; 2851 3558 unsigned int period = tinfo->curr.period; 2852 - unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; 2853 3559 unsigned long flags; 2854 3560 struct ahc_syncrate *syncrate; 2855 3561 ··· 2857 3565 2858 3566 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2859 3567 starget->channel + 'A', ROLE_INITIATOR); 2860 - syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, 2861 - dt ? AHC_SYNCRATE_DT : AHC_SYNCRATE_ULTRA2); 3568 + syncrate = ahc_find_syncrate(ahc, &period, &ppr_options, AHC_SYNCRATE_DT); 2862 3569 ahc_lock(ahc, &flags); 2863 3570 ahc_set_syncrate(ahc, &devinfo, syncrate, period, tinfo->curr.offset, 2864 3571 ppr_options, AHC_TRANS_GOAL, FALSE); ··· 2890 3599 static int __init 2891 3600 ahc_linux_init(void) 2892 3601 { 2893 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 2894 3602 ahc_linux_transport_template = spi_attach_transport(&ahc_linux_transport_functions); 2895 3603 if (!ahc_linux_transport_template) 2896 3604 return -ENODEV; ··· 2898 3608 spi_release_transport(ahc_linux_transport_template); 2899 3609 ahc_linux_exit(); 2900 3610 return -ENODEV; 2901 - #else 2902 - scsi_register_module(MODULE_SCSI_HA, &aic7xxx_driver_template); 2903 - if (aic7xxx_driver_template.present == 0) { 2904 - scsi_unregister_module(MODULE_SCSI_HA, 2905 - &aic7xxx_driver_template); 2906 - return (-ENODEV); 2907 - } 2908 - 2909 - return (0); 2910 - #endif 2911 3611 } 2912 3612 2913 3613 static void 2914 3614 ahc_linux_exit(void) 2915 3615 { 2916 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 2917 - /* 2918 - * In 2.4 we have to unregister from the PCI core _after_ 2919 - * unregistering from the scsi midlayer to avoid dangling 2920 - * references. 2921 - */ 2922 - scsi_unregister_module(MODULE_SCSI_HA, &aic7xxx_driver_template); 2923 - #endif 2924 3616 ahc_linux_pci_exit(); 2925 3617 ahc_linux_eisa_exit(); 2926 3618 spi_release_transport(ahc_linux_transport_template);
+25 -144
drivers/scsi/aic7xxx/aic7xxx_osm.h
··· 59 59 #ifndef _AIC7XXX_LINUX_H_ 60 60 #define _AIC7XXX_LINUX_H_ 61 61 62 + #include <linux/config.h> 62 63 #include <linux/types.h> 63 64 #include <linux/blkdev.h> 64 65 #include <linux/delay.h> ··· 67 66 #include <linux/pci.h> 68 67 #include <linux/smp_lock.h> 69 68 #include <linux/version.h> 69 + #include <linux/interrupt.h> 70 70 #include <linux/module.h> 71 + #include <linux/slab.h> 71 72 #include <asm/byteorder.h> 72 73 #include <asm/io.h> 73 74 74 - #include <linux/interrupt.h> /* For tasklet support. */ 75 - #include <linux/config.h> 76 - #include <linux/slab.h> 75 + #include <scsi/scsi.h> 76 + #include <scsi/scsi_cmnd.h> 77 + #include <scsi/scsi_eh.h> 78 + #include <scsi/scsi_device.h> 79 + #include <scsi/scsi_host.h> 80 + #include <scsi/scsi_tcq.h> 77 81 78 82 /* Core SCSI definitions */ 79 83 #define AIC_LIB_PREFIX ahc 80 - #include "scsi.h" 81 - #include <scsi/scsi_host.h> 82 84 83 85 /* Name space conflict with BSD queue macros */ 84 86 #ifdef LIST_HEAD ··· 110 106 /************************* Forward Declarations *******************************/ 111 107 struct ahc_softc; 112 108 typedef struct pci_dev *ahc_dev_softc_t; 113 - typedef Scsi_Cmnd *ahc_io_ctx_t; 109 + typedef struct scsi_cmnd *ahc_io_ctx_t; 114 110 115 111 /******************************* Byte Order ***********************************/ 116 112 #define ahc_htobe16(x) cpu_to_be16(x) ··· 148 144 extern u_int aic7xxx_no_probe; 149 145 extern u_int aic7xxx_allow_memio; 150 146 extern int aic7xxx_detect_complete; 151 - extern Scsi_Host_Template aic7xxx_driver_template; 147 + extern struct scsi_host_template aic7xxx_driver_template; 152 148 153 149 /***************************** Bus Space/DMA **********************************/ 154 150 ··· 178 174 }; 179 175 typedef struct ahc_linux_dma_tag* bus_dma_tag_t; 180 176 181 - struct ahc_linux_dmamap 182 - { 183 - dma_addr_t bus_addr; 184 - }; 185 - typedef struct ahc_linux_dmamap* bus_dmamap_t; 177 + typedef dma_addr_t bus_dmamap_t; 186 178 187 179 typedef int bus_dma_filter_t(void*, dma_addr_t); 188 180 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); ··· 281 281 /***************************** SMP support ************************************/ 282 282 #include <linux/spinlock.h> 283 283 284 - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) || defined(SCSI_HAS_HOST_LOCK)) 285 - #define AHC_SCSI_HAS_HOST_LOCK 1 286 - #else 287 - #define AHC_SCSI_HAS_HOST_LOCK 0 288 - #endif 289 - 290 284 #define AIC7XXX_DRIVER_VERSION "6.2.36" 291 285 292 286 /**************************** Front End Queues ********************************/ ··· 322 328 */ 323 329 TAILQ_HEAD(ahc_busyq, ahc_cmd); 324 330 typedef enum { 325 - AHC_DEV_UNCONFIGURED = 0x01, 326 331 AHC_DEV_FREEZE_TIL_EMPTY = 0x02, /* Freeze queue until active == 0 */ 327 - AHC_DEV_TIMER_ACTIVE = 0x04, /* Our timer is active */ 328 - AHC_DEV_ON_RUN_LIST = 0x08, /* Queued to be run later */ 329 332 AHC_DEV_Q_BASIC = 0x10, /* Allow basic device queuing */ 330 333 AHC_DEV_Q_TAGGED = 0x20, /* Allow full SCSI2 command queueing */ 331 334 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 332 - AHC_DEV_SLAVE_CONFIGURED = 0x80 /* slave_configure() has been called */ 333 335 } ahc_linux_dev_flags; 334 336 335 337 struct ahc_linux_target; 336 338 struct ahc_linux_device { 337 339 TAILQ_ENTRY(ahc_linux_device) links; 338 - struct ahc_busyq busyq; 339 340 340 341 /* 341 342 * The number of transactions currently ··· 371 382 ahc_linux_dev_flags flags; 372 383 373 384 /* 374 - * Per device timer. 375 - */ 376 - struct timer_list timer; 377 - 378 - /* 379 385 * The high limit for the tags variable. 380 386 */ 381 387 u_int maxtags; ··· 403 419 #define AHC_OTAG_THRESH 500 404 420 405 421 int lun; 406 - Scsi_Device *scsi_device; 422 + struct scsi_device *scsi_device; 407 423 struct ahc_linux_target *target; 408 424 }; 409 425 ··· 423 439 * manner and are allocated below 4GB, the number of S/G segments is 424 440 * unrestricted. 425 441 */ 426 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 427 - /* 428 - * We dynamically adjust the number of segments in pre-2.5 kernels to 429 - * avoid fragmentation issues in the SCSI mid-layer's private memory 430 - * allocator. See aic7xxx_osm.c ahc_linux_size_nseg() for details. 431 - */ 432 - extern u_int ahc_linux_nseg; 433 - #define AHC_NSEG ahc_linux_nseg 434 - #define AHC_LINUX_MIN_NSEG 64 435 - #else 436 442 #define AHC_NSEG 128 437 - #endif 438 443 439 444 /* 440 445 * Per-SCB OSM storage. 441 446 */ 442 - typedef enum { 443 - AHC_UP_EH_SEMAPHORE = 0x1 444 - } ahc_linux_scb_flags; 445 - 446 447 struct scb_platform_data { 447 448 struct ahc_linux_device *dev; 448 449 dma_addr_t buf_busaddr; 449 450 uint32_t xfer_len; 450 451 uint32_t sense_resid; /* Auto-Sense residual */ 451 - ahc_linux_scb_flags flags; 452 452 }; 453 453 454 454 /* ··· 441 473 * alignment restrictions of the various platforms supported by 442 474 * this driver. 443 475 */ 444 - typedef enum { 445 - AHC_RUN_CMPLT_Q_TIMER = 0x10 446 - } ahc_linux_softc_flags; 447 - 448 - TAILQ_HEAD(ahc_completeq, ahc_cmd); 449 - 450 476 struct ahc_platform_data { 451 477 /* 452 478 * Fields accessed from interrupt context. 453 479 */ 454 480 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 455 - TAILQ_HEAD(, ahc_linux_device) device_runq; 456 - struct ahc_completeq completeq; 457 481 458 482 spinlock_t spin_lock; 459 - struct tasklet_struct runq_tasklet; 460 483 u_int qfrozen; 461 - pid_t dv_pid; 462 - struct timer_list completeq_timer; 463 484 struct timer_list reset_timer; 464 485 struct semaphore eh_sem; 465 - struct semaphore dv_sem; 466 - struct semaphore dv_cmd_sem; /* XXX This needs to be in 467 - * the target struct 468 - */ 469 - struct scsi_device *dv_scsi_dev; 470 486 struct Scsi_Host *host; /* pointer to scsi host */ 471 487 #define AHC_LINUX_NOIRQ ((uint32_t)~0) 472 488 uint32_t irq; /* IRQ for this adapter */ 473 489 uint32_t bios_address; 474 490 uint32_t mem_busaddr; /* Mem Base Addr */ 475 - uint64_t hw_dma_mask; 476 - ahc_linux_softc_flags flags; 491 + 492 + #define AHC_UP_EH_SEMAPHORE 0x1 493 + uint32_t flags; 477 494 }; 478 495 479 496 /************************** OS Utility Wrappers *******************************/ ··· 547 594 548 595 /**************************** Initialization **********************************/ 549 596 int ahc_linux_register_host(struct ahc_softc *, 550 - Scsi_Host_Template *); 597 + struct scsi_host_template *); 551 598 552 599 uint64_t ahc_linux_get_memsize(void); 553 600 ··· 567 614 static __inline void ahc_lockinit(struct ahc_softc *); 568 615 static __inline void ahc_lock(struct ahc_softc *, unsigned long *flags); 569 616 static __inline void ahc_unlock(struct ahc_softc *, unsigned long *flags); 570 - 571 - /* Lock acquisition and release of the above lock in midlayer entry points. */ 572 - static __inline void ahc_midlayer_entrypoint_lock(struct ahc_softc *, 573 - unsigned long *flags); 574 - static __inline void ahc_midlayer_entrypoint_unlock(struct ahc_softc *, 575 - unsigned long *flags); 576 - 577 - /* Lock held during command compeletion to the upper layer */ 578 - static __inline void ahc_done_lockinit(struct ahc_softc *); 579 - static __inline void ahc_done_lock(struct ahc_softc *, unsigned long *flags); 580 - static __inline void ahc_done_unlock(struct ahc_softc *, unsigned long *flags); 581 617 582 618 /* Lock held during ahc_list manipulation and ahc softc frees */ 583 619 extern spinlock_t ahc_list_spinlock; ··· 590 648 ahc_unlock(struct ahc_softc *ahc, unsigned long *flags) 591 649 { 592 650 spin_unlock_irqrestore(&ahc->platform_data->spin_lock, *flags); 593 - } 594 - 595 - static __inline void 596 - ahc_midlayer_entrypoint_lock(struct ahc_softc *ahc, unsigned long *flags) 597 - { 598 - /* 599 - * In 2.5.X and some 2.4.X versions, the midlayer takes our 600 - * lock just before calling us, so we avoid locking again. 601 - * For other kernel versions, the io_request_lock is taken 602 - * just before our entry point is called. In this case, we 603 - * trade the io_request_lock for our per-softc lock. 604 - */ 605 - #if AHC_SCSI_HAS_HOST_LOCK == 0 606 - spin_unlock(&io_request_lock); 607 - spin_lock(&ahc->platform_data->spin_lock); 608 - #endif 609 - } 610 - 611 - static __inline void 612 - ahc_midlayer_entrypoint_unlock(struct ahc_softc *ahc, unsigned long *flags) 613 - { 614 - #if AHC_SCSI_HAS_HOST_LOCK == 0 615 - spin_unlock(&ahc->platform_data->spin_lock); 616 - spin_lock(&io_request_lock); 617 - #endif 618 - } 619 - 620 - static __inline void 621 - ahc_done_lockinit(struct ahc_softc *ahc) 622 - { 623 - /* 624 - * In 2.5.X, our own lock is held during completions. 625 - * In previous versions, the io_request_lock is used. 626 - * In either case, we can't initialize this lock again. 627 - */ 628 - } 629 - 630 - static __inline void 631 - ahc_done_lock(struct ahc_softc *ahc, unsigned long *flags) 632 - { 633 - #if AHC_SCSI_HAS_HOST_LOCK == 0 634 - spin_lock_irqsave(&io_request_lock, *flags); 635 - #endif 636 - } 637 - 638 - static __inline void 639 - ahc_done_unlock(struct ahc_softc *ahc, unsigned long *flags) 640 - { 641 - #if AHC_SCSI_HAS_HOST_LOCK == 0 642 - spin_unlock_irqrestore(&io_request_lock, *flags); 643 - #endif 644 651 } 645 652 646 653 static __inline void ··· 658 767 } ahc_power_state; 659 768 660 769 /**************************** VL/EISA Routines ********************************/ 661 - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) \ 662 - && (defined(__i386__) || defined(__alpha__)) \ 663 - && (!defined(CONFIG_EISA))) 664 - #define CONFIG_EISA 665 - #endif 666 - 667 770 #ifdef CONFIG_EISA 668 771 extern uint32_t aic7xxx_probe_eisa_vl; 669 772 int ahc_linux_eisa_init(void); ··· 773 888 } 774 889 775 890 /**************************** Proc FS Support *********************************/ 776 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 777 - int ahc_linux_proc_info(char *, char **, off_t, int, int, int); 778 - #else 779 891 int ahc_linux_proc_info(struct Scsi_Host *, char *, char **, 780 892 off_t, int, int); 781 - #endif 782 893 783 894 /*************************** Domain Validation ********************************/ 784 895 /*********************** Transaction Access Wrappers *************************/ 785 - static __inline void ahc_cmd_set_transaction_status(Scsi_Cmnd *, uint32_t); 896 + static __inline void ahc_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t); 786 897 static __inline void ahc_set_transaction_status(struct scb *, uint32_t); 787 - static __inline void ahc_cmd_set_scsi_status(Scsi_Cmnd *, uint32_t); 898 + static __inline void ahc_cmd_set_scsi_status(struct scsi_cmnd *, uint32_t); 788 899 static __inline void ahc_set_scsi_status(struct scb *, uint32_t); 789 - static __inline uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd); 900 + static __inline uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd); 790 901 static __inline uint32_t ahc_get_transaction_status(struct scb *); 791 - static __inline uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd); 902 + static __inline uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd); 792 903 static __inline uint32_t ahc_get_scsi_status(struct scb *); 793 904 static __inline void ahc_set_transaction_tag(struct scb *, int, u_int); 794 905 static __inline u_long ahc_get_transfer_length(struct scb *); ··· 803 922 static __inline void ahc_freeze_scb(struct scb *scb); 804 923 805 924 static __inline 806 - void ahc_cmd_set_transaction_status(Scsi_Cmnd *cmd, uint32_t status) 925 + void ahc_cmd_set_transaction_status(struct scsi_cmnd *cmd, uint32_t status) 807 926 { 808 927 cmd->result &= ~(CAM_STATUS_MASK << 16); 809 928 cmd->result |= status << 16; ··· 816 935 } 817 936 818 937 static __inline 819 - void ahc_cmd_set_scsi_status(Scsi_Cmnd *cmd, uint32_t status) 938 + void ahc_cmd_set_scsi_status(struct scsi_cmnd *cmd, uint32_t status) 820 939 { 821 940 cmd->result &= ~0xFFFF; 822 941 cmd->result |= status; ··· 829 948 } 830 949 831 950 static __inline 832 - uint32_t ahc_cmd_get_transaction_status(Scsi_Cmnd *cmd) 951 + uint32_t ahc_cmd_get_transaction_status(struct scsi_cmnd *cmd) 833 952 { 834 953 return ((cmd->result >> 16) & CAM_STATUS_MASK); 835 954 } ··· 841 960 } 842 961 843 962 static __inline 844 - uint32_t ahc_cmd_get_scsi_status(Scsi_Cmnd *cmd) 963 + uint32_t ahc_cmd_get_scsi_status(struct scsi_cmnd *cmd) 845 964 { 846 965 return (cmd->result & 0xFFFF); 847 966 }
+1 -10
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
··· 221 221 && ahc_linux_get_memsize() > 0x80000000 222 222 && pci_set_dma_mask(pdev, mask_39bit) == 0) { 223 223 ahc->flags |= AHC_39BIT_ADDRESSING; 224 - ahc->platform_data->hw_dma_mask = mask_39bit; 225 224 } else { 226 225 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 227 226 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 228 227 return (-ENODEV); 229 228 } 230 - ahc->platform_data->hw_dma_mask = DMA_32BIT_MASK; 231 229 } 232 230 ahc->dev_softc = pci; 233 231 error = ahc_pci_config(ahc, entry); ··· 234 236 return (-error); 235 237 } 236 238 pci_set_drvdata(pdev, ahc); 237 - if (aic7xxx_detect_complete) { 238 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 239 + if (aic7xxx_detect_complete) 239 240 ahc_linux_register_host(ahc, &aic7xxx_driver_template); 240 - #else 241 - printf("aic7xxx: ignoring PCI device found after " 242 - "initialization\n"); 243 - return (-ENODEV); 244 - #endif 245 - } 246 241 return (0); 247 242 } 248 243
-13
drivers/scsi/aic7xxx/aic7xxx_proc.c
··· 289 289 * Return information to handle /proc support for the driver. 290 290 */ 291 291 int 292 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 293 - ahc_linux_proc_info(char *buffer, char **start, off_t offset, 294 - int length, int hostno, int inout) 295 - #else 296 292 ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 297 293 off_t offset, int length, int inout) 298 - #endif 299 294 { 300 295 struct ahc_softc *ahc; 301 296 struct info_str info; ··· 302 307 303 308 retval = -EINVAL; 304 309 ahc_list_lock(&s); 305 - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 306 - TAILQ_FOREACH(ahc, &ahc_tailq, links) { 307 - if (ahc->platform_data->host->host_no == hostno) 308 - break; 309 - } 310 - #else 311 310 ahc = ahc_find_softc(*(struct ahc_softc **)shost->hostdata); 312 - #endif 313 - 314 311 if (ahc == NULL) 315 312 goto done; 316 313
-1
drivers/scsi/aic7xxx/aiclib.c
··· 35 35 #include <linux/version.h> 36 36 37 37 /* Core SCSI definitions */ 38 - #include "scsi.h" 39 38 #include <scsi/scsi_host.h> 40 39 #include "aiclib.h" 41 40 #include "cam.h"
+161 -27
drivers/scsi/scsi_transport_spi.c
··· 35 35 36 36 #define SPI_PRINTK(x, l, f, a...) dev_printk(l, &(x)->dev, f , ##a) 37 37 38 - #define SPI_NUM_ATTRS 10 /* increase this if you add attributes */ 38 + #define SPI_NUM_ATTRS 13 /* increase this if you add attributes */ 39 39 #define SPI_OTHER_ATTRS 1 /* Increase this if you add "always 40 40 * on" attributes */ 41 41 #define SPI_HOST_ATTRS 1 ··· 219 219 struct scsi_target *starget = to_scsi_target(dev); 220 220 221 221 spi_period(starget) = -1; /* illegal value */ 222 + spi_min_period(starget) = 0; 222 223 spi_offset(starget) = 0; /* async */ 224 + spi_max_offset(starget) = 255; 223 225 spi_width(starget) = 0; /* narrow */ 226 + spi_max_width(starget) = 1; 224 227 spi_iu(starget) = 0; /* no IU */ 225 228 spi_dt(starget) = 0; /* ST */ 226 229 spi_qas(starget) = 0; ··· 236 233 init_MUTEX(&spi_dv_sem(starget)); 237 234 238 235 return 0; 236 + } 237 + 238 + #define spi_transport_show_simple(field, format_string) \ 239 + \ 240 + static ssize_t \ 241 + show_spi_transport_##field(struct class_device *cdev, char *buf) \ 242 + { \ 243 + struct scsi_target *starget = transport_class_to_starget(cdev); \ 244 + struct spi_transport_attrs *tp; \ 245 + \ 246 + tp = (struct spi_transport_attrs *)&starget->starget_data; \ 247 + return snprintf(buf, 20, format_string, tp->field); \ 248 + } 249 + 250 + #define spi_transport_store_simple(field, format_string) \ 251 + \ 252 + static ssize_t \ 253 + store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 254 + size_t count) \ 255 + { \ 256 + int val; \ 257 + struct scsi_target *starget = transport_class_to_starget(cdev); \ 258 + struct spi_transport_attrs *tp; \ 259 + \ 260 + tp = (struct spi_transport_attrs *)&starget->starget_data; \ 261 + val = simple_strtoul(buf, NULL, 0); \ 262 + tp->field = val; \ 263 + return count; \ 239 264 } 240 265 241 266 #define spi_transport_show_function(field, format_string) \ ··· 292 261 struct spi_internal *i = to_spi_internal(shost->transportt); \ 293 262 \ 294 263 val = simple_strtoul(buf, NULL, 0); \ 264 + i->f->set_##field(starget, val); \ 265 + return count; \ 266 + } 267 + 268 + #define spi_transport_store_max(field, format_string) \ 269 + static ssize_t \ 270 + store_spi_transport_##field(struct class_device *cdev, const char *buf, \ 271 + size_t count) \ 272 + { \ 273 + int val; \ 274 + struct scsi_target *starget = transport_class_to_starget(cdev); \ 275 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \ 276 + struct spi_internal *i = to_spi_internal(shost->transportt); \ 277 + struct spi_transport_attrs *tp \ 278 + = (struct spi_transport_attrs *)&starget->starget_data; \ 279 + \ 280 + val = simple_strtoul(buf, NULL, 0); \ 281 + if (val > tp->max_##field) \ 282 + val = tp->max_##field; \ 295 283 i->f->set_##field(starget, val); \ 296 284 return count; \ 297 285 } ··· 322 272 show_spi_transport_##field, \ 323 273 store_spi_transport_##field); 324 274 275 + #define spi_transport_simple_attr(field, format_string) \ 276 + spi_transport_show_simple(field, format_string) \ 277 + spi_transport_store_simple(field, format_string) \ 278 + static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \ 279 + show_spi_transport_##field, \ 280 + store_spi_transport_##field); 281 + 282 + #define spi_transport_max_attr(field, format_string) \ 283 + spi_transport_show_function(field, format_string) \ 284 + spi_transport_store_max(field, format_string) \ 285 + spi_transport_simple_attr(max_##field, format_string) \ 286 + static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \ 287 + show_spi_transport_##field, \ 288 + store_spi_transport_##field); 289 + 325 290 /* The Parallel SCSI Tranport Attributes: */ 326 - spi_transport_rd_attr(offset, "%d\n"); 327 - spi_transport_rd_attr(width, "%d\n"); 291 + spi_transport_max_attr(offset, "%d\n"); 292 + spi_transport_max_attr(width, "%d\n"); 328 293 spi_transport_rd_attr(iu, "%d\n"); 329 294 spi_transport_rd_attr(dt, "%d\n"); 330 295 spi_transport_rd_attr(qas, "%d\n"); ··· 365 300 366 301 /* Translate the period into ns according to the current spec 367 302 * for SDTR/PPR messages */ 368 - static ssize_t show_spi_transport_period(struct class_device *cdev, char *buf) 369 - 303 + static ssize_t 304 + show_spi_transport_period_helper(struct class_device *cdev, char *buf, 305 + int period) 370 306 { 371 - struct scsi_target *starget = transport_class_to_starget(cdev); 372 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 373 - struct spi_transport_attrs *tp; 374 307 int len, picosec; 375 - struct spi_internal *i = to_spi_internal(shost->transportt); 376 308 377 - tp = (struct spi_transport_attrs *)&starget->starget_data; 378 - 379 - if (i->f->get_period) 380 - i->f->get_period(starget); 381 - 382 - if (tp->period < 0 || tp->period > 0xff) { 309 + if (period < 0 || period > 0xff) { 383 310 picosec = -1; 384 - } else if (tp->period <= SPI_STATIC_PPR) { 385 - picosec = ppr_to_ps[tp->period]; 311 + } else if (period <= SPI_STATIC_PPR) { 312 + picosec = ppr_to_ps[period]; 386 313 } else { 387 - picosec = tp->period * 4000; 314 + picosec = period * 4000; 388 315 } 389 316 390 317 if (picosec == -1) { ··· 391 334 } 392 335 393 336 static ssize_t 394 - store_spi_transport_period(struct class_device *cdev, const char *buf, 395 - size_t count) 337 + store_spi_transport_period_helper(struct class_device *cdev, const char *buf, 338 + size_t count, int *periodp) 396 339 { 397 - struct scsi_target *starget = transport_class_to_starget(cdev); 398 - struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 399 - struct spi_internal *i = to_spi_internal(shost->transportt); 400 340 int j, picosec, period = -1; 401 341 char *endp; 402 342 ··· 422 368 if (period > 0xff) 423 369 period = 0xff; 424 370 425 - i->f->set_period(starget, period); 371 + *periodp = period; 426 372 427 373 return count; 374 + } 375 + 376 + static ssize_t 377 + show_spi_transport_period(struct class_device *cdev, char *buf) 378 + { 379 + struct scsi_target *starget = transport_class_to_starget(cdev); 380 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 381 + struct spi_internal *i = to_spi_internal(shost->transportt); 382 + struct spi_transport_attrs *tp = 383 + (struct spi_transport_attrs *)&starget->starget_data; 384 + 385 + if (i->f->get_period) 386 + i->f->get_period(starget); 387 + 388 + return show_spi_transport_period_helper(cdev, buf, tp->period); 389 + } 390 + 391 + static ssize_t 392 + store_spi_transport_period(struct class_device *cdev, const char *buf, 393 + size_t count) 394 + { 395 + struct scsi_target *starget = transport_class_to_starget(cdev); 396 + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 397 + struct spi_internal *i = to_spi_internal(shost->transportt); 398 + struct spi_transport_attrs *tp = 399 + (struct spi_transport_attrs *)&starget->starget_data; 400 + int period, retval; 401 + 402 + retval = store_spi_transport_period_helper(cdev, buf, count, &period); 403 + 404 + if (period < tp->min_period) 405 + period = tp->min_period; 406 + 407 + i->f->set_period(starget, period); 408 + 409 + return retval; 428 410 } 429 411 430 412 static CLASS_DEVICE_ATTR(period, S_IRUGO | S_IWUSR, 431 413 show_spi_transport_period, 432 414 store_spi_transport_period); 415 + 416 + static ssize_t 417 + show_spi_transport_min_period(struct class_device *cdev, char *buf) 418 + { 419 + struct scsi_target *starget = transport_class_to_starget(cdev); 420 + struct spi_transport_attrs *tp = 421 + (struct spi_transport_attrs *)&starget->starget_data; 422 + 423 + return show_spi_transport_period_helper(cdev, buf, tp->min_period); 424 + } 425 + 426 + static ssize_t 427 + store_spi_transport_min_period(struct class_device *cdev, const char *buf, 428 + size_t count) 429 + { 430 + struct scsi_target *starget = transport_class_to_starget(cdev); 431 + struct spi_transport_attrs *tp = 432 + (struct spi_transport_attrs *)&starget->starget_data; 433 + 434 + return store_spi_transport_period_helper(cdev, buf, count, 435 + &tp->min_period); 436 + } 437 + 438 + 439 + static CLASS_DEVICE_ATTR(min_period, S_IRUGO | S_IWUSR, 440 + show_spi_transport_min_period, 441 + store_spi_transport_min_period); 442 + 433 443 434 444 static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf) 435 445 { ··· 760 642 { 761 643 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt); 762 644 struct scsi_device *sdev = sreq->sr_device; 645 + struct scsi_target *starget = sdev->sdev_target; 763 646 int len = sdev->inquiry_len; 764 647 /* first set us up for narrow async */ 765 648 DV_SET(offset, 0); ··· 774 655 } 775 656 776 657 /* test width */ 777 - if (i->f->set_width && sdev->wdtr) { 658 + if (i->f->set_width && spi_max_width(starget) && sdev->wdtr) { 778 659 i->f->set_width(sdev->sdev_target, 1); 660 + 661 + printk("WIDTH IS %d\n", spi_max_width(starget)); 779 662 780 663 if (spi_dv_device_compare_inquiry(sreq, buffer, 781 664 buffer + len, ··· 805 684 retry: 806 685 807 686 /* now set up to the maximum */ 808 - DV_SET(offset, 255); 809 - DV_SET(period, 1); 687 + DV_SET(offset, spi_max_offset(starget)); 688 + DV_SET(period, spi_min_period(starget)); 810 689 811 690 if (len == 0) { 812 691 SPI_PRINTK(sdev->sdev_target, KERN_INFO, "Domain Validation skipping write tests\n"); ··· 1013 892 if (i->f->show_##field) \ 1014 893 count++ 1015 894 895 + #define SETUP_RELATED_ATTRIBUTE(field, rel_field) \ 896 + i->private_attrs[count] = class_device_attr_##field; \ 897 + if (!i->f->set_##rel_field) { \ 898 + i->private_attrs[count].attr.mode = S_IRUGO; \ 899 + i->private_attrs[count].store = NULL; \ 900 + } \ 901 + i->attrs[count] = &i->private_attrs[count]; \ 902 + if (i->f->show_##rel_field) \ 903 + count++ 904 + 1016 905 #define SETUP_HOST_ATTRIBUTE(field) \ 1017 906 i->private_host_attrs[count] = class_device_attr_##field; \ 1018 907 if (!i->f->set_##field) { \ ··· 1106 975 i->f = ft; 1107 976 1108 977 SETUP_ATTRIBUTE(period); 978 + SETUP_RELATED_ATTRIBUTE(min_period, period); 1109 979 SETUP_ATTRIBUTE(offset); 980 + SETUP_RELATED_ATTRIBUTE(max_offset, offset); 1110 981 SETUP_ATTRIBUTE(width); 982 + SETUP_RELATED_ATTRIBUTE(max_width, width); 1111 983 SETUP_ATTRIBUTE(iu); 1112 984 SETUP_ATTRIBUTE(dt); 1113 985 SETUP_ATTRIBUTE(qas);
+13 -6
drivers/serial/8250.c
··· 682 682 * from EXCR1. Switch back to bank 0, change it in MCR. Then 683 683 * switch back to bank 2, read it from EXCR1 again and check 684 684 * it's changed. If so, set baud_base in EXCR2 to 921600. -- dwmw2 685 - * On PowerPC we don't want to change baud_base, as we have 686 - * a number of different divisors. -- Tom Rini 687 685 */ 688 686 serial_outp(up, UART_LCR, 0); 689 687 status1 = serial_in(up, UART_MCR); ··· 697 699 serial_outp(up, UART_MCR, status1); 698 700 699 701 if ((status2 ^ status1) & UART_MCR_LOOP) { 700 - #ifndef CONFIG_PPC 702 + unsigned short quot; 703 + 701 704 serial_outp(up, UART_LCR, 0xE0); 705 + 706 + quot = serial_inp(up, UART_DLM) << 8; 707 + quot += serial_inp(up, UART_DLL); 708 + quot <<= 3; 709 + 702 710 status1 = serial_in(up, 0x04); /* EXCR1 */ 703 711 status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */ 704 712 status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */ 705 713 serial_outp(up, 0x04, status1); 706 - serial_outp(up, UART_LCR, 0); 707 - up->port.uartclk = 921600*16; 708 - #endif 714 + 715 + serial_outp(up, UART_DLL, quot & 0xff); 716 + serial_outp(up, UART_DLM, quot >> 8); 709 717 718 + serial_outp(up, UART_LCR, 0); 719 + 720 + up->port.uartclk = 921600*16; 710 721 up->port.type = PORT_NS16550A; 711 722 up->capabilities |= UART_NATSEMI; 712 723 return;
+71 -38
drivers/serial/sunsab.c
··· 61 61 unsigned char pvr_dtr_bit; /* Which PVR bit is DTR */ 62 62 unsigned char pvr_dsr_bit; /* Which PVR bit is DSR */ 63 63 int type; /* SAB82532 version */ 64 + 65 + /* Setting configuration bits while the transmitter is active 66 + * can cause garbage characters to get emitted by the chip. 67 + * Therefore, we cache such writes here and do the real register 68 + * write the next time the transmitter becomes idle. 69 + */ 70 + unsigned int cached_ebrg; 71 + unsigned char cached_mode; 72 + unsigned char cached_pvr; 73 + unsigned char cached_dafo; 64 74 }; 65 75 66 76 /* ··· 246 236 } 247 237 248 238 static void sunsab_stop_tx(struct uart_port *, unsigned int); 239 + static void sunsab_tx_idle(struct uart_sunsab_port *); 249 240 250 241 static void transmit_chars(struct uart_sunsab_port *up, 251 242 union sab82532_irq_status *stat) ··· 269 258 return; 270 259 271 260 set_bit(SAB82532_XPR, &up->irqflags); 261 + sunsab_tx_idle(up); 272 262 273 263 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) { 274 264 up->interrupt_mask1 |= SAB82532_IMR1_XPR; ··· 409 397 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 410 398 411 399 if (mctrl & TIOCM_RTS) { 412 - writeb(readb(&up->regs->rw.mode) & ~SAB82532_MODE_FRTS, 413 - &up->regs->rw.mode); 414 - writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS, 415 - &up->regs->rw.mode); 400 + up->cached_mode &= ~SAB82532_MODE_FRTS; 401 + up->cached_mode |= SAB82532_MODE_RTS; 416 402 } else { 417 - writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_FRTS, 418 - &up->regs->rw.mode); 419 - writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS, 420 - &up->regs->rw.mode); 403 + up->cached_mode |= (SAB82532_MODE_FRTS | 404 + SAB82532_MODE_RTS); 421 405 } 422 406 if (mctrl & TIOCM_DTR) { 423 - writeb(readb(&up->regs->rw.pvr) & ~(up->pvr_dtr_bit), &up->regs->rw.pvr); 407 + up->cached_pvr &= ~(up->pvr_dtr_bit); 424 408 } else { 425 - writeb(readb(&up->regs->rw.pvr) | up->pvr_dtr_bit, &up->regs->rw.pvr); 409 + up->cached_pvr |= up->pvr_dtr_bit; 426 410 } 411 + 412 + set_bit(SAB82532_REGS_PENDING, &up->irqflags); 413 + if (test_bit(SAB82532_XPR, &up->irqflags)) 414 + sunsab_tx_idle(up); 427 415 } 428 416 429 417 /* port->lock is not held. */ ··· 459 447 460 448 up->interrupt_mask1 |= SAB82532_IMR1_XPR; 461 449 writeb(up->interrupt_mask1, &up->regs->w.imr1); 450 + } 451 + 452 + /* port->lock held by caller. */ 453 + static void sunsab_tx_idle(struct uart_sunsab_port *up) 454 + { 455 + if (test_bit(SAB82532_REGS_PENDING, &up->irqflags)) { 456 + u8 tmp; 457 + 458 + clear_bit(SAB82532_REGS_PENDING, &up->irqflags); 459 + writeb(up->cached_mode, &up->regs->rw.mode); 460 + writeb(up->cached_pvr, &up->regs->rw.pvr); 461 + writeb(up->cached_dafo, &up->regs->w.dafo); 462 + 463 + writeb(up->cached_ebrg & 0xff, &up->regs->w.bgr); 464 + tmp = readb(&up->regs->rw.ccr2); 465 + tmp &= ~0xc0; 466 + tmp |= (up->cached_ebrg >> 2) & 0xc0; 467 + writeb(tmp, &up->regs->rw.ccr2); 468 + } 462 469 } 463 470 464 471 /* port->lock held by caller. */ ··· 548 517 549 518 spin_lock_irqsave(&up->port.lock, flags); 550 519 551 - val = readb(&up->regs->rw.dafo); 520 + val = up->cached_dafo; 552 521 if (break_state) 553 522 val |= SAB82532_DAFO_XBRK; 554 523 else 555 524 val &= ~SAB82532_DAFO_XBRK; 556 - writeb(val, &up->regs->rw.dafo); 525 + up->cached_dafo = val; 526 + 527 + set_bit(SAB82532_REGS_PENDING, &up->irqflags); 528 + if (test_bit(SAB82532_XPR, &up->irqflags)) 529 + sunsab_tx_idle(up); 557 530 558 531 spin_unlock_irqrestore(&up->port.lock, flags); 559 532 } ··· 601 566 SAB82532_CCR2_TOE, &up->regs->w.ccr2); 602 567 writeb(0, &up->regs->w.ccr3); 603 568 writeb(SAB82532_CCR4_MCK4 | SAB82532_CCR4_EBRG, &up->regs->w.ccr4); 604 - writeb(SAB82532_MODE_RTS | SAB82532_MODE_FCTS | 605 - SAB82532_MODE_RAC, &up->regs->w.mode); 569 + up->cached_mode = (SAB82532_MODE_RTS | SAB82532_MODE_FCTS | 570 + SAB82532_MODE_RAC); 571 + writeb(up->cached_mode, &up->regs->w.mode); 606 572 writeb(SAB82532_RFC_DPS|SAB82532_RFC_RFTH_32, &up->regs->w.rfc); 607 573 608 574 tmp = readb(&up->regs->rw.ccr0); ··· 634 598 { 635 599 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 636 600 unsigned long flags; 637 - unsigned char tmp; 638 601 639 602 spin_lock_irqsave(&up->port.lock, flags); 640 603 ··· 644 609 writeb(up->interrupt_mask1, &up->regs->w.imr1); 645 610 646 611 /* Disable break condition */ 647 - tmp = readb(&up->regs->rw.dafo); 648 - tmp &= ~SAB82532_DAFO_XBRK; 649 - writeb(tmp, &up->regs->rw.dafo); 612 + up->cached_dafo = readb(&up->regs->rw.dafo); 613 + up->cached_dafo &= ~SAB82532_DAFO_XBRK; 614 + writeb(up->cached_dafo, &up->regs->rw.dafo); 650 615 651 616 /* Disable Receiver */ 652 - tmp = readb(&up->regs->rw.mode); 653 - tmp &= ~SAB82532_MODE_RAC; 654 - writeb(tmp, &up->regs->rw.mode); 617 + up->cached_mode &= ~SAB82532_MODE_RAC; 618 + writeb(up->cached_mode, &up->regs->rw.mode); 655 619 656 620 /* 657 621 * XXX FIXME ··· 719 685 unsigned int iflag, unsigned int baud, 720 686 unsigned int quot) 721 687 { 722 - unsigned int ebrg; 723 688 unsigned char dafo; 724 689 int bits, n, m; 725 690 ··· 747 714 } else { 748 715 dafo |= SAB82532_DAFO_PAR_EVEN; 749 716 } 717 + up->cached_dafo = dafo; 750 718 751 719 calc_ebrg(baud, &n, &m); 752 720 753 - ebrg = n | (m << 6); 721 + up->cached_ebrg = n | (m << 6); 754 722 755 723 up->tec_timeout = (10 * 1000000) / baud; 756 724 up->cec_timeout = up->tec_timeout >> 2; ··· 804 770 uart_update_timeout(&up->port, cflag, 805 771 (up->port.uartclk / (16 * quot))); 806 772 807 - /* Now bang the new settings into the chip. */ 808 - sunsab_cec_wait(up); 809 - sunsab_tec_wait(up); 810 - writeb(dafo, &up->regs->w.dafo); 811 - writeb(ebrg & 0xff, &up->regs->w.bgr); 812 - writeb((readb(&up->regs->rw.ccr2) & ~0xc0) | ((ebrg >> 2) & 0xc0), 813 - &up->regs->rw.ccr2); 814 - 815 - writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RAC, &up->regs->rw.mode); 816 - 773 + /* Now schedule a register update when the chip's 774 + * transmitter is idle. 775 + */ 776 + up->cached_mode |= SAB82532_MODE_RAC; 777 + set_bit(SAB82532_REGS_PENDING, &up->irqflags); 778 + if (test_bit(SAB82532_XPR, &up->irqflags)) 779 + sunsab_tx_idle(up); 817 780 } 818 781 819 782 /* port->lock is not held. */ ··· 1115 1084 up->pvr_dsr_bit = (1 << 3); 1116 1085 up->pvr_dtr_bit = (1 << 2); 1117 1086 } 1118 - writeb((1 << 1) | (1 << 2) | (1 << 4), &up->regs->w.pvr); 1119 - writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_FRTS, 1120 - &up->regs->rw.mode); 1121 - writeb(readb(&up->regs->rw.mode) | SAB82532_MODE_RTS, 1122 - &up->regs->rw.mode); 1087 + up->cached_pvr = (1 << 1) | (1 << 2) | (1 << 4); 1088 + writeb(up->cached_pvr, &up->regs->w.pvr); 1089 + up->cached_mode = readb(&up->regs->rw.mode); 1090 + up->cached_mode |= SAB82532_MODE_FRTS; 1091 + writeb(up->cached_mode, &up->regs->rw.mode); 1092 + up->cached_mode |= SAB82532_MODE_RTS; 1093 + writeb(up->cached_mode, &up->regs->rw.mode); 1123 1094 1124 1095 up->tec_timeout = SAB82532_MAX_TEC_TIMEOUT; 1125 1096 up->cec_timeout = SAB82532_MAX_CEC_TIMEOUT;
+1
drivers/serial/sunsab.h
··· 126 126 /* irqflags bits */ 127 127 #define SAB82532_ALLS 0x00000001 128 128 #define SAB82532_XPR 0x00000002 129 + #define SAB82532_REGS_PENDING 0x00000004 129 130 130 131 /* RFIFO Status Byte */ 131 132 #define SAB82532_RSTAT_PE 0x80
+1
fs/namei.c
··· 1580 1580 fail: 1581 1581 return dentry; 1582 1582 } 1583 + EXPORT_SYMBOL_GPL(lookup_create); 1583 1584 1584 1585 int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) 1585 1586 {
-1
fs/reiserfs/stree.c
··· 230 230 __constant_cpu_to_le32(0xffffffff)},} 231 231 }; 232 232 233 - const struct in_core_key MAX_IN_CORE_KEY = {~0U, ~0U, ~0ULL>>4, 15}; 234 233 235 234 /* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom 236 235 of the path, and going upwards. We must check the path's validity at each step. If the key is not in
+3 -1
fs/reiserfs/super.c
··· 164 164 165 165 /* compose key to look for "save" links */ 166 166 max_cpu_key.version = KEY_FORMAT_3_5; 167 - max_cpu_key.on_disk_key = MAX_IN_CORE_KEY; 167 + max_cpu_key.on_disk_key.k_dir_id = ~0U; 168 + max_cpu_key.on_disk_key.k_objectid = ~0U; 169 + set_cpu_key_k_offset (&max_cpu_key, ~0U); 168 170 max_cpu_key.key_length = 3; 169 171 170 172 #ifdef CONFIG_QUOTA
include/asm-ia64/ioctl32.h
include/asm-um/arch-signal-i386.h
+1 -1
include/asm-um/elf-i386.h
··· 5 5 #ifndef __UM_ELF_I386_H 6 6 #define __UM_ELF_I386_H 7 7 8 - #include "user.h" 8 + #include <asm/user.h> 9 9 10 10 #define R_386_NONE 0 11 11 #define R_386_32 1
+23 -1
include/asm-um/elf-x86_64.h
··· 8 8 9 9 #include <asm/user.h> 10 10 11 + /* x86-64 relocation types, taken from asm-x86_64/elf.h */ 12 + #define R_X86_64_NONE 0 /* No reloc */ 13 + #define R_X86_64_64 1 /* Direct 64 bit */ 14 + #define R_X86_64_PC32 2 /* PC relative 32 bit signed */ 15 + #define R_X86_64_GOT32 3 /* 32 bit GOT entry */ 16 + #define R_X86_64_PLT32 4 /* 32 bit PLT address */ 17 + #define R_X86_64_COPY 5 /* Copy symbol at runtime */ 18 + #define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ 19 + #define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ 20 + #define R_X86_64_RELATIVE 8 /* Adjust by program base */ 21 + #define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative 22 + offset to GOT */ 23 + #define R_X86_64_32 10 /* Direct 32 bit zero extended */ 24 + #define R_X86_64_32S 11 /* Direct 32 bit sign extended */ 25 + #define R_X86_64_16 12 /* Direct 16 bit zero extended */ 26 + #define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ 27 + #define R_X86_64_8 14 /* Direct 8 bit sign extended */ 28 + #define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ 29 + 30 + #define R_X86_64_NUM 16 31 + 11 32 typedef unsigned long elf_greg_t; 12 33 13 34 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) ··· 65 44 } while (0) 66 45 67 46 #ifdef TIF_IA32 /* XXX */ 68 - clear_thread_flag(TIF_IA32); \ 47 + #error XXX, indeed 48 + clear_thread_flag(TIF_IA32); 69 49 #endif 70 50 71 51 #define USE_ELF_CORE_DUMP
include/asm-x86_64/ioctl32.h
+3 -1
include/linux/err.h
··· 13 13 * This should be a per-architecture thing, to allow different 14 14 * error and pointer decisions. 15 15 */ 16 + #define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L) 17 + 16 18 static inline void *ERR_PTR(long error) 17 19 { 18 20 return (void *) error; ··· 27 25 28 26 static inline long IS_ERR(const void *ptr) 29 27 { 30 - return unlikely((unsigned long)ptr > (unsigned long)-1000L); 28 + return IS_ERR_VALUE((unsigned long)ptr); 31 29 } 32 30 33 31 #endif /* _LINUX_ERR_H */
+27
include/linux/mmc/protocol.h
··· 195 195 #define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */ 196 196 #define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */ 197 197 198 + /* 199 + * Card Command Classes (CCC) 200 + */ 201 + #define CCC_BASIC (1<<0) /* (0) Basic protocol functions */ 202 + /* (CMD0,1,2,3,4,7,9,10,12,13,15) */ 203 + #define CCC_STREAM_READ (1<<1) /* (1) Stream read commands */ 204 + /* (CMD11) */ 205 + #define CCC_BLOCK_READ (1<<2) /* (2) Block read commands */ 206 + /* (CMD16,17,18) */ 207 + #define CCC_STREAM_WRITE (1<<3) /* (3) Stream write commands */ 208 + /* (CMD20) */ 209 + #define CCC_BLOCK_WRITE (1<<4) /* (4) Block write commands */ 210 + /* (CMD16,24,25,26,27) */ 211 + #define CCC_ERASE (1<<5) /* (5) Ability to erase blocks */ 212 + /* (CMD32,33,34,35,36,37,38,39) */ 213 + #define CCC_WRITE_PROT (1<<6) /* (6) Able to write protect blocks */ 214 + /* (CMD28,29,30) */ 215 + #define CCC_LOCK_CARD (1<<7) /* (7) Able to lock down card */ 216 + /* (CMD16,CMD42) */ 217 + #define CCC_APP_SPEC (1<<8) /* (8) Application specific */ 218 + /* (CMD55,56,57,ACMD*) */ 219 + #define CCC_IO_MODE (1<<9) /* (9) I/O mode */ 220 + /* (CMD5,39,40,52,53) */ 221 + #define CCC_SWITCH (1<<10) /* (10) High speed switch */ 222 + /* (CMD6,34,35,36,37,50) */ 223 + /* (11) Reserved */ 224 + /* (CMD?) */ 198 225 199 226 /* 200 227 * CSD field definitions
+4 -4
include/linux/spinlock.h
··· 248 248 249 249 #define _spin_trylock_bh(lock) ({preempt_disable(); local_bh_disable(); \ 250 250 _raw_spin_trylock(lock) ? \ 251 - 1 : ({preempt_enable(); local_bh_enable(); 0;});}) 251 + 1 : ({preempt_enable_no_resched(); local_bh_enable(); 0;});}) 252 252 253 253 #define _spin_lock(lock) \ 254 254 do { \ ··· 383 383 #define _spin_unlock_bh(lock) \ 384 384 do { \ 385 385 _raw_spin_unlock(lock); \ 386 - preempt_enable(); \ 386 + preempt_enable_no_resched(); \ 387 387 local_bh_enable(); \ 388 388 __release(lock); \ 389 389 } while (0) ··· 391 391 #define _write_unlock_bh(lock) \ 392 392 do { \ 393 393 _raw_write_unlock(lock); \ 394 - preempt_enable(); \ 394 + preempt_enable_no_resched(); \ 395 395 local_bh_enable(); \ 396 396 __release(lock); \ 397 397 } while (0) ··· 423 423 #define _read_unlock_bh(lock) \ 424 424 do { \ 425 425 _raw_read_unlock(lock); \ 426 + preempt_enable_no_resched(); \ 426 427 local_bh_enable(); \ 427 - preempt_enable(); \ 428 428 __release(lock); \ 429 429 } while (0) 430 430
+1
include/linux/vmalloc.h
··· 41 41 extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags, 42 42 unsigned long start, unsigned long end); 43 43 extern struct vm_struct *remove_vm_area(void *addr); 44 + extern struct vm_struct *__remove_vm_area(void *addr); 44 45 extern int map_vm_area(struct vm_struct *area, pgprot_t prot, 45 46 struct page ***pages); 46 47 extern void unmap_vm_area(struct vm_struct *area);
+2 -2
include/net/act_generic.h
··· 2 2 * include/net/act_generic.h 3 3 * 4 4 */ 5 - #ifndef ACT_GENERIC_H 6 - #define ACT_GENERIC_H 5 + #ifndef _NET_ACT_GENERIC_H 6 + #define _NET_ACT_GENERIC_H 7 7 static inline int tcf_defact_release(struct tcf_defact *p, int bind) 8 8 { 9 9 int ret = 0;
+6
include/scsi/scsi_transport_spi.h
··· 27 27 28 28 struct spi_transport_attrs { 29 29 int period; /* value in the PPR/SDTR command */ 30 + int min_period; 30 31 int offset; 32 + int max_offset; 31 33 unsigned int width:1; /* 0 - narrow, 1 - wide */ 34 + unsigned int max_width:1; 32 35 unsigned int iu:1; /* Information Units enabled */ 33 36 unsigned int dt:1; /* DT clocking enabled */ 34 37 unsigned int qas:1; /* Quick Arbitration and Selection enabled */ ··· 66 63 67 64 /* accessor functions */ 68 65 #define spi_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->period) 66 + #define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period) 69 67 #define spi_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->offset) 68 + #define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset) 70 69 #define spi_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->width) 70 + #define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width) 71 71 #define spi_iu(x) (((struct spi_transport_attrs *)&(x)->starget_data)->iu) 72 72 #define spi_dt(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dt) 73 73 #define spi_qas(x) (((struct spi_transport_attrs *)&(x)->starget_data)->qas)
+1 -1
kernel/sched.c
··· 4243 4243 4244 4244 /* No more Mr. Nice Guy. */ 4245 4245 if (dest_cpu == NR_CPUS) { 4246 - tsk->cpus_allowed = cpuset_cpus_allowed(tsk); 4246 + cpus_setall(tsk->cpus_allowed); 4247 4247 dest_cpu = any_online_cpu(tsk->cpus_allowed); 4248 4248 4249 4249 /*
+4 -4
kernel/spinlock.c
··· 294 294 void __lockfunc _spin_unlock_bh(spinlock_t *lock) 295 295 { 296 296 _raw_spin_unlock(lock); 297 - preempt_enable(); 297 + preempt_enable_no_resched(); 298 298 local_bh_enable(); 299 299 } 300 300 EXPORT_SYMBOL(_spin_unlock_bh); ··· 318 318 void __lockfunc _read_unlock_bh(rwlock_t *lock) 319 319 { 320 320 _raw_read_unlock(lock); 321 - preempt_enable(); 321 + preempt_enable_no_resched(); 322 322 local_bh_enable(); 323 323 } 324 324 EXPORT_SYMBOL(_read_unlock_bh); ··· 342 342 void __lockfunc _write_unlock_bh(rwlock_t *lock) 343 343 { 344 344 _raw_write_unlock(lock); 345 - preempt_enable(); 345 + preempt_enable_no_resched(); 346 346 local_bh_enable(); 347 347 } 348 348 EXPORT_SYMBOL(_write_unlock_bh); ··· 354 354 if (_raw_spin_trylock(lock)) 355 355 return 1; 356 356 357 - preempt_enable(); 357 + preempt_enable_no_resched(); 358 358 local_bh_enable(); 359 359 return 0; 360 360 }
+1 -1
mm/filemap.c
··· 1004 1004 if (pos < size) { 1005 1005 retval = generic_file_direct_IO(READ, iocb, 1006 1006 iov, pos, nr_segs); 1007 - if (retval >= 0 && !is_sync_kiocb(iocb)) 1007 + if (retval > 0 && !is_sync_kiocb(iocb)) 1008 1008 retval = -EIOCBQUEUED; 1009 1009 if (retval > 0) 1010 1010 *ppos = pos + retval;
+31 -28
mm/mmap.c
··· 1302 1302 get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, 1303 1303 unsigned long pgoff, unsigned long flags) 1304 1304 { 1305 - if (flags & MAP_FIXED) { 1306 - unsigned long ret; 1305 + unsigned long ret; 1307 1306 1308 - if (addr > TASK_SIZE - len) 1309 - return -ENOMEM; 1310 - if (addr & ~PAGE_MASK) 1311 - return -EINVAL; 1312 - if (file && is_file_hugepages(file)) { 1313 - /* 1314 - * Check if the given range is hugepage aligned, and 1315 - * can be made suitable for hugepages. 1316 - */ 1317 - ret = prepare_hugepage_range(addr, len); 1318 - } else { 1319 - /* 1320 - * Ensure that a normal request is not falling in a 1321 - * reserved hugepage range. For some archs like IA-64, 1322 - * there is a separate region for hugepages. 1323 - */ 1324 - ret = is_hugepage_only_range(current->mm, addr, len); 1325 - } 1326 - if (ret) 1327 - return -EINVAL; 1328 - return addr; 1307 + if (!(flags & MAP_FIXED)) { 1308 + unsigned long (*get_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1309 + 1310 + get_area = current->mm->get_unmapped_area; 1311 + if (file && file->f_op && file->f_op->get_unmapped_area) 1312 + get_area = file->f_op->get_unmapped_area; 1313 + addr = get_area(file, addr, len, pgoff, flags); 1314 + if (IS_ERR_VALUE(addr)) 1315 + return addr; 1329 1316 } 1330 1317 1331 - if (file && file->f_op && file->f_op->get_unmapped_area) 1332 - return file->f_op->get_unmapped_area(file, addr, len, 1333 - pgoff, flags); 1334 - 1335 - return current->mm->get_unmapped_area(file, addr, len, pgoff, flags); 1318 + if (addr > TASK_SIZE - len) 1319 + return -ENOMEM; 1320 + if (addr & ~PAGE_MASK) 1321 + return -EINVAL; 1322 + if (file && is_file_hugepages(file)) { 1323 + /* 1324 + * Check if the given range is hugepage aligned, and 1325 + * can be made suitable for hugepages. 1326 + */ 1327 + ret = prepare_hugepage_range(addr, len); 1328 + } else { 1329 + /* 1330 + * Ensure that a normal request is not falling in a 1331 + * reserved hugepage range. For some archs like IA-64, 1332 + * there is a separate region for hugepages. 1333 + */ 1334 + ret = is_hugepage_only_range(current->mm, addr, len); 1335 + } 1336 + if (ret) 1337 + return -EINVAL; 1338 + return addr; 1336 1339 } 1337 1340 1338 1341 EXPORT_SYMBOL(get_unmapped_area);
+26 -19
mm/vmalloc.c
··· 248 248 return __get_vm_area(size, flags, VMALLOC_START, VMALLOC_END); 249 249 } 250 250 251 + /* Caller must hold vmlist_lock */ 252 + struct vm_struct *__remove_vm_area(void *addr) 253 + { 254 + struct vm_struct **p, *tmp; 255 + 256 + for (p = &vmlist ; (tmp = *p) != NULL ;p = &tmp->next) { 257 + if (tmp->addr == addr) 258 + goto found; 259 + } 260 + return NULL; 261 + 262 + found: 263 + unmap_vm_area(tmp); 264 + *p = tmp->next; 265 + 266 + /* 267 + * Remove the guard page. 268 + */ 269 + tmp->size -= PAGE_SIZE; 270 + return tmp; 271 + } 272 + 251 273 /** 252 274 * remove_vm_area - find and remove a contingous kernel virtual area 253 275 * ··· 277 255 * 278 256 * Search for the kernel VM area starting at @addr, and remove it. 279 257 * This function returns the found VM area, but using it is NOT safe 280 - * on SMP machines. 258 + * on SMP machines, except for its size or flags. 281 259 */ 282 260 struct vm_struct *remove_vm_area(void *addr) 283 261 { 284 - struct vm_struct **p, *tmp; 285 - 262 + struct vm_struct *v; 286 263 write_lock(&vmlist_lock); 287 - for (p = &vmlist ; (tmp = *p) != NULL ;p = &tmp->next) { 288 - if (tmp->addr == addr) 289 - goto found; 290 - } 264 + v = __remove_vm_area(addr); 291 265 write_unlock(&vmlist_lock); 292 - return NULL; 293 - 294 - found: 295 - unmap_vm_area(tmp); 296 - *p = tmp->next; 297 - write_unlock(&vmlist_lock); 298 - 299 - /* 300 - * Remove the guard page. 301 - */ 302 - tmp->size -= PAGE_SIZE; 303 - return tmp; 266 + return v; 304 267 } 305 268 306 269 void __vunmap(void *addr, int deallocate_pages)
+8
net/ipv4/ip_output.c
··· 490 490 /* Partially cloned skb? */ 491 491 if (skb_shared(frag)) 492 492 goto slow_path; 493 + 494 + BUG_ON(frag->sk); 495 + if (skb->sk) { 496 + sock_hold(skb->sk); 497 + frag->sk = skb->sk; 498 + frag->destructor = sock_wfree; 499 + skb->truesize -= frag->truesize; 500 + } 493 501 } 494 502 495 503 /* Everything is OK. Generate! */
-1
net/ipv4/ipvs/ip_vs_xmit.c
··· 508 508 rc = NF_ACCEPT; 509 509 /* do not touch skb anymore */ 510 510 atomic_inc(&cp->in_pkts); 511 - __ip_vs_conn_put(cp); 512 511 goto out; 513 512 } 514 513
+8 -20
net/ipv4/netfilter/ip_conntrack_core.c
··· 940 940 struct sk_buff * 941 941 ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user) 942 942 { 943 - struct sock *sk = skb->sk; 944 943 #ifdef CONFIG_NETFILTER_DEBUG 945 944 unsigned int olddebug = skb->nf_debug; 946 945 #endif 947 946 948 - if (sk) { 949 - sock_hold(sk); 950 - skb_orphan(skb); 951 - } 947 + skb_orphan(skb); 952 948 953 949 local_bh_disable(); 954 950 skb = ip_defrag(skb, user); 955 951 local_bh_enable(); 956 952 957 - if (!skb) { 958 - if (sk) 959 - sock_put(sk); 960 - return skb; 961 - } 962 - 963 - if (sk) { 964 - skb_set_owner_w(skb, sk); 965 - sock_put(sk); 966 - } 967 - 968 - ip_send_check(skb->nh.iph); 969 - skb->nfcache |= NFC_ALTERED; 953 + if (skb) { 954 + ip_send_check(skb->nh.iph); 955 + skb->nfcache |= NFC_ALTERED; 970 956 #ifdef CONFIG_NETFILTER_DEBUG 971 - /* Packet path as if nothing had happened. */ 972 - skb->nf_debug = olddebug; 957 + /* Packet path as if nothing had happened. */ 958 + skb->nf_debug = olddebug; 973 959 #endif 960 + } 961 + 974 962 return skb; 975 963 } 976 964
+8 -6
net/ipv6/ip6_output.c
··· 552 552 skb_headroom(frag) < hlen) 553 553 goto slow_path; 554 554 555 - /* Correct socket ownership. */ 556 - if (frag->sk == NULL) 557 - goto slow_path; 558 - 559 555 /* Partially cloned skb? */ 560 556 if (skb_shared(frag)) 561 557 goto slow_path; 558 + 559 + BUG_ON(frag->sk); 560 + if (skb->sk) { 561 + sock_hold(skb->sk); 562 + frag->sk = skb->sk; 563 + frag->destructor = sock_wfree; 564 + skb->truesize -= frag->truesize; 565 + } 562 566 } 563 567 564 568 err = 0; ··· 1120 1116 tail_skb = &(tmp_skb->next); 1121 1117 skb->len += tmp_skb->len; 1122 1118 skb->data_len += tmp_skb->len; 1123 - #if 0 /* Logically correct, but useless work, ip_fragment() will have to undo */ 1124 1119 skb->truesize += tmp_skb->truesize; 1125 1120 __sock_put(tmp_skb->sk); 1126 1121 tmp_skb->destructor = NULL; 1127 1122 tmp_skb->sk = NULL; 1128 - #endif 1129 1123 } 1130 1124 1131 1125 ipv6_addr_copy(final_dst, &fl->fl6_dst);
+9 -4
net/netlink/af_netlink.c
··· 735 735 736 736 sock_hold(sk); 737 737 if (p->skb2 == NULL) { 738 - if (atomic_read(&p->skb->users) != 1) { 738 + if (skb_shared(p->skb)) { 739 739 p->skb2 = skb_clone(p->skb, p->allocation); 740 740 } else { 741 - p->skb2 = p->skb; 742 - atomic_inc(&p->skb->users); 741 + p->skb2 = skb_get(p->skb); 742 + /* 743 + * skb ownership may have been set when 744 + * delivered to a previous socket. 745 + */ 746 + skb_orphan(p->skb2); 743 747 } 744 748 } 745 749 if (p->skb2 == NULL) { ··· 789 785 sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list) 790 786 do_one_broadcast(sk, &info); 791 787 788 + kfree_skb(skb); 789 + 792 790 netlink_unlock_table(); 793 791 794 792 if (info.skb2) 795 793 kfree_skb(info.skb2); 796 - kfree_skb(skb); 797 794 798 795 if (info.delivered) { 799 796 if (info.congested && (allocation & __GFP_WAIT))
+3 -25
net/unix/af_unix.c
··· 770 770 err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd); 771 771 if (err) 772 772 goto out_mknod_parent; 773 - /* 774 - * Yucky last component or no last component at all? 775 - * (foo/., foo/.., /////) 776 - */ 777 - err = -EEXIST; 778 - if (nd.last_type != LAST_NORM) 779 - goto out_mknod; 780 - /* 781 - * Lock the directory. 782 - */ 783 - down(&nd.dentry->d_inode->i_sem); 784 - /* 785 - * Do the final lookup. 786 - */ 787 - dentry = lookup_hash(&nd.last, nd.dentry); 773 + 774 + dentry = lookup_create(&nd, 0); 788 775 err = PTR_ERR(dentry); 789 776 if (IS_ERR(dentry)) 790 777 goto out_mknod_unlock; 791 - err = -ENOENT; 792 - /* 793 - * Special case - lookup gave negative, but... we had foo/bar/ 794 - * From the vfs_mknod() POV we just have a negative dentry - 795 - * all is fine. Let's be bastards - you had / on the end, you've 796 - * been asking for (non-existent) directory. -ENOENT for you. 797 - */ 798 - if (nd.last.name[nd.last.len] && !dentry->d_inode) 799 - goto out_mknod_dput; 778 + 800 779 /* 801 780 * All right, let's create it. 802 781 */ ··· 824 845 dput(dentry); 825 846 out_mknod_unlock: 826 847 up(&nd.dentry->d_inode->i_sem); 827 - out_mknod: 828 848 path_release(&nd); 829 849 out_mknod_parent: 830 850 if (err==-EEXIST)
+1 -1
net/xfrm/xfrm_algo.c
··· 698 698 return -ENOMEM; 699 699 700 700 if (skb1->sk) 701 - skb_set_owner_w(skb, skb1->sk); 701 + skb_set_owner_w(skb2, skb1->sk); 702 702 703 703 /* Looking around. Are we still alive? 704 704 * OK, link new skb, drop old one */
+12 -3
net/xfrm/xfrm_user.c
··· 34 34 { 35 35 struct rtattr *rt = xfrma[type - 1]; 36 36 struct xfrm_algo *algp; 37 + int len; 37 38 38 39 if (!rt) 39 40 return 0; 40 41 41 - if ((rt->rta_len - sizeof(*rt)) < sizeof(*algp)) 42 + len = (rt->rta_len - sizeof(*rt)) - sizeof(*algp); 43 + if (len < 0) 42 44 return -EINVAL; 43 45 44 46 algp = RTA_DATA(rt); 47 + 48 + len -= (algp->alg_key_len + 7U) / 8; 49 + if (len < 0) 50 + return -EINVAL; 51 + 45 52 switch (type) { 46 53 case XFRMA_ALG_AUTH: 47 54 if (!algp->alg_key_len && ··· 169 162 struct rtattr *rta = u_arg; 170 163 struct xfrm_algo *p, *ualg; 171 164 struct xfrm_algo_desc *algo; 165 + int len; 172 166 173 167 if (!rta) 174 168 return 0; ··· 181 173 return -ENOSYS; 182 174 *props = algo->desc.sadb_alg_id; 183 175 184 - p = kmalloc(sizeof(*ualg) + ualg->alg_key_len, GFP_KERNEL); 176 + len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8; 177 + p = kmalloc(len, GFP_KERNEL); 185 178 if (!p) 186 179 return -ENOMEM; 187 180 188 - memcpy(p, ualg, sizeof(*ualg) + ualg->alg_key_len); 181 + memcpy(p, ualg, len); 189 182 *algpp = p; 190 183 return 0; 191 184 }